I was attempting to use PbdObjectCellRemoval to remove cells from a tetrahedral mesh similarly to how it is done in the PBDTissueCut example. I was also attempting to use collision with the mesh, however following the cut the collision does not work as expected. Previously on an older version of iMSTK I removed the collision interaction from the scene, re-created the same collision with the cut mesh, added the new collision to the scene and then reinitialized the scene. This used to work, however it now slows down the simulation significantly with each cut made. I was wondering if there is an better alternative to update the collisions.
Hey Justin, we’d have to look at that. I’m surprised that reinitializing the scene during runtime ever worked fast enough for this to be a viable solution. My assumption is that there is a bug somehwere. in the synchronization between the physics data and the collision data. What version of imstk are you using at the moment ?
Hi Harald, I am currently using the most recent version of iMSTK from the GitLab repository. Specifically I was using this within the iMSTK Unreal Engine plugin I was working on where the reinitializing of the scene would only cause a minor hitch for a fraction of a second. After noticing the collision issue in Unreal I tested it in iMSTK standalone and had similar results.
So i don’t know how efficient it is, but calling extractSurfaceMesh() on the teterhedral mesh, rebuilding the from the tet mesh to the surface mesh and using the extracted mesh as the new collision mesh would probably be the fastest approach that is already implemented. I’m not sure we’re doing this anywhere though at the moment
This is the method I was using, however it only appears to work properly after updating the collision interaction as well, which I believe can only be done by creating a new interaction and seems to need re initializing of the scene.
cellRemoval->apply();
auto surfMesh = tissueMesh->extractSurfaceMesh();
auto map = std::make_shared<PointwiseMap>(tissueMesh, surfMesh);
tissueObj->setPhysicsToCollidingMap(map);
tissueObj->setCollidingGeometry(surfMesh);
scene->removeSceneObject(interaction);
interaction = std::make_shared<PbdObjectCollision>(toolObj2, tissueObj);
scene->addInteraction(interaction);
scene->initialize();
Here is the code that works, but causes the simulation to slow down significantly after each cut.
I have a very similar problem, because colliding and visual meshes are not working as expected. I can see the cut mesh but objects are still colliding and the VisualGeometry is still the original one. I can see the cut mesh because I’m using the extractSurfaceMesh function.
Look at this, I posted all here:
Basically, I can’t update visual and colliding geometries.
As you can see, the deleted vertices in the mesh are now free vertices with no constraints and falling into the void (in the VisualGeometry and CollisionGeometry), so, for both geometries, the new vertices doesn’t exist and the “free” deleted particles are no reused to create new vertices, but simulated with no constraints
Hi there, thanks for keeping us updated on your progress! What are the new values you mention for the indices and vertices for the two geometry filters, is this the geometry outputted by the cell removal? I wanted to try this in iMSTK standalone where I was running the tests previously. I was also wondering if you had to reinitialize the collision interaction or the scene in some way to fix the collisions.