Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    BaseContainer Performance

    SDK Help
    0
    3
    272
    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.
    • H
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 29/08/2006 at 07:47, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   9.6 
      Platform:   Windows  ; Mac  ;  
      Language(s) :     C++  ;

      ---------
      Hi,

      I have a general question concerning getting values out of a BaseContainer instance.

      I need some values from my plugin object several times in a calculation, so I am asking myself if it´s faster to store the value from the basecontainer in a variable of mine and use this one or if it´s performance-wise the same if I´d retrieve the values directly from the basecontainer?

      I assume the former is the case but I am not absolutely sure.

      Thanks
      Katachi

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 29/08/2006 at 09:50, xxxxxxxx wrote:

        Most definitely faster to use a variable to store the BaseContainer value if you are going to use it more than once. This will be slow if done multiple times:

        x = m * obj->GetDataInstance()->GetReal(ID_MYREAL);
        y = n * obj->GetDataInstance()->GetReal(ID_MYREAL);
        z = o * obj->GetDataInstance()->GetReal(ID_MYREAL);

        This won't be quite as slow:

        BaseContainer* bc = obj->GetDataInstance();
        x = m * bc->GetReal(ID_MYREAL);
        y = n * bc->GetReal(ID_MYREAL);
        z = o * bc->GetReal(ID_MYREAL);

        But this is better:

        BaseContainer* bc = obj->GetDataInstance();
        r = bc->GetReal(ID_MYREAL);
        x = m * r;
        y = n * r;
        z = o * r;

        Of course, you should weigh how many times you'll need to reference the BaseContainer to set or get values as well as how often the values are needed. For a one-off use, the quickest method would be (and avoid the stack variables) :

        x = m * obj->GetDataInstance()->GetReal(ID_MYREAL);

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 29/08/2006 at 10:01, xxxxxxxx wrote:

          Hi Kuro,

          thanks, that confirms what I am currently doing. Thanks for the check! 🙂

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