Array reseting on undo



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

    On 26/12/2004 at 04:57, xxxxxxxx wrote:

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

    ---------
        Hi,

    I have a tag plugin that modifies the points of a spline object that the tag is on. I have a button for that tag plugin to remember the current state of the spline (the point locations), so I can reset it at anytime by clicking another button in the AM.

    To keep a current state of the spline, I create an member array, and copy the SplineObject::GetPoint() values into my new array, like this

      
    lPointCount = op->GetPointCount();  
      
    OriginalPoints = new Vector[lPointCount];  
    Vector *vadr = op->GetPoints();  
      
    for(j=0; j < lPointCount; j++)  
    {  
    // Store original point  
    OriginalPoints[j] = vadr[j];  
    }  
    

    OriginalPoints is a member variable.

    My problem is, if I move the points of the spline using standard c4d tools, and then clicking the undo button in C4D, it NULL's my OriginalPoints variable, causing it crash on some functions of my plugin.

    Why would undo reset my OriginalPoints variable?

    This is a bad problem, as I'm saving the OriginalPoints array to the file, and if the user clicks undo first. It crashes C4D

    Thanks



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

    On 26/12/2004 at 10:15, xxxxxxxx wrote:

    Undo would call CopyTo. Do copy all of the data in the CopyTo function?

    darf



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

    On 27/12/2004 at 08:25, xxxxxxxx wrote:

    Thanks Darf,

    I didn't know Undo called CopyTo so consequently I wasn't passing the array.

    It works a charm now, thanks again

    Ian



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

    On 27/12/2004 at 10:53, xxxxxxxx wrote:

    Cool. Its the little things that get ya. It is easy to miss ( very easy ). 9-)

    Regards,
    darf


Log in to reply