mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 04:44:08 +02:00
script update and visuallyReady entities
This commit is contained in:
parent
11ab6dd0b5
commit
3796675123
12 changed files with 83 additions and 13 deletions
interface/src
libraries
entities-renderer/src
entities/src
scripts/system
|
@ -5519,6 +5519,7 @@ void Application::update(float deltaTime) {
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!_physicsEnabled) {
|
||||
if (!domainLoadingInProgress) {
|
||||
PROFILE_ASYNC_BEGIN(app, "Scene Loading", "");
|
||||
|
@ -5528,7 +5529,9 @@ 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 renderReady = _octreeProcessor.isEntitiesRenderReady();
|
||||
qDebug() << "--> render ready: " << renderReady;
|
||||
if (isServerlessMode() || (_octreeProcessor.isLoadSequenceComplete() && renderReady)) {
|
||||
// we've received a new full-scene octree stats packet, or it's been long enough to try again anyway
|
||||
_lastPhysicsCheckTime = now;
|
||||
_fullSceneCounterAtLastPhysicsCheck = _fullSceneReceivedCounter;
|
||||
|
|
|
@ -138,6 +138,10 @@ bool OctreePacketProcessor::isLoadSequenceComplete() const {
|
|||
return _safeLanding->isLoadSequenceComplete();
|
||||
}
|
||||
|
||||
bool OctreePacketProcessor::isEntitiesRenderReady() const {
|
||||
return _safeLanding->entitiesRenderReady();
|
||||
}
|
||||
|
||||
float OctreePacketProcessor::domainLoadProgress() {
|
||||
return _safeLanding->loadingProgressPercentage();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ public:
|
|||
|
||||
void startEntitySequence();
|
||||
bool isLoadSequenceComplete() const;
|
||||
bool isEntitiesRenderReady() const;
|
||||
float domainLoadProgress();
|
||||
|
||||
signals:
|
||||
|
|
|
@ -36,6 +36,7 @@ void SafeLanding::startEntitySequence(QSharedPointer<EntityTreeRenderer> entityT
|
|||
if (entityTree) {
|
||||
Locker lock(_lock);
|
||||
_entityTree = entityTree;
|
||||
_trackedEntitiesRenderStatus.clear();
|
||||
_trackedEntities.clear();
|
||||
_trackingEntities = true;
|
||||
connect(std::const_pointer_cast<EntityTree>(_entityTree).get(),
|
||||
|
@ -76,22 +77,24 @@ void SafeLanding::addTrackedEntity(const EntityItemID& entityID) {
|
|||
if (hasAABox && downloadedCollisionTypes.count(modelEntity->getShapeType()) != 0) {
|
||||
// Only track entities with downloaded collision bodies.
|
||||
_trackedEntities.emplace(entityID, entity);
|
||||
|
||||
float trackedEntityCount = (float)_trackedEntities.size();
|
||||
|
||||
if (trackedEntityCount > _maxTrackedEntityCount) {
|
||||
_maxTrackedEntityCount = trackedEntityCount;
|
||||
}
|
||||
qCDebug(interfaceapp) << "Safe Landing: Tracking entity " << entity->getItemName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_trackedEntitiesRenderStatus.emplace(entityID, entity);
|
||||
float trackedEntityCount = (float)_trackedEntitiesRenderStatus.size();
|
||||
|
||||
if (trackedEntityCount > _maxTrackedEntityCount) {
|
||||
_maxTrackedEntityCount = trackedEntityCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SafeLanding::deleteTrackedEntity(const EntityItemID& entityID) {
|
||||
Locker lock(_lock);
|
||||
_trackedEntities.erase(entityID);
|
||||
_trackedEntitiesRenderStatus.erase(entityID);
|
||||
}
|
||||
|
||||
void SafeLanding::setCompletionSequenceNumbers(int first, int last) {
|
||||
|
@ -165,6 +168,24 @@ bool SafeLanding::isEntityPhysicsComplete() {
|
|||
return _trackedEntities.empty();
|
||||
}
|
||||
|
||||
bool SafeLanding::entitiesRenderReady() {
|
||||
Locker lock(_lock);
|
||||
|
||||
for (auto entityMapIter = _trackedEntitiesRenderStatus.begin(); entityMapIter != _trackedEntitiesRenderStatus.end(); ++entityMapIter) {
|
||||
auto entity = entityMapIter->second;
|
||||
bool visuallyReady = entity->isVisuallyReady();
|
||||
qDebug() << "is entityType: " << EntityTypes::getEntityTypeName(entity->getType()) << " " << visuallyReady;
|
||||
if (visuallyReady) {
|
||||
entityMapIter = _trackedEntitiesRenderStatus.erase(entityMapIter);
|
||||
if (entityMapIter == _trackedEntitiesRenderStatus.end()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
qDebug() << "list size: -> " << _trackedEntitiesRenderStatus.size();
|
||||
return _trackedEntitiesRenderStatus.empty();
|
||||
}
|
||||
|
||||
float SafeLanding::ElevatedPriority(const EntityItem& entityItem) {
|
||||
return entityItem.getCollisionless() ? 0.0f : 10.0f;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <QtCore/QSharedPointer>
|
||||
|
||||
#include "EntityItem.h"
|
||||
#include "EntityDynamicInterface.h"
|
||||
|
||||
class EntityTreeRenderer;
|
||||
class EntityItemID;
|
||||
|
@ -29,6 +30,7 @@ public:
|
|||
void setCompletionSequenceNumbers(int first, int last); // 'last' exclusive.
|
||||
void noteReceivedsequenceNumber(int sequenceNumber);
|
||||
bool isLoadSequenceComplete();
|
||||
bool entitiesRenderReady();
|
||||
float loadingProgressPercentage();
|
||||
|
||||
private slots:
|
||||
|
@ -46,6 +48,7 @@ private:
|
|||
EntityTreePointer _entityTree;
|
||||
using EntityMap = std::map<EntityItemID, EntityItemPointer>;
|
||||
EntityMap _trackedEntities;
|
||||
EntityMap _trackedEntitiesRenderStatus;
|
||||
|
||||
static constexpr int INVALID_SEQUENCE = -1;
|
||||
int _initialStart { INVALID_SEQUENCE };
|
||||
|
|
|
@ -1441,7 +1441,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
|||
// That is where _currentFrame and _lastAnimated were updated.
|
||||
if (_animating) {
|
||||
DETAILED_PROFILE_RANGE(simulation_physics, "Animate");
|
||||
|
||||
|
||||
if (!jointsMapped()) {
|
||||
mapJoints(entity, model->getJointNames());
|
||||
//else the joint have been mapped before but we have a new animation to load
|
||||
|
@ -1457,6 +1457,14 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void ModelEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
|
||||
withWriteLock([&] {
|
||||
bool visuallyReady = (_prevModelLoaded && _texturesLoaded);
|
||||
entity->setVisuallyReady(visuallyReady);
|
||||
});
|
||||
}
|
||||
|
||||
void ModelEntityRenderer::setIsVisibleInSecondaryCamera(bool value) {
|
||||
Parent::setIsVisibleInSecondaryCamera(value);
|
||||
setKey(_didLastVisualGeometryRequestSucceed);
|
||||
|
|
|
@ -38,11 +38,13 @@ class ModelEntityWrapper : public ModelEntityItem {
|
|||
using Parent = ModelEntityItem;
|
||||
friend class render::entities::ModelEntityRenderer;
|
||||
|
||||
public:
|
||||
bool isModelLoaded() const;
|
||||
|
||||
protected:
|
||||
ModelEntityWrapper(const EntityItemID& entityItemID) : Parent(entityItemID) {}
|
||||
void setModel(const ModelPointer& model);
|
||||
ModelPointer getModel() const;
|
||||
bool isModelLoaded() const;
|
||||
|
||||
bool _needsInitialSimulation{ true };
|
||||
private:
|
||||
|
@ -162,6 +164,8 @@ protected:
|
|||
virtual void doRender(RenderArgs* args) override;
|
||||
virtual void doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) override;
|
||||
|
||||
virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override;
|
||||
|
||||
render::hifi::Tag getTagMask() const override;
|
||||
|
||||
void setIsVisibleInSecondaryCamera(bool value) override;
|
||||
|
|
|
@ -258,6 +258,16 @@ void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen
|
|||
if (hazeChanged) {
|
||||
updateHazeFromEntity(entity);
|
||||
}
|
||||
|
||||
bool visuallyReady = true;
|
||||
uint32_t skyboxMode = entity->getSkyboxMode();
|
||||
if (skyboxMode == COMPONENT_MODE_ENABLED) {
|
||||
bool skyboxLoadedOrFailed = (_skyboxTexture && (_skyboxTexture->isLoaded() || _skyboxTexture->isFailed()));
|
||||
qDebug() << "------> " << skyboxLoadedOrFailed;
|
||||
visuallyReady = (!_skyboxTextureURL.isEmpty() || skyboxLoadedOrFailed);
|
||||
}
|
||||
|
||||
entity->setVisuallyReady(visuallyReady);
|
||||
}
|
||||
|
||||
void ZoneEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
|
||||
|
|
|
@ -305,6 +305,7 @@ public:
|
|||
void setDynamic(bool value);
|
||||
|
||||
virtual bool shouldBePhysical() const { return false; }
|
||||
bool isVisuallyReady() const { return _visuallyReady; }
|
||||
|
||||
bool getLocked() const;
|
||||
void setLocked(bool value);
|
||||
|
@ -527,6 +528,7 @@ public:
|
|||
void removeCloneID(const QUuid& cloneID);
|
||||
const QVector<QUuid> getCloneIDs() const;
|
||||
void setCloneIDs(const QVector<QUuid>& cloneIDs);
|
||||
void setVisuallyReady(bool visuallyReady) { _visuallyReady = visuallyReady; }
|
||||
|
||||
signals:
|
||||
void requestRenderUpdate();
|
||||
|
@ -639,6 +641,7 @@ protected:
|
|||
EntityTreeElementPointer _element; // set by EntityTreeElement
|
||||
void* _physicsInfo { nullptr }; // set by EntitySimulation
|
||||
bool _simulated { false }; // set by EntitySimulation
|
||||
bool _visuallyReady { true };
|
||||
|
||||
bool addActionInternal(EntitySimulationPointer simulation, EntityDynamicPointer action);
|
||||
bool removeActionInternal(const QUuid& actionID, EntitySimulationPointer simulation = nullptr);
|
||||
|
|
|
@ -40,6 +40,7 @@ ModelEntityItem::ModelEntityItem(const EntityItemID& entityItemID) : EntityItem(
|
|||
_type = EntityTypes::Model;
|
||||
_lastKnownCurrentFrame = -1;
|
||||
_color[0] = _color[1] = _color[2] = 0;
|
||||
_visuallyReady = false;
|
||||
}
|
||||
|
||||
const QString ModelEntityItem::getTextures() const {
|
||||
|
|
|
@ -42,6 +42,7 @@ ZoneEntityItem::ZoneEntityItem(const EntityItemID& entityItemID) : EntityItem(en
|
|||
|
||||
_shapeType = DEFAULT_SHAPE_TYPE;
|
||||
_compoundShapeURL = DEFAULT_COMPOUND_SHAPE_URL;
|
||||
_visuallyReady = false;
|
||||
}
|
||||
|
||||
EntityItemProperties ZoneEntityItem::getProperties(EntityPropertyFlags desiredProperties) const {
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
var BUTTON_PROPERTIES = {
|
||||
text: "Interstitial"
|
||||
};
|
||||
|
||||
var tablet = null;
|
||||
var button = null;
|
||||
|
||||
|
@ -336,11 +337,12 @@
|
|||
Overlays.editOverlay(loadingBarPlacard, properties);
|
||||
Overlays.editOverlay(loadingBarProgress, loadingBarProperties);
|
||||
|
||||
if (physicsEnabled) {
|
||||
if (physicsEnabled && !HMD.active) {
|
||||
toolbar.writeProperty("visible", true);
|
||||
resetValues();
|
||||
}
|
||||
|
||||
resetValues();
|
||||
|
||||
Camera.mode = "first person";
|
||||
}
|
||||
|
||||
|
@ -356,7 +358,13 @@
|
|||
Overlays.editOverlay(anchorOverlay, { localPosition: localPosition });
|
||||
}
|
||||
|
||||
|
||||
Window.interstitialStatusChanged.connect(function(interstitialMode) {
|
||||
print("------> insterstitial mode changed " + interstitialMode + " <------");
|
||||
});
|
||||
|
||||
function update() {
|
||||
var downloadInfo = GlobalServices.getDownloadInfo();
|
||||
var physicsEnabled = Window.isPhysicsEnabled();
|
||||
var thisInterval = Date.now();
|
||||
var deltaTime = (thisInterval - lastInterval);
|
||||
|
@ -365,7 +373,7 @@
|
|||
var domainLoadingProgressPercentage = Window.domainLoadingProgress();
|
||||
|
||||
var progress = MAX_X_SIZE * domainLoadingProgressPercentage;
|
||||
print(progress);
|
||||
//print(progress);
|
||||
if (progress >= target) {
|
||||
target = progress;
|
||||
}
|
||||
|
@ -383,6 +391,7 @@
|
|||
};
|
||||
|
||||
Overlays.editOverlay(loadingBarProgress, properties);
|
||||
print(JSON.stringify(downloadInfo));
|
||||
if ((physicsEnabled && (currentProgress >= (MAX_X_SIZE - EPSILON)))) {
|
||||
updateOverlays((physicsEnabled || connectionToDomainFailed));
|
||||
endAudio();
|
||||
|
@ -431,7 +440,9 @@
|
|||
renderViewTask.getConfig("LightingModel")["enableAmbientLight"] = true;
|
||||
renderViewTask.getConfig("LightingModel")["enableDirectionalLight"] = true;
|
||||
renderViewTask.getConfig("LightingModel")["enablePointLight"] = true;
|
||||
toolbar.writeProperty("visible", true);
|
||||
if (!HMD.active) {
|
||||
toolbar.writeProperty("visible", true);
|
||||
}
|
||||
}
|
||||
|
||||
Script.scriptEnding.connect(cleanup);
|
||||
|
|
Loading…
Reference in a new issue