mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 15:43:50 +02:00
Merge pull request #13452 from AndrewMeadows/avatar-entities-001
fix physics deactivation of avatar-entities
This commit is contained in:
commit
ca70b865d3
5 changed files with 33 additions and 4 deletions
|
@ -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));
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue