Fixed issue with events having a negative delta of time between them.
This commit is contained in:
parent
6a6c5bccda
commit
5b3eed5dce
@ -41,6 +41,9 @@ class OSGGA_EXPORT EventQueue : public osg::Referenced
|
||||
/** Take the entire event queue leaving the EventQueue' event queue empty.*/
|
||||
bool takeEvents(Events& events);
|
||||
|
||||
/** Take the events that were recorded before with specified time queue.*/
|
||||
bool takeEvents(Events& events, double cutOffTime);
|
||||
|
||||
/** Take a copy the entire event queue leaving the EventQueue' event queue intact.*/
|
||||
bool copyEvents(Events& events) const;
|
||||
|
||||
|
@ -62,6 +62,34 @@ bool EventQueue::takeEvents(Events& events)
|
||||
}
|
||||
}
|
||||
|
||||
bool EventQueue::takeEvents(Events& events, double cutOffTime)
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_eventQueueMutex);
|
||||
if (!_eventQueue.empty())
|
||||
{
|
||||
bool eventsTaken = false;
|
||||
Events::iterator itr = _eventQueue.begin();
|
||||
for(;
|
||||
itr != _eventQueue.end() && ((*itr)->getTime() <= cutOffTime);
|
||||
++itr)
|
||||
{
|
||||
events.push_back(*itr);
|
||||
eventsTaken = true;
|
||||
}
|
||||
|
||||
if (eventsTaken)
|
||||
{
|
||||
_eventQueue.erase(_eventQueue.begin(), itr);
|
||||
}
|
||||
|
||||
return eventsTaken;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool EventQueue::copyEvents(Events& events) const
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_eventQueueMutex);
|
||||
|
@ -635,6 +635,15 @@ void CompositeViewer::advance(double simulationTime)
|
||||
_frameStamp->setSimulationTime(simulationTime);
|
||||
}
|
||||
|
||||
for(RefViews::iterator vitr = _views.begin();
|
||||
vitr != _views.end();
|
||||
++vitr)
|
||||
{
|
||||
View* view = vitr->get();
|
||||
view->getEventQueue()->frame( getFrameStamp()->getReferenceTime() );
|
||||
}
|
||||
|
||||
|
||||
if (getViewerStats() && getViewerStats()->collectStats("frame_rate"))
|
||||
{
|
||||
// update previous frame stats
|
||||
@ -676,6 +685,8 @@ void CompositeViewer::eventTraversal()
|
||||
|
||||
if (_views.empty()) return;
|
||||
|
||||
double cutOffTime = _frameStamp->getReferenceTime();
|
||||
|
||||
double beginEventTraversal = osg::Timer::instance()->delta_s(_startTick, osg::Timer::instance()->tick());
|
||||
|
||||
// OSG_NOTICE<<"CompositeViewer::frameEventTraversal()."<<std::endl;
|
||||
@ -716,7 +727,7 @@ void CompositeViewer::eventTraversal()
|
||||
gw->checkEvents();
|
||||
|
||||
osgGA::EventQueue::Events gw_events;
|
||||
gw->getEventQueue()->takeEvents(gw_events);
|
||||
gw->getEventQueue()->takeEvents(gw_events, cutOffTime);
|
||||
|
||||
osgGA::EventQueue::Events::iterator itr;
|
||||
for(itr = gw_events.begin();
|
||||
@ -895,8 +906,7 @@ void CompositeViewer::eventTraversal()
|
||||
++vitr)
|
||||
{
|
||||
View* view = vitr->get();
|
||||
view->getEventQueue()->frame( getFrameStamp()->getReferenceTime() );
|
||||
view->getEventQueue()->takeEvents(viewEventsMap[view]);
|
||||
view->getEventQueue()->takeEvents(viewEventsMap[view], cutOffTime);
|
||||
}
|
||||
|
||||
|
||||
|
@ -584,6 +584,11 @@ void Viewer::advance(double simulationTime)
|
||||
_frameStamp->setSimulationTime(simulationTime);
|
||||
}
|
||||
|
||||
if (_eventQueue.valid())
|
||||
{
|
||||
_eventQueue->frame( getFrameStamp()->getReferenceTime() );
|
||||
}
|
||||
|
||||
if (getViewerStats() && getViewerStats()->collectStats("frame_rate"))
|
||||
{
|
||||
// update previous frame stats
|
||||
@ -595,6 +600,7 @@ void Viewer::advance(double simulationTime)
|
||||
getViewerStats()->setAttribute(_frameStamp->getFrameNumber(), "Reference time", _frameStamp->getReferenceTime());
|
||||
}
|
||||
|
||||
|
||||
if (osg::Referenced::getDeleteHandler())
|
||||
{
|
||||
osg::Referenced::getDeleteHandler()->flush();
|
||||
@ -607,6 +613,7 @@ void Viewer::eventTraversal()
|
||||
{
|
||||
if (_done) return;
|
||||
|
||||
double cutOffTime = _frameStamp->getReferenceTime();
|
||||
double beginEventTraversal = osg::Timer::instance()->delta_s(_startTick, osg::Timer::instance()->tick());
|
||||
|
||||
// OSG_NOTICE<<"Viewer::frameEventTraversal()."<<std::endl;
|
||||
@ -645,7 +652,7 @@ void Viewer::eventTraversal()
|
||||
gw->checkEvents();
|
||||
|
||||
osgGA::EventQueue::Events gw_events;
|
||||
gw->getEventQueue()->takeEvents(gw_events);
|
||||
gw->getEventQueue()->takeEvents(gw_events, cutOffTime);
|
||||
|
||||
osgGA::EventQueue::Events::iterator itr;
|
||||
for(itr = gw_events.begin();
|
||||
@ -791,9 +798,7 @@ void Viewer::eventTraversal()
|
||||
|
||||
// OSG_NOTICE<<"mouseEventState Xmin = "<<eventState->getXmin()<<" Ymin="<<eventState->getYmin()<<" xMax="<<eventState->getXmax()<<" Ymax="<<eventState->getYmax()<<std::endl;
|
||||
|
||||
|
||||
_eventQueue->frame( getFrameStamp()->getReferenceTime() );
|
||||
_eventQueue->takeEvents(events);
|
||||
_eventQueue->takeEvents(events, cutOffTime);
|
||||
|
||||
|
||||
#if 0
|
||||
|
Loading…
Reference in New Issue
Block a user