mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-16 11:40:11 +02:00
Safe Landing checkpoint
This commit is contained in:
parent
88bd4e3d9a
commit
4395e1fa26
5 changed files with 90 additions and 16 deletions
|
@ -5495,6 +5495,7 @@ void Application::update(float deltaTime) {
|
|||
if (!_physicsEnabled) {
|
||||
if (!domainLoadingInProgress) {
|
||||
PROFILE_ASYNC_BEGIN(app, "Scene Loading", "");
|
||||
_octreeProcessor.startEntitySequence();
|
||||
domainLoadingInProgress = true;
|
||||
}
|
||||
|
||||
|
@ -5504,7 +5505,7 @@ void Application::update(float deltaTime) {
|
|||
// Check for flagged EntityData having arrived.
|
||||
auto entityTreeRenderer = getEntities();
|
||||
if (isServerlessMode() ||
|
||||
(entityTreeRenderer && _octreeProcessor.octreeSequenceIsComplete(entityTreeRenderer->getLastOctreeMessageSequence()) )) {
|
||||
(_octreeProcessor.isLoadSequenceComplete() )) {
|
||||
// we've received a new full-scene octree stats packet, or it's been long enough to try again anyway
|
||||
_lastPhysicsCheckTime = now;
|
||||
_fullSceneCounterAtLastPhysicsCheck = _fullSceneReceivedCounter;
|
||||
|
@ -6166,7 +6167,6 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType) {
|
|||
_octreeQuery.setOctreeSizeScale(DEFAULT_OCTREE_SIZE_SCALE);
|
||||
static constexpr float MIN_LOD_ADJUST = -20.0f;
|
||||
_octreeQuery.setBoundaryLevelAdjust(MIN_LOD_ADJUST);
|
||||
_octreeProcessor.startEntitySequence();
|
||||
} else {
|
||||
_octreeQuery.setConicalViews(_conicalViews);
|
||||
auto lodManager = DependencyManager::get<LODManager>();
|
||||
|
|
|
@ -112,6 +112,7 @@ void OctreePacketProcessor::processPacket(QSharedPointer<ReceivedMessage> messag
|
|||
auto renderer = qApp->getEntities();
|
||||
if (renderer) {
|
||||
renderer->processDatagram(*message, sendingNode);
|
||||
_safeLanding->sequenceNumberReceived(renderer->getLastOctreeMessageSequence());
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
@ -145,12 +146,16 @@ namespace {
|
|||
}
|
||||
}
|
||||
|
||||
bool OctreePacketProcessor::octreeSequenceIsComplete(int sequenceNumber) const {
|
||||
// If we've received the flagged seq # and the current one is >= it.
|
||||
return _completionSequenceNumber != INVALID_SEQUENCE &&
|
||||
!lessThanWraparound<OCTREE_PACKET_SEQUENCE>(sequenceNumber, _completionSequenceNumber);
|
||||
}
|
||||
//bool OctreePacketProcessor::octreeSequenceIsComplete(int sequenceNumber) const {
|
||||
// // If we've received the flagged seq # and the current one is >= it.
|
||||
// return _completionSequenceNumber != INVALID_SEQUENCE &&
|
||||
// !lessThanWraparound<OCTREE_PACKET_SEQUENCE>(sequenceNumber, _completionSequenceNumber);
|
||||
//}
|
||||
|
||||
void OctreePacketProcessor::startEntitySequence() {
|
||||
_safeLanding->startEntitySequence(qApp->getEntities());
|
||||
}
|
||||
|
||||
bool OctreePacketProcessor::isLoadSequenceComplete() const {
|
||||
return _safeLanding->isLoadSequenceComplete();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
~OctreePacketProcessor();
|
||||
|
||||
void startEntitySequence();
|
||||
bool octreeSequenceIsComplete(int sequenceNumber) const;
|
||||
bool isLoadSequenceComplete() const;
|
||||
|
||||
signals:
|
||||
void packetVersionMismatch();
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
|
||||
#include "SafeLanding.h"
|
||||
#include "EntityTreeRenderer.h"
|
||||
#include "ModelEntityItem.h"
|
||||
#include "model-networking/ModelCache.h"
|
||||
#include "InterfaceLogging.h"
|
||||
|
||||
const int SafeLanding::SEQUENCE_MODULO = std::numeric_limits<OCTREE_PACKET_SEQUENCE>::max() + 1;
|
||||
|
||||
|
@ -31,8 +34,6 @@ bool SafeLanding::SequenceLessThan::operator()(const int& a, const int& b) const
|
|||
SafeLanding::SafeLanding() {
|
||||
}
|
||||
|
||||
SafeLanding::~SafeLanding() { }
|
||||
|
||||
void SafeLanding::startEntitySequence(QSharedPointer<EntityTreeRenderer> entityTreeRenderer) {
|
||||
if (!_trackingEntities) {
|
||||
auto entityTree = entityTreeRenderer->getTree();
|
||||
|
@ -45,7 +46,6 @@ void SafeLanding::startEntitySequence(QSharedPointer<EntityTreeRenderer> entityT
|
|||
&EntityTree::deletingEntity, this, &SafeLanding::deleteTrackedEntity);
|
||||
_trackingEntities = true;
|
||||
_sequenceNumbers.clear();
|
||||
_isSequenceComplete = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,10 +70,10 @@ void SafeLanding::addTrackedEntity(const EntityItemID& entityID) {
|
|||
|
||||
if (solidTypes.count(entity->getType()) && !entity->getCollisionless()) {
|
||||
_trackedEntities.emplace(entityID, entity);
|
||||
trackResources(entity);
|
||||
qCDebug(interfaceapp) << "Tracking entity " << entity->getItemName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,3 +111,67 @@ bool SafeLanding::sequenceNumbersComplete() {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SafeLanding::trackResources(EntityItemPointer entity) {
|
||||
if (entity->getType() == EntityTypes::Model) {
|
||||
ModelEntityItem * modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity).get();
|
||||
QString resourceURL;
|
||||
QSharedPointer<Resource> resource;
|
||||
auto shapeType = modelEntity->getShapeType();
|
||||
|
||||
if (shapeType == SHAPE_TYPE_COMPOUND) {
|
||||
resourceURL = modelEntity->getCompoundShapeURL();
|
||||
resource = DependencyManager::get<ModelCache>()->getCollisionGeometryResource(resourceURL);
|
||||
} else if (shapeType == SHAPE_TYPE_STATIC_MESH || shapeType == SHAPE_TYPE_SIMPLE_COMPOUND) {
|
||||
resourceURL = modelEntity->getModelURL();
|
||||
resource = DependencyManager::get<ModelCache>()->getGeometryResource(resourceURL);
|
||||
}
|
||||
|
||||
if (resource) {
|
||||
connect(resource.data(), &Resource::loaded, this, &SafeLanding::resourceLoaded);
|
||||
// Remove it either way:
|
||||
connect(resource.data(), &Resource::failed, this, &SafeLanding::resourceLoaded);
|
||||
if (!resource->isLoaded()) {
|
||||
_trackedURLs.insert(resourceURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SafeLanding::resourceLoaded() {
|
||||
QObject * sender = QObject::sender();
|
||||
if (sender) {
|
||||
Resource * resource = dynamic_cast<Resource*>(sender);
|
||||
const QString resourceURL = resource->getURL().toString();
|
||||
_trackedURLs.erase(resourceURL);
|
||||
qCDebug(interfaceapp) << "Removed tracked URL" << resourceURL;
|
||||
}
|
||||
}
|
||||
|
||||
bool SafeLanding::isLoadSequenceComplete() {
|
||||
if (sequenceNumbersComplete() && _trackedURLs.empty()) {
|
||||
_trackingEntities = false;
|
||||
_trackedEntities.clear();
|
||||
}
|
||||
|
||||
return !_trackingEntities;
|
||||
}
|
||||
|
||||
void SafeLanding::DebugDumpSequenceIDs() const {
|
||||
int p = -1;
|
||||
qCDebug(interfaceapp) << "Sequence set size:" << _sequenceNumbers.size();
|
||||
for (auto s: _sequenceNumbers) {
|
||||
if (p == -1) {
|
||||
p = s;
|
||||
qCDebug(interfaceapp) << "First: " << s;
|
||||
} else {
|
||||
if (s != p + 1) {
|
||||
qCDebug(interfaceapp) << "Gap from" << p << "to" << s << "(exclusive)";
|
||||
p = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (p != -1) {
|
||||
qCDebug(interfaceapp) << "Last:" << p;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,26 +25,30 @@ class EntityItemID;
|
|||
class SafeLanding : public QObject {
|
||||
public:
|
||||
SafeLanding();
|
||||
~SafeLanding();
|
||||
~SafeLanding() = default;
|
||||
|
||||
void startEntitySequence(QSharedPointer<EntityTreeRenderer> entityTreeRenderer);
|
||||
void stopEntitySequence();
|
||||
void setCompletionSequenceNumbers(int first, int last);
|
||||
void sequenceNumberReceived(int sequenceNumber);
|
||||
bool isSequenceComplete() const { return _isSequenceComplete; }
|
||||
bool isLoadSequenceComplete();
|
||||
|
||||
private slots:
|
||||
void addTrackedEntity(const EntityItemID& entityID);
|
||||
void deleteTrackedEntity(const EntityItemID& entityID);
|
||||
void resourceLoaded();
|
||||
|
||||
private:
|
||||
bool sequenceNumbersComplete();
|
||||
void trackResources(EntityItemPointer entity);
|
||||
void DebugDumpSequenceIDs() const;
|
||||
|
||||
bool _trackingEntities { false };
|
||||
EntityTreePointer _entityTree;
|
||||
using EntityMap = std::map<EntityItemID, EntityItemPointer>;
|
||||
EntityMap _trackedEntities;
|
||||
|
||||
static constexpr int INVALID_SEQUENCE = -1;
|
||||
bool _isSequenceComplete { true };
|
||||
int _initialStart { INVALID_SEQUENCE };
|
||||
int _initialEnd { INVALID_SEQUENCE }; // final sequence, exclusive.
|
||||
|
||||
|
@ -53,6 +57,7 @@ private:
|
|||
};
|
||||
|
||||
std::set<int, SequenceLessThan> _sequenceNumbers;
|
||||
std::set<QString> _trackedURLs;
|
||||
|
||||
static const int SEQUENCE_MODULO;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue