Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Question about the collision filter for the particles
#3
(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
Reply


Messages In This Thread
RE: Question about the collision filter for the particles - by snowtv - 14-11-2022, 05:08 PM