From 04b6a0888b5ae10579dbe73dbf664bc955340865 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 22 Nov 2010 19:38:18 +0000 Subject: [PATCH] Build fixes for building OSG with OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION set to OFF --- examples/osganalysis/osganalysis.cpp | 2 +- include/osgGA/GUIEventAdapter | 2 +- include/osgParticle/CompositePlacer | 4 +- src/osgGA/MultiTouchTrackballManipulator.cpp | 79 ++++++++++---------- 4 files changed, 45 insertions(+), 42 deletions(-) diff --git a/examples/osganalysis/osganalysis.cpp b/examples/osganalysis/osganalysis.cpp index 0d2f9898e..562b47534 100644 --- a/examples/osganalysis/osganalysis.cpp +++ b/examples/osganalysis/osganalysis.cpp @@ -676,7 +676,7 @@ int main(int argc, char** argv) databasePagingThread->add(databasePagingOperation.get()); osg::ref_ptr group = new osg::Group; - viewer.setSceneData(group); + viewer.setSceneData(group.get()); viewer.realize(); diff --git a/include/osgGA/GUIEventAdapter b/include/osgGA/GUIEventAdapter index bbb52ebfb..e6867ea6a 100644 --- a/include/osgGA/GUIEventAdapter +++ b/include/osgGA/GUIEventAdapter @@ -501,7 +501,7 @@ public: void addTouchPoint(unsigned int id, TouchPhase phase, float x, float y, unsigned int tapCount = 0); - TouchData* getTouchData() const { return _touchData; } + TouchData* getTouchData() const { return _touchData.get(); } bool isMultiTouchEvent() const { return (_touchData.valid()); } protected: diff --git a/include/osgParticle/CompositePlacer b/include/osgParticle/CompositePlacer index 744dc9838..226835cd1 100644 --- a/include/osgParticle/CompositePlacer +++ b/include/osgParticle/CompositePlacer @@ -48,8 +48,8 @@ public: { if (i<_placers.size()) _placers.erase(_placers.begin()+i); } /// Get a child placer - Placer* getPlacer( unsigned int i ) { return _placers.at(i); } - const Placer* getPlacer( unsigned int i ) const { return _placers.at(i); } + Placer* getPlacer( unsigned int i ) { return _placers[i].get(); } + const Placer* getPlacer( unsigned int i ) const { return _placers[i].get(); } /// Get number of placers unsigned int getNumPlacers() const { return _placers.size(); } diff --git a/src/osgGA/MultiTouchTrackballManipulator.cpp b/src/osgGA/MultiTouchTrackballManipulator.cpp index 67c745479..148e6fa1c 100644 --- a/src/osgGA/MultiTouchTrackballManipulator.cpp +++ b/src/osgGA/MultiTouchTrackballManipulator.cpp @@ -43,41 +43,40 @@ void MultiTouchTrackballManipulator::handleMultiTouchDrag(GUIEventAdapter::Touch osg::Vec2 pt_2_now(now->get(1).x,now->get(1).y); osg::Vec2 pt_1_last(last->get(0).x,last->get(0).y); osg::Vec2 pt_2_last(last->get(1).x,last->get(1).y); - - - + + + float gap_now((pt_1_now - pt_2_now).length()); float gap_last((pt_1_last - pt_2_last).length()); - + // osg::notify(osg::ALWAYS) << gap_now << " " << gap_last << std::endl; - - if (abs(gap_last - gap_now) >= zoom_threshold) + + if (abs(gap_last - gap_now) >= zoom_threshold) { // zoom gesture zoomModel( (gap_last - gap_now) * eventTimeDelta, true ); - } - - // drag gesture - - osg::Vec2 delta = ((pt_1_last - pt_1_now) + (pt_2_last - pt_2_now)) / 2.0f; - - float scale = 0.2f * _distance * eventTimeDelta; - - // osg::notify(osg::ALWAYS) << "drag: " << delta << " scale: " << scale << std::endl; - - panModel( delta.x() * scale, delta.y() * scale * (-1)); // flip y-coord because of different origins. + } - + // drag gesture + + osg::Vec2 delta = ((pt_1_last - pt_1_now) + (pt_2_last - pt_2_now)) / 2.0f; + + float scale = 0.2f * _distance * eventTimeDelta; + + // osg::notify(osg::ALWAYS) << "drag: " << delta << " scale: " << scale << std::endl; + + panModel( delta.x() * scale, delta.y() * scale * (-1)); // flip y-coord because of different origins. } bool MultiTouchTrackballManipulator::handle( const GUIEventAdapter& ea, GUIActionAdapter& us ) { - + bool handled(false); - - switch(ea.getEventType()) { - + + switch(ea.getEventType()) + { + case osgGA::GUIEventAdapter::PUSH: case osgGA::GUIEventAdapter::DRAG: case osgGA::GUIEventAdapter::RELEASE: @@ -90,37 +89,41 @@ bool MultiTouchTrackballManipulator::handle( const GUIEventAdapter& ea, GUIActio eventTimeDelta = 0.; } osgGA::GUIEventAdapter::TouchData* data = ea.getTouchData(); - + // three touches or two taps for home position - if ((data->getNumTouchPoints() == 3) || ((data->getNumTouchPoints() == 1) && (data->get(0).tapCount >= 2))) { + if ((data->getNumTouchPoints() == 3) || ((data->getNumTouchPoints() == 1) && (data->get(0).tapCount >= 2))) + { flushMouseEventStack(); _thrown = false; home(ea,us); handled = true; - } - - else if (data->getNumTouchPoints() >= 2) + } + + else if (data->getNumTouchPoints() >= 2) { - if ((_lastTouchData.valid()) && (_lastTouchData->getNumTouchPoints() >= 2)) { - handleMultiTouchDrag(data, _lastTouchData, eventTimeDelta); + if ((_lastTouchData.valid()) && (_lastTouchData->getNumTouchPoints() >= 2)) + { + handleMultiTouchDrag(data, _lastTouchData.get(), eventTimeDelta); } - + handled = true; - } - - _lastTouchData = data; - + } + + _lastTouchData = data; + // check if all touches ended unsigned int num_touches_ended(0); - for(osgGA::GUIEventAdapter::TouchData::iterator i = data->begin(); i != data->end(); ++i) { + for(osgGA::GUIEventAdapter::TouchData::iterator i = data->begin(); i != data->end(); ++i) + { if ((*i).phase == osgGA::GUIEventAdapter::TOUCH_ENDED) num_touches_ended++; } - - if(num_touches_ended == data->getNumTouchPoints()) { + + if(num_touches_ended == data->getNumTouchPoints()) + { _lastTouchData = NULL; } - + } break; default: