Hello,
I'm trying to get the positions of the mograph matrix object in my ObjectData plugin and i'm having trouble with checking if it's cache is dirty and updating.
I'm using GetAndCheckHierarchyClone to tell if the cache is dirty, which is working, but for some reason it's saying that the cache is dirty twice.
Also when it does say the cache is dirty, I go to read the Matrix Array, and it returns outdated data.
Am I missing a step somewhere?
I'm developing on Mac OSX with C4D R18.
Here's my code (shortened for clarity and no error checking):
BaseObject* GetVirtualObjects(BaseObject* op, HierarchyHelp* hh)
{
GeData myData;
Bool dirty;
BaseObject *outObject, *inObject, *hClone;
outObject = BaseObject::Alloc(Ocube);
dirty = false;
hClone = nullptr;
inObject = op->GetDown();
hClone = op->GetAndCheckHierarchyClone(hh, inObject, HIERARCHYCLONEFLAGS_ASIS, &dirty, nullptr, false);
if (!dirty) {
blDelete(outObject);
return hClone;
}
maxon::BaseArray<Vector> pointList;
MoData *md;
GetMoDataMessage mdm;
mdm.modata = nullptr;
mdm.index = 0; // Get first set of modata
BaseTag *mct = hClone->GetTag(ID_MOBAKETAG); // check for cache
BaseTag *mdt = hClone->GetTag(ID_MOTAGDATA); // get mograph tag
if (!mct && !mdt) // we need at least one
return nullptr;
if (mct) // check cache first
mct->Message(MSG_GET_MODATA, &mdm);
if (!mdm.modata) // if cache didn't work, or if there is no cache
mdt->Message(MSG_GET_MODATA, &mdm);
if (mdm.user_owned)
md = mdm.Release();
else
md = mdm.modata;
MDArray<Matrix> marr = md->GetMatrixArray(MODATA_MATRIX);
for (Int32 x = 0; x < md->GetCount(); x++)
{
pointList.Append(marr[x].off);
}
if (mdm.user_owned)
MoData::Free(md);
GePrint( String::IntToString( pointList.GetCount() ) );
return outObject;
}