Changing spline points via a tag?



  • On 19/11/2015 at 00:54, xxxxxxxx wrote:

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

    ---------
    I'm trying to change the points and segments of a spline from a tag plugin.

    I can do this easily enough using the SplineObject() API. However, after I do, it doesn't immediately update in the viewport. I have to mouse over the viewport first (I don't need to click or anything though, which is weird, so long as the mouse enters the viewport region of the C4D window) before it'll update.

    I'm sending MSG_UPDATE to the spline object after I change the points. Is there something else I have to do as well?

    I know the API docs mention a MSG_SEGMENTS_CHANGED message, but that appears to be used for messaging a spline object and getting it to change points and stuff through the Message() interface (and not directly using the SplineObject() API).

    -CMPX



  • On 19/11/2015 at 02:37, xxxxxxxx wrote:

    Hmm, looking at my own spline controller code, I only find these messages in my Execute() method (and the first is even commented out) :

      
    // l_pSpline->Message(MSG_POINTS_CHANGED); // takes a VariableChanged as second parameter if points have been inserted or deleted!   
    l_pSpline->Message(MSG_UPDATE); // MSG_POINTS_CHANGED is not enough, and an UPDATE must be sent anyway because the bounding box may have changed!   
    

    So, I'm essentially doing the same that you do, and it works fine without touching the View window (I just checked). Maybe a priority issue? Do you return EXECUTIONRESULT_OK? Are you doing something outside the Execute() method? Do you leave the method early through a premature "return" and skip the message?



  • On 19/11/2015 at 03:43, xxxxxxxx wrote:

    Hi,

    to me it sounds like you are missing anEventAdd(). If I'm wrong, you will need to give me some details (where in the plugin do you modify the spline? some code,...).
    Just realized, you are in a TagData plugin, sorry I overlooked this info.



  • On 19/11/2015 at 07:50, xxxxxxxx wrote:

    Ok, now I had some coffee...
    I did some tests here and as Cairyn said, it simply works. With one exception: If you "raise" the priority of the tag to at least "Generators, 0" (Generators, -1 still works), then there's the lag you described. This is basically because, the tag will be executed after all generators and the spline is a generator in this situation.



  • On 19/11/2015 at 18:03, xxxxxxxx wrote:

    Huh.

    You're correct, I've got the plugin configured for Generators, 0 by default because I need access to the deform cache of another polygon object.

    What's the best way go configure things then? Make sure the tag is set to Generators, -1 instead?

    It looks like EventAdd(EVENT_NOEXPRESSION) will force a VP update, but it sounds like I probably shouldn't be calling this from a tag plugin.

    -CMPX



  • On 20/11/2015 at 09:55, xxxxxxxx wrote:

    Hi,

    actually quite funny, that you seem to have similar problem as Joe at virtually the same time...
    Maybe you can share your misery 😠

    Please see the other thread for a more in detail explanation.
    If you can live with priority Generators/-1, then that would be the way to go. Definitely.
    I think, your EventAdd(EVENT_NOEXPRESSION) should work as well (I even proposed it myself in the other thread), but of course it has a major drawback: The scene will be evaluated two times. It will slow down everything and will surely get annoying with more complex scenes.

    Important warning for anybody reading this thread:
    Be careful with EventAdd() in Execute(). The EVENT_NOEXPRESSION flag is very, very, very (perhaps I should stress it a bit more: VERY) important. If the flag is omitted, the tag will cause the scene to be re-evaluated all over again and again and again, basically an infinite loop. I'm pretty sure very user of your plugin or script will most likely hate you, if you do something like this.

    And finally, I'm note sure, it is possible in your situation, but maybe you could implement what you need in an ObjectData(OBJECT_GENERATOR | OBJECT_INPUT | OBJECT_ISSPLINE) plugin, with the polygon object as an input. Just thinking...



  • On 21/11/2015 at 01:44, xxxxxxxx wrote:

    Yeah, EventAdd() is really killing scene performance. I'll have to find some other way of dealing with this, I guess. Thanks for your help though. At least I now know it's not a bug.

    -CMPX


Log in to reply