Page 1 of 1

StaticMesh - Update Vertices?

Posted: Wed Jun 15, 2016 2:10 pm
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

Re: StaticMesh - Update Vertices?

Posted: Wed Jun 15, 2016 2:37 pm
by tice
I added

Code: Select all

myStaticMesh.UpdateBoundingBox();
after setting the new Vertices and it seems to work!

Re: StaticMesh - Update Vertices?

Posted: Wed Jun 15, 2016 7:37 pm
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.