save/keep cache of generator plugin
-
hi there,
i've built a python generator, where i use its cache unless some parameters are dirty. when close and reopen the scene, the cache is gone and has to be rebuild. in principal, is there (not too complicated) way to keep/save these caches inside the scene?
would this be possible with a python generator or a proper plugin?
i'm using python.to be a bit more specific: by clicking a checkbox on the python generator, i do a cloth simulation in a temp doc. the result of the sim is convertet to polygons and returned by the python generator. the simulation is not super heavy, but it woud be nice if i could avoid the recalculation. so i'd like to store the point data in the scene/generator. i'd like to avoid external files too, if possible.
my code is a bit long at the moment, i would post a shorter version, if you say it should be possible ...
best, sebastian -
I would also be interested.
I cache all kinds of things, but not the mesh at the end.
# check if any dependency changed def CacheCheck(self, op, doc): """ :param op: :param doc: :return: """ if op[res.GRIDDER_CACHE] is not None: preOption = op[res.GRIDDER_CACHE].GetString(1001) preNoise = op[res.GRIDDER_CACHE].GetFloat(1002) preField = op[res.GRIDDER_CACHE].GetFloat(1003) preFrame = op[res.GRIDDER_CACHE].GetFloat(1004) rd = doc.GetActiveRenderData() self.rs.SetStartFrame(rd[c4d.RDATA_FRAMEFROM].GetFrame(doc.GetFps())) force = op[res.GRIDDER_EVERYFRAME] frame = doc.GetTime().GetFrame(doc.GetFps()) noise, shaderAnimated = self.CacheShader(op, doc) if force is 1 and preFrame != frame: return False if preOption != self.HelperGetOptions(op): return False if preNoise != noise: return False field = self.CacheField(op, doc) if preField != field: return False return True return False #----------------------------------------------------------------- # after everything is calculated: bc = c4d.BaseContainer() bc.SetData(1001, self.HelperGetOptions(op)) bc.SetData(1002, self.CacheShader(op, doc)[0]) bc.SetData(1003, self.CacheField(op, doc)) if doc != None: bc.SetData(1004, frame) op[res.GRIDDER_CACHE] = bc
-
Hi Sebastian,
FYI I'll get to answer your posting beginning next week.
Cheers,
Ilia -
Hi Sebastian,
Sorry for the delay.
I'm afraid you're quite limited with the python generator, when it comes to storing your data, so the general suggestion would be switching to using the plugin. This way you could just override the
NodeData.Read
,NodeData.Write
andNodeData.CopyTo
to store and load your data using the HyperFile. For the more information on the NodeData.Read/Write function you could check the C++ manual.Let me know you have any other questions!
Cheers,
Ilia -
Could you provide an snipped where you show how to cache it in a plugin?