On 08/06/2015 at 05:44, xxxxxxxx wrote:
Cinema 4D Version: R16
Platform: Mac OSX ;
Language(s) : C++ ;
I have an ObjectData plugin.
Inside GetVirtualObjects I change the size and positions of my objects, which are modifications to the active scene. In the document "Important Threading Information" it says that you need to call StopAllThreads() before making any modifications to the active scene.
My problem is, when I add StopAllThreads() at the top of GetVirtualObjects(), every change I have in my description triggers a redraw of the whole scene. Because of that I can't accurately see how much I've changed my object, or how much I've changed it in comparison to other objects (they also get redrawn).
Because my plugin is mainly about those objects, and their position, relative to the other objects, this is very bad. If the scene updates on every little change I do, I cannot directly see WHICH change I'm doing, and this will cost the users of the plugin quite some time, which I cannot have.
Is there a workaround for this?
Should I delete StopAllThreads and manually make sure that there can't be two threads at the same time?
Or is there a possibility, when there needs to be a redraw, to check what needs to be redrawn and what not? And if so, how should I go on this?
I assume not every plugin-developer uses StopAllThreads(), or they have a workaround to solve the redraw problem, I guess?
I have seen a house-plugin which doesn't redraw the whole scene, but just that one element.
Thanks in advance for your help and time!
On 08/06/2015 at 05:53, xxxxxxxx wrote:
I never use StopAllThreads() in GVO(). It is mainly for GUI/User interactions or 'asynchronous document changes'. In the case of GVO(), you are not really doing that. You are processing a generator object wherein the output is displayed through passing a virtual object to C4D. I would not use it at all there.
On 08/06/2015 at 06:17, xxxxxxxx wrote:
just to make this clear:
Never ever call StopAllThreads() from within GetVirtualObjects()!
Or a bit more general: Never call StopAllThreads() from any threaded function or from plugins derived from NodeData.
StopAllThreads() is thought to be used from the main thread or in asynchronous dialogs to safely apply any changes.
And, as discussed multiple times in other threads, you are NOT allowed to do any scene modifications from with GetVirtualObjects(). No StopAllThreads() and surely no self-built synchronization/serialization mechanism will change this rule.
On 08/06/2015 at 07:08, xxxxxxxx wrote:
Well, now I'm totally confused.
Inside the article "Important Threading Information" I read this:
"Before making modifications in the active scene, for example from a dialog, you always need to call StopAllThreads(). You have to do this even if you yourself are in the main thread, since there could be other threads that read from the scene."
It states clearly "You have to do this even if you yourself are in the main thread.". This implies that you also have to do it in other threads, right?
Or could it be that I'm simply confusing things and that I'm not even modifying the scene?
Inside GVO() I start with allocating a null (my parent object), which I return at the end.
Then I allocate the child objects and set their position (because the objects aren't in the scene yet, this is allowed, I guess. Or am I wrong??) before I insert them under my parent object, or childs.
This causes my pluginObject to change while I change sliders (I probably saw this as a scene modification?).
So, I probably told you some wrong information (which I'm sorry for), and I hope I'm doing it right in my plugin. I also think an answer on this will give me a good understanding of how things work.
I'm looking forward to hear more information!
Thanks in advance for your help and time!
With kind regards,
On 09/06/2015 at 09:43, xxxxxxxx wrote:
I have updated my last post. Hope it makes it a bit clearer.
On 09/06/2015 at 11:01, xxxxxxxx wrote:
The things you highlighted in your previous post were allready clear to me, but thanks anyway!
One last question, though:
"Inside GVO() I start with allocating a null (my parent object), which I return at the end.
Then I allocate the child objects and set their position before I insert them under my parent object, or childs"
Does C4D see this as a scene modification?
Thanks for your help and time!
On 09/06/2015 at 11:03, xxxxxxxx wrote:
No, this is exactly as GVO is thought to be used.
You are not inserting the Null object into the scene, right? This is done upon return from GVO.
On 09/06/2015 at 11:05, xxxxxxxx wrote:
Okay, now I know that my last understanding about how it works is right!
You can mark this post as closed, I guess.