doyubkim / fluid-engine-dev

Fluid simulation engine for computer graphics applications
https://fluidenginedevelopment.org/
MIT License
1.89k stars 266 forks source link

How to move colliders #267

Open kentbarber opened 5 years ago

kentbarber commented 5 years ago

I can't seem to get colliders moving and interacting with the fluid how I expect it to.

I have a LevelSetLiquid that is half full with fluid. I then move a sphere in from outside of the domain that slowly moves through it.

I am moving it by setting the transform of the colliders Surface3.

surf->transform.setOrientation(jet::QuaternionD(quat.w, -quat.v.x, -quat.v.y, -quat.v.z));
surf->transform.setTranslation(jet::Vector3D(p.x, p.y, p.z));

But I think I may need to add velocity to the RigidBody as well, but I tried adding linearvelocity to it but it doesn't seem to work.

What happens is I see some slight affect on the fluid as the sphere moves in. But I am expecting the sphere to completely push the entire fluid, which it doesn't.

I will try to get another gif to you later today to demonstrate the issue, but if you are able to provide an example where I could manually set the location of objects before the solver->update method is called that would be great. I am not using your callback system due to the way my code is structured.

kentbarber commented 5 years ago

Here is a gif illustrating the current issue I am having. Most likely a user error on my part, but if you have any ideas of how to allow for this type of moving collider that would be great.

collisionproblem

doyubkim commented 5 years ago

Thanks for reporting this! I think what you did is correct -- set the transform of surface and velocity of the rigid body. (And now that I think of it, the API itself might be confusing. Rigid body collider should have the capability to move around the collider.)

The artifact you are seeing might be the result of the lack of voxels between the sphere and the walls. Looking at the mesh, it seems like a couple of voxels only. I suggest testing with a smaller sphere (like, the diameter being 1/3 of the domain size) and see what happens.