Render Plugin: DirtyState, UniqueId, ActiveDoc

On 14/11/2014 at 08:57, xxxxxxxx wrote:

I agree with you, that the proposed hack will not lead to a smooth user experience.
As Sebastian already elaborated the different existing mechanisms to identify objects and none of these seems to fulfill your needs, I'd like to do a step back for a moment.
Please be patient with me, I only have a very faint idea, how your project looks like and what you are trying to achieve.
You already said, you are doing your own renderer. And in my imagination you are trying to optimize it in a way, that you only need to transfer/transform changed data (be it geometry, be it materials, textures) to your renderer. While I understand your concern, you should take into account that C4D is copying the scene in certain cases for good reasons. And I think, you should consider, if it wouldn't be better to rebuild your entire data from the given copy of the scene, rather than trying to detect changes in these cases.

Now I can already see you jumping up and down, calling me names. But hope we can discuss this peacefully 😉

On 14/11/2014 at 10:06, xxxxxxxx wrote:

there is a solution "not sure if it is (correct)" but it may work, use SetUniqueIP() , at the first render, you just set each object from your RayObject(s) , after that, when you render again, check all ray objects that are set "got a valid unique ip in a known range that you define" , and if the object is dirty, send it, if it has invalid unique ip, give it a new unique ip, and send it, this approach will let you control the IPs, but I sense it is pretty dangerous

On 14/11/2014 at 10:09, xxxxxxxx wrote:

I'd rather recommend to use a hidden tag for this.

On 15/11/2014 at 04:02, xxxxxxxx wrote:

I'd rather recommend to use a hidden tag for this.

I think this might be the right track! 🙂

I will try the following:
* Create a tag that simply stores a unique id in its container, the ids are, for example, created by simple incrementing a windows HUGE ^^
* When a render call happens, iterate over all objects in the scene and attach the tag to them, if they don't already have the tag
* Now if I want to identify an object, I can simply check for the tag because the id in the tag will not change even when the scene is copied.
* In the end I will hide the tag (I guess that this is easy?!)

I report back, if I have tested this approach.

Thanks Andreas for this hint! 🙂

On 15/11/2014 at 04:05, xxxxxxxx wrote:

To be honest, the idea came from Sebastian, when I discussed this topic with him. Nevertheless glad it may help.

On 17/11/2014 at 10:09, xxxxxxxx wrote:

Hi all,

I don't think that storing a unique ID in a hidden tag would solve all the problems. Think of generators that clone objects, i.e. emitters, arrays mograph and so on.

You will end up with multiple objects with the same unique ID.

That might be helpful in a few cases, but when you want to keep track of objects across several frames (for motion blur), it won't work.

I would also like to see some way to actually be able to uniquely identify objects *reliably*. None of the available methods actually work.

* Markers: will not give consistent unique IDs.
* Unique IPs: only work properly in external renderer, somewhat consistently, but I have a scene or two where they fail. Magic number IPs for generators and black magic IP generation that only works in the external renderer? Has to be some sort of inside joke 🙂
* GetGUID: doesn't give consistent IDs and fails in the same cases as the unique IPs. It's based on them, not sure what I expected.

But even the best IP system doesn't help you if you want to track changes in a scene, as it will break when changing the order, removing or inserting. (In this case the hidden tags might help).

On 17/11/2014 at 12:25, xxxxxxxx wrote:

Welcome fused to this old unanswered topic^^

I have thought about the tag system and there are a lot of problems related to copy pasting objects from one scene to another and there are also problems related to undo/redo functionality.

The interesting part is, that C4D has to keep track of objects inside it too. Is it possible to hear a comment of someone actually developing C4D?

On 17/11/2014 at 12:36, xxxxxxxx wrote:

Oh and another one:
Is it possible to identify a document? Let's say my open scene is named "TestScene.c4d". When I render into the Render View the document should be the same, so no copy. I can check this with RENDERFLAGS_NODOCUMENTCLONE but I want to identify a copy as well. So, for example, my original TestScene.c4d has id 12345 and when I work on a copy the id of the document is, e.g. 987768. This is important because I have found that my caching system even breaks when materials should be checked for dirty states because they seem to be a copy too. So I need to setup a separate caching system for each document C4D copies/creates on the way down the rendering pipeline.

Maybe a C4D programmer can join this discussion here?

On 17/11/2014 at 15:29, xxxxxxxx wrote:

@FrozenTarzan I think this is an unavoidable behavior!!
in Maxwell render, and even in Cinema 4D standard and physical render, once you click render it will start creating BVH from scratch every time

On 18/11/2014 at 19:27, xxxxxxxx wrote:

For your information FrozenTarzan, Sebastian is currently working in C4D's rendering code. You can't get closer to a C4D developer than this.

The workflow in C4D is to clone the scene sent for renderering. As MohamedSakr pointed out, All professionnal renderer plugins live fine with this. I suggest to either go with the flow or follow one of the solution ideas discussed.  The tag with an ID seems promising to me and yes there will be complexity to resolve around generators and procedural objects.

Unless you have questions about our current APIs I'm not sure we will be able to help you much.
best regards,

Jean-Francois Yelle
Development Support Manager

On 19/11/2014 at 04:08, xxxxxxxx wrote:

Hi Jean-Francois Yelle,

I'm trying hard to be polite, but your answer has nothing to do with my questions. You don't have to sell your API here, you don't have to convince me that your API in C4D is well designed. I'm already developing with it. And yes my project might be good advertisement for Cinema4D as a whole in the future. All I'm asking is to receive honest and clear answers to simple questions. It is absolutely ok to tell me "Yes every engine, every software handling objects in any way has to have a solution for uniquely identifying them. Of course C4D does this as well internally, but our API does not offer a consistent, unique and stable way to do this from a user/programmer/developer perspective." Non, absolutely not a single one of the ideas presented in this forum is the solution to my problem. It is ok to admit this.

And again, there is no problem with admitting problems in C4D, it is no problem to tell us that you don't know the answer. It is also ok to admit that C4D's API is old, really old and based on strange C-style patterns. This is the normal way a software grows when time goes on. But I beg you to give honest and clear answers to questions. Sebastian, for example, have posted that there seems to be a bug in the render region functionality here:
This is so cool, because since then I know that it is not my fault and I can go on with the project, so thanks again! 🙂

I have a team behind me for this project and we will go on working hard on it, so I'm looking forward to interesting and productive discussions here in the plugincafe community.


On 19/11/2014 at 06:47, xxxxxxxx wrote:


C4D is 20 years old, and has a rendering pipeline built around creating a copy of the scene which enables the user to his work while rendering.
In this rendering pipeline, our internal UID system cannot be used to recognize scene changes and relate to the cloned object. Sebastian's proposal to use your own UID in tags around a variation of a subject/observer design pattern still seems to us like your best option.

Sebastian and Andreas are rock solid, but unless you explain them what you are really trying to achieve, and that we find something better to suggest than what has already been said, we will have to apologize and say our API support job is done. We don't have a solution to everything unfortunately.

If you need to discuss more about your development issue, you should provide more details on what you really are trying to achieve. Right now, we're all out of ideas to help you out.
If you need to discuss on how to have a productive conversation with me or my team or to talk about consulting services, I invite you to mail me at [email protected].

Jean-Francois Yelle
Development Support Manager