From 0d427ed157de5e544072ce8be9ea9e6ae5ab4bd3 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 24 Jun 2016 11:52:54 +0100 Subject: [PATCH] Added handling of null dynamic_cast --- src/osgGA/FirstPersonManipulator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/osgGA/FirstPersonManipulator.cpp b/src/osgGA/FirstPersonManipulator.cpp index 5261b0a49..a37167cf3 100644 --- a/src/osgGA/FirstPersonManipulator.cpp +++ b/src/osgGA/FirstPersonManipulator.cpp @@ -263,6 +263,9 @@ bool FirstPersonManipulator::handleMouseWheel( const GUIEventAdapter& ea, GUIAct } } + FirstPersonAnimationData *ad = dynamic_cast< FirstPersonAnimationData*>( _animationData.get() ); + if (!ad) return false; + switch( sm ) { @@ -270,7 +273,7 @@ bool FirstPersonManipulator::handleMouseWheel( const GUIEventAdapter& ea, GUIAct case GUIEventAdapter::SCROLL_UP: { // move forward - moveForward( isAnimating() ? dynamic_cast< FirstPersonAnimationData* >( _animationData.get() )->_targetRot : _rotation, + moveForward( isAnimating() ? ad->_targetRot : _rotation, -_wheelMovement * (getRelativeFlag( _wheelMovementFlagIndex ) ? _modelSize : 1. )); us.requestRedraw(); us.requestContinuousUpdate( isAnimating() || _thrown );