BitMasks

Can someone explain me the use of BitMasks a bit more detailed?

btw: Why is BitMask32 not in the api documentation?

Thanks Martin

Good question. I don’t know. I’ll investigate.

In the documentation is a BitArray.
BitMask and BitArray are not the sam,e aren’t they?

They are not exactly the same, but they are very similar, and have many of the same interfaces.

Technically, a BitMask32 is an array of bits that fits within one word–that is, 32 bits. A BitArray is an unbounded array of bits (it allocates additional words as needed to go beyond bit 32). Other than that, though, they do the same sorts of things: you can set or clear individual bits, or test individual bits; or you can perform traditional boolean operations like &, |, and ^.

If you’re not comfortable with the boolean operations of bitmasks, then don’t use those operations. Just think of a BitMask32 as an array of 32 values, each of which can only be either 1 or 0. (By the same token, a BitArray is an array of an unlimited number of values, but again each can only be 1 or 0.)

There are several uses for BitMask32 in Panda. One of the most common uses is in the collision system–a bitmask is used to indicate which “into” objects a particular “from” object might be interested in colliding with. The documentation for this is found in the Panda3D manual. Another use is in the camera drawmask system; this is an advanced usage that is not yet documented, but it can be used to hide and show certain objects from one camera but not from another.

David

I should mention - many things that are not properly documented, are nonetheless shown in detail in the sample programs. I believe we have sample programs using BitMasks as camera masks.

-Josh