Obi Official Forum
Help Question about the collision filter for the particles - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html)
+--- Thread: Help Question about the collision filter for the particles (/thread-3640.html)



Question about the collision filter for the particles - snowtv - 12-11-2022

Hello, in the document it says:

Integer value used for collision filtering. Less significant 16 bits contain a collision category (from 0 to 15) and most significant 16 bits contain a collision mask. 

Which are the less significant bits and which are the most significant bits?


RE: Question about the collision filter for the particles - josemendez - 14-11-2022

(12-11-2022, 12:24 AM)snowtv Wrote: Hello, in the document it says:

Integer value used for collision filtering. Less significant 16 bits contain a collision category (from 0 to 15) and most significant 16 bits contain a collision mask. 

Which are the less significant bits and which are the most significant bits?

Hi snowtv,

In a number, most significant digits are the leftmost ones and less significant digits are the rightmost ones. When taking a about the binary representation of a number, 'digits' become 'bits':
https://en.wikipedia.org/wiki/Bit_numbering

Intuitively speaking, digits to the left have a greater impact on the magnitude of the number. Eg. 5672 is 5000 + 600 + 70 + 2, so '5' is more significant than '6', '6' more significant than '7', and so on. Same with any base, for instance when using base 2 (binary numbers) 10000 > 1000 > 100 > 10, etc.

It's quite common in programming to deal with individual bits in order to cram as much information as possible in very little memory, as this has a direct impact on performance (since memory accesses are often a bottleneck in modern computers, so the more information you can retrieve with a single memory lookup the better). That's why bitwise operators such as left/right shift ('<<' and '>>'), bitwise or/and  ('|' and '&') and others exist in most languages, and why messing with bits is often a better alternative to having an array of booleans when dealing with a bunch of on/off values. If you're unfamiliar with bit manipulation, I'd advise to read about it since it's fairly useful: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/bitwise-and-shift-operators

Obi compresses all information regarding collision filtering in a single 32 bit integer, just like Unity does with layer masks. If you're looking for info on how to build your own filter, see "collision filters" at the end of the collisions scripting section:
http://obi.virtualmethodstudio.com/manual/6.3/scriptingcollisions.html

kind regards,


RE: Question about the collision filter for the particles - snowtv - 14-11-2022

(14-11-2022, 08:28 AM)josemendez Wrote: Hi snowtv,

In a number, most significant digits are the leftmost ones and less significant digits are the rightmost ones. When taking a about the binary representation of a number, 'digits' become 'bits':
https://en.wikipedia.org/wiki/Bit_numbering

Intuitively speaking, digits to the left have a greater impact on the magnitude of the number. Eg. 5672 is 5000 + 600 + 70 + 2, so '5' is more significant than '6', '6' more significant than '7', and so on. Same with any base, for instance when using base 2 (binary numbers) 10000 > 1000 > 100 > 10, etc.

It's quite common in programming to deal with individual bits in order to cram as much information as possible in very little memory, as this has a direct impact on performance (since memory accesses are often a bottleneck in modern computers, so the more information you can retrieve with a single memory lookup the better). That's why bitwise operators such as left/right shift ('<<' and '>>'), bitwise or/and  ('|' and '&') and others exist in most languages, and why messing with bits is often a better alternative to having an array of booleans when dealing with a bunch of on/off values. If you're unfamiliar with bit manipulation, I'd advise to read about it since it's fairly useful: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/bitwise-and-shift-operators

Obi compresses all information regarding collision filtering in a single 32 bit integer, just like Unity does with layer masks. If you're looking for info on how to build your own filter, see "collision filters" at the end of the collisions scripting section:
http://obi.virtualmethodstudio.com/manual/6.3/scriptingcollisions.html

kind regards,

Thanks for the explanation. So if I use ObiActor.SetFilterMask(), do I only pass in the 16 digits filter using something like

Code:
int mask = (1 << 1) | (1 << 3) | (1 << 6);

And if I want to edit the Filter value of individual particles I use something like

Code:
int filter = ObiUtils.MakeFilter(mask, 0);

then do this?

Code:
solver.filters[particle] = filter



RE: Question about the collision filter for the particles - snowtv - 15-11-2022

I think I figured out the collision filter (although I can't test it yet because I got another problem with Obi's raycast)

[Image: q62ZhHE.png]

As you can see I'm raycasting from the left side of the cyan lines in the direction of these lines, however the particles been hit seems to be off, they are to the left of the starting point of the ray. My ray's thickness is 1.5, is this the reason why it's happening? Also, does the raycast example in http://obi.virtualmethodstudio.com/manual/6.3/scriptingqueries.html return every particle hit by the ray or only the first particle? Maybe I should use all simplices inside some boxes instead?


RE: Question about the collision filter for the particles - josemendez - 15-11-2022

(15-11-2022, 12:54 AM)snowtv Wrote: I think I figured out the collision filter (although I can't test it yet because I got another problem with Obi's raycast)

[Image: q62ZhHE.png]

As you can see I'm raycasting from the left side of the cyan lines in the direction of these lines, however the particles been hit seems to be off, they are to the left of the starting point of the ray. My ray's thickness is 1.5, is this the reason why it's happening?

A thickness of 1.5 meters is a lot, chances are the rays are hitting something right at their origin point.


(15-11-2022, 12:54 AM)snowtv Wrote: Also, does the raycast example in http://obi.virtualmethodstudio.com/manual/6.3/scriptingqueries.html return every particle hit by the ray or only the first particle?
Maybe I should use all simplices inside some boxes instead?

Raycasts return the first hit only. If you want to return all particles within an area, using a box query would be a better approach indeed.

kind regards,


RE: Question about the collision filter for the particles - snowtv - 16-11-2022

(15-11-2022, 08:31 AM)josemendez Wrote: A thickness of 1.5 meters is a lot, chances are the rays are hitting something right at their origin point.



Raycasts return the first hit only. If you want to return all particles within an area, using a box query would be a better approach indeed.

kind regards,

Hi, I tested my filter editing code and it doesn't seem to work, and I can't figure it out. I want this actor to collide every category except 3, this is what I'm doing currently and it doesn't collide with my ObiCollider with category 0

Am I using the ObiActor.SetFilterMask() wrong?

Code:
int colon0Mask = 1 << 3;
        colon0Mask = ~colon0Mask;
        ClothColonManager.instance.usedColon0.SetFilterMask(colon0Filter);