Problem when modifying staticmesh

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
roimort
Posts: 2
Joined: Sat Jul 28, 2012 2:03 am

Problem when modifying staticmesh

Post by roimort »

Hi,

I have terrain that can be modified and I use staticmeshes for it.

After the vertex and index data is changed, I call
staticMesh.Mesh.Tree.Refit();
staticMesh.UpdateBoundingBox();

This works mostly fine. The problem is that when there is some still object on the mesh (I have tried sphere and CharacterController so far) and a hole is made into the mesh under the object, the object does not fall unless something hits it.

Can I inform the object somehow that the mesh has changed or is there some other possible fix for this? I tried disabling DeactivationManager in case it had something to do with the problem but it did not help.

Thanks!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Problem when modifying staticmesh

Post by Norbo »

If there's an already known subset of objects you want to wake up, then just calling their entity.ActivityInformation.Activate() would work. If it's just the set of all objects colliding with the StaticMesh, iterate through the StaticMesh.Pairs list. Each Pair has EntityA and EntityB properties, among other things. One of them will be null because the StaticMesh is not an entity. The other can be activated by calling the entity.ActivityInformation.Activate() method.

It could also be that there are some cached contacts persisting through the change, supporting even an active entity. In this case, call the ClearContacts method of each pair.
roimort
Posts: 2
Joined: Sat Jul 28, 2012 2:03 am

Re: Problem when modifying staticmesh

Post by roimort »

Thanks Norbo! ClearContacts fixed the problem.
Post Reply