Made TouchData and osg::Object to aid with serialization.

This commit is contained in:
Robert Osfield 2012-10-05 16:31:23 +00:00
parent 47c5ddbce5
commit 740f660ef1

View File

@ -329,8 +329,9 @@ public:
TOUCH_ENDED TOUCH_ENDED
}; };
class TouchData : public osg::Referenced { class TouchData : public osg::Object {
public: public:
struct TouchPoint { struct TouchPoint {
unsigned int id; unsigned int id;
TouchPhase phase; TouchPhase phase;
@ -353,7 +354,15 @@ public:
typedef TouchSet::iterator iterator; typedef TouchSet::iterator iterator;
typedef TouchSet::const_iterator const_iterator; typedef TouchSet::const_iterator const_iterator;
TouchData() : osg::Referenced() {} TouchData() : osg::Object() {}
TouchData(const TouchData& td, const osg::CopyOp& copyop):
osg::Object(td,copyop),
_touches(td._touches) {}
META_Object(osgGA, TouchData);
unsigned int getNumTouchPoints() const { return _touches.size(); } unsigned int getNumTouchPoints() const { return _touches.size(); }
@ -367,6 +376,8 @@ public:
protected: protected:
virtual ~TouchData() {}
void addTouchPoint(unsigned int id, TouchPhase phase, float x, float y, unsigned int tap_count) { void addTouchPoint(unsigned int id, TouchPhase phase, float x, float y, unsigned int tap_count) {
_touches.push_back(TouchPoint(id, phase, x, y, tap_count)); _touches.push_back(TouchPoint(id, phase, x, y, tap_count));
} }