Skip to content

Commit

Permalink
gdtf: Check model dimensions before 3ds transform (#209)
Browse files Browse the repository at this point in the history
- In some 3DS files the model dimensions are equal with blender dimensions. 
- Check the dimensions before transforming the models.
  • Loading branch information
nrgsille76 authored Jul 27, 2024
1 parent e39c0ba commit d707684
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gdtf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import hashlib
from types import SimpleNamespace
import pathlib
from mathutils import Euler, Matrix
from mathutils import Euler, Matrix, Vector

from . import pygdtf
from .logging import DMX_Log
Expand Down Expand Up @@ -233,8 +233,10 @@ def loadModel(profile, model):
file_name = os.path.join(extract_to_folder_path, inside_zip_path)
try:
load_3ds(file_name, bpy.context, FILTER={'MESH'}, KEYFRAME=False, APPLY_MATRIX=False)
obj_dimension = Vector((model.length, model.width, model.height))
for ob in bpy.context.selected_objects:
ob.data.transform(Matrix.Scale(0.001, 4))
if ob.dimensions.to_tuple(3) > obj_dimension.to_tuple(3):
ob.data.transform(Matrix.Scale(0.001, 4))
except Exception as e:
DMX_Log.log.error(f"Error loading a 3DS file {e}")
traceback.print_exception(e)
Expand Down

0 comments on commit d707684

Please sign in to comment.