Posts: 51
Threads: 11
Joined: Aug 2021
Reputation:
0
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?
Posts: 6,322
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
14-11-2022, 08:28 AM
(This post was last modified: 14-11-2022, 08:34 AM by josemendez.)
(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...-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/manua...sions.html
kind regards,
Posts: 51
Threads: 11
Joined: Aug 2021
Reputation:
0
(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...-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/manua...sions.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
Posts: 51
Threads: 11
Joined: Aug 2021
Reputation:
0
I think I figured out the collision filter (although I can't test it yet because I got another problem with Obi's raycast)
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/manua...eries.html return every particle hit by the ray or only the first particle? Maybe I should use all simplices inside some boxes instead?
Posts: 6,322
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
15-11-2022, 08:31 AM
(This post was last modified: 15-11-2022, 08:32 AM by josemendez.)
(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)
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/manua...eries.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,
Posts: 51
Threads: 11
Joined: Aug 2021
Reputation:
0
(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);
|