taichi-dev / taichi_elements

High-performance multi-material continuum physics engine in Taichi
MIT License
483 stars 69 forks source link

Sphere colliders #17

Open yuanming-hu opened 4 years ago

yuanming-hu commented 4 years ago

I can add simple colliders to the solver. To begin with, I would simply do spheric colliders only.

A question for @PavelBlend: what is the best way to specify the trajectory of the sphere?

PavelBlend commented 4 years ago

It is possible to make a motionless sphere for now. Or do you want the sphere to interact with particles? If the sphere is dynamic, then you can simply indicate to it the initial velocity along the X axis (1.0, 0.0, 0.0).

yuanming-hu commented 4 years ago

Sure, I can easily do motionless or specify a fixed velocity.

PavelBlend commented 4 years ago

But will it be difficult in the future to make the sphere dynamic? Will I have to break a lot of code? If not, then for the first time you can get around motionless obstacles.

yuanming-hu commented 4 years ago

No, that's not difficult at all. I agree we should just demonstrate the possibility and let the community to contribute fancier versions.

PavelBlend commented 4 years ago

I have a question: What will colliders be like? Particles, voxels or mesh?

yuanming-hu commented 4 years ago

I have a question: What will colliders be like? Particles, voxels or mesh?

Currently, just spheres. We can improve later to support arbitrary meshes/voxels.

anthropoy commented 2 years ago

Hi Yuan Ming,

I have started looking into supporting arbitrary meshes. What I have done is quite simple, I just get the positions and normals of the triangles centroid and add them to the engine using add_surface_collider. It works but it's very slow during initialisation. The number of triangles is just over 1000 when it took more than 5 minutes to initialise. How can we speed up the initialisation process when adding these colliders or we need a different approach? Thanks.

Sam

Jack12xl commented 2 years ago

Hi, Could you show me the code where you add these triangles? Maybe I could take a look when available. Maybe we should try using SDF instead of manually add these triangles

anthropoy commented 2 years ago

Hi Jack,

Thanks for responding. After dwelling in a bit more, I did realise that what I did there was wrong. The existing add_surface_collider function is not suitable for arbitrary meshes, it will just create an infinite plane for each point and normals. I was looking for existing python packages that could calculate SDF for meshes fast. Trimesh seems to be a good candidate but I'm not sure what's the best way to integrate this into taichi_element. Or what do you suggest? Appreciate your help and pointers. Thanks!

r03ert0 commented 2 years ago

you may want to check libigl (comes with python bindings)