Page 1 of 1

Distort MobileMesh

Posted: Thu Nov 07, 2013 1:11 pm
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!

Re: Distort MobileMesh

Posted: Thu Nov 07, 2013 3:01 pm
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);

Re: Distort MobileMesh

Posted: Thu Nov 07, 2013 3:32 pm
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.

Re: Distort MobileMesh

Posted: Thu Nov 07, 2013 7:15 pm
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.

Re: Distort MobileMesh

Posted: Fri Nov 08, 2013 3:12 pm
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.

Re: Distort MobileMesh

Posted: Fri Nov 08, 2013 6:57 pm
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.