StaticMesh - Update Vertices?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
tice
Posts: 2
Joined: Wed Jun 15, 2016 1:59 pm

StaticMesh - Update Vertices?

Post by tice »

Hello,

I tried updating the Vertices of a StaticMesh like this:

Code: Select all

// startup
myStaticMesh = new StaticMesh(vertices, indices);
Space.Add(myStaticMesh);

Code: Select all

// sometime later in the program
for (int i = 0; i < vertices.Length; i++)
  vertices[i] += new Vector3(10, 0, 0);
myStaticMesh.Mesh.Data.Vertices = vertices;
myStaticMesh.Mesh.Tree.Reconstruct();
Something is not updated correctly because a RayCast via Space.BroadPhase.QueryAccelerator.RayCast
cant seem to hit the new StaticMesh.

Any Ideas?

Thanks,
tice
Last edited by tice on Wed Jun 15, 2016 2:38 pm, edited 1 time in total.
tice
Posts: 2
Joined: Wed Jun 15, 2016 1:59 pm

Re: StaticMesh - Update Vertices?

Post by tice »

I added

Code: Select all

myStaticMesh.UpdateBoundingBox();
after setting the new Vertices and it seems to work!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: StaticMesh - Update Vertices?

Post by Norbo »

Adding that UpdateBoundingBox to pull the new underlying AABB data over should indeed work properly- it's been a while since I've fiddled with that part of the codebase, but I'm pretty sure that doesn't leave anything misconfigured.
Post Reply