Unable to modify vertices in spatial mesh?

Hi,

I’m trying to modify the spatial mesh vertices. Works fine in the Unity Editor and I don’t see any substantial difference between my code and HoloToolkit’s vertex removal (other than that I preserve the number of triangles and do not remove any):

Mesh mesh = mesh_filter.sharedMesh;

Vector3[ ] verts = mesh.vertices;
… do some work on verts[ ] …
mesh.vertices = verts;
mesh.RecalculateBounds();
MeshCollider collider = mesh_filter.gameObject.GetComponent();
if (collider != null)
{
collider.sharedMesh = null;
collider.sharedMesh = mesh;
}

I render the spatial mesh with the wireframe material so I can see deformations but nothing happens on the actual device. It is as if they are not being updated at all! I’ve tried even more drastic things like clearing the mesh – both using Clear() and manually zeroing out the vertices – no effect!

Note: mesh_filter is obtained when spatial mapping is complete and I stop the observer. I obtain all the mesh filters using SpatialMappingManager.Instance.GetMeshFilters() once and then I keep them around in a List<>.

Any ideas?

Thanks,

Bart

Okay, I’m an idiot. The mesh code works flawlessly. The problem was in the “do some work on verts[ ]” bit that I omitted.

I was doing some intersection testing using the spatial mesh’s AABB (mesh.bounds) against a box collider AABB (collider.bounds), and these fail on the device because the values seem wonky. I understand that mesh bounds are in local space and collider bounds in world units but they should be equivalent given that the spatial meshes have no parent transform. In the editor, this is certainly the case. I’ll post another thread since this one is now irrelevant.