Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    SetBit vs. SetAllBits etc... flags documentation?

    Cinema 4D SDK
    r21 python
    2
    3
    400
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • CairynC
      Cairyn
      last edited by

      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 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 SetBit() and SetAllBits() 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 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_OFOLD has been replaced by NBIT_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's BIT_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.)

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi @Cairyn

        1. SetBit as the name suggest will only set the passed bit doing l_bitfeld = l_bitfeld | mask; where mask is the Int32 input bit (so you can toggle multiple bit passing a BitField), while SetAllBit do l_bitfeld = bits; where bits is the Int32 bitfield, so if you pass only BIT_ACTIVE to SetAllBit only BIT_ACTIVE will be set and not the other.
        2. 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++.
        3. 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 than return (bits & InputBitSetToTest) == InputBitSetToTest;.
        4. 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.
        5. BIT_MFOLD means folded in the material manager when used as a Texture Layer mode (in bodypaint).
        6. 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.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        CairynC 1 Reply Last reply Reply Quote 1
        • CairynC
          Cairyn @m_adam
          last edited by

          @m_adam Thanks for the info! I knew I was still missing a few flags 😉

          1 Reply Last reply Reply Quote 0
          • First post
            Last post