Fix crash with Touch animation mouse-up

This commit is contained in:
James Turner
2020-04-05 14:04:19 +01:00
parent ef002f6dfa
commit 6185b8fd0d
+15 -12
View File
@@ -921,9 +921,9 @@ class TouchPickCallback : public SGPickCallback {
_hover = readBindingList(hoverNode->getChildren("binding"), modelRoot); _hover = readBindingList(hoverNode->getChildren("binding"), modelRoot);
} }
virtual bool buttonPressed(int touchIdx, bool buttonPressed(int touchIdx,
const osgGA::GUIEventAdapter& event, const osgGA::GUIEventAdapter& event,
const Info& info) const Info& info) override
{ {
if (_touches.find(touchIdx) == _touches.end()) { if (_touches.find(touchIdx) == _touches.end()) {
return false; return false;
@@ -940,18 +940,21 @@ class TouchPickCallback : public SGPickCallback {
fireBindingList(_bindingsTouched, params.ptr()); fireBindingList(_bindingsTouched, params.ptr());
return true; return true;
} }
virtual void buttonReleased(int keyModState,
void buttonReleased(int keyModState,
const osgGA::GUIEventAdapter&, const osgGA::GUIEventAdapter&,
const Info* info) const Info* info) override
{ {
SG_UNUSED(keyModState); SG_UNUSED(keyModState);
SGPropertyNode_ptr params(new SGPropertyNode); SGPropertyNode_ptr params(new SGPropertyNode);
params->setDoubleValue("x", info->uv[0]); if (info) {
params->setDoubleValue("y", info->uv[1]); params->setDoubleValue("x", info->uv[0]);
params->setDoubleValue("y", info->uv[1]);
}
fireBindingList(_bindingsReleased, params.ptr()); fireBindingList(_bindingsReleased, params.ptr());
} }
virtual void update(double dt, int keyModState) void update(double dt, int keyModState) override
{ {
SG_UNUSED(keyModState); SG_UNUSED(keyModState);
if (!_repeatable) if (!_repeatable)
@@ -964,8 +967,8 @@ class TouchPickCallback : public SGPickCallback {
} }
} }
virtual bool hover(const osg::Vec2d& windowPos, bool hover(const osg::Vec2d& windowPos,
const Info& info) const Info& info) override
{ {
if (!anyBindingEnabled(_hover)) { if (!anyBindingEnabled(_hover)) {
return false; return false;
@@ -978,12 +981,12 @@ class TouchPickCallback : public SGPickCallback {
return true; return true;
} }
std::string getCursor() const std::string getCursor() const override
{ {
return _cursorName; return _cursorName;
} }
virtual bool needsUV() const { return true; } bool needsUV() const override { return true; }
private: private:
SGBindingList _bindingsTouched; SGBindingList _bindingsTouched;
@@ -1010,7 +1013,7 @@ osg::Group* SGTouchAnimation::createMainGroup(osg::Group* pr)
void SGTouchAnimation::setupCallbacks(SGSceneUserData* ud, osg::Group*) void SGTouchAnimation::setupCallbacks(SGSceneUserData* ud, osg::Group*)
{ {
TouchPickCallback* touchCb = NULL; TouchPickCallback* touchCb = nullptr;
// add actions that become macro and command invocations // add actions that become macro and command invocations
std::vector<SGPropertyNode_ptr> actions; std::vector<SGPropertyNode_ptr> actions;