From b31acc421a7eb38607910f678a95d082ce81dd8c Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 20 Oct 2016 10:36:14 -0700 Subject: [PATCH] fix crash on startup --- libraries/physics/src/CharacterController.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libraries/physics/src/CharacterController.cpp b/libraries/physics/src/CharacterController.cpp index 19207f13ed..5c85f8fc50 100644 --- a/libraries/physics/src/CharacterController.cpp +++ b/libraries/physics/src/CharacterController.cpp @@ -524,7 +524,7 @@ void CharacterController::computeNewVelocity(btScalar dt, glm::vec3& velocity) { } void CharacterController::preSimulation() { - if (_enabled && _dynamicsWorld) { + if (_enabled && _dynamicsWorld && _rigidBody) { quint64 now = usecTimestampNow(); // slam body to where it is supposed to be @@ -632,9 +632,10 @@ void CharacterController::preSimulation() { void CharacterController::postSimulation() { // postSimulation() exists for symmetry and just in case we need to do something here later - - btVector3 velocity = _rigidBody->getLinearVelocity(); - _velocityChange = velocity - _preSimulationVelocity; + if (_enabled && _dynamicsWorld && _rigidBody) { + btVector3 velocity = _rigidBody->getLinearVelocity(); + _velocityChange = velocity - _preSimulationVelocity; + } }