Is it safe/possible to remove Triangles from a StaticMesh?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Spankenstein
Posts: 249
Joined: Wed Nov 17, 2010 1:49 pm

Is it safe/possible to remove Triangles from a StaticMesh?

Post by Spankenstein »

I create a static mesh for the level from a set of triangle vertices (and indices). Some of the triangles are marked as destructible and I would like them to either become passable or completely removed from the physics space when shot.

Is it safe/possible to remove triangles from a StaticMesh object?

Code: Select all

staticMesh.Mesh.Data.Vertices
I could create a separate object that slots into the mesh for destructible objects but I would like to know your take on the matter first. :)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Is it safe/possible to remove Triangles from a StaticMes

Post by Norbo »

Removing a triangle changes the topology of the mesh, so a hierarchy reconstruction would be necessary. This can be performed externally:

Code: Select all

staticMesh.Mesh.Tree.Reconstruct();
However, the reconstruction process is basically the entire cost of creating a new mesh object. You don't gain much other than keeping the same StaticMesh reference.

If the mesh isn't too big, then you could probably get away with doing this reconstruction each time. For reference, in some fracture prototypes, reconstruction was't much of a problem even with a few thousand elements and multiple reconstructions happening in quick succession (sometimes multiple in one frame). If the reconstruction is too expensive, then the 'destructible pieces' approach would be necessary.
Post Reply