ModifyObject - Use Previous Cache?
-
On 06/05/2014 at 15:08, xxxxxxxx wrote:
Hi,
sorry I remembered this wrong. What you quoted from the documentation is what I was
referring to. Unfortunately, I can't really conclude from your postings what the exact
behavior is as I don't know the state of the code you use. You should call op->SetDirty(...)
when you want your deformer to be updated, and not call it if you want it not to. It could
still be re-evaluated, as I mentioned in my previous post.-Niklas
-
On 06/05/2014 at 15:54, xxxxxxxx wrote:
Well at the moment it updates every frame ( i think when the timeline advances it sets dirty automatically ) - so what i`d like is to avoid that if possible ( or force it to use the previous deformer cache if none of the parameters within my plugin have changed ), which would be much more efficient..
Thanks for all the help thus far it`s much appreciated!
-
On 06/05/2014 at 17:19, xxxxxxxx wrote:
( i think when the timeline advances it sets dirty automatically )
What is the code for your CheckDirty() method? It is not by any chance the exact same code that
is shown in the SDK Documentation (which you quoted)? -
On 07/05/2014 at 01:14, xxxxxxxx wrote:
Nah it aint the code in the docs. All my CheckDirty() code is doing, is comparing the GetDirty(DIRTYFLAGS_MATRIX) of some objects with previous, and if different, doing op->SetDirty(DIRTYFLAGS_DATA)..
I
ve even tried commenting out my entire CheckDirty() code, so i
m now thinking that maybe something else in the code is triggering the cache rebuild / ModifyObject() ..Will get back to you on this
Either way if there is some way to force the previous deformer cache from within the ModifyObject() function, i`d like to know about it!
-
On 07/05/2014 at 05:18, xxxxxxxx wrote:
No there is no way to "force" the cache to be re-used instead of doing recalculations.
I'll try to set up an example, and maybe even verify the behaviour you describe. But it
sounds a little strange to me at the moment.Best,
-Niklas -
On 07/05/2014 at 06:14, xxxxxxxx wrote:
Howdy,
I suspect that the deform cache is not saved and must always be rebuilt. I made a simple little test in the cinema4dsdk project's spherify.cpp example.
I added this code:
if(!mod->IsDirty(DIRTYFLAGS_MATRIX|DIRTYFLAGS_DATA)) return true;
... and it caused the deformer to not deform the object.
So, then I changed the code by removing the "!" (not) operator:
if(mod->IsDirty(DIRTYFLAGS_MATRIX|DIRTYFLAGS_DATA)) return true;
... and the deformer worked again.
That leads me to believe that if ObjectData::ModifyObject() returns without making the modification calculations to the object's points, the object doesn't get deformed.
Adios,
Cactus Dan -
On 07/05/2014 at 15:09, xxxxxxxx wrote:
CactusDan - are you saying that ObjectData deformer rebuilds the cache or does nothing ( no deform ) - ie there`s no obvious way of retaining the previous cache?
-
On 07/05/2014 at 16:23, xxxxxxxx wrote:
Howdy,
Hmmmm, looking at the code again I'm not so sure, because the "not" version never builds the deform cache in the first place.
Adios,
Cactus Dan -
On 07/05/2014 at 16:53, xxxxxxxx wrote:
Howdy,
OK, I tried another test where I added a global boolean variable "checkDirtyModifyer" set it to false in the PluginStart() function, and changed the code in ObjectData::ModifyObject() to this:
if(checkDirtyModifyer && !mod->IsDirty(DIRTYFLAGS_MATRIX|DIRTYFLAGS_DATA)) return true;
...then I created a simple CommandData plugin that set the checkDirtyModifyer global to true so I can invoke that command after the deformer object has already deformed the object and created a deform cache.
Here's what happened:
When the deformer is first applied to the object it works as normal. After the command is invoked to set the global variable to true, nothing happens. The moment I move the deformer or change the strength parameter the deformer stops working.So maybe my sus**cion was partially correct?
Adios,
Cactus Dan -
On 08/05/2014 at 01:19, xxxxxxxx wrote:
Hmm yeah, bummer i think..
I might just have to run with allowing it to constantly re-build the deforms then, until i can find a way to get the cache doing what a cache is supposed to do.
Thanks for doing tests Dan. Would be nice to keep this thread updated if anybody can come up with any other ideas..
I have a sus**cion Niklas might be asking the devs as he hasn`t come back with anything yet, or maybe he just got busy