On 12/11/2014 at 05:53, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 15
Platform: Windows ;
Language(s) : C++ ;
---------
Hi, me again :-)
This post will be related to uniqueness of objects and information available in this thread:
Thread A: https://plugincafe.maxon.net/topic/8214/10707_uniqueobjectidgetmarkerstampexgetmarker-solved
I'm trying to write some sort of caching system that lets me listen to dirty states of objects (polygon-objects, lights, materials). I'm only interested in objects that have changed compared to my last render call. My procedure works like this:
When a render call is sent, for each object of interest:
1. Create a unique id from the object of interest (refer to thread A on top)
2. Check in a map/container if the object is dirty, if no, go to 3. if yes go to 4.
3. Object is not dirty, so we skip it, CONTINUE with 1.
4. Object is dirty, so we extract valuable information from it
5. Update the dirty state of the object in our map/container, or if it is not present, insert it
6. CONTINUE with 1.
My problem is now, that the unique id and the dirty mechanism of C4D only work if the scene/document stays the same. Unfortunately, C4D copies the document when rendering. This happens, as far as I know, because the artists should be able to keep on working while rendering.
Here I summarize what I have found out about the copying behavior in C4D:
* Editor Render View: My dirty mechanism works great, all unique ids are actually unique, the dirty states are correct.
* Picture Viewer: When rendering a whole animation the whole dirty mechanism fails for the first frame, so everything "has changed". But afterwards my procedure works fine.
* Picture Viewer: When rendering single images, and clicking the Picture Viewer icon one after the other, my mechanism completely breaks. I found out that the dirty states of the object in a test scene stays exactly the same! So, for example, a Cube sitting there might have the dirty state (of all flags for simplicity) of 22. When I move the camera, and hit on the Picture Viewer again, the Cube receives a new unique id from my code, but the dirty state stays the same. So I and C4D know that the object has not changed, but since it is a copy, I cannot get the same id back from the rendering before.
* Interactive Render Region: This is crazy as hell, every time the region is update, all my unique ids change to new ones, so my algorithm breaks.
Now my questions:
* Is it true that all this happens because C4D always copies a document before rendering?
* Is there a way to tell C4D to not copy the document at all? I will promise to return quickly, so that the user won't wait for long!
* Is it somehow possible (and this is actually the same question as in thread A) to get a REALLY UNIQUE OBJECT ID. This should behave like when looking at a scene and saying: "Oh, a green cube up there!" This green cube up there is the same and I can clearly see it, so I want a mechanism in C4D to do exactly this.
I would go back to using the GetActiveDocument() but I was told to not do so, because it can lead to crashes and strange bugs.
In my case the easiest solution would be to stop C4D from copying the document, although I already can hear you all shouting at me! ;-)
Alternatively, please give me an actually unique object id, an id that identifies it. An id that lets me know if it is the same object in the current frame, 100 frames later, stretched, rotated, moved, disabled, etc. In all those cases, it is still the same object and I don't care if C4D wants to copy a scene, I simply want a unique id!
Thanks,
Andreas