mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 14:18:24 +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;
|
uint64_t updateExpiry = startTime + UPDATE_BUDGET;
|
||||||
int numAvatarsUpdated = 0;
|
int numAvatarsUpdated = 0;
|
||||||
int numAVatarsNotUpdated = 0;
|
int numAVatarsNotUpdated = 0;
|
||||||
|
bool physicsEnabled = qApp->isPhysicsEnabled();
|
||||||
|
|
||||||
render::Transaction transaction;
|
render::Transaction transaction;
|
||||||
while (!sortedAvatars.empty()) {
|
while (!sortedAvatars.empty()) {
|
||||||
|
@ -202,7 +203,7 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
|
||||||
if (_shouldRender) {
|
if (_shouldRender) {
|
||||||
avatar->ensureInScene(avatar, qApp->getMain3DScene());
|
avatar->ensureInScene(avatar, qApp->getMain3DScene());
|
||||||
}
|
}
|
||||||
if (!avatar->isInPhysicsSimulation()) {
|
if (physicsEnabled && !avatar->isInPhysicsSimulation()) {
|
||||||
ShapeInfo shapeInfo;
|
ShapeInfo shapeInfo;
|
||||||
avatar->computeShapeInfo(shapeInfo);
|
avatar->computeShapeInfo(shapeInfo);
|
||||||
btCollisionShape* shape = const_cast<btCollisionShape*>(ObjectMotionState::getShapeManager()->getShape(shapeInfo));
|
btCollisionShape* shape = const_cast<btCollisionShape*>(ObjectMotionState::getShapeManager()->getShape(shapeInfo));
|
||||||
|
|
|
@ -154,6 +154,10 @@ const QUuid AvatarMotionState::getObjectID() const {
|
||||||
return _avatar->getSessionUUID();
|
return _avatar->getSessionUUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString AvatarMotionState::getName() const {
|
||||||
|
return _avatar->getName();
|
||||||
|
}
|
||||||
|
|
||||||
// virtual
|
// virtual
|
||||||
QUuid AvatarMotionState::getSimulatorID() const {
|
QUuid AvatarMotionState::getSimulatorID() const {
|
||||||
return _avatar->getSessionUUID();
|
return _avatar->getSessionUUID();
|
||||||
|
|
|
@ -59,6 +59,7 @@ public:
|
||||||
|
|
||||||
virtual const QUuid getObjectID() const override;
|
virtual const QUuid getObjectID() const override;
|
||||||
|
|
||||||
|
virtual QString getName() const override;
|
||||||
virtual QUuid getSimulatorID() const override;
|
virtual QUuid getSimulatorID() const override;
|
||||||
|
|
||||||
void setBoundingBox(const glm::vec3& corner, const glm::vec3& diagonal);
|
void setBoundingBox(const glm::vec3& corner, const glm::vec3& diagonal);
|
||||||
|
|
|
@ -312,11 +312,26 @@ void PhysicalEntitySimulation::handleDeactivatedMotionStates(const VectorOfMotio
|
||||||
assert(state);
|
assert(state);
|
||||||
if (state->getType() == MOTIONSTATE_TYPE_ENTITY) {
|
if (state->getType() == MOTIONSTATE_TYPE_ENTITY) {
|
||||||
EntityMotionState* entityState = static_cast<EntityMotionState*>(state);
|
EntityMotionState* entityState = static_cast<EntityMotionState*>(state);
|
||||||
if (!serverlessMode) {
|
|
||||||
entityState->handleDeactivation();
|
|
||||||
}
|
|
||||||
EntityItemPointer entity = entityState->getEntity();
|
EntityItemPointer entity = entityState->getEntity();
|
||||||
_entitiesToSort.insert(entity);
|
_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();
|
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 {
|
class PhysicalEntitySimulation : public EntitySimulation {
|
||||||
|
|
Loading…
Reference in a new issue