Merge pull request #13452 from AndrewMeadows/avatar-entities-001

fix physics deactivation of avatar-entities
This commit is contained in:
Andrew Meadows 2018-06-25 16:18:01 -07:00 committed by GitHub
commit ca70b865d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 4 deletions

View file

@ -186,6 +186,7 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
uint64_t updateExpiry = startTime + UPDATE_BUDGET;
int numAvatarsUpdated = 0;
int numAVatarsNotUpdated = 0;
bool physicsEnabled = qApp->isPhysicsEnabled();
render::Transaction transaction;
while (!sortedAvatars.empty()) {
@ -202,7 +203,7 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
if (_shouldRender) {
avatar->ensureInScene(avatar, qApp->getMain3DScene());
}
if (!avatar->isInPhysicsSimulation()) {
if (physicsEnabled && !avatar->isInPhysicsSimulation()) {
ShapeInfo shapeInfo;
avatar->computeShapeInfo(shapeInfo);
btCollisionShape* shape = const_cast<btCollisionShape*>(ObjectMotionState::getShapeManager()->getShape(shapeInfo));

View file

@ -154,6 +154,10 @@ const QUuid AvatarMotionState::getObjectID() const {
return _avatar->getSessionUUID();
}
QString AvatarMotionState::getName() const {
return _avatar->getName();
}
// virtual
QUuid AvatarMotionState::getSimulatorID() const {
return _avatar->getSessionUUID();

View file

@ -59,6 +59,7 @@ public:
virtual const QUuid getObjectID() const override;
virtual QString getName() const override;
virtual QUuid getSimulatorID() const override;
void setBoundingBox(const glm::vec3& corner, const glm::vec3& diagonal);

View file

@ -312,11 +312,26 @@ void PhysicalEntitySimulation::handleDeactivatedMotionStates(const VectorOfMotio
assert(state);
if (state->getType() == MOTIONSTATE_TYPE_ENTITY) {
EntityMotionState* entityState = static_cast<EntityMotionState*>(state);
if (!serverlessMode) {
entityState->handleDeactivation();
}
EntityItemPointer entity = entityState->getEntity();
_entitiesToSort.insert(entity);
if (!serverlessMode) {
if (entity->getClientOnly()) {
switch (entityState->getOwnershipState()) {
case EntityMotionState::OwnershipState::PendingBid:
_bids.removeFirst(entityState);
entityState->clearOwnershipState();
break;
case EntityMotionState::OwnershipState::LocallyOwned:
_owned.removeFirst(entityState);
entityState->clearOwnershipState();
break;
default:
break;
}
} else {
entityState->handleDeactivation();
}
}
}
}
}

View file

@ -37,6 +37,14 @@ public:
}
pop_back();
}
void removeFirst(EntityMotionState* state) {
for (uint32_t i = 0; i < size(); ++i) {
if ((*this)[i] == state) {
remove(i);
break;
}
}
}
};
class PhysicalEntitySimulation : public EntitySimulation {