mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 06:38:29 +02:00
BUGZ-223 - Physics was not starting in TheSpot-dev
This was caused by two issues involving the SafeLanding system: * Race condition on domain load The domain is hard-reset twice during typical start, first after login completes, and second, when ice/domain renegotiation occurs Entities added during the first reset caused an add to the safe landing system which, because those adds were queued, possibly happened after the second hard reset. Second, Safe landing checks whether physics is ready on entities before letting physics start. Physics is ready when the entities have a physics shape associated with them if they're static meshes. The physics shape is only generated if the entity is in Region 1 or 2. Safe landing, however, was not checking the region of the entity and was therefore waiting on entities that were not in region 1 or 2
This commit is contained in:
parent
c1de3ecfd8
commit
dddb171b52
2 changed files with 27 additions and 22 deletions
|
@ -10,7 +10,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "SafeLanding.h"
|
#include "SafeLanding.h"
|
||||||
|
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
|
||||||
#include "EntityTreeRenderer.h"
|
#include "EntityTreeRenderer.h"
|
||||||
|
@ -35,24 +34,26 @@ bool SafeLanding::SequenceLessThan::operator()(const int& a, const int& b) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void SafeLanding::startEntitySequence(QSharedPointer<EntityTreeRenderer> entityTreeRenderer) {
|
void SafeLanding::startEntitySequence(QSharedPointer<EntityTreeRenderer> entityTreeRenderer) {
|
||||||
auto entityTree = entityTreeRenderer->getTree();
|
|
||||||
|
|
||||||
if (entityTree) {
|
if (!entityTreeRenderer.isNull()) {
|
||||||
Locker lock(_lock);
|
auto entityTree = entityTreeRenderer->getTree();
|
||||||
_entityTree = entityTree;
|
if (entityTree) {
|
||||||
_trackedEntities.clear();
|
Locker lock(_lock);
|
||||||
_trackingEntities = true;
|
_entityTreeRenderer = entityTreeRenderer;
|
||||||
_maxTrackedEntityCount = 0;
|
_trackedEntities.clear();
|
||||||
connect(std::const_pointer_cast<EntityTree>(_entityTree).get(),
|
_trackingEntities = true;
|
||||||
&EntityTree::addingEntity, this, &SafeLanding::addTrackedEntity);
|
_maxTrackedEntityCount = 0;
|
||||||
connect(std::const_pointer_cast<EntityTree>(_entityTree).get(),
|
connect(std::const_pointer_cast<EntityTree>(entityTree).get(),
|
||||||
&EntityTree::deletingEntity, this, &SafeLanding::deleteTrackedEntity);
|
&EntityTree::addingEntity, this, &SafeLanding::addTrackedEntity, Qt::DirectConnection);
|
||||||
|
connect(std::const_pointer_cast<EntityTree>(entityTree).get(),
|
||||||
|
&EntityTree::deletingEntity, this, &SafeLanding::deleteTrackedEntity);
|
||||||
|
|
||||||
_sequenceNumbers.clear();
|
_sequenceNumbers.clear();
|
||||||
_initialStart = INVALID_SEQUENCE;
|
_initialStart = INVALID_SEQUENCE;
|
||||||
_initialEnd = INVALID_SEQUENCE;
|
_initialEnd = INVALID_SEQUENCE;
|
||||||
_startTime = usecTimestampNow();
|
_startTime = usecTimestampNow();
|
||||||
EntityTreeRenderer::setEntityLoadingPriorityFunction(&ElevatedPriority);
|
EntityTreeRenderer::setEntityLoadingPriorityFunction(&ElevatedPriority);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +71,7 @@ void SafeLanding::stopEntitySequence() {
|
||||||
void SafeLanding::addTrackedEntity(const EntityItemID& entityID) {
|
void SafeLanding::addTrackedEntity(const EntityItemID& entityID) {
|
||||||
if (_trackingEntities) {
|
if (_trackingEntities) {
|
||||||
Locker lock(_lock);
|
Locker lock(_lock);
|
||||||
EntityItemPointer entity = _entityTree->findEntityByID(entityID);
|
EntityItemPointer entity = _entityTreeRenderer->getTree()->findEntityByID(entityID);
|
||||||
|
|
||||||
if (entity && !entity->isLocalEntity() && entity->getCreated() < _startTime) {
|
if (entity && !entity->isLocalEntity() && entity->getCreated() < _startTime) {
|
||||||
|
|
||||||
|
@ -111,7 +112,7 @@ bool SafeLanding::isLoadSequenceComplete() {
|
||||||
Locker lock(_lock);
|
Locker lock(_lock);
|
||||||
_initialStart = INVALID_SEQUENCE;
|
_initialStart = INVALID_SEQUENCE;
|
||||||
_initialEnd = INVALID_SEQUENCE;
|
_initialEnd = INVALID_SEQUENCE;
|
||||||
_entityTree = nullptr;
|
_entityTreeRenderer.clear();
|
||||||
_trackingEntities = false; // Don't track anything else that comes in.
|
_trackingEntities = false; // Don't track anything else that comes in.
|
||||||
EntityTreeRenderer::setEntityLoadingPriorityFunction(StandardPriority);
|
EntityTreeRenderer::setEntityLoadingPriorityFunction(StandardPriority);
|
||||||
}
|
}
|
||||||
|
@ -158,7 +159,7 @@ bool SafeLanding::isSequenceNumbersComplete() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isEntityPhysicsReady(const EntityItemPointer& entity) {
|
bool SafeLanding::isEntityPhysicsReady(const EntityItemPointer& entity) {
|
||||||
if (entity && !entity->getCollisionless()) {
|
if (entity && !entity->getCollisionless()) {
|
||||||
const auto& entityType = entity->getType();
|
const auto& entityType = entity->getType();
|
||||||
if (entityType == EntityTypes::Model) {
|
if (entityType == EntityTypes::Model) {
|
||||||
|
@ -168,7 +169,10 @@ bool isEntityPhysicsReady(const EntityItemPointer& entity) {
|
||||||
bool hasAABox;
|
bool hasAABox;
|
||||||
entity->getAABox(hasAABox);
|
entity->getAABox(hasAABox);
|
||||||
if (hasAABox && downloadedCollisionTypes.count(modelEntity->getShapeType()) != 0) {
|
if (hasAABox && downloadedCollisionTypes.count(modelEntity->getShapeType()) != 0) {
|
||||||
return (!entity->shouldBePhysical() || entity->isInPhysicsSimulation() || modelEntity->computeShapeFailedToLoad());
|
auto space = _entityTreeRenderer->getWorkloadSpace();
|
||||||
|
uint8_t region = space ? space->getRegion(entity->getSpaceIndex()) : workload::Region::INVALID;
|
||||||
|
bool shouldBePhysical = region < workload::Region::R3 && entity->shouldBePhysical();
|
||||||
|
return (!shouldBePhysical || entity->isInPhysicsSimulation() || modelEntity->computeShapeFailedToLoad());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,13 +38,14 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isSequenceNumbersComplete();
|
bool isSequenceNumbersComplete();
|
||||||
|
bool isEntityPhysicsReady(const EntityItemPointer& entity);
|
||||||
void debugDumpSequenceIDs() const;
|
void debugDumpSequenceIDs() const;
|
||||||
bool isEntityLoadingComplete();
|
bool isEntityLoadingComplete();
|
||||||
|
|
||||||
std::mutex _lock;
|
std::mutex _lock;
|
||||||
using Locker = std::lock_guard<std::mutex>;
|
using Locker = std::lock_guard<std::mutex>;
|
||||||
bool _trackingEntities { false };
|
bool _trackingEntities { false };
|
||||||
EntityTreePointer _entityTree;
|
QSharedPointer<EntityTreeRenderer> _entityTreeRenderer;
|
||||||
using EntityMap = std::map<EntityItemID, EntityItemPointer>;
|
using EntityMap = std::map<EntityItemID, EntityItemPointer>;
|
||||||
EntityMap _trackedEntities;
|
EntityMap _trackedEntities;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue