<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Overriding &#96;NodeData::GetAccessedObjects(..)&#96; prevents cache generation of cloned hierarchy]]></title><description><![CDATA[<p dir="auto">Hi, I'm currently trying to implement the new <code>NodeData::GetAccessedObjects(..)</code> as described in this <a href="https://developers.maxon.net/docs/cpp/2024_2_0/manual_migrating_plugins_to_2024.html#manual_migrating_plugins_2024_nodedata_data_access" target="_blank" rel="noopener noreferrer nofollow ugc">post</a>. But something is not right, because after derived for one particular object, the objects in the cache are left without their caches.</p>
<p dir="auto">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 <code>NodeData::GetAccessedObjects(..)</code> for this generator object, the cache is missing. A simplified version of my code below:</p>
<pre><code>maxon::Result&lt;Bool&gt; MyGenerator::GetAccessedObjects(const BaseList2D *node, METHOD_ID method, AccessedObjectsCallback &amp;access) const {
	yield_scope;
	switch (method) {
		case METHOD_ID::GET_VIRTUAL_OBJECTS: {
			node-&gt;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-&gt;GetDown();
	if (!firstChild) {
		return nullptr;
	}
	bool dirtyInput=false;
	BaseObject *input=object-&gt;GetAndCheckHierarchyClone(hierarchyHelp, firstChild, HIERARCHYCLONEFLAGS::ASIS, &amp;dirtyInput, nullptr, true);
	if (input) {
		if (!dirtyInput) {
			return object-&gt;GetCache();
		}
		BaseObject *cacheRoot=BaseObject::Alloc(Oconnector);
		if (!cacheRoot) {
			return cacheRoot;
		}
		input-&gt;InsertUnder(cacheRoot);
		return cacheRoot;
	}
	return nullptr;
}
</code></pre>
<p dir="auto">I tried several different flags to be used in the <code>GetAccessedObjects(..)</code> implementation, but none seemed to work. Only using <code>acess.MayAccessAnything()</code> in the implementation results in the previous behavior, but that is not the point of actually using the function.</p>
<p dir="auto">Am I missing something obvious or there might be a problem with my approach as a whole?</p>
]]></description><link>http://developers.maxon.net/forum/topic/15325/overriding-nodedata-getaccessedobjects-prevents-cache-generation-of-cloned-hierarchy</link><generator>RSS for Node</generator><lastBuildDate>Mon, 11 May 2026 17:58:05 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/15325.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 09 Jan 2024 18:27:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Overriding &#96;NodeData::GetAccessedObjects(..)&#96; prevents cache generation of cloned hierarchy on Thu, 11 Jan 2024 10:13:32 GMT]]></title><description><![CDATA[<p dir="auto">Thanks a lot for the clarification! It would be nice to include more usecase examples of <code>GetAccessedObjects(..)</code> implementation in the SDK examples in the future. I will try your suggestion once 2024.4 becomes available.</p>
]]></description><link>http://developers.maxon.net/forum/post/73514</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/73514</guid><dc:creator><![CDATA[Deyan]]></dc:creator><pubDate>Thu, 11 Jan 2024 10:13:32 GMT</pubDate></item><item><title><![CDATA[Reply to Overriding &#96;NodeData::GetAccessedObjects(..)&#96; prevents cache generation of cloned hierarchy on Thu, 11 Jan 2024 07:10:15 GMT]]></title><description><![CDATA[<p dir="auto">The function <code>GetAndCheckHierarchyClone</code> creates clones of all children, therefore it has to read everything from the children and you need <code>ACCESSED_OBJECTS_MASK::ALL</code> in the read part. It'll also mark the children as being consumed by your generator so that they don't create virtual objects on their own (only their clones in the cache of your generator will create virtual objects), and for this mark you need <code>ACCESSED_OBJECTS_MASK::CACHE</code> in the write part.</p>
<p dir="auto"><code>GetAndCheckHierarchyClone</code> doesn't read global matrices, so the <code>GLOBAL_MATRIX</code> flag isn't needed.</p>
<p dir="auto">The flags in the other call can be reduced to <code>access.MayAccess(node, ACCESSED_OBJECTS_MASK::NONE, ACCESSED_OBJECTS_MASK::CACHE)</code>. That's because your <code>GetVirtualObjects</code> doesn't read anything from the generator itself (<code>NONE</code>), it'll only set up its virtual objects (<code>CACHE</code>). As soon as you access the BaseContainer of your generator, you have to add <code>DATA</code>. For the matrix <code>MATRIX</code> or even <code>GLOBAL_MATRIX</code> etc.</p>
]]></description><link>http://developers.maxon.net/forum/post/73512</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/73512</guid><dc:creator><![CDATA[o_kniemeyer]]></dc:creator><pubDate>Thu, 11 Jan 2024 07:10:15 GMT</pubDate></item><item><title><![CDATA[Reply to Overriding &#96;NodeData::GetAccessedObjects(..)&#96; prevents cache generation of cloned hierarchy on Wed, 10 Jan 2024 13:14:15 GMT]]></title><description><![CDATA[<p dir="auto">Thank you for you answer <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/o_kniemeyer">@<bdi>o_kniemeyer</bdi></a> . Just to be clear about the proper implementation <em>once</em> <code>GetAccessedObjects(..)</code> is implemented for the Connector - what are the minimal read and write flags for the hierarchy call, if <code>GetVirtualObjects(..)</code> calls <code>GetAndCheckHierarchyClone(hierarchyHelp, firstChild, HIERARCHYCLONEFLAGS::ASIS, &amp;dirtyInput, nullptr, true);</code>. I'm asking because in my example I tried with <code>ACCESSED_OBJECTS_MASK::ALL | ACCESSED_OBJECTS_MASK::GLOBAL_MATRIX</code> for read and <code>ACCESSED_OBJECTS_MASK::CACHE</code> for write, but I have a suspicion this may not be optimal (the write flags even feel wrong).</p>
]]></description><link>http://developers.maxon.net/forum/post/73504</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/73504</guid><dc:creator><![CDATA[Deyan]]></dc:creator><pubDate>Wed, 10 Jan 2024 13:14:15 GMT</pubDate></item><item><title><![CDATA[Reply to Overriding &#96;NodeData::GetAccessedObjects(..)&#96; prevents cache generation of cloned hierarchy on Wed, 10 Jan 2024 12:39:14 GMT]]></title><description><![CDATA[<p dir="auto">There's no way for you to know if an object implements <code>GetAccessedObjects</code> or not. And even if there was a way, that wouldn't help in general because that implementation could still decide to call <code>MayAccessAnything()</code>, e.g. based on the object's settings. You need the knowledge that the connect object supports <code>GetAccessedObjects</code> AND won't call <code>MayAccessAnything()</code> in the configuration which you create in your code.</p>
<p dir="auto">The only clean way would be to call <code>GetAccessedObjects</code> on the connect object within <code>MyGenerator::GetAccessedObjects</code>. That's what <code>node-&gt;GetAccessedObjectsOfFirstChildHierarchy()</code> does with the object's children. But you don't have the connect object yet in <code>GetAccessedObjects</code>, so that's not feasible.</p>
]]></description><link>http://developers.maxon.net/forum/post/73503</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/73503</guid><dc:creator><![CDATA[o_kniemeyer]]></dc:creator><pubDate>Wed, 10 Jan 2024 12:39:14 GMT</pubDate></item><item><title><![CDATA[Reply to Overriding &#96;NodeData::GetAccessedObjects(..)&#96; prevents cache generation of cloned hierarchy on Wed, 10 Jan 2024 12:29:34 GMT]]></title><description><![CDATA[<p dir="auto">Hi Deyan,</p>
<p dir="auto">your code for GetAccessedObjects is correct. The problem is that you use the connect object, and this object doesn't implement GetAccessedObjects yet. There are a lot of objects in the C4D code base, and we at Maxon haven't had the time yet to implement GetAccessedObjects for all of them.</p>
<p dir="auto">A GetAccessedObjects implementation has to tell about all access which GetVirtualObjects will make to the scene, and also about all access which the objects created by GetVirtualObjects will make to the scene when GetVirtualObjects is called on them. Also all objects created by GetVirtualObjects have to support GetAccessedObjects. The connect object doesn't, so your code fails.</p>
<p dir="auto">The connect object will support GetAccessedObjects in 2024.4. So you have to wait a bit, I'm sorry.</p>
]]></description><link>http://developers.maxon.net/forum/post/73502</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/73502</guid><dc:creator><![CDATA[o_kniemeyer]]></dc:creator><pubDate>Wed, 10 Jan 2024 12:29:34 GMT</pubDate></item></channel></rss>