mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 20:44:14 +02:00
cleaup to help unravel one spaghetti strand
This commit is contained in:
parent
496a7f3608
commit
00185ee82e
6 changed files with 42 additions and 27 deletions
|
@ -6165,6 +6165,24 @@ void Application::updateSecondaryCameraViewFrustum() {
|
|||
|
||||
static bool domainLoadingInProgress = false;
|
||||
|
||||
void Application::tryToEnablePhysics() {
|
||||
bool enableInterstitial = DependencyManager::get<NodeList>()->getDomainHandler().getInterstitialModeEnabled();
|
||||
|
||||
if (gpuTextureMemSizeStable() || !enableInterstitial) {
|
||||
_fullSceneCounterAtLastPhysicsCheck = _fullSceneReceivedCounter;
|
||||
_lastQueriedViews.clear(); // Force new view.
|
||||
|
||||
// process octree stats packets are sent in between full sends of a scene (this isn't currently true).
|
||||
// We keep physics disabled until we've received a full scene and everything near the avatar in that
|
||||
// scene is ready to compute its collision shape.
|
||||
if (getMyAvatar()->isReadyForPhysics()) {
|
||||
_physicsEnabled = true;
|
||||
setIsInterstitialMode(false);
|
||||
getMyAvatar()->updateMotionBehaviorFromMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Application::update(float deltaTime) {
|
||||
PROFILE_RANGE_EX(app, __FUNCTION__, 0xffff0000, (uint64_t)_graphicsEngine._renderFrameCount + 1);
|
||||
|
||||
|
@ -6172,7 +6190,6 @@ void Application::update(float deltaTime) {
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!_physicsEnabled) {
|
||||
if (!domainLoadingInProgress) {
|
||||
PROFILE_ASYNC_BEGIN(app, "Scene Loading", "");
|
||||
|
@ -6182,21 +6199,13 @@ void Application::update(float deltaTime) {
|
|||
// we haven't yet enabled physics. we wait until we think we have all the collision information
|
||||
// for nearby entities before starting bullet up.
|
||||
quint64 now = usecTimestampNow();
|
||||
if (isServerlessMode() || _octreeProcessor.isLoadSequenceComplete()) {
|
||||
bool enableInterstitial = DependencyManager::get<NodeList>()->getDomainHandler().getInterstitialModeEnabled();
|
||||
|
||||
if (gpuTextureMemSizeStable() || !enableInterstitial) {
|
||||
_fullSceneCounterAtLastPhysicsCheck = _fullSceneReceivedCounter;
|
||||
_lastQueriedViews.clear(); // Force new view.
|
||||
|
||||
// process octree stats packets are sent in between full sends of a scene (this isn't currently true).
|
||||
// We keep physics disabled until we've received a full scene and everything near the avatar in that
|
||||
// scene is ready to compute its collision shape.
|
||||
if (getMyAvatar()->isReadyForPhysics()) {
|
||||
_physicsEnabled = true;
|
||||
setIsInterstitialMode(false);
|
||||
getMyAvatar()->updateMotionBehaviorFromMenu();
|
||||
}
|
||||
if (isServerlessMode()) {
|
||||
tryToEnablePhysics();
|
||||
} else if (_failedToConnectToEntityServer) {
|
||||
_octreeProcessor.stopSafeLanding();
|
||||
} else {
|
||||
if (_octreeProcessor.isLoadSequenceComplete()) {
|
||||
tryToEnablePhysics();
|
||||
}
|
||||
}
|
||||
} else if (domainLoadingInProgress) {
|
||||
|
|
|
@ -564,6 +564,7 @@ private:
|
|||
void cleanupBeforeQuit();
|
||||
|
||||
void idle();
|
||||
void tryToEnablePhysics();
|
||||
void update(float deltaTime);
|
||||
|
||||
// Various helper functions called during update()
|
||||
|
|
|
@ -115,7 +115,7 @@ void OctreePacketProcessor::processPacket(QSharedPointer<ReceivedMessage> messag
|
|||
auto renderer = qApp->getEntities();
|
||||
if (renderer) {
|
||||
renderer->processDatagram(*message, sendingNode);
|
||||
_safeLanding->noteReceivedsequenceNumber(renderer->getLastOctreeMessageSequence());
|
||||
_safeLanding->updateSequence(renderer->getLastOctreeMessageSequence());
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
@ -124,7 +124,7 @@ void OctreePacketProcessor::processPacket(QSharedPointer<ReceivedMessage> messag
|
|||
// Read sequence #
|
||||
OCTREE_PACKET_SEQUENCE completionNumber;
|
||||
message->readPrimitive(&completionNumber);
|
||||
_safeLanding->setCompletionSequenceNumbers(0, completionNumber);
|
||||
_safeLanding->finishSequence(0, completionNumber);
|
||||
} break;
|
||||
|
||||
default: {
|
||||
|
@ -134,5 +134,9 @@ void OctreePacketProcessor::processPacket(QSharedPointer<ReceivedMessage> messag
|
|||
}
|
||||
|
||||
void OctreePacketProcessor::startSafeLanding() {
|
||||
_safeLanding->startEntitySequence(qApp->getEntities());
|
||||
_safeLanding->startTracking(qApp->getEntities());
|
||||
}
|
||||
|
||||
void OctreePacketProcessor::stopSafeLanding() {
|
||||
_safeLanding->stopTracking();
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ public:
|
|||
~OctreePacketProcessor();
|
||||
|
||||
void startSafeLanding();
|
||||
void stopSafeLanding();
|
||||
bool isLoadSequenceComplete() const { return _safeLanding->isLoadSequenceComplete(); }
|
||||
float domainLoadingProgress() const { return _safeLanding->loadingProgressPercentage(); }
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ bool SafeLanding::SequenceLessThan::operator()(const int& a, const int& b) const
|
|||
return lessThanWraparound<OCTREE_PACKET_SEQUENCE>(a, b);
|
||||
}
|
||||
|
||||
void SafeLanding::startEntitySequence(QSharedPointer<EntityTreeRenderer> entityTreeRenderer) {
|
||||
void SafeLanding::startTracking(QSharedPointer<EntityTreeRenderer> entityTreeRenderer) {
|
||||
if (!entityTreeRenderer.isNull()) {
|
||||
auto entityTree = entityTreeRenderer->getTree();
|
||||
if (entityTree && !_trackingEntities) {
|
||||
|
@ -81,7 +81,7 @@ void SafeLanding::deleteTrackedEntity(const EntityItemID& entityID) {
|
|||
_trackedEntities.erase(entityID);
|
||||
}
|
||||
|
||||
void SafeLanding::setCompletionSequenceNumbers(int first, int last) {
|
||||
void SafeLanding::finishSequence(int first, int last) {
|
||||
Locker lock(_lock);
|
||||
if (_initialStart == INVALID_SEQUENCE) {
|
||||
_initialStart = first;
|
||||
|
@ -89,7 +89,7 @@ void SafeLanding::setCompletionSequenceNumbers(int first, int last) {
|
|||
}
|
||||
}
|
||||
|
||||
void SafeLanding::noteReceivedsequenceNumber(int sequenceNumber) {
|
||||
void SafeLanding::updateSequence(int sequenceNumber) {
|
||||
if (_trackingEntities) {
|
||||
Locker lock(_lock);
|
||||
_sequenceNumbers.insert(sequenceNumber);
|
||||
|
@ -97,7 +97,7 @@ void SafeLanding::noteReceivedsequenceNumber(int sequenceNumber) {
|
|||
}
|
||||
|
||||
bool SafeLanding::isLoadSequenceComplete() {
|
||||
if ((isEntityLoadingComplete() && isSequenceNumbersComplete()) || qApp->failedToConnectToEntityServer()) {
|
||||
if (isEntityLoadingComplete() && isSequenceNumbersComplete()) {
|
||||
stopTracking();
|
||||
}
|
||||
return !_trackingEntities;
|
||||
|
|
|
@ -25,9 +25,10 @@ class EntityItemID;
|
|||
|
||||
class SafeLanding : public QObject {
|
||||
public:
|
||||
void startEntitySequence(QSharedPointer<EntityTreeRenderer> entityTreeRenderer);
|
||||
void setCompletionSequenceNumbers(int first, int last); // 'last' exclusive.
|
||||
void noteReceivedsequenceNumber(int sequenceNumber);
|
||||
void startTracking(QSharedPointer<EntityTreeRenderer> entityTreeRenderer);
|
||||
void stopTracking();
|
||||
void finishSequence(int first, int last); // 'last' exclusive.
|
||||
void updateSequence(int sequenceNumber);
|
||||
bool isLoadSequenceComplete();
|
||||
float loadingProgressPercentage();
|
||||
|
||||
|
@ -40,7 +41,6 @@ private:
|
|||
bool isEntityPhysicsReady(const EntityItemPointer& entity);
|
||||
void debugDumpSequenceIDs() const;
|
||||
bool isEntityLoadingComplete();
|
||||
void stopTracking();
|
||||
|
||||
std::mutex _lock;
|
||||
using Locker = std::lock_guard<std::mutex>;
|
||||
|
|
Loading…
Reference in a new issue