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,