3
0
Fork 0
mirror of https://github.com/lubosz/overte.git synced 2025-04-27 15:15:32 +02:00

Reset SafeLanding in all cases

Also remove unused data member, elevate load priority only
for entities with collisions, handle case of no nearby entities.
This commit is contained in:
Simon Walton 2018-08-20 12:31:21 -07:00
parent 829b83c61d
commit a891b74fac
3 changed files with 29 additions and 22 deletions

View file

@ -5272,6 +5272,7 @@ void Application::resetPhysicsReadyInformation() {
_nearbyEntitiesCountAtLastPhysicsCheck = 0;
_nearbyEntitiesStabilityCount = 0;
_physicsEnabled = false;
_octreeProcessor.startEntitySequence();
}
@ -6324,8 +6325,6 @@ void Application::clearDomainOctreeDetails() {
// reset the model renderer
getEntities()->clear();
_octreeProcessor.startEntitySequence();
auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
skyStage->setBackgroundMode(graphics::SunSkyStage::SKY_DEFAULT);

View file

@ -31,22 +31,22 @@ bool SafeLanding::SequenceLessThan::operator()(const int& a, const int& b) const
}
void SafeLanding::startEntitySequence(QSharedPointer<EntityTreeRenderer> entityTreeRenderer) {
if (!_trackingEntities) {
auto entityTree = entityTreeRenderer->getTree();
auto entityTree = entityTreeRenderer->getTree();
if (entityTree) {
Locker lock(_lock);
_entityTree = entityTree;
_trackingEntities = true;
connect(std::const_pointer_cast<EntityTree>(_entityTree).get(),
&EntityTree::addingEntity, this, &SafeLanding::addTrackedEntity);
connect(std::const_pointer_cast<EntityTree>(_entityTree).get(),
&EntityTree::deletingEntity, this, &SafeLanding::deleteTrackedEntity);
_sequenceNumbers.clear();
_initialStart = INVALID_SEQUENCE;
_initialEnd = INVALID_SEQUENCE;
EntityTreeRenderer::setEntityLoadingPriorityFunction(&ElevatedPriority);
}
if (entityTree) {
Locker lock(_lock);
_entityTree = entityTree;
_trackedEntities.clear();
_trackingEntities = true;
connect(std::const_pointer_cast<EntityTree>(_entityTree).get(),
&EntityTree::addingEntity, this, &SafeLanding::addTrackedEntity);
connect(std::const_pointer_cast<EntityTree>(_entityTree).get(),
&EntityTree::deletingEntity, this, &SafeLanding::deleteTrackedEntity);
_sequenceNumbers.clear();
_initialStart = INVALID_SEQUENCE;
_initialEnd = INVALID_SEQUENCE;
EntityTreeRenderer::setEntityLoadingPriorityFunction(&ElevatedPriority);
}
}
@ -70,7 +70,9 @@ void SafeLanding::addTrackedEntity(const EntityItemID& entityID) {
ModelEntityItem * modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity).get();
static const std::set<ShapeType> downloadedCollisionTypes
{ SHAPE_TYPE_COMPOUND, SHAPE_TYPE_SIMPLE_COMPOUND, SHAPE_TYPE_STATIC_MESH, SHAPE_TYPE_SIMPLE_HULL };
if (downloadedCollisionTypes.count(modelEntity->getShapeType()) != 0) {
bool hasAABox;
entity->getAABox(hasAABox);
if (hasAABox && downloadedCollisionTypes.count(modelEntity->getShapeType()) != 0) {
// Only track entities with downloaded collision bodies.
_trackedEntities.emplace(entityID, entity);
qCDebug(interfaceapp) << "Safe Landing: Tracking entity " << entity->getItemName();
@ -117,11 +119,14 @@ bool SafeLanding::isLoadSequenceComplete() {
bool SafeLanding::sequenceNumbersComplete() {
if (_initialStart != INVALID_SEQUENCE) {
Locker lock(_lock);
int sequenceSize = _initialStart < _initialEnd ? _initialEnd - _initialStart:
int sequenceSize = _initialStart <= _initialEnd ? _initialEnd - _initialStart:
_initialEnd + SEQUENCE_MODULO - _initialStart;
auto startIter = _sequenceNumbers.find(_initialStart);
auto endIter = _sequenceNumbers.find(_initialEnd);
if (startIter != _sequenceNumbers.end() && endIter != _sequenceNumbers.end() && distance(startIter, endIter) == sequenceSize) {
if (sequenceSize == 0 ||
(startIter != _sequenceNumbers.end()
&& endIter != _sequenceNumbers.end()
&& distance(startIter, endIter) == sequenceSize) ) {
_trackingEntities = false; // Don't track anything else that comes in.
return true;
}
@ -143,6 +148,10 @@ bool SafeLanding::entityPhysicsComplete() {
return _trackedEntities.empty();
}
float SafeLanding::ElevatedPriority(const EntityItem& entityItem) {
return entityItem.getCollisionless() ? 0.0f : 10.0f;
}
void SafeLanding::debugDumpSequenceIDs() const {
int p = -1;
qCDebug(interfaceapp) << "Sequence set size:" << _sequenceNumbers.size();

View file

@ -55,9 +55,8 @@ private:
};
std::set<int, SequenceLessThan> _sequenceNumbers;
std::set<QString> _trackedURLs;
static float ElevatedPriority(const EntityItem&) { return 10.0f; }
static float ElevatedPriority(const EntityItem& entityItem);
static float StandardPriority(const EntityItem&) { return 0.0f; }
static const int SEQUENCE_MODULO;