Skip to content

Commit

Permalink
Fixes 284
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderFabisch committed Sep 6, 2024
1 parent dbdbe5b commit 5f26751
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions pytransform3d/_mesh_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,36 @@ def load(self):
return False
obj = trimesh.load(self.filename)
if isinstance(obj, trimesh.Scene): # pragma: no cover
# Special case in which we load a collada file that contains
# multiple meshes. We might lose textures. This is excluded
# from testing as it would add another dependency.
obj = obj.dump().sum()
obj = self._convert_scene_to_mesh(obj)
self.mesh = obj
return True

def _convert_scene_to_mesh(self, obj): # pragma: no cover
# Special case in which we load a collada file that contains
# multiple meshes. We might lose textures. This is excluded
# from testing as it would add another dependency.
import trimesh
trimesh_version_parts = trimesh.__version__.split(".")
major_version = int(trimesh_version_parts[0])
if major_version >= 4:
try:
minor_version = int(trimesh_version_parts[1])
except:
minor_version = 0
try:
patch_version = int(trimesh_version_parts[2])
except: # most likely release candidate (rc) version
patch_version = 0
if minor_version >= 4 and patch_version >= 9:
obj = obj.to_mesh()
elif minor_version >= 2:
obj = obj.dump(concatenate=True)
else:
obj = obj.dump().sum()
else:
obj = obj.dump().sum()
return obj

def convex_hull(self):
self.mesh = self.mesh.convex_hull

Expand Down

0 comments on commit 5f26751

Please sign in to comment.