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