SetBit vs. SetAllBits etc... flags documentation?
-
Here's a documentation question I just stumbled over:
The functions
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 functionSetAllBits()
which... does the same asSetBit()
? 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 betweenSetBit()
andSetAllBits()
that I fail to see?The function
GetBit()
is documented as returning an int. It does return a bool though. (So in this case, there is a significant difference toGetAllBits()
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_OFOLD
has been replaced byNBIT_OM1/2/3/4_FOLD
some 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'sBIT_MFOLD
currently doing?There is also still no formal constant BIT_SELECTRENDERDATA to denote selected render data entries - searching this forum yields the numeric value
0x08
so I guess that still counts as undocumented functionality. (Again, I didn't verify yet.) -
Hi @Cairyn
SetBit
as the name suggest will only set the passed bit doingl_bitfeld = l_bitfeld | mask;
wheremask
is the Int32 input bit (so you can toggle multiple bit passing a BitField), while SetAllBit dol_bitfeld = bits;
wherebits
is the Int32 bitfield, so if you pass only BIT_ACTIVE to SetAllBit only BIT_ACTIVE will be set and not the other.GetBit
should 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++.GetBit
can accept a bitfield and return True only when all bits of the bitfield is set in the object. in fact GetBit is nothing more thanreturn (bits & InputBitSetToTest) == InputBitSetToTest;
.BIT_OFOLD
is 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_MFOLD
means 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,
Cheers,
Maxime. -
@m_adam Thanks for the info! I knew I was still missing a few flags