Hi, I'm currently trying to implement the new NodeData::GetAccessedObjects(..)
as described in this post. But something is not right, because after derived for one particular object, the objects in the cache are left without their caches.
To give a bit more details - I have an object generator implementation, which is effectively cloning its child hierarchy and putting it under a Connector object. But after adding an override of NodeData::GetAccessedObjects(..)
for this generator object, the cache is missing. A simplified version of my code below:
maxon::Result<Bool> MyGenerator::GetAccessedObjects(const BaseList2D *node, METHOD_ID method, AccessedObjectsCallback &access) const {
yield_scope;
switch (method) {
case METHOD_ID::GET_VIRTUAL_OBJECTS: {
node->GetAccessedObjectsOfFirstChildHierarchy(
ACCESSED_OBJECTS_MASK::ALL | ACCESSED_OBJECTS_MASK::GLOBAL_MATRIX,
ACCESSED_OBJECTS_MASK::CACHE,
METHOD_ID::GET_VIRTUAL_OBJECTS_AND_MODIFY_OBJECT,
access
) yield_return;
return access.MayAccess(
node,
ACCESSED_OBJECTS_MASK::DATA | ACCESSED_OBJECTS_MASK::GLOBAL_MATRIX,
ACCESSED_OBJECTS_MASK::CACHE
);
}
}
return ObjectBase::GetAccessedObjects(node, method, access);
}
BaseObject* MyGenerator::GetVirtualObjects(BaseObject *object, const HierarchyHelp *hierarchyHelp) {
BaseObject *firstChild=object->GetDown();
if (!firstChild) {
return nullptr;
}
bool dirtyInput=false;
BaseObject *input=object->GetAndCheckHierarchyClone(hierarchyHelp, firstChild, HIERARCHYCLONEFLAGS::ASIS, &dirtyInput, nullptr, true);
if (input) {
if (!dirtyInput) {
return object->GetCache();
}
BaseObject *cacheRoot=BaseObject::Alloc(Oconnector);
if (!cacheRoot) {
return cacheRoot;
}
input->InsertUnder(cacheRoot);
return cacheRoot;
}
return nullptr;
}
I tried several different flags to be used in the GetAccessedObjects(..)
implementation, but none seemed to work. Only using acess.MayAccessAnything()
in the implementation results in the previous behavior, but that is not the point of actually using the function.
Am I missing something obvious or there might be a problem with my approach as a whole?