mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-29 06:09:55 +02:00
saving work
This commit is contained in:
parent
3b1e0dc7d9
commit
d3368146ce
5 changed files with 84 additions and 82 deletions
|
@ -122,6 +122,7 @@
|
||||||
#include <RecordingScriptingInterface.h>
|
#include <RecordingScriptingInterface.h>
|
||||||
#include <UpdateSceneTask.h>
|
#include <UpdateSceneTask.h>
|
||||||
#include <RenderViewTask.h>
|
#include <RenderViewTask.h>
|
||||||
|
#include <render/EngineStats.h>
|
||||||
#include <SecondaryCamera.h>
|
#include <SecondaryCamera.h>
|
||||||
#include <ResourceCache.h>
|
#include <ResourceCache.h>
|
||||||
#include <ResourceRequest.h>
|
#include <ResourceRequest.h>
|
||||||
|
@ -5346,8 +5347,8 @@ void Application::resetPhysicsReadyInformation() {
|
||||||
// collision information of nearby entities to make running bullet be safe.
|
// collision information of nearby entities to make running bullet be safe.
|
||||||
_fullSceneReceivedCounter = 0;
|
_fullSceneReceivedCounter = 0;
|
||||||
_fullSceneCounterAtLastPhysicsCheck = 0;
|
_fullSceneCounterAtLastPhysicsCheck = 0;
|
||||||
_nearbyEntitiesCountAtLastPhysicsCheck = 0;
|
_gpuTextureMemSizeStabilityCount = 0;
|
||||||
_nearbyEntitiesStabilityCount = 0;
|
_gpuTextureMemSizeAtLastCheck = 0;
|
||||||
_physicsEnabled = false;
|
_physicsEnabled = false;
|
||||||
_octreeProcessor.startEntitySequence();
|
_octreeProcessor.startEntitySequence();
|
||||||
}
|
}
|
||||||
|
@ -5586,18 +5587,20 @@ void Application::update(float deltaTime) {
|
||||||
// for nearby entities before starting bullet up.
|
// for nearby entities before starting bullet up.
|
||||||
quint64 now = usecTimestampNow();
|
quint64 now = usecTimestampNow();
|
||||||
if (isServerlessMode() || _octreeProcessor.isLoadSequenceComplete()) {
|
if (isServerlessMode() || _octreeProcessor.isLoadSequenceComplete()) {
|
||||||
// we've received a new full-scene octree stats packet, or it's been long enough to try again anyway
|
if (gpuTextureMemSizeStable()) {
|
||||||
_lastPhysicsCheckTime = now;
|
// we've received a new full-scene octree stats packet, or it's been long enough to try again anyway
|
||||||
_fullSceneCounterAtLastPhysicsCheck = _fullSceneReceivedCounter;
|
_lastPhysicsCheckTime = now;
|
||||||
_lastQueriedViews.clear(); // Force new view.
|
_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).
|
// 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
|
// 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.
|
// scene is ready to compute its collision shape.
|
||||||
if (getMyAvatar()->isReadyForPhysics()) {
|
if (getMyAvatar()->isReadyForPhysics()) {
|
||||||
_physicsEnabled = true;
|
_physicsEnabled = true;
|
||||||
setIsInterstitialMode(false);
|
setIsInterstitialMode(false);
|
||||||
getMyAvatar()->updateMotionBehaviorFromMenu();
|
getMyAvatar()->updateMotionBehaviorFromMenu();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (domainLoadingInProgress) {
|
} else if (domainLoadingInProgress) {
|
||||||
|
@ -6234,9 +6237,14 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType) {
|
||||||
const bool isModifiedQuery = !_physicsEnabled;
|
const bool isModifiedQuery = !_physicsEnabled;
|
||||||
if (isModifiedQuery) {
|
if (isModifiedQuery) {
|
||||||
// Create modified view that is a simple sphere.
|
// Create modified view that is a simple sphere.
|
||||||
|
|
||||||
ConicalViewFrustum sphericalView;
|
ConicalViewFrustum sphericalView;
|
||||||
|
ConicalViewFrustum farView;
|
||||||
|
|
||||||
|
farView.set(_viewFrustum);
|
||||||
|
|
||||||
sphericalView.setSimpleRadius(INITIAL_QUERY_RADIUS);
|
sphericalView.setSimpleRadius(INITIAL_QUERY_RADIUS);
|
||||||
_octreeQuery.setConicalViews({ sphericalView });
|
_octreeQuery.setConicalViews({ sphericalView, farView });
|
||||||
_octreeQuery.setOctreeSizeScale(DEFAULT_OCTREE_SIZE_SCALE);
|
_octreeQuery.setOctreeSizeScale(DEFAULT_OCTREE_SIZE_SCALE);
|
||||||
static constexpr float MIN_LOD_ADJUST = -20.0f;
|
static constexpr float MIN_LOD_ADJUST = -20.0f;
|
||||||
_octreeQuery.setBoundaryLevelAdjust(MIN_LOD_ADJUST);
|
_octreeQuery.setBoundaryLevelAdjust(MIN_LOD_ADJUST);
|
||||||
|
@ -6548,69 +6556,23 @@ void Application::trackIncomingOctreePacket(ReceivedMessage& message, SharedNode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::nearbyEntitiesAreReadyForPhysics() {
|
bool Application::gpuTextureMemSizeStable() {
|
||||||
// this is used to avoid the following scenario:
|
auto renderConfig = qApp->getRenderEngine()->getConfiguration();
|
||||||
// A table has some items sitting on top of it. The items are at rest, meaning they aren't active in bullet.
|
auto renderStats = renderConfig->getConfig<render::EngineStats>("Stats");
|
||||||
// Someone logs in close to the table. They receive information about the items on the table before they
|
|
||||||
// receive information about the table. The items are very close to the avatar's capsule, so they become
|
|
||||||
// activated in bullet. This causes them to fall to the floor, because the table's shape isn't yet in bullet.
|
|
||||||
EntityTreePointer entityTree = getEntities()->getTree();
|
|
||||||
if (!entityTree) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We don't want to use EntityTree::findEntities(AABox, ...) method because that scan will snarf parented entities
|
quint64 textureResourceGPUMemSize = renderStats->textureResourceGPUMemSize;
|
||||||
// whose bounding boxes cannot be computed (it is too loose for our purposes here). Instead we manufacture
|
quint64 texturePopulatedGPUMemSize = renderStats->textureResourcePopulatedGPUMemSize;
|
||||||
// custom filters and use the general-purpose EntityTree::findEntities(filter, ...)
|
|
||||||
QVector<EntityItemPointer> entities;
|
|
||||||
AABox avatarBox(getMyAvatar()->getWorldPosition() - glm::vec3(PHYSICS_READY_RANGE), glm::vec3(2 * PHYSICS_READY_RANGE));
|
|
||||||
// create two functions that use avatarBox (entityScan and elementScan), the second calls the first
|
|
||||||
std::function<bool (EntityItemPointer&)> entityScan = [=](EntityItemPointer& entity) {
|
|
||||||
if (entity->shouldBePhysical()) {
|
|
||||||
bool success = false;
|
|
||||||
AABox entityBox = entity->getAABox(success);
|
|
||||||
// important: bail for entities that cannot supply a valid AABox
|
|
||||||
return success && avatarBox.touches(entityBox);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
std::function<bool(const OctreeElementPointer&, void*)> elementScan = [&](const OctreeElementPointer& element, void* unused) {
|
|
||||||
if (element->getAACube().touches(avatarBox)) {
|
|
||||||
EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element);
|
|
||||||
entityTreeElement->getEntities(entityScan, entities);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
entityTree->withReadLock([&] {
|
if (_gpuTextureMemSizeAtLastCheck == textureResourceGPUMemSize) {
|
||||||
// Pass the second function to the general-purpose EntityTree::findEntities()
|
_gpuTextureMemSizeStabilityCount++;
|
||||||
// which will traverse the tree, apply the two filter functions (to element, then to entities)
|
|
||||||
// as it traverses. The end result will be a list of entities that match.
|
|
||||||
entityTree->findEntities(elementScan, entities);
|
|
||||||
});
|
|
||||||
|
|
||||||
uint32_t nearbyCount = entities.size();
|
|
||||||
if (nearbyCount == _nearbyEntitiesCountAtLastPhysicsCheck) {
|
|
||||||
_nearbyEntitiesStabilityCount++;
|
|
||||||
} else {
|
} else {
|
||||||
_nearbyEntitiesStabilityCount = 0;
|
_gpuTextureMemSizeStabilityCount = 0;
|
||||||
}
|
}
|
||||||
_nearbyEntitiesCountAtLastPhysicsCheck = nearbyCount;
|
_gpuTextureMemSizeAtLastCheck = textureResourceGPUMemSize;
|
||||||
|
|
||||||
const uint32_t MINIMUM_NEARBY_ENTITIES_STABILITY_COUNT = 3;
|
const uint32_t MINIMUM_GPU_TEXTURE_MEM_SIZE_STABILITY_COUNT = 10;
|
||||||
if (_nearbyEntitiesStabilityCount >= MINIMUM_NEARBY_ENTITIES_STABILITY_COUNT) {
|
if (_gpuTextureMemSizeStabilityCount >= MINIMUM_GPU_TEXTURE_MEM_SIZE_STABILITY_COUNT) {
|
||||||
// We've seen the same number of nearby entities for several stats packets in a row. assume we've got all
|
return (textureResourceGPUMemSize == texturePopulatedGPUMemSize);
|
||||||
// the local entities.
|
|
||||||
bool result = true;
|
|
||||||
foreach (EntityItemPointer entity, entities) {
|
|
||||||
if (entity->shouldBePhysical() && !entity->isReadyToComputeShape()) {
|
|
||||||
HIFI_FCDEBUG(interfaceapp(), "Physics disabled until entity loads: " << entity->getID() << entity->getName());
|
|
||||||
// don't break here because we want all the relevant entities to start their downloads
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -528,7 +528,7 @@ private:
|
||||||
bool importFromZIP(const QString& filePath);
|
bool importFromZIP(const QString& filePath);
|
||||||
bool importImage(const QString& urlString);
|
bool importImage(const QString& urlString);
|
||||||
|
|
||||||
bool nearbyEntitiesAreReadyForPhysics();
|
bool gpuTextureMemSizeStable();
|
||||||
int processOctreeStats(ReceivedMessage& message, SharedNodePointer sendingNode);
|
int processOctreeStats(ReceivedMessage& message, SharedNodePointer sendingNode);
|
||||||
void trackIncomingOctreePacket(ReceivedMessage& message, SharedNodePointer sendingNode, bool wasStatsPacket);
|
void trackIncomingOctreePacket(ReceivedMessage& message, SharedNodePointer sendingNode, bool wasStatsPacket);
|
||||||
|
|
||||||
|
@ -725,8 +725,10 @@ private:
|
||||||
|
|
||||||
std::atomic<uint32_t> _fullSceneReceivedCounter { 0 }; // how many times have we received a full-scene octree stats packet
|
std::atomic<uint32_t> _fullSceneReceivedCounter { 0 }; // how many times have we received a full-scene octree stats packet
|
||||||
uint32_t _fullSceneCounterAtLastPhysicsCheck { 0 }; // _fullSceneReceivedCounter last time we checked physics ready
|
uint32_t _fullSceneCounterAtLastPhysicsCheck { 0 }; // _fullSceneReceivedCounter last time we checked physics ready
|
||||||
uint32_t _nearbyEntitiesCountAtLastPhysicsCheck { 0 }; // how many in-range entities last time we checked physics ready
|
|
||||||
uint32_t _nearbyEntitiesStabilityCount { 0 }; // how many times has _nearbyEntitiesCountAtLastPhysicsCheck been the same
|
quint64 _gpuTextureMemSizeStabilityCount { 0 };
|
||||||
|
quint64 _gpuTextureMemSizeAtLastCheck { 0 };
|
||||||
|
|
||||||
quint64 _lastPhysicsCheckTime { usecTimestampNow() }; // when did we last check to see if physics was ready
|
quint64 _lastPhysicsCheckTime { usecTimestampNow() }; // when did we last check to see if physics was ready
|
||||||
|
|
||||||
bool _keyboardDeviceHasFocus { true };
|
bool _keyboardDeviceHasFocus { true };
|
||||||
|
|
|
@ -171,6 +171,9 @@ bool SafeLanding::isEntityLoadingComplete() {
|
||||||
|
|
||||||
bool isVisuallyReady = true;
|
bool isVisuallyReady = true;
|
||||||
|
|
||||||
|
|
||||||
|
qDebug() << "EntityTpye" << EntityTypes::getEntityTypeName(entity->getType()) << entity->getEntityItemID();
|
||||||
|
|
||||||
Settings settings;
|
Settings settings;
|
||||||
bool enableInterstitial = settings.value("enableIntersitialMode", false).toBool();
|
bool enableInterstitial = settings.value("enableIntersitialMode", false).toBool();
|
||||||
|
|
||||||
|
@ -188,6 +191,7 @@ bool SafeLanding::isEntityLoadingComplete() {
|
||||||
entityMapIter++;
|
entityMapIter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
qDebug() << "EntityList size" << _trackedEntities.size() << "\n";
|
||||||
return _trackedEntities.empty();
|
return _trackedEntities.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,4 +75,4 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
Script.include("/~/system/libraries/Xform.js");
|
Script.include("/~/system/libraries/Xform.js");
|
||||||
var DEBUG = false;
|
var DEBUG = true;
|
||||||
var MIN_LOADING_PROGRESS = 3.6;
|
var MIN_LOADING_PROGRESS = 3.6;
|
||||||
var TOTAL_LOADING_PROGRESS = 3.8;
|
var TOTAL_LOADING_PROGRESS = 3.8;
|
||||||
var EPSILON = 0.01;
|
var EPSILON = 0.01;
|
||||||
|
@ -186,6 +186,8 @@
|
||||||
var currentDomain = "no domain";
|
var currentDomain = "no domain";
|
||||||
var timer = null;
|
var timer = null;
|
||||||
var target = 0;
|
var target = 0;
|
||||||
|
var textureMemSizeStabilityCount = 0;
|
||||||
|
var textureMemSizeAtLastCheck = 0;
|
||||||
|
|
||||||
var connectionToDomainFailed = false;
|
var connectionToDomainFailed = false;
|
||||||
|
|
||||||
|
@ -228,6 +230,8 @@
|
||||||
updateOverlays(false);
|
updateOverlays(false);
|
||||||
startAudio();
|
startAudio();
|
||||||
target = 0;
|
target = 0;
|
||||||
|
textureMemSizeStabilityCount = 0;
|
||||||
|
textureMemSizeAtLastCheck = 0;
|
||||||
currentProgress = 0.1;
|
currentProgress = 0.1;
|
||||||
connectionToDomainFailed = false;
|
connectionToDomainFailed = false;
|
||||||
previousCameraMode = Camera.mode;
|
previousCameraMode = Camera.mode;
|
||||||
|
@ -348,10 +352,11 @@
|
||||||
Overlays.editOverlay(loadingBarPlacard, properties);
|
Overlays.editOverlay(loadingBarPlacard, properties);
|
||||||
Overlays.editOverlay(loadingBarProgress, loadingBarProperties);
|
Overlays.editOverlay(loadingBarProgress, loadingBarProperties);
|
||||||
|
|
||||||
|
if (!DEBUG) {
|
||||||
Menu.setIsOptionChecked("Show Overlays", physicsEnabled);
|
Menu.setIsOptionChecked("Show Overlays", physicsEnabled);
|
||||||
if (!HMD.active) {
|
if (!HMD.active) {
|
||||||
toolbar.writeProperty("visible", physicsEnabled);
|
toolbar.writeProperty("visible", physicsEnabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resetValues();
|
resetValues();
|
||||||
|
@ -374,6 +379,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
|
var renderStats = Render.getConfig("Stats");
|
||||||
var physicsEnabled = Window.isPhysicsEnabled();
|
var physicsEnabled = Window.isPhysicsEnabled();
|
||||||
var thisInterval = Date.now();
|
var thisInterval = Date.now();
|
||||||
var deltaTime = (thisInterval - lastInterval);
|
var deltaTime = (thisInterval - lastInterval);
|
||||||
|
@ -381,11 +387,39 @@
|
||||||
|
|
||||||
var domainLoadingProgressPercentage = Window.domainLoadingProgress();
|
var domainLoadingProgressPercentage = Window.domainLoadingProgress();
|
||||||
|
|
||||||
var progress = MIN_LOADING_PROGRESS * domainLoadingProgressPercentage;
|
var progress = ((TOTAL_LOADING_PROGRESS * 0.4) * domainLoadingProgressPercentage);
|
||||||
if (progress >= target) {
|
if (progress >= target) {
|
||||||
target = progress;
|
target = progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentProgress >= (TOTAL_LOADING_PROGRESS * 0.4)) {
|
||||||
|
var textureResourceGPUMemSize = renderStats.textureResourceGPUMemSize;
|
||||||
|
var texturePopulatedGPUMemSize = renderStats.textureResourcePopulatedGPUMemSize;
|
||||||
|
|
||||||
|
if (textureMemSizeAtLastCheck === textureResourceGPUMemSize) {
|
||||||
|
textureMemSizeStabilityCount++;
|
||||||
|
} else {
|
||||||
|
textureMemSizeStabilityCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
textureMemSizeAtLastCheck = textureResourceGPUMemSize;
|
||||||
|
|
||||||
|
if (textureMemSizeStabilityCount >= 15) {
|
||||||
|
|
||||||
|
if (textureResourceGPUMemSize > 0) {
|
||||||
|
print((texturePopulatedGPUMemSize / textureResourceGPUMemSize));
|
||||||
|
var gpuPercantage = (TOTAL_LOADING_PROGRESS * 0.6) * (texturePopulatedGPUMemSize / textureResourceGPUMemSize);
|
||||||
|
print("---> gpu: " + gpuPercantage);
|
||||||
|
print("----> current: " + progress);
|
||||||
|
var totalProgress = progress + gpuPercantage;
|
||||||
|
print("------> totalProgress: " + totalProgress + "\n");
|
||||||
|
if (totalProgress >= target) {
|
||||||
|
target = totalProgress;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((physicsEnabled && (currentProgress < TOTAL_LOADING_PROGRESS))) {
|
if ((physicsEnabled && (currentProgress < TOTAL_LOADING_PROGRESS))) {
|
||||||
target = TOTAL_LOADING_PROGRESS;
|
target = TOTAL_LOADING_PROGRESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue