Digital Art Zone

 
     
Detect if an object is modified
Posted: 08 October 2012 03:48 AM   [ Ignore ]
Member
Avatar
Rank
Total Posts:  123
Joined  2007-09-12

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)

 Signature 

Favourite Figure: Olympia 6
My website: http://mattiascibien.net
My Art Gallery: http://mattiascibien.deviantart.com/
Developer of AutoCam (commercial follow-up of my thesis project, currently on hold).

Profile
 
 
Posted: 08 October 2012 05:34 AM   [ Ignore ]   [ # 1 ]
New Member
Total Posts:  13
Joined  2009-10-15

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

Profile
 
 
Posted: 08 October 2012 05:45 AM   [ Ignore ]   [ # 2 ]
Member
Avatar
Rank
Total Posts:  123
Joined  2007-09-12

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

 Signature 

Favourite Figure: Olympia 6
My website: http://mattiascibien.net
My Art Gallery: http://mattiascibien.deviantart.com/
Developer of AutoCam (commercial follow-up of my thesis project, currently on hold).

Profile
 
 
Posted: 08 October 2012 05:50 AM   [ Ignore ]   [ # 3 ]
New Member
Total Posts:  13
Joined  2009-10-15

That one is actually also called drawnDataChanged().

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

Profile
 
 
Posted: 09 October 2012 05:17 AM   [ Ignore ]   [ # 4 ]
Member
Avatar
Rank
Total Posts:  123
Joined  2007-09-12

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?

 Signature 

Favourite Figure: Olympia 6
My website: http://mattiascibien.net
My Art Gallery: http://mattiascibien.deviantart.com/
Developer of AutoCam (commercial follow-up of my thesis project, currently on hold).

Profile
 
 
Posted: 09 October 2012 07:06 AM   [ Ignore ]   [ # 5 ]
New Member
Total Posts:  13
Joined  2009-10-15

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…...

Profile
 
 
Posted: 09 October 2012 10:30 AM   [ Ignore ]   [ # 6 ]
Member
Avatar
Rank
Total Posts:  123
Joined  2007-09-12

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)

 Signature 

Favourite Figure: Olympia 6
My website: http://mattiascibien.net
My Art Gallery: http://mattiascibien.deviantart.com/
Developer of AutoCam (commercial follow-up of my thesis project, currently on hold).

Profile
 
 
Posted: 10 October 2012 04:01 AM   [ Ignore ]   [ # 7 ]
New Member
Total Posts:  13
Joined  2009-10-15

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

drawnChanged
   
if isInEdit
      reset timer
   
else
      
isInEdit true
      set timer 
for 2 seconds

OnTimerEvent
   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.

Profile
 
 
Posted: 10 October 2012 07:46 AM   [ Ignore ]   [ # 8 ]
Member
Avatar
Rank
Total Posts:  123
Joined  2007-09-12

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?

 Signature 

Favourite Figure: Olympia 6
My website: http://mattiascibien.net
My Art Gallery: http://mattiascibien.deviantart.com/
Developer of AutoCam (commercial follow-up of my thesis project, currently on hold).

Profile