count steps during which an EntityItem is moving but has no simulation owner. Once the count is high enough (how high is TBD), attempt to claim ownership

This commit is contained in:
Seth Alves 2015-04-25 07:17:21 -07:00
parent 48ec0c8339
commit 81ff8a4448
2 changed files with 9 additions and 1 deletions

View file

@ -38,7 +38,8 @@ void EntityMotionState::enqueueOutgoingEntity(EntityItem* entity) {
EntityMotionState::EntityMotionState(EntityItem* entity) :
_entity(entity),
_accelerationNearlyGravityCount(0),
_shouldClaimSimulationOwnership(false)
_shouldClaimSimulationOwnership(false),
_movingStepsWithoutSimulationOwner(0)
{
_type = MOTION_STATE_TYPE_ENTITY;
assert(entity != NULL);
@ -116,6 +117,12 @@ void EntityMotionState::setWorldTransform(const btTransform& worldTrans) {
if (_entity->getSimulatorID().isNull() && isMoving()) {
// object is moving and has no owner. attempt to claim simulation ownership.
_movingStepsWithoutSimulationOwner++;
} else {
_movingStepsWithoutSimulationOwner = 0;
}
if (_movingStepsWithoutSimulationOwner > 4) { // XXX maybe meters from our characterController ?
setShouldClaimSimulationOwnership(true);
}

View file

@ -74,6 +74,7 @@ protected:
EntityItem* _entity;
quint8 _accelerationNearlyGravityCount;
bool _shouldClaimSimulationOwnership;
quint32 _movingStepsWithoutSimulationOwner;
};
#endif // hifi_EntityMotionState_h