diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index 56b178cc4f..ed01aa7ca2 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -389,5 +389,13 @@ protected: }; +extern const float IGNORE_POSITION_DELTA; +extern const float IGNORE_DIMENSIONS_DELTA; +extern const float IGNORE_ALIGNMENT_DOT; +extern const float IGNORE_LINEAR_VELOCITY_DELTA; +extern const float IGNORE_DAMPING_DELTA; +extern const float IGNORE_GRAVITY_DELTA; +extern const float IGNORE_ANGULAR_VELOCITY_DELTA; + #endif // hifi_EntityItem_h diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index d6857de337..2e3013af0f 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -104,16 +104,23 @@ void EntityMotionState::setWorldTransform(const btTransform& worldTrans) { _entity->setLastSimulated(usecTimestampNow()); - if (_entity->getSimulatorID().isNull() && isMoving()) { - // object is moving and has no owner. attempt to claim simulation ownership. - _movingStepsWithoutSimulationOwner++; + // if (_entity->getSimulatorID().isNull() && isMoving()) { + if (_entity->getSimulatorID().isNull()) { + // if object is moving and has no owner, attempt to claim simulation ownership. + auto alignmentDot = glm::abs(glm::dot(_sentRotation, _entity->getRotation())); + if (glm::distance(_sentPosition, _entity->getPosition()) > IGNORE_POSITION_DELTA || + alignmentDot < IGNORE_ALIGNMENT_DOT) { + _movingStepsWithoutSimulationOwner++; + } else { + _movingStepsWithoutSimulationOwner = 0; + } } else { _movingStepsWithoutSimulationOwner = 0; } - if (_movingStepsWithoutSimulationOwner > 100) { // XXX maybe meters from our characterController ? - // qDebug() << "XXX XXX XXX -- claiming something I saw moving"; - // setShouldClaimSimulationOwnership(true); + if (_movingStepsWithoutSimulationOwner > 50) { // XXX maybe meters from our characterController ? + qDebug() << "XXX XXX XXX -- claiming something I saw moving"; + setShouldClaimSimulationOwnership(true); } #ifdef WANT_DEBUG