trimesh icon indicating copy to clipboard operation
trimesh copied to clipboard

SceneViewer rendering contains holes after update_face() call

Open tconlon opened this issue 3 years ago • 2 comments

Hi Mike,

I'm encountering some odd behavior in Scene rendering that I was hoping you had some insight into. At a high level, I'm cropping my original scene by 1) dumping its meshes, 2) checking whether various triangles in each mesh intersect with my smaller area of interest, and then 3) using mesh.update_face(valid_ixs) to retrieve the smaller parts of the meshes that I'm interested in (i'll call these updated_meshes, then 4) reconstituting the updated meshes in a Scene (I'll call this updated_scene).

I'm encountering no issues rendering the original Scene. However, visualizing updated_scene in SceneViewer produces a bunch of a holes in the mesh when I rotate/zoom. Pic attached.

Oddly, when I run updated_scene.show(viewer='notebook'), the scene renders correctly inline without any holes.

For reference, I've tried repairing updated_scene with the trimesh.repair functions and applying .fill_holes() and fix_normals() to each mesh in updated_meshes, to no avail.

Thanks in advance for any thoughts you may have!

Screen Shot 2022-09-15 at 3 49 53 PM

tconlon avatar Sep 15 '22 20:09 tconlon

Update: Scaling the updated_meshes by a factor of 0.01 eliminates the improperly rendered faces. I'm not 100% sure why this behavior happens, but downscaling does seem to provide a workaround.

tconlon avatar Sep 16 '22 12:09 tconlon

Ah yeah it could be the scale and opengl's z_near/z_far. Scaling to a unit bounding box might addresses this (or maybe we could handle it in set_camera).

Are the holes actually in the mesh or is it the visualization? You could try checking with trimesh.repair.broken_faces(...color=[255,0,0,255])

mikedh avatar Sep 21 '22 20:09 mikedh