THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 03/12/2008 at 10:26, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R10+
Platform: Windows ;
Language(s) : C++ ;
---------
Hi folks,
I'm trying to record keys for an animation... I have created tracks for each joint (position and rotation XYZ tracks) and am then looping through my data to create keys for each at the appropriate keyframes.
What I'm basically doing is, for any change in position, I do a RecordKey() for X, Y and Z position tracks. For any change in rotation, I do a RecordKey() for X, Y and Z rotation tracks (in other words, for any 'keyframe', there's either 3 or 6 new keys, for any particular joint object).
Now, in my test case, the stats are as follows:
- Joints: 49 (a few of them have 0 or 1 keyframes, but most have many)
- total frames: 1680
- total keys to be generated to include XYZtranslation/XYZrotation for all joints, at the desired frames: 189,234
...note that the final number above is the total number of calls to doc->RecordKey() for the test case.
Ok, so here's the problem... If I Import this scene as .FBX, it loads fine and in fact, there are 3 copies of that skeletal strucure and as far as I can tell, there may be a 'keyframe' for _every_ joint at _every_ frame (in other words, far more keys than I'm trying to record with my plugin).
When I try to record all the keys, I quickly/eventually run out of memory(!). If I add a skip value and only record half the frames (or every 10th or 5th), it works fine. I have looked over the code multiple times now and just can't find any obvious source of memory leaks, so I'm hitting a brick wall.
Has anyone else noticed huge memory consumption with calling doc->RecordKey() ? The actual relevent secion of code (for position keys) looks like this:
if( (DWORD)(pKey->time) == i )
{
// convert to Cinema4D Matrix
Matrix am = Matrix( Vector(pJ->matLocal[0][3], pJ->matLocal[1][3], pJ->matLocal[2][3]),
Vector(pJ->matLocal[0][0], pJ->matLocal[1][0], pJ->matLocal[2][0]),
Vector(pJ->matLocal[0][1], pJ->matLocal[1][1], pJ->matLocal[2][1]),
Vector(pJ->matLocal[0][2], pJ->matLocal[1][2], pJ->matLocal[2][2]));
BaseObject *pJointObj = pJ->pJointObj;
pJointObj->SetMl(am);
pJointObj->Message(MSG_UPDATE);
stime = BaseTime::BaseTime(pKey->time, m_animationFps);
m_pBaseDoc->RecordKey(pJointObj, stime, DescID(DescLevel(ID_BASEOBJECT_POSITION,DTYPE_VECTOR,0),
DescLevel(VECTOR_X,DTYPE_REAL,0)), NULL, false, false, false);
m_pBaseDoc->RecordKey(pJointObj, stime, DescID(DescLevel(ID_BASEOBJECT_POSITION,DTYPE_VECTOR,0),
DescLevel(VECTOR_Y,DTYPE_REAL,0)), NULL, false, false, false);
m_pBaseDoc->RecordKey(pJointObj, stime, DescID(DescLevel(ID_BASEOBJECT_POSITION,DTYPE_VECTOR,0),
DescLevel(VECTOR_Z,DTYPE_REAL,0)), NULL, false, false, false);
totalkeys += 3;
break;
}
...with similar code for the rotation keys.