GetDeformCache() alternatives? [SOLVED]



  • On 23/12/2014 at 17:34, xxxxxxxx wrote:

    Are there any alternatives to GetDeformCache() in Python?

    I need to access the deformed geometry of a polygon object (after deformers such as Skin and MSkin have been executed), but GetDeformCache() isn't guaranteed to return anything anytime. In practice, this generally means that anything calling GetDeformCache() right after scene load will receive None instead of a valid object (which you can work around, but having your plugin "wait" for GDC to return something breaks network rendering and causes some really strange delayed viewport performance).

    I'm aware that the documentation says I should call SendModelingCommand() instead with c4d.MCOMMAND_CURRENTSTATETOOBJECT, but this seems to clone the targeted geometry in RAM and I would rather not do that since the objects I'm trying to access the deform cache for can be quite large (so 60 plugin instances accessing the same object means that object is cloned 60 times).

    What should I do to access the deformed geometry in a safe and predictable manner? Is CSTO really my only option? I've thought about splitting my plugin into two parts (a "fake deformer" that processes the geometry, and several auxiliary objects that act upon the processed data) but this too seems like a fairly dirty kludge.

    -CMPX



  • On 23/12/2014 at 17:48, xxxxxxxx wrote:

    Just thinking out loud - but couldn't you use GetDeformCache() and if it returns None, then go to the trouble of CurrentStateToObject?



  • On 23/12/2014 at 18:57, xxxxxxxx wrote:

    Yes, but then I'd be consuming a large amount of RAM when the job is rendered across a network (experience suggests that GetDeformCache() almost always returns None when the scene is initially loaded and rendered immediately, as it is when submitted as a network job).

    Slightly off topic: is there any way to communicate between Python plugins without going through the subscripting/base container? Ie, if plugin A wants to call a function on plugin B, how would that happen?

    -CMPX



  • On 25/12/2014 at 17:32, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Just thinking out loud - but couldn't you use GetDeformCache() and if it returns None, then go to the trouble of CurrentStateToObject?

    Well, looks like you were right.

    According to the manual, CSTO "modifies existing caches". Apparently you can abuse this and call CSTO on your target object directly, and force the building of the deform cache. Subsequent calls to GetDeformCache() succeed 100% of the time and always return a valid object.

    I've basically rewritten my plugin to call CSTO once if GetDeformCache() initially returns None, then to retry the call immediately afterwards (which works). At the worst, it seems like I might be copying the object in RAM precisely once (that initial CSTO call). In most cases, my plugin instances are all pointing at the same polygon object so every other plugin instance that gets executed returns a valid object from GetDeformCache() right away, skipping the CSTO bit.

    -CMPX



  • On 26/12/2014 at 11:17, xxxxxxxx wrote:

    Glad that worked out!



  • On 14/01/2015 at 20:49, xxxxxxxx wrote:

    @CMPXCHG8B - would you mind posting a code sample of how you're getting caches now? I'm finding myself in a similar situation. Thanks!


Log in to reply