Skip to content

Commit 12cf0b8

Browse files
committed
Fix CI.
1 parent c27b22e commit 12cf0b8

File tree

5 files changed

+18
-19
lines changed

5 files changed

+18
-19
lines changed

genesis/engine/entities/fem_entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def sample(self):
407407
# the solver will use 0 UVs for rendering. A mesh with 0 UVs means that no tangent directions can be recomputed,
408408
# thus texture mapping and anisotropic surfaces will not work properly.
409409
self._uvs = None
410-
if mesh.visual.uv is not None:
410+
if isinstance(mesh.visual, trimesh.visual.texture.TextureVisuals) and mesh.visual.uv is not None:
411411
self._uvs = mesh.visual.uv.astype(gs.np_float, copy=True)
412412
else:
413413
gs.raise_exception(f"Cloth material only supports Mesh morph. Got: {self.morph}.")

genesis/engine/mesh.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,13 @@ def from_trimesh(
241241

242242
mesh = mesh.copy(**(dict(include_cache=True) if isinstance(mesh, trimesh.Trimesh) else {}))
243243

244-
try: # always parse uvs because roughness and normal map also need uvs
244+
# Always parse uvs if available because roughness and normal map also need uvs.
245+
# Note that some visual may not have uv, e.g. ColorVisuals.
246+
uvs = None
247+
if isinstance(mesh.visual, trimesh.visual.texture.TextureVisuals) and mesh.visual.uv is not None:
248+
# Note that 'trimesh' uses uvs starting from top left corner.
245249
uvs = mesh.visual.uv.copy()
246-
uvs[:, 1] = 1.0 - uvs[:, 1] # trimesh uses uvs starting from top left corner
247-
except AttributeError:
248-
# Visual may not have uv, e.g. ColorVisuals
249-
uvs = None
250+
uvs[:, 1] = 1.0 - uvs[:, 1]
250251

251252
metadata = metadata or {}
252253
must_update_surface = True

genesis/ext/pyrender/mesh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def _get_trimesh_props(mesh, smooth=False, material=None):
269269
# Process texture colors
270270
if mesh.visual.kind == "texture":
271271
# Configure UV coordinates
272-
if mesh.visual.uv is not None:
272+
if isinstance(mesh.visual, trimesh.visual.texture.TextureVisuals) and mesh.visual.uv is not None:
273273
uv = mesh.visual.uv.copy()
274274
if smooth:
275275
texcoords = uv

genesis/utils/element.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,15 @@ def mesh_to_elements(file, pos=(0, 0, 0), scale=1.0, tet_cfg=dict()):
6060

6161
verts += np.array(pos)
6262

63-
# Extract UVs from mesh before tetrahedralization
64-
# (tetgen preserves original vertices at start of output array)
65-
n_original = len(mesh.vertices)
66-
try:
67-
original_uvs = mesh.visual.uv.copy()
68-
original_uvs = original_uvs.astype(gs.np_float)
69-
except AttributeError:
70-
original_uvs = None
71-
72-
# Build full UV array: original vertices get their UVs, interior vertices get zeros
73-
uvs = np.pad(original_uvs, ((0, len(verts) - n_original), (0, 0)))
63+
# Build full UV array
64+
uvs = None
65+
if isinstance(mesh.visual, trimesh.visual.texture.TextureVisuals) and mesh.visual.uv is not None:
66+
# Extract UVs from mesh before tetrahedralization.
67+
# Note that 'tetgen' preserves original vertices at start of output array.
68+
uvs_orig = mesh.visual.uv.astype(gs.np_float, copy=False)
69+
70+
# Original vertices get their UVs, interior vertices get zeros
71+
uvs = np.pad(uvs_orig, ((0, len(verts) - len(mesh.vertices)), (0, 0)))
7472

7573
return verts, elems, uvs
7674

tests/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
DEFAULT_BRANCH_NAME = "main"
3939

4040
HUGGINGFACE_ASSETS_REVISION = "ca29b66018b449a37738257a3a76a78529d29bcc"
41-
HUGGINGFACE_SNAPSHOT_REVISION = "c6ea95b0eeacd54bbf5aafb23646d5d6f89e1d45"
41+
HUGGINGFACE_SNAPSHOT_REVISION = "0cf1780dd70b67dc426023cd97738037f0d834e3"
4242

4343
MESH_EXTENSIONS = (".mtl", *MESH_FORMATS, *GLTF_FORMATS, *USD_FORMATS)
4444
IMAGE_EXTENSIONS = (".png", ".jpg")

0 commit comments

Comments
 (0)