I keep having this strange behavior with my custom osgGA::GUIEventHandler class : the handle() method is executed twice each time I click on the handled object... I'm catching PUSH events only, and every single click on my object results in two runs in the corresponding block of the handle() method.
The first idea would be that my EventHandler is added twice on my object but it is NOT the case. I'm setting it inside the constructor of another object, which is instanciated only once in the whole app.
My handled object is inside an osg::Camera, could it be because of this? Picking objects inside a camera is tricky, but I managed to do it. The only problem is that they are picked twice... does a camera generate two PUSH events when clicked?
So here I am... Does anyone have a clue on what's wrong with my handler? Or how I could debug it?
Thanks! :)
Cheers,
Ku
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=29301#29301
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Hope it helps
Martin Naylor
I actually managed to solve the problem, although I'm not sure of what caused it! :)
Here's the code for my handler, may it help someone in the same case :
Code:
bool CRightPanelEventHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object* object, osg::NodeVisitor* nv)
{
if (nv->getFrameStamp() != NULL && nv->getFrameStamp()->getFrameNumber() != _lastFrame)
{
_lastFrame = nv->getFrameStamp()->getFrameNumber();
if (ea.getEventType() == osgGA::GUIEventAdapter::PUSH)
{
// Stuff
}
}
}
Checking and recording the framestamp at each loop avoids processing a same frame two times. But I have no idea why my handler processed each frame two times...
Cheers,
Ku
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=29360#29360