DiffCloth
DiffCloth copied to clipboard
Possibility of adding more obstacles?
Hi, Yifei.
I have briefly looked through Primitive.cpp
and Primitive.h
and I have another question regarding to how to add other obstacles that are not provided by the simulator.
- First, if I add obstacle by inheriting
Primitive
class, set its mesh and implement collistion detection functionisInContact
, what should I do to ensure the collision detection function is differentiable becuase I think the collision detection function is (or not?) in our computational graph? - Second, as a specific case for the first question, how can we implement the
isInContact
forCUBE
, which is included in the enumPrimitiveType
but is not implemented? - Third, is there any possibility of adding some complex obstacles not by analytical setting the mesh like
Sphere
, but by using a pre-provided.obj
file?
Hi,
- Collision detection is assumed not to be differentiable and yes it will introduce discontinuities when the contact set changes between frames. Implementation-wise you don't need to worry about this.
- One possible way might be to make use of the isCollection attribute of the Primitive and build the Cube as a collection of 6 Plane primitives. The collision at the corners and corresponding normals probably need to be handled with care. I think the LowerLeg and Foot primitives do something similar and you can reference it.
- You probably need to look into arbitrary mesh collision detection algorithms likely coupled with spatial acceleration structures for fast collision queries (for example KD-trees). I didn't implement it since the current primitives suffice for demo purposes, but I do recommend implementing this if you want to use the system for more complex scenes. In terms of collision detection, another aspect to make the detection more robust is implementing Continuous Collision Detection. In general there are probably very good papers and impelemntations that devote to robust cloth collision handling for arbitrary meshes, so it might be good to look into those.
Hi, Yifei.
Thanks for your previous answer.
To the best of my understanding (sorry i'm new to simulation), the collision test in DiffCloth only supports detection between every point in the cloth mesh and the whole obstacle mesh (according to the Simulation::collisionDetection
function in src/code/simulation/Simulation.cpp). It's more like the point cloud of cloth collide the obstacle mesh and it means that it do not support collison test between triangle faces.
So, how can the simulator detect the situation when one triangle edge in the cloth mesh penetrate into the obstacle?
In terms of solving collisions (as in resolving collision and cloth dynamics simultaneously at every time step), currently the framework only supports nodal contacts, (node-node, but not vertex-face or edge-edge). This is a limitation inherited from the simulation framework used by diffcloth (https://hal.inria.fr/hal-02563307v2/document Sec 5.4). However you can still add edge-edge and vertex-face for collision detections, and treat them as nodal contact constraints when adding them to the solver, which should still make collision handling more robust. Currently for collision detection I've only implemented nodal self-collisions and primitive collisions, which you probably already figured out. Let me know if you have any other questions.
I'm closing this issue for now. If you have other questions let me know.