Detect if an object is modified

mattiascibienmattiascibien Posts: 107

Hello fellow developers,
I am continuously working on my bachelor thesis and I have found that I need to detect wether an object in my scene is modified. For example added, removed does not seem to be a problem but when it is modified (moved, rotated, scaled) or posed I am not able to find a signal for it in dzScene.

Is there some signal to detect whether an object is modified? I have seen a signal which tells me that an object needs to be redrawn but it does not seem to be my case.

Thank you for your help

(I will quote you in the acknowlegments obviously)


  • spielereinzspielereinz Posts: 11
    edited December 1969

    If your object inherits from DzObject, the DzObject::drawnDataChanged() signal should o the trick.

  • mattiascibienmattiascibien Posts: 107
    edited December 1969

    Isn't something like that is the DzScene? I should not inherit from DzObject,.

  • spielereinzspielereinz Posts: 11
    edited December 1969

    That one is actually also called drawnDataChanged().

    So if you connect to the dzScene->drawnDataChanged() signal, it should, at least conceptually, work :)

  • mattiascibienmattiascibien Posts: 107
    edited October 2012

    The problem is that I should able to get the geometry of the modified node in another class and drawnDataChanged() doesn't seem go pass me the DzNode.

    EDIT: can i do that with a cas on QObject::sender() in my slot?

    EDIT2: sender() made my day but however using drawDataChanged() for a node is almost impossibile since it is called every time my Node il clicked other than moved, morpehed or similar.

    EDIT3: by setting breakpoints i have detected that it acutally acts even during the manipulation? isn't there anyway to detect whether an object manipulation ends?

    Post edited by mattiascibien on
  • spielereinzspielereinz Posts: 11
    edited December 1969

    DzNode has its own implementation of drawnDataChanged(), so I guess you could hook up to that one instead of the DzScene one.
    Without having tried it, I guess the problem with "spam" messages will stay the same though.

    A simple solution could be to hook up to the selected signal ( DzNode::selected(DzNode* node , bool onOff) ) and spawn a manual update once the node is no longer selected.

    Of course, this has it's own drawbacks - but at least you can handle your internal magic in a single slot definition in your own program (switch on the node->getLabel()).

    If I had a better idea on what your are trying to accomplice I might be able to give a better suggestion......

  • mattiascibienmattiascibien Posts: 107
    edited December 1969

    I have to pass every geometry of the scene to Bullet Physics in order to get a Raycast. And my supervisor asked me to try to see if I can update the Bullet Wolrd only when objects are modified (and maybe update only the one I modify)

  • spielereinzspielereinz Posts: 11
    edited December 1969

    Unless you are really keen on re-implementing DzNode I guess that the simple solution is to hook up to the DzNode::drawnDataChanged() signal and filter out the events you do not need.

    I would do that by using a simple timer.

    [pseudo code]

    isInEdit = false
       if isInEdit
          reset timer
          isInEdit = true
          set timer for 2 seconds
       isInEdit = false
       update the node for render // This should ensure that the geometry has been finalized
       send update to Bullet

    Somewhat crude - but it should get the job done and you get a "per node" event.

  • mattiascibienmattiascibien Posts: 107
    edited December 1969

    look's like a nice idea... However. If I subclass DzNode to detect if node is in editing mode will the subclass be on my scene everytime I add a DzNode or do I have to do a lot of casting?

Sign In or Register to comment.
Rocket Fuel