SetBit vs. SetAllBits etc... flags documentation?
Cairyn last edited by
Here's a documentation question I just stumbled over:
BaseList2D.Set/Del/ToggleBit()all accept a bitfield as parameter (of type int), in which several bits can be set. They work fine that way.
However, there is an additional function
SetAllBits()which... does the same as
SetBit()? I just can't see a difference in behavior. Having such a function suggests (by its name) that the other three functions are meant to accept only a single bit as argument? So, is there a difference between
SetAllBits()that I fail to see?
GetBit()is documented as returning an int. It does return a bool though. (So in this case, there is a significant difference to
GetAllBits()which indeed returns an int containing the full bitfield.)
GetBit() accepts a bitfield with multiple bits set, just like the other "singular" functions above. The return value seems to be True when all bits from this bitfield are actually set in the object. Docs don't say so though.
Third, there are some flags which are dubious.
BIT_OFOLDhas been replaced by
NBIT_OM1/2/3/4_FOLDsome time ago, but the documentation still says Folded in object manager. Even in the C++ documentation. Reading on, I find the hint that this flag is now used to mark folded layers in the Layer Manager - so it's not deprecated at least. (I didn't verify this usage yet.) And what's
There is also still no formal constant BIT_SELECTRENDERDATA to denote selected render data entries - searching this forum yields the numeric value
0x08so I guess that still counts as undocumented functionality. (Again, I didn't verify yet.)
m_adam last edited by
SetBitas the name suggest will only set the passed bit doing
l_bitfeld = l_bitfeld | mask;where
maskis the Int32 input bit (so you can toggle multiple bit passing a BitField), while SetAllBit do
l_bitfeld = bits;where
bitsis the Int32 bitfield, so if you pass only BIT_ACTIVE to SetAllBit only BIT_ACTIVE will be set and not the other.
GetBitshould return a bool this is a python doc issue, thanks for reporting it, it's going to be fixed. The issue is not here in C++.
GetBitcan accept a bitfield and return True only when all bits of the bitfield is set in the object. in fact GetBit is nothing more than
return (bits & InputBitSetToTest) == InputBitSetToTest;.
BIT_OFOLDis still used to determine in treeview (e.g. Layer TreeView but also in some other parts). I will fix both C++ and Python doc.
BIT_MFOLDmeans folded in the material manager when used as a Texture Layer mode (in bodypaint).
- Yes, unfortunately, some old part of Cinema 4D are still hardcoded... And the RenderSetting treeview ID is one of them. Here are the values:
#define RENDERSETTINGS_BIT_SELECTED (1 << 3) #define RENDERSETTINGS_BIT_OPENED (1 << 4) #define RENDERSETTINGS_BIT_MPOPENED (1 << 5) #define RENDERSETTINGS_BIT_OVERRIDEBEHAVIOUR (1 << 6)
I hope I didn't miss any questions, if yes feel free to ask,
Cairyn last edited by
@m_adam Thanks for the info! I knew I was still missing a few flags ;-)