Skip to content

Commit

Permalink
avoid trimesh import failure when pyrender has issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Kashu7100 committed Dec 26, 2024
1 parent 66e3f84 commit 4f553d7
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions genesis/vis/rasterizer_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import genesis.utils.geom as gu
import genesis.utils.mesh as mu
import genesis.utils.particle as pu
from genesis.ext import trimesh

try:
from genesis.ext import pyrender, trimesh
from genesis.ext import pyrender
from genesis.ext.pyrender.jit_render import JITRenderer
except Exception as e:
print(f"[Error]: {e}\n")
Expand Down Expand Up @@ -199,14 +200,13 @@ def update_link_frame(self, buffer_updates):

for link in links:
link_T = gu.trans_quat_to_T(links_pos[link.idx], links_quat[link.idx])
buffer_updates[self._scene.get_buffer_id(self.link_frame_nodes[link.uid], "model")] = (
link_T.transpose([0, 2, 1])
)
buffer_updates[
self._scene.get_buffer_id(self.link_frame_nodes[link.uid], "model")
] = link_T.transpose([0, 2, 1])

def on_tool(self):
if self.sim.tool_solver.is_active():
for tool_entity in self.sim.tool_solver.entities:

if tool_entity.mesh is not None:
mesh = trimesh.Trimesh(
tool_entity.mesh.init_vertices_np,
Expand Down Expand Up @@ -411,9 +411,9 @@ def update_mpm(self, buffer_updates):
tfs = np.tile(np.eye(4), (mpm_entity.n_particles, 1, 1))
tfs[:, :3, 3] = particles_all[mpm_entity.particle_start : mpm_entity.particle_end]

buffer_updates[self._scene.get_buffer_id(self.static_nodes[mpm_entity.uid], "model")] = (
tfs.transpose([0, 2, 1])
)
buffer_updates[
self._scene.get_buffer_id(self.static_nodes[mpm_entity.uid], "model")
] = tfs.transpose([0, 2, 1])

elif mpm_entity.surface.vis_mode == "visual":
mpm_entity._vmesh.verts = vverts_all[mpm_entity.vvert_start : mpm_entity.vvert_end]
Expand Down Expand Up @@ -476,9 +476,9 @@ def update_sph(self, buffer_updates):
tfs = np.tile(np.eye(4), (sph_entity.n_particles, 1, 1))
tfs[:, :3, 3] = particles_all[sph_entity.particle_start : sph_entity.particle_end]

buffer_updates[self._scene.get_buffer_id(self.static_nodes[sph_entity.uid], "model")] = (
tfs.transpose([0, 2, 1])
)
buffer_updates[
self._scene.get_buffer_id(self.static_nodes[sph_entity.uid], "model")
] = tfs.transpose([0, 2, 1])

def on_pbd(self):
if self.sim.pbd_solver.is_active():
Expand Down Expand Up @@ -556,9 +556,9 @@ def update_pbd(self, buffer_updates):
tfs = np.tile(np.eye(4), (pbd_entity.n_particles, 1, 1))
tfs[:, :3, 3] = particles_all[pbd_entity.particle_start : pbd_entity.particle_end]

buffer_updates[self._scene.get_buffer_id(self.static_nodes[pbd_entity.uid], "model")] = (
tfs.transpose([0, 2, 1])
)
buffer_updates[
self._scene.get_buffer_id(self.static_nodes[pbd_entity.uid], "model")
] = tfs.transpose([0, 2, 1])

elif self.render_particle_as == "tet":
new_verts = mu.transform_tets_mesh_verts(
Expand All @@ -574,7 +574,6 @@ def update_pbd(self, buffer_updates):
buffer_updates[self._scene.get_buffer_id(node, "normal")] = normal_data

elif pbd_entity.surface.vis_mode == "visual":

vverts = vverts_all[pbd_entity.vvert_start : pbd_entity.vvert_end]
node = self.static_nodes[pbd_entity.uid]
update_data = self._scene.reorder_vertices(node, vverts)
Expand Down

0 comments on commit 4f553d7

Please sign in to comment.