multiple inits



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

    On 08/05/2005 at 12:55, xxxxxxxx wrote:

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

    ---------
    Hi All,
    Now this must be very stupid of me.
    I use the MyTagPlug::Init(GeListNode*node) to initialize this and that.
    just for fun (not really) added a passcounter.
    It shows that Init is called multiple times, even when dragging a slider!
    So i added a blocking: increment a PassCounter on every pass of Init.
    if (PassCounter is >0) return false;
    And i added a decrementer in MyTagPlug::Free(GeListNode*node).

    This should work out fine: every time a new instance is made, one initialization, every deletion of the tag: a decrement of the PassCounter.
    Not so: it shows several inits and free's.
    Think its not only my plug, tested it with the SDK 'LookAtCamera' tag. Same things hapening.
    What is this ? What am i doing wrong?
    With Regards,



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

    On 08/05/2005 at 14:55, xxxxxxxx wrote:

    Nothing is being done wrong. You must remember that Cinema 4D makes copies of the document and objects before rendering and during redraws. Redraws are done everytime there is an update. Everything is copied, therefore the Init()/Free() are called on the copies as well as the original that you (or the user) created.

    It is maddening though. If the manual would only lay out some of what happens during redraws and renders in a schematic layout, it would make us all understand these seeming peculiarities.



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

    On 08/05/2005 at 23:14, xxxxxxxx wrote:

    Quote: It is maddening though. If the manual would only lay out some of what happens during redraws and renders in a schematic layout, it would make us all understand these seeming peculiarities.
    >
    > * * *
    >
    > * * *

    And that would change what? Your plugin must be initialised for every call anyway. That´s why the init function is called. It means the document needs updated data. And most of the time this happens for rendering. So if you know why or not, it wouldn´t change anything.

    Rather get your head around sth that is really important and not those logic-buggers that just waste your time.

    Just my POV :)



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

    On 09/05/2005 at 01:13, xxxxxxxx wrote:

    Just noticed my answer might sound a bit harsh. No offense intented though! :)



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

    On 09/05/2005 at 13:03, xxxxxxxx wrote:

    Hi,
    Thanks, both, but i was'nt playing with code.
    I thought i found a smart way to detect an allready running instance of my plug. (i need that info because only one is allowed).
    Anyway, blocking this way does'nt help because i realize now that not only the object, but new variables must be made too, when this copying happens.
    But: if the init is run again for a certain task needed, all variables are reset in the Init, this instance must believe its the beginning of its universe, hmm, this is getting complicated. Better find another way.
    Regards,



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

    On 09/05/2005 at 13:45, xxxxxxxx wrote:

    Hi jana,
    i ran into the same problem with my objectPlugin, where i discovered that it is not me who is in control about instantiating like i am used to when doing OOP. Unfortunately there is no copyConstructor which might be used to at least keep the data of instances consistent.
    The only way i see for plugindeveloper is create some global instance of an singleton dataobject holding the data you need. At least this works for constructive objects, with interactively editable objects there are multithreading problems, meaning you might loose contact to your global data while mousemoving with the MOVE-tool.
    If you find better solutions please let us know.

    greetings
    Peter



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

    On 09/05/2005 at 14:39, xxxxxxxx wrote:

    Actually, there is. The NodeData class has three methods:

    Read()
    Write()
    CopyTo()

    When a copy of an instantiated object is made (by C4D), C4D allocates the copy, calls Init(), and then CopyTo() (through a transparent AliasTrans) in order to have a clone. If all of your data is stored in Resources/Descriptions, the CopyTo() is automatic. If you have data members in your Data class that need to be copied (like an allocated array), then you need to implement all three of these for data persistence.


Log in to reply