RecordKey() & Memory usage
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/12/2008 at 09:48, xxxxxxxx wrote:
Yeah, I've been suspecting that RecordKey() is doing some sort of AddUndo() internally, based on the symptoms. Where can I change the Undo Level setting? nm.. I found it in preferences... testing now...
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/12/2008 at 10:08, xxxxxxxx wrote:
Well, changing the Undo Depth doesn't seem to help, but I'll start looking into the lower level methods - thanks.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/12/2008 at 10:10, xxxxxxxx wrote:
Automatic undos in the SDK can be either a blessing or a curse. I've no experience with RecordKey() so am unfamiliar with its behavior. It may be storing a full change undo (UNDO_CHANGE) which always includes the object, its children, and it branches (including tags, materials, animation) which can eat memory for breakfast as I was forced to deal with unavoidably.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/12/2008 at 10:32, xxxxxxxx wrote:
Hmm... just to clarify...
Say I have 50 joints, with 6 tracks each (posx, posy, posz, rotx, roty, rotz). So that's 300 total tracks. To add a new key, I would then:- look up or otherwise retrieve my ptr to the CTrack (if I ultimately don't need CTrack pointers, I might just stash the CCurve pointers to start with)
- get the CCurve from the CTrack ( pCurve = pTrack->GetCurve() )
- either:
- Allocate a CKey ( pKey = CKey::Alloc() ), fill it in and pCurve->InsertKey(pKey) it.
- or: pKey = pCurve->AddKey( time ) then just fill the key in ( pCurve->SetKeyDefault() + pKey->SetValue() )
...is that all? What's this undo stuff you're talking about? In this case, I'm creating a new document, with enirely new data / keys. Is there any need for me to create undos?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/12/2008 at 11:10, xxxxxxxx wrote:
Bingo! Well, I need to figure out/fix the rotation values again (as soon as I finish my happy-dance), but I went from 277MB being used down to 3MB by just doing the CCurve/CKey thing (it's a lot faster as well).
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/12/2008 at 11:15, xxxxxxxx wrote:
When you create the new CTrack and CKeys, you could be adding undos (UNDO_NEW) - but it depends. In my case (IPP), the content could be being added to an existing document in which the user wants to be able to undo the addition. But if you are always creating a new document, the undos for these is probably unnecessary as there is nothing to 'undo' in a newly created document.
I should add, if you aren't doing this already, after filling in your document, do doc->SetChanged() so that it is marked as unsaved (you only need to do this if you don't add undos).
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/12/2008 at 11:24, xxxxxxxx wrote:
...and I went from _not being able to load the full animation_ to 33MB for the entire ~190,000 keys - yay.
It looks like I just need to fix some gimble-lock issue with the rotations now. Once I get it working, I'll post the updated code. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/12/2008 at 12:18, xxxxxxxx wrote:
After taking time out for another happy-dance, here's the final working code (this time I'll post the rotation key section instead of the position key section.. and have removed all the memory tracking stuff for clarity) :
//---------...S N I P...--- some variables setup earlier ----------------- Matrix am; CKey *pCKey; LONG keyNdx; Vector hpbBase = MatrixToHPB(pJ->ml); // 'rest' position, per joint BaseTime stime = BaseTime(i, m_animationFps); //---------...S N I P...----------------------------------------------- if( (DWORD)(pMyKey->time) == i ) // pMyKey is not a CKey, it's a different structure where my data is stored { // convert to Cinema4D 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])); Vector hpb = MatrixToHPB(am); // get HPB angles from joint-local animation matrix hpb = GetOptimalAngle(hpbBase, hpb); // correct for gimble-lock pCKey= pJ->pCurves[3]->AddKey(stime, &keyNdx); // RotX key if( pCKey) { pJ->pCurves[3]->SetKeyDefault(m_pBaseDoc, keyNdx); pCKey->SetValue(pJ->pCurves[3], hpb.x); } pCKey= pJ->pCurves[4]->AddKey(stime, &keyNdx); // RotY key if( pCKey) { pJ->pCurves[4]->SetKeyDefault(m_pBaseDoc, keyNdx); pCKey->SetValue(pJ->pCurves[4], hpb.y); } pCKey= pJ->pCurves[5]->AddKey(stime, &keyNdx); // RotZ key if( pCKey) { pJ->pCurves[5]->SetKeyDefault(m_pBaseDoc, keyNdx); pCKey->SetValue(pJ->pCurves[5], hpb.z); } break; }
...the position-key code is basically the same, but just uses am.off.x/y/z values. Also, I just cached the CCurve pointers as an array in my joint structure (0,1,2 are the position curve pointers).
As a final comment for the curious, each key generated now uses ~200 bytes :). -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/12/2008 at 02:02, xxxxxxxx wrote:
I gather you resolved your problem then?
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/12/2008 at 02:21, xxxxxxxx wrote:
Yes - thanks. It's apparently not a good idea to use RecordKey() :).
I could sure use some help with CAWeight Tags now though: https://developers.maxon.net/forum/topic/4233