Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How detect amount of fluid in a container
#6
(15-01-2020, 10:07 AM)N0Skillz Wrote: Hi there,

Since this awesome asset is new to me, I'm still learning its depth therefore I kindly ask you to bear with me as I'm just going to let my thoughts out...

Is there any option to subscribe only to a specific collision layer, i.e. "Bucket" ? - or is there any "collision matrix" like the Unity's "Layer Collision Matrix"? 
... as per the documentation under "Scripting Collisions" I'm receiving all the particle contacts/collisions and having to call :

Code:
foreach (Oni.Contact contact in currentContacts)
{
   Component coll;
   if (ObiCollider.idToCollider.TryGetValue(contact.other, out coll))
   {
       if (coll.gameObject.layer != 11) // Layer I want to check against
           continue;

       // ... Rest of the code ...
   }
}

And with 1000 particles I get approximately 10-15k iterations which seems a bit of overkill.

Am I missing something or this is the only way to do it?

Hi,

It depends on how many colliders you have, and how large their bounding box is. When a particle enters the bounding box of a collider, it generates a speculative contact. It is not uncommon for the engine to process 40-80k contacts per frame in scenes with many particles/colliders. That's the reason we cannot use Unity's vanilla collision callbacks, as under the hood Obi is pretty much DOTS in disguise and works with massive amounts of data.

The issue is iterating trough them in C# in a single thread. For a large enough amount of contacts, I'd use jobs/threads to process them in parallel.

You can use phases to filter out collisions between particles and colliders, similar to Unity's collision matrix/layers. See:
http://obi.virtualmethodstudio.com/tutor...sions.html
Reply


Messages In This Thread
RE: How detect amount of fluid in a container - by josemendez - 15-01-2020, 10:52 AM