Crash when creating keyframes



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

    On 30/04/2008 at 13:35, xxxxxxxx wrote:

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

    ---------
    Hi,

    in my expression tag, I have a function to record keyframes... it gets global position and rotation, as well as other attributes, from the camera object the tag is attached to, and stores them in keyframes for another camera object.

    Some users (they all use Win32) experience a crash immediately when using that function. The problem is: whatever I do, I can't reproduce that crash. It just runs perfectly on my computer. Tested in R10.1 and R10.5, no difference.

    Here's my code of the recording function:

    > <code>          Vector GlobalPos = op->GetMg().off;
    >           Vector GlobalRot = MatrixToHPB(op->GetMg());
    >           SC_RecorderCam->SetMg(op->GetMg());
    >           if (SC_FocusEnabled)
    >           {
    >                SC_RecorderCam->GetDataInstance()->SetBool(CAMERAOBJECT_FRONTBLUR, true);
    >                SC_RecorderCam->GetDataInstance()->SetBool(CAMERAOBJECT_REARBLUR, true);
    >                CreateKey(doc, SC_RecorderCam, currentTime, CAMERAOBJECT_TARGETDISTANCE, SC_FocusDistance + SC_FocusOffset + SC_DeFocusOffset);
    >                CreateKey(doc, SC_RecorderCam, currentTime, CAMERAOBJECT_FRONTSTART, SC_FocusRangeMin / 2);
    >                CreateKey(doc, SC_RecorderCam, currentTime, CAMERAOBJECT_FRONTEND, SC_FocusRangeMin / 2);
    >                CreateKey(doc, SC_RecorderCam, currentTime, CAMERAOBJECT_REARSTART, SC_FocusRangeMin / 2);
    >                CreateKey(doc, SC_RecorderCam, currentTime, CAMERAOBJECT_REAREND, SC_FocusRangeMax / 2);
    >                CreateKey(doc, SC_RecorderCam, currentTime, CAMERA_FOCUS, SC_FocusZoom);
    >           }
    >           CreateVectorKey(doc, SC_RecorderCam, currentTime, ID_BASEOBJECT_POSITION, GlobalPos);
    >           CreateVectorKey(doc, SC_RecorderCam, currentTime, ID_BASEOBJECT_ROTATION, GlobalRot);
    >           tag->GetDataInstance()->SetString(SCOOBYCAMEXP_RECORDER_INFOTEXT, GeLoadString(SCOOBYCAMEXP_MSG_RECORD_RECORDING));
    > </code>

    The functions CreateKey and CreateVectorKey look like this:

    > <code>static Bool CreateKey(BaseDocument *doc, BaseObject *op, const BaseTime &time;, LONG index, Real value)
    > {
    >      // check if track exists
    >      CTrack *track = op->FindCTrack(DescLevel(index,DTYPE_REAL,0));
    >      if (!track)
    >      {
    >           track = CTrack::Alloc(op,DescLevel(index,DTYPE_REAL,0)); if (!track) return FALSE;
    >           op->InsertTrackSorted(track);
    >      }
    >
    >      CKey *key = track->GetCurve()->AddKey(time); if (!key) return FALSE;
    >      key->SetValue(track->GetCurve(),value);
    >      return TRUE;
    > }
    >
    > static Bool CreateVectorKey(BaseDocument *doc, BaseObject *op, const BaseTime &time;, LONG index, Vector value)
    > {
    >      // check if tracks exist
    >      CTrack *trackX = op->FindCTrack(DescID(DescLevel(index,DTYPE_VECTOR,0),DescLevel(VECTOR_X,DTYPE_REAL,0)));
    >      CTrack *trackY = op->FindCTrack(DescID(DescLevel(index,DTYPE_VECTOR,0),DescLevel(VECTOR_Y,DTYPE_REAL,0)));
    >      CTrack *trackZ = op->FindCTrack(DescID(DescLevel(index,DTYPE_VECTOR,0),DescLevel(VECTOR_Z,DTYPE_REAL,0)));
    >
    >      if (!trackX)
    >      {
    >           trackX = CTrack::Alloc(op,DescID(DescLevel(index,DTYPE_VECTOR,0),DescLevel(VECTOR_X,DTYPE_REAL,0)));
    >           op->InsertTrackSorted(trackX);
    >      }
    >      if (!trackY)
    >      {
    >           trackY = CTrack::Alloc(op,DescID(DescLevel(index,DTYPE_VECTOR,0),DescLevel(VECTOR_Y,DTYPE_REAL,0)));
    >           op->InsertTrackSorted(trackY);
    >      }
    >      if (!trackZ)
    >      {
    >           trackZ = CTrack::Alloc(op,DescID(DescLevel(index,DTYPE_VECTOR,0),DescLevel(VECTOR_Z,DTYPE_REAL,0)));
    >           op->InsertTrackSorted(trackZ);
    >      }
    >
    >      CKey *keyX = trackX->GetCurve()->AddKey(time); if (!keyX) return FALSE;
    >      CKey *keyY = trackY->GetCurve()->AddKey(time); if (!keyY) return FALSE;
    >      CKey *keyZ = trackZ->GetCurve()->AddKey(time); if (!keyZ) return FALSE;
    >
    >      keyX->SetValue(trackX->GetCurve(),value.x);
    >      keyY->SetValue(trackY->GetCurve(),value.y);
    >      keyZ->SetValue(trackZ->GetCurve(),value.z);
    >
    >      return TRUE;
    > }</code>

    Greetings and thanks for any help,
    Jack



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

    On 01/05/2008 at 05:53, xxxxxxxx wrote:

    I tracked the crash down now...

    It happens in function
    static Bool CreateKey(BaseDocument *doc, BaseObject *op, const BaseTime &time;, LONG index, Real value)
    in the line
    CKey *key = track->GetCurve()->AddKey(time); if (!key) return FALSE;

    It seems that track is a Null pointer, but I can't tell why. Also, the crash only happens in C4D R10.5 and only if I use certain optimization options in VisualStudio.

    When I deactivate the "Global Optimization", my .cdl file grows by about 50KBytes, but the crash does not happen anymore.

    Strange, but I can live with it.

    Greetings,
    Jack



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

    On 01/05/2008 at 06:25, xxxxxxxx wrote:

    A plugin compiled in 10.1 will crash in 10.5 when GetCurve() is used. You have to provide a 10.5 compiled version of your plugin. See also this thread:

    CTrack::GetCurve in 10.5 crashes

    cheers,
    Matthias



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

    On 03/05/2008 at 03:01, xxxxxxxx wrote:

    OK, I will remember that. Thanks Matthias!

    I just wonder about the fact that it now works pretty fine, just because I deacivated the Global Optimization.

    Maybe I'll leave it as it is now, those bunch of KBytes don't really matter to me ;-) Or is there anything bad about it?

    Or would it be possible to query if the plugin is running in R10.1 or R10.5? Like:

    if (R10.1)
    { do what I always do }
    else
    { do something special for 10.5 }

    Greetings,
    Jack



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

    On 03/05/2008 at 06:18, xxxxxxxx wrote:

    GetC4DVersion() returns the full version of Cinema 4D being run in a LONG value such as 10111 (10.111) or 9603 (9.603).


Log in to reply