mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
fix logic with infectious simulation ownership
This commit is contained in:
parent
10e5378396
commit
2ca592de8b
3 changed files with 31 additions and 24 deletions
|
@ -62,14 +62,13 @@ public:
|
||||||
virtual uint32_t getIncomingDirtyFlags() const;
|
virtual uint32_t getIncomingDirtyFlags() const;
|
||||||
virtual void clearIncomingDirtyFlags(uint32_t flags) { _entity->clearDirtyFlags(flags); }
|
virtual void clearIncomingDirtyFlags(uint32_t flags) { _entity->clearDirtyFlags(flags); }
|
||||||
|
|
||||||
EntityItem* getEntity() const { return _entity; }
|
|
||||||
|
|
||||||
void incrementAccelerationNearlyGravityCount() { _accelerationNearlyGravityCount++; }
|
void incrementAccelerationNearlyGravityCount() { _accelerationNearlyGravityCount++; }
|
||||||
void resetAccelerationNearlyGravityCount() { _accelerationNearlyGravityCount = 0; }
|
void resetAccelerationNearlyGravityCount() { _accelerationNearlyGravityCount = 0; }
|
||||||
quint8 getAccelerationNearlyGravityCount() { return _accelerationNearlyGravityCount; }
|
quint8 getAccelerationNearlyGravityCount() { return _accelerationNearlyGravityCount; }
|
||||||
|
|
||||||
void setShouldClaimSimulationOwnership(bool value) { _shouldClaimSimulationOwnership = value; }
|
virtual EntityItem* getEntity() const { return _entity; }
|
||||||
bool getShouldClaimSimulationOwnership() { return _shouldClaimSimulationOwnership; }
|
virtual void setShouldClaimSimulationOwnership(bool value) { _shouldClaimSimulationOwnership = value; }
|
||||||
|
virtual bool getShouldClaimSimulationOwnership() { return _shouldClaimSimulationOwnership; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EntityItem* _entity;
|
EntityItem* _entity;
|
||||||
|
|
|
@ -111,6 +111,12 @@ public:
|
||||||
virtual bool isMoving() const = 0;
|
virtual bool isMoving() const = 0;
|
||||||
|
|
||||||
friend class PhysicsEngine;
|
friend class PhysicsEngine;
|
||||||
|
|
||||||
|
// these are here so we can call into EntityMotionObject with a base-class pointer
|
||||||
|
virtual EntityItem* getEntity() const { return NULL; }
|
||||||
|
virtual void setShouldClaimSimulationOwnership(bool value) { }
|
||||||
|
virtual bool getShouldClaimSimulationOwnership() { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setRigidBody(btRigidBody* body);
|
void setRigidBody(btRigidBody* body);
|
||||||
|
|
||||||
|
|
|
@ -391,29 +391,31 @@ void PhysicsEngine::computeCollisionEvents() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* a = objectA->getUserPointer();
|
ObjectMotionState* a = static_cast<ObjectMotionState*>(objectA->getUserPointer());
|
||||||
EntityMotionState* entityMotionStateA = static_cast<EntityMotionState*>(a);
|
ObjectMotionState* b = static_cast<ObjectMotionState*>(objectB->getUserPointer());
|
||||||
EntityItem* entityA = entityMotionStateA ? entityMotionStateA->getEntity() : NULL;
|
EntityItem* entityA = a ? a->getEntity() : NULL;
|
||||||
void* b = objectB->getUserPointer();
|
EntityItem* entityB = b ? b->getEntity() : NULL;
|
||||||
EntityMotionState* entityMotionStateB = static_cast<EntityMotionState*>(b);
|
bool aIsDynamic = entityA && !objectA->isStaticOrKinematicObject();
|
||||||
EntityItem* entityB = entityMotionStateB ? entityMotionStateB->getEntity() : NULL;
|
bool bIsDynamic = entityB && !objectB->isStaticOrKinematicObject();
|
||||||
|
|
||||||
if (a || b) {
|
if (a || b) {
|
||||||
// the manifold has up to 4 distinct points, but only extract info from the first
|
// the manifold has up to 4 distinct points, but only extract info from the first
|
||||||
_contactMap[ContactKey(a, b)].update(_numContactFrames, contactManifold->getContactPoint(0), _originOffset);
|
_contactMap[ContactKey(a, b)].update(_numContactFrames, contactManifold->getContactPoint(0), _originOffset);
|
||||||
|
}
|
||||||
// collisions cause infectious spread of simulation-ownership. we also attempt to take
|
// collisions cause infectious spread of simulation-ownership. we also attempt to take
|
||||||
// ownership of anything that collides with our avatar.
|
// ownership of anything that collides with our avatar.
|
||||||
if (entityA && entityB && !objectA->isStaticOrKinematicObject() && !objectB->isStaticOrKinematicObject()) {
|
if ((aIsDynamic && entityA->getSimulatorID() == myNodeID) ||
|
||||||
if (entityA->getSimulatorID() == myNodeID ||
|
(a && a->getShouldClaimSimulationOwnership()) ||
|
||||||
entityMotionStateA->getShouldClaimSimulationOwnership() ||
|
(objectA == characterCollisionObject)) {
|
||||||
objectA == characterCollisionObject) {
|
if (bIsDynamic) {
|
||||||
entityMotionStateB->setShouldClaimSimulationOwnership(true);
|
b->setShouldClaimSimulationOwnership(true);
|
||||||
}
|
}
|
||||||
if (entityB->getSimulatorID() == myNodeID ||
|
}
|
||||||
entityMotionStateB->getShouldClaimSimulationOwnership() ||
|
if ((bIsDynamic && entityB->getSimulatorID() == myNodeID) ||
|
||||||
objectB == characterCollisionObject) {
|
(b && b->getShouldClaimSimulationOwnership()) ||
|
||||||
entityMotionStateA->setShouldClaimSimulationOwnership(true);
|
(objectB == characterCollisionObject)) {
|
||||||
}
|
if (aIsDynamic) {
|
||||||
|
a->setShouldClaimSimulationOwnership(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue