Prevent recalculation while moving



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 23/01/2009 at 11:04, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   10.1 
    Platform:   Windows  ; Mac  ;  
    Language(s) :     C++  ;

    ---------
    Hi,

    normaly it's a good thing that Expressions and Geenrator objects are recalculated so frequently.

    But now I want to prevent the recalculation of my Generator object (output through ->GetVirtualObjects()) while the user is dragging the mouse using the pan/rotate/zoom gadgets.

    Is that possible?

    Greetings & thanks in advance,
    Jack



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 26/01/2009 at 05:14, xxxxxxxx wrote:

    At the begin of GetVirtualObjects() check for the cache of the object and its dirty state. Something like this:

    > \> BaseObject \*AtomObject::GetVirtualObjects(PluginObject \*op, HierarchyHelp \*hh) \> { \>      Bool dirty = op->CheckCache(hh) || op->IsDirty(DIRTY_DATA); \>      if (!dirty) return op->GetCache(hh); \> ... \>

    cheers,
    Matthias



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 30/01/2009 at 18:03, xxxxxxxx wrote:

    Great! This works perfectly!!
    Thanks Matthias!

    Cheers,
    Jack



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 30/01/2009 at 18:32, xxxxxxxx wrote:

    But by the way, how can I check if any other linked object was changed? For example, if I have a camera object linked somewhere in my object's descriptions (link field in Attribute Manager)?

    Will I be able to detect if the camera has been moved by calling the following?

    > mycam->IsDirty(DIRTY_DATA);

    Thanks in advance :-)

    Greetings,
    Jack



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 31/01/2009 at 14:04, xxxxxxxx wrote:

    Hm, OK, I will explain more detailled...

    Some of the function in my plugin depend from the camera. That may be the Editor camera, the active scene camera object, or a camera that has been linked (dragged into a link field of my plugin) by the user. If a camera has been linked, it must be used instead of editor/active scene camera.

    I get the camera like this:

    > CameraObject \*Cam = (CameraObject\* ) bc->GetObjectLink(SURFACESPREAD_FILTER_PERFORMANCECAM, doc); \> if (!Cam) Cam = GetCurrentCamera(doc); \>

    The function GetCurrentCamera() looks like this:

    > CameraObject \*GetCurrentCamera(BaseDocument \*doc) \> { \>      // Get active/Editor camera \>      if (doc->GetRenderBaseDraw()->HasCameraLink()) \>           return (CameraObject\* ) doc->GetRenderBaseDraw()->GetSceneCamera(doc); \>      else \>           return (CameraObject\* ) doc->GetRenderBaseDraw()->GetEditorCamera(); \> } \>

    So now I definitely have a camera. Either the editor camera, the active scene camera, or a linked camera object.

    I now want to check if that camera has been moved or if its parameters have changed. If so, I must recalculate my plugin instead of using the cache.

    > \> Bool dirty = op->CheckCache(hh) || op->IsDirty(DIRTY_DATA) || Cam->IsDirty(DIRTY_DATA) || Cam->IsDirty(DIRTY_MATRIX); \> if (!dirty) return op->GetCache(hh); \>

    The strange thing is: This ONLY works with the Editor camera. With a camera object in the document (active scene camera or linked camera), I never get anything.

    I tried to set a dependency by doing:

    > Cam->AddDependence(hh, op);

    But that didn't change anything.

    How can I detect changes in the Matrix or the Attributes of a camera object?

    Thanks for any help!

    Greetings,
    Jack



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 01/02/2009 at 03:42, xxxxxxxx wrote:

    Aha, I found out that it only works, if the camera object comes AFTER my plugin object in the Object Manager. Otherwise, the Dirty status seems to be cleared before my plugin object is called.

    Is there any way to change that?

    Greetings,
    Jack



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 02/02/2009 at 09:00, xxxxxxxx wrote:

    Adding the camera to the dependence list seems to work.

    > \> Bool dirty; \> \> if(cam) \> { \>      op->NewDependenceList(); \>      op->AddDependence(hh, cam); \>      dirty = !op->CompareDependenceList(); \> } \> else \>      dirty = op->CheckCache(hh) || op->IsDirty(DIRTY_DATA); \> \> if (!dirty) return op->GetCache(hh); \>

    cheers,
    Matthias



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 02/02/2009 at 09:13, xxxxxxxx wrote:

    Yes :) :)
    You're the best, Matthias!

    Anyway, the entry "BaseObject::NewDependenceList()" in the SDK documentation should be changed. It sais: "Note: The object must be children of your object." but it turns out, it also works fine with objects that are not children.

    Thanks!!

    Greetings,
    Jack



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 02/02/2009 at 09:46, xxxxxxxx wrote:

    Quote: Originally posted by c4dJack on 02 February 2009
    >
    > * * *
    >
    >
    > Anyway, the entry "BaseObject::NewDependenceList()" in the SDK documentation should be changed. It sais: "Note: The object must be children of your object." but it turns out, it also works fine with objects that are not children.
    >
    >
    > * * *

    Actually that is something I still have to get a confirmation from the developers. I am not 100 percent sure yet if it is safe to use. I will let you know when I get an answer.

    cheers,
    Matthias



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 02/02/2009 at 10:24, xxxxxxxx wrote:

    Thanks :-)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 18/04/2009 at 17:12, xxxxxxxx wrote:

    Well, did you get any answer from the developers yet?

    Also, I just wonder about your code (which works fine) :

    > Bool dirty = op->CheckCache(hh) || op->IsDirty(DIRTY_DATA);

    Does this mean that GetCache returns FALSE if the cache is valid? The SDk documentation sais, GetCache returns TRUE in that case, but wouldn't that mean the return op->GetCache(hh) is only called if the object's cache is NOT valid?

    Greetings,
    Jack



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 18/04/2009 at 21:23, xxxxxxxx wrote:

    That makes sense. If the cache needs to be rebuilt, it would return TRUE (cache is dirty), otherwise there is a valid cache. 'dirty' would be set correctly to TRUE if either or both CheckCache() and IsDirty() return TRUE.

    GetCache() is a different method that returns a BaseObject*. Don't confuse them.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 19/04/2009 at 03:48, xxxxxxxx wrote:

    Ah, damn, misspelled. Of course I ment CheckCache().

    SDK documentation sais, it returns TRUE if the cache is valid. But obviously it returns TRUE if the cache is not valid, right?

    Cheers,
    Jack



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/04/2009 at 02:55, xxxxxxxx wrote:

    Sorry, I have no answer yet. But seeing as this chaching stuff can be quite confusing I'll discuss this with the developers to make the documentation more complete regarding this topic.

    cheers,
    Matthias


Log in to reply