Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid trimesh import failure when pyrender has issue #327

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading