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

    Best way to store "Bake" Information

    Cinema 4D SDK
    2
    3
    501
    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.
    • D
      d_schmidt
      last edited by d_schmidt

      Hello! I had a more general question about the proper way to do something within Cinema.

      I want to have a 'Bake' button on my plugin that will do some of the heavy lifting as a single step, so that these calculations don't need to be done on a per update basis. I could create the needed data structures once and use those instead of constantly rebuilding them.

      My question is what is the best way to implement this. My initial thought was to use a BaseArray of a custom Class to store the needed data. Something along the lines of one entry per child object to keep track of relationships and choices. Is this a valid way to go about it?

      I was running into some problems with Read and Write, converting the Class to be read and written could be done though. One thing I was stumped on is that if I Free my BaseArray when the object is deleted then how would I bring it back if Undo was used?

      Thanks for any help,
      Dan

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        Hi,

        I'm guessing you are in an NodeData?

        There's no "best way".

        Depending on your data, you need to create a container for them. Could be a class, an array.
        You must implement Read, Write and CopyTo. (If you implement one, you need all of them).

        Either you serialized the data into smaller data that can be read/write to hyperfiles with already existing function, or you can use WriteMemory that will allow you to write object to hyperfiles. Be aware that WriteMemory is not platform independent. Then, you can use ReadMemory.

        If you delete the object, the object will be copied to the undo stack. The CopyTo willl be used to copy your data.

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • D
          d_schmidt
          last edited by

          Hi Manuel,

          I didn't think about CopyTo being called on undo. That might be all I need then, thanks. I did a couple tweaks and as of now everything is perfect.

          Dan

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