Repository: Genesis-Embodied-AI/Genesis
File: genesis/engine/entities/fem_entity.py (Python)

Code before:
            If the morph type is unsupported.
        """
        from genesis.engine.materials.FEM.cloth import Cloth as ClothMaterial

        is_cloth = isinstance(self.material, ClothMaterial)
        self._uvs = None

        if is_cloth:
            # Cloth: load surface mesh directly (no tetrahedralization)
            if isinstance(self.morph, gs.options.morphs.Mesh):
                import trimesh

                mesh = trimesh.load_mesh(self._morph.file)
                verts = mesh.vertices * self._morph.scale + np.array(self._morph.pos)
                faces = mesh.faces
                # For cloth, we store faces as "elements" (treating them as surface elements)
                self.instantiate(verts, faces)

                # Load UVs from mesh (1:1 mapping for cloth)
                try:
                    self._uvs = mesh.visual.uv.astype(gs.np_float, copy=True)
                except AttributeError:
                    # UVs are not always available in 3D file, in case they are missing we set the entity UVs to None
                    # When UVs are None, the solver will use 0 UVs for rendering. A mesh with 0 UVs means that no tangent directions
                    # can be recomputed, thus texture mapping and anisotropic surfaces will not work properly.
                    self._uvs = None
            else:
                gs.raise_exception(f"Cloth material only supports Mesh morph. Got: {self.morph}.")
        else:
            # Regular FEM: tetrahedralize mesh
            if isinstance(self.morph, gs.options.morphs.Sphere):
                verts, elems = eu.sphere_to_elements(
                    pos=self._morph.pos,
                    radius=self._morph.radius,
                    tet_cfg=self.tet_cfg,
                )
            elif isinstance(self.morph, gs.options.morphs.Box):
                verts, elems = eu.box_to_elements(
                    pos=self._morph.pos,
                    size=self._morph.size,
                    tet_cfg=self.tet_cfg,
                )
            elif isinstance(self.morph, gs.options.morphs.Cylinder):
                verts, elems = eu.cylinder_to_elements()
            elif isinstance(self.morph, gs.options.morphs.Mesh):
                # We don't need to proces UVs here because the tetrahedralization process append new vertices
                # and faces at the end of the vertex list, thus the original UVs are preserved at the beginning.
                # We can't generate UVs for newly created internal vertices as it doesn't make sense but they're
                # not used for rendering so it's fine.
                verts, elems, self._uvs = eu.mesh_to_elements(
                    file=self._morph.file,

Review comment (suggestion):
* Everything must fit into 120 chars limit, including comments
* We prefer explicit check instead of try-except in this context
```python
# Load UVs from mesh (1:1 mapping for cloth).
# UVs are not always available in 3D file, in case they are missing we set the entity UVs to None when UVs are None, 
# the solver will use 0 UVs for rendering. A mesh with 0 UVs means that no tangent directions can be recomputed, 
# thus texture mapping and anisotropic surfaces will not work properly.
self._uvs = None
if mesh.visual.uv is not None:
    self._uvs = mesh.visual.uv.astype(gs.np_float, copy=True)
```

Code after:
            If the morph type is unsupported.
        """
        from genesis.engine.materials.FEM.cloth import Cloth as ClothMaterial

        is_cloth = isinstance(self.material, ClothMaterial)
        self._uvs = None

        if is_cloth:
            # Cloth: load surface mesh directly (no tetrahedralization)
            if isinstance(self.morph, gs.options.morphs.Mesh):
                import trimesh

                mesh = trimesh.load_mesh(self._morph.file)
                verts = mesh.vertices * self._morph.scale + np.array(self._morph.pos)
                faces = mesh.faces
                # For cloth, we store faces as "elements" (treating them as surface elements)
                self.instantiate(verts, faces)

                # Load UVs from mesh (1:1 mapping for cloth).
                # UVs are not always available in 3D file, in case they are missing we set the entity UVs to None when UVs are None,
                # the solver will use 0 UVs for rendering. A mesh with 0 UVs means that no tangent directions can be recomputed,
                # thus texture mapping and anisotropic surfaces will not work properly.
                self._uvs = None
                if isinstance(mesh.visual, trimesh.visual.texture.TextureVisuals) and mesh.visual.uv is not None:
                    self._uvs = mesh.visual.uv.astype(gs.np_float, copy=False)
            else:
                gs.raise_exception(f"Cloth material only supports Mesh morph. Got: {self.morph}.")
        else:
            # Regular FEM: tetrahedralize mesh
            if isinstance(self.morph, gs.options.morphs.Sphere):
                verts, elems = eu.sphere_to_elements(
                    pos=self._morph.pos,
                    radius=self._morph.radius,
                    tet_cfg=self.tet_cfg,
                )
            elif isinstance(self.morph, gs.options.morphs.Box):
                verts, elems = eu.box_to_elements(
                    pos=self._morph.pos,
                    size=self._morph.size,
                    tet_cfg=self.tet_cfg,
                )
            elif isinstance(self.morph, gs.options.morphs.Cylinder):
                verts, elems = eu.cylinder_to_elements()
            elif isinstance(self.morph, gs.options.morphs.Mesh):
                # We don't need to proces UVs here because the tetrahedralization process append new vertices
                # and faces at the end of the vertex list, thus the original UVs are preserved at the beginning.
                # We can't generate UVs for newly created internal vertices as it doesn't make sense but they're
                # not used for rendering so it's fine.
                verts, elems, self._uvs = eu.mesh_to_elements(
                    file=self._morph.file,
                    pos=self._morph.pos,