Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Callback for particle-particle collision
#1
Hi there!

I'm looking for a way to know when particles from different phases are colliding, in order to do some custom logic for each collision. The collision physics itself is working so I guess there's nothing wrong with my setup, but it might be the case, I'm fairly new with Obi Fluid.
I've looked into the ObiSolver.OnCollision callback, but it seems that it only provides data for the collisions against the Colliders of my scene!
Is there a way of achieving this particle-against-particle detection? Maybe directly through the Oni API? I don't know if that's realistically feasible in terms of performance, but let's try hehehe


Cheers and thanks for this great plugin!
Tom
Reply
#2
(26-01-2018, 10:44 PM)tooomg Wrote: Hi there!

I'm looking for a way to know when particles from different phases are colliding, in order to do some custom logic for each collision. The collision physics itself is working so I guess there's nothing wrong with my setup, but it might be the case, I'm fairly new with Obi Fluid.
I've looked into the ObiSolver.OnCollision callback, but it seems that it only provides data for the collisions against the Colliders of my scene!
Is there a way of achieving this particle-against-particle detection? Maybe directly through the Oni API? I don't know if that's realistically feasible in terms of performance, but let's try hehehe


Cheers and thanks for this great plugin!
Tom

Hi Tom!

Unfortunately it is not possible to get particle-particle collision callbacks right now, basically because of how fluids work particles never actually collide between them. Each particle has a neighborhood and it applies position corrections to all particles within this radius using a support function known as "kernel" in fluid simulation jargon, that acts as a decay function to apply less intense corrections to particles further away from the one at the center of the kernel.

We might expose the list of per-particle neighbors for each particle on future versions. However due to the sheer amount of operations needed per particle, applying custom logic to this list in C# might prove unpractical due to low performance.
Reply
#3
Thanks for the reply! I didn't know how the simulation worked internally regarding collisions, but this approach actually makes sense performance-wise. That's an interesting topic Sonrisa
Then, maybe it would make more sense to be able to get the neighboring particles at least from different phases. Of course, that would still need to be "flagged" in the docs as a low-performance approach, but depending on the use case, it might be actually reasonable (ie: in my project, I'm replacing colliding particles from 2 phases into a new emitted one, as they flow in each other, so it ends up having only a reasonable operations per second, as the mix of the two liquids occurs progressively, and each particle can only collides once into another phase before being replaced).

But anyway, in my case, I cheated a bit and added a trigger where the mix is supposed to take place, and the collision detection is performed against this collider and not the other phase. I don't know if there would be a more precise approach, but at least is works roughly Guiño
Reply