mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 07:23:39 +02:00
attempt to claim simulation ownership of entities the avatar crashes with
This commit is contained in:
parent
f452e47577
commit
fbff3627dc
2 changed files with 35 additions and 4 deletions
|
@ -305,6 +305,8 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_
|
||||||
qCDebug(physics) << "EntityMotionState::sendUpdate()... calling queueEditEntityMessage()...";
|
qCDebug(physics) << "EntityMotionState::sendUpdate()... calling queueEditEntityMessage()...";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
qCDebug(physics) << "EntityMotionState::sendUpdate()";
|
||||||
|
|
||||||
entityPacketSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, id, properties);
|
entityPacketSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, id, properties);
|
||||||
} else {
|
} else {
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
|
|
|
@ -23,8 +23,9 @@ uint32_t PhysicsEngine::getNumSubsteps() {
|
||||||
return _numSubsteps;
|
return _numSubsteps;
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicsEngine::PhysicsEngine(const glm::vec3& offset)
|
PhysicsEngine::PhysicsEngine(const glm::vec3& offset) :
|
||||||
: _originOffset(offset) {
|
_originOffset(offset),
|
||||||
|
_characterController(NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicsEngine::~PhysicsEngine() {
|
PhysicsEngine::~PhysicsEngine() {
|
||||||
|
@ -367,6 +368,12 @@ void PhysicsEngine::stepNonPhysicalKinematics(const quint64& now) {
|
||||||
|
|
||||||
void PhysicsEngine::computeCollisionEvents() {
|
void PhysicsEngine::computeCollisionEvents() {
|
||||||
BT_PROFILE("computeCollisionEvents");
|
BT_PROFILE("computeCollisionEvents");
|
||||||
|
|
||||||
|
const btCollisionObject* characterCollisionObject =
|
||||||
|
_characterController ? _characterController->getCollisionObject() : NULL;
|
||||||
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
const QUuid& myNodeID = nodeList->getSessionUUID();
|
||||||
|
|
||||||
// update all contacts every frame
|
// update all contacts every frame
|
||||||
int numManifolds = _collisionDispatcher->getNumManifolds();
|
int numManifolds = _collisionDispatcher->getNumManifolds();
|
||||||
for (int i = 0; i < numManifolds; ++i) {
|
for (int i = 0; i < numManifolds; ++i) {
|
||||||
|
@ -387,7 +394,29 @@ void PhysicsEngine::computeCollisionEvents() {
|
||||||
void* b = objectB->getUserPointer();
|
void* b = objectB->getUserPointer();
|
||||||
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);
|
const ContactKey& contactKey = ContactKey(a, b);
|
||||||
|
ContactInfo& contactInfo = _contactMap[contactKey];
|
||||||
|
contactInfo.update(_numContactFrames, contactManifold->getContactPoint(0), _originOffset);
|
||||||
|
|
||||||
|
// if our character capsule is colliding with something dynamic, claim simulation ownership.
|
||||||
|
// do this by setting the entity's simulator-id to NULL, thereby causing EntityMotionState::sendUpdate
|
||||||
|
// to set ownership to us.
|
||||||
|
if (objectA == characterCollisionObject && !objectB->isStaticOrKinematicObject() && b) {
|
||||||
|
ObjectMotionState* B = static_cast<ObjectMotionState*>(b);
|
||||||
|
EntityItem* entityB = static_cast<EntityMotionState*>(B)->getEntity();
|
||||||
|
if (entityB->getSimulatorID() != myNodeID) {
|
||||||
|
qDebug() << "CLAIMING B";
|
||||||
|
entityB->setSimulatorID(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (objectB == characterCollisionObject && !objectA->isStaticOrKinematicObject() && a) {
|
||||||
|
ObjectMotionState* A = static_cast<ObjectMotionState*>(a);
|
||||||
|
EntityItem* entityA = static_cast<EntityMotionState*>(A)->getEntity();
|
||||||
|
if (entityA->getSimulatorID() != myNodeID) {
|
||||||
|
qDebug() << "CLAIMING A";
|
||||||
|
entityA->setSimulatorID(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue