What could cause the IRR to stop working when an ObjectPlugin is generating geometry?
Solved Sometimes, IRR stops working when my plugin is placed on a scene.
We want you to use the forum tool to mark your thread as a question. Try to think about it for the next thread.
Your question and the information you are giving us is too vague to have a precise answer. Try to reproduce the issue in a way that is failing all the time or define what do you mean with "Sometimes". Give us more information about what your plugin is in the scene (generator, deformer, tag etc..) and what it is supposed to do (created an object, use another object as input...). Also, what do you call "stop working"? Does the render stopped and start again over and over? Is it just black? Does only your plugins is not working?
Like this, i would say that your object plugin is a generator, and you are not checking if you can re-use the cache, so your object is always dirty, and the render restart from the beginning over and over.
Whenever it is possible try to reproduce the issue with the minimum amount of code so we can reproduce the issue on our system and check what is going wrong.
I will try to create a way to reproduce it.
But I'm checking if I can re-use a cached version. And I only set it as dirty when parameters change.
Here is a demonstration of the problem with the IRR, using my plugin:
do you have any message on the console?
Are you using
GetContour to generate the spline? If so, how do you check if you can re-use the cache already generated?
Yes, I'm using GetContour. And I'm just adjusting the "dirtyness" of the object, with this:
def CheckDirty(self, op, doc): v1 = op[FR_STARTPOINT] v2 = op[FR_ENDPOINT] v3 = op.GetDown() d1 = d2 = d3 = d4 = d5 = False # d5 signals that the playhead has moved and the animation is to be taken into account frame = doc.GetTime().GetFrame(doc.GetFps()) if self.old_frame != frame: self.old_frame = frame d5 = op[FR_TIME_CHANGE] == 1 # d1 signals that the starting point was changed if v1 is not None: d1 = v1.GetDirty(c4d.DIRTYFLAGS_DATA) > self.dirty1a or v1.GetDirty(c4d.DIRTY_MATRIX) > self.dirty1b if d1: self.dirty1a = v1.GetDirty(c4d.DIRTYFLAGS_DATA) self.dirty1b = v1.GetDirty(c4d.DIRTY_MATRIX) # d2 signals that the end point was changed if v2 is not None: d2 = v2.GetDirty(c4d.DIRTYFLAGS_DATA) > self.dirty2a or v2.GetDirty(c4d.DIRTY_MATRIX) > self.dirty2b if d2: self.dirty2a = v2.GetDirty(c4d.DIRTYFLAGS_DATA) self.dirty2b = v2.GetDirty(c4d.DIRTY_MATRIX) # d3 signals that a child was added to the object and there are no starting and ending points if v1 is None and v2 is None and v3 is not None: d3 = v3.GetDirty(c4d.DIRTYFLAGS_DATA) > self.dirty3a or v3.GetDirty(c4d.DIRTY_MATRIX) > self.dirty3b or op.GetDirty(c4d.DIRTY_CHILDREN) > self.dirty_child if d3: self.dirty3a = v3.GetDirty(c4d.DIRTYFLAGS_DATA) self.dirty3b = v3.GetDirty(c4d.DIRTY_MATRIX) self.dirty_child = op.GetDirty(c4d.DIRTY_CHILDREN) # check if the added child is a spline d3 = d3 and ((v3.GetInfo() & c4d.OBJECT_ISSPLINE) != 0) # compare the previous state of having a child or not with the new state. has_child_now = v3 is not None if has_child_now != self.has_child: self.has_child = has_child_now # if any of the conditions is True, set the object as Dirty if d1 or d2 or d3 or d4 or d5: op.SetDirty(c4d.DIRTYFLAGS_DATA) c4d.EventAdd()
That is not a good idea in the
you can have a look at this example on github that use both GetVirtualObject and GetCountour and CheckDirty.
you are storing data in 'self' but i cannot be sure that they are not modified somewhere else.
I got the feeling that this is an issue with the cache of your object. That is why i recommend simplifying as much as possible your code.
I will look into the example.
However, if I do have to check old values for changes, what is the best way? Those variables inside the class (the 'self' ones) are any used inside the CheckDirty.
The problem is not to use self.xxxx to store data, the problem was that i could not see if they were modified somewhere else or not.
Could you share what was the issue so other people (including myself) could benefit from your experience?
I am happy that the problem is solved.
Since I know exactly what methods access/check/change the self.xxxx variables, it is a risk I'm willing to take ;-)
As for the solution, I removed the c4d.EventAdd() and at the GetContour method I was simply calling the function that was creating the spline. Now I perform a few checks for "dirtyness" and only after they show that something is dirty, I call the function to produce the spline.