Distort MobileMesh

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
templar_vii
Posts: 17
Joined: Wed Nov 06, 2013 2:56 pm

Distort MobileMesh

Post by templar_vii »

Hi BEPU-Friends

I'd like to destort a mobile mesh.
In this forum I read it's possible by recreate or modify it's MobileMeshShape.
I tried like this:

Code: Select all

myMesh.CollisionInformation.Shape.TriangleMesh.Data = newStaticMeshData;
But the shape did not change.
Does anyone have an idea what I'm doing wrong?

Thanks a lot!
templar_vii
Posts: 17
Joined: Wed Nov 06, 2013 2:56 pm

Re: Distort MobileMesh

Post by templar_vii »

It seams to work!
The distortion was just not visible.
I use the ModelDrawer from the examples for visualisation.
It seams the ModelDrawer did not notice about the changes.
If I replace all the entities, the distortion is visible.

Code: Select all

myModelDrawer.Clear();
foreach (var mesh in myMeshes)
	myModelDrawer.Add(mesh);
templar_vii
Posts: 17
Joined: Wed Nov 06, 2013 2:56 pm

Re: Distort MobileMesh

Post by templar_vii »

Unfortunately, the Space also don't notice the changes of the MobileMeshes :(
I guess, I should reinitialize something or call an OnChanged-Method.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Distort MobileMesh

Post by Norbo »

The MobileMeshShape should be treated as immutable. The ability to change stuff within the TriangleMesh object is a weakness in the enforced immutability that needs to be fixed, but that change will probably wait until the hierarchy overhauls.

Instead, I would recommend recreating the shape. That will ensure the shape properties are properly computed.
templar_vii
Posts: 17
Joined: Wed Nov 06, 2013 2:56 pm

Re: Distort MobileMesh

Post by templar_vii »

Thank you Norbo!

I discovered the MorphableEntity.
It looks like, this is the Entity for distortions.

To distort my mesh, I can create a new MobileMeshCollidable and assign it by SetCollisionInformation().

Code: Select all

var collidable = new MobileMeshCollidable(newShape);
myMorphableEntity.SetCollisionInformation(collidable);
Unfortunately this is not that fast.
But supposably BEPU is not made to destort a complex Mesh every frame.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Distort MobileMesh

Post by Norbo »

Unfortunately this is not that fast.
But supposably BEPU is not made to destort a complex Mesh every frame.
That's correct; while simpler shapes like boxes, cylinders, and so on can be resized very cheaply, meshes are quite heavy. Whenever the shape changes, the hierarchy must be refit (or reconstructed, if there are topology changes) and the physical properties like volume distribution must be recomputed.

There exists a constructor on the MobileMeshShape which takes all of the information required to fully initialize a MobileMeshShape under the assumption that it is all correct. You could use that overload and provide the data directly so that it doesn't need to be recomputed. The data source could be precomputed or just approximated.
Post Reply