From 7084908df3eeb01870ad3b1b1eae616e966fda43 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 20 Aug 2019 15:36:43 -0700 Subject: [PATCH] add isStuck logging, add assert because singleton --- libraries/physics/src/CharacterController.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libraries/physics/src/CharacterController.cpp b/libraries/physics/src/CharacterController.cpp index e488a4da98..e102388822 100755 --- a/libraries/physics/src/CharacterController.cpp +++ b/libraries/physics/src/CharacterController.cpp @@ -105,6 +105,8 @@ CharacterController::CharacterMotor::CharacterMotor(const glm::vec3& vel, const } } +static uint32_t _numCharacterControllers { 0 }; + CharacterController::CharacterController() { _floorDistance = _scaleFactor * DEFAULT_AVATAR_FALL_HEIGHT; @@ -123,6 +125,11 @@ CharacterController::CharacterController() { _hasSupport = false; _pendingFlags = PENDING_FLAG_UPDATE_SHAPE; + + // ATM CharacterController is a singleton. When we want more we'll have to + // overhaul the applyPairwiseFilter() logic to handle multiple instances. + ++_numCharacterControllers; + assert(numCharacterControllers == 1); } CharacterController::~CharacterController() { @@ -279,6 +286,7 @@ bool CharacterController::checkForSupport(btCollisionWorld* collisionWorld) { if (_stuckTransitionCount > NUM_SUBSTEPS_FOR_STUCK_TRANSITION) { // we've been in this "probablyStuck" state for several consecutive substeps // --> make it official by changing state + qCDebug(physics) << "CharacterController::_isStuck :" << _isStuck << "-->" << probablyStuck; _isStuck = probablyStuck; // init _numStuckSubsteps at NUM_SUBSTEPS_FOR_SAFE_LANDING_RETRY so SafeLanding tries to help immediately _numStuckSubsteps = NUM_SUBSTEPS_FOR_SAFE_LANDING_RETRY;