mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 20:39:55 +02:00
try to improve performance
This commit is contained in:
parent
d6f31369ee
commit
a5f5f9fc5d
5 changed files with 8 additions and 60 deletions
|
@ -222,16 +222,6 @@ void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene
|
||||||
_renderablesToUpdate.insert({ entityId, renderable });
|
_renderablesToUpdate.insert({ entityId, renderable });
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Looping over all the entity renderers is likely to be a bottleneck in the future
|
|
||||||
// Currently, this is necessary because the model entity loading logic requires constant polling
|
|
||||||
// This was working fine because the entity server used to send repeated updates as your view changed,
|
|
||||||
// but with the improved entity server logic (PR 11141), updateInScene (below) would not be triggered enough
|
|
||||||
for (const auto& entry : _entitiesInScene) {
|
|
||||||
const auto& renderable = entry.second;
|
|
||||||
if (renderable) {
|
|
||||||
renderable->update(scene, transaction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!_renderablesToUpdate.empty()) {
|
if (!_renderablesToUpdate.empty()) {
|
||||||
for (const auto& entry : _renderablesToUpdate) {
|
for (const auto& entry : _renderablesToUpdate) {
|
||||||
const auto& renderable = entry.second;
|
const auto& renderable = entry.second;
|
||||||
|
|
|
@ -291,18 +291,6 @@ void EntityRenderer::updateInScene(const ScenePointer& scene, Transaction& trans
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityRenderer::update(const ScenePointer& scene, Transaction& transaction) {
|
|
||||||
if (!isValidRenderItem()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!needsUpdate()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
doUpdate(scene, transaction, _entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Internal methods
|
// Internal methods
|
||||||
//
|
//
|
||||||
|
@ -316,11 +304,6 @@ bool EntityRenderer::needsRenderUpdate() const {
|
||||||
return needsRenderUpdateFromEntity(_entity);
|
return needsRenderUpdateFromEntity(_entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if the item needs to have update called
|
|
||||||
bool EntityRenderer::needsUpdate() const {
|
|
||||||
return needsUpdateFromEntity(_entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if the item in question needs to have updateInScene called because of changes in the entity
|
// Returns true if the item in question needs to have updateInScene called because of changes in the entity
|
||||||
bool EntityRenderer::needsRenderUpdateFromEntity(const EntityItemPointer& entity) const {
|
bool EntityRenderer::needsRenderUpdateFromEntity(const EntityItemPointer& entity) const {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
|
@ -49,8 +49,6 @@ public:
|
||||||
virtual bool addToScene(const ScenePointer& scene, Transaction& transaction) final;
|
virtual bool addToScene(const ScenePointer& scene, Transaction& transaction) final;
|
||||||
virtual void removeFromScene(const ScenePointer& scene, Transaction& transaction);
|
virtual void removeFromScene(const ScenePointer& scene, Transaction& transaction);
|
||||||
|
|
||||||
virtual void update(const ScenePointer& scene, Transaction& transaction);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool needsRenderUpdateFromEntity() const final { return needsRenderUpdateFromEntity(_entity); }
|
virtual bool needsRenderUpdateFromEntity() const final { return needsRenderUpdateFromEntity(_entity); }
|
||||||
virtual void onAddToScene(const EntityItemPointer& entity);
|
virtual void onAddToScene(const EntityItemPointer& entity);
|
||||||
|
@ -73,12 +71,6 @@ protected:
|
||||||
// Returns true if the item in question needs to have updateInScene called because of changes in the entity
|
// Returns true if the item in question needs to have updateInScene called because of changes in the entity
|
||||||
virtual bool needsRenderUpdateFromEntity(const EntityItemPointer& entity) const;
|
virtual bool needsRenderUpdateFromEntity(const EntityItemPointer& entity) const;
|
||||||
|
|
||||||
// Returns true if the item in question needs to have update called
|
|
||||||
virtual bool needsUpdate() const;
|
|
||||||
|
|
||||||
// Returns true if the item in question needs to have update called because of changes in the entity
|
|
||||||
virtual bool needsUpdateFromEntity(const EntityItemPointer& entity) const { return false; }
|
|
||||||
|
|
||||||
// Will be called on the main thread from updateInScene. This can be used to fetch things like
|
// Will be called on the main thread from updateInScene. This can be used to fetch things like
|
||||||
// network textures or model geometry from resource caches
|
// network textures or model geometry from resource caches
|
||||||
virtual void doRenderUpdateSynchronous(const ScenePointer& scene, Transaction& transaction, const EntityItemPointer& entity) { }
|
virtual void doRenderUpdateSynchronous(const ScenePointer& scene, Transaction& transaction, const EntityItemPointer& entity) { }
|
||||||
|
@ -88,8 +80,6 @@ protected:
|
||||||
// data in this method if using multi-threaded rendering
|
// data in this method if using multi-threaded rendering
|
||||||
virtual void doRenderUpdateAsynchronous(const EntityItemPointer& entity);
|
virtual void doRenderUpdateAsynchronous(const EntityItemPointer& entity);
|
||||||
|
|
||||||
virtual void doUpdate(const ScenePointer& scene, Transaction& transaction, const EntityItemPointer& entity) { }
|
|
||||||
|
|
||||||
// Called by the `render` method after `needsRenderUpdate`
|
// Called by the `render` method after `needsRenderUpdate`
|
||||||
virtual void doRender(RenderArgs* args) = 0;
|
virtual void doRender(RenderArgs* args) = 0;
|
||||||
|
|
||||||
|
@ -158,15 +148,6 @@ protected:
|
||||||
onRemoveFromSceneTyped(_typedEntity);
|
onRemoveFromSceneTyped(_typedEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
using Parent::needsUpdateFromEntity;
|
|
||||||
// Returns true if the item in question needs to have update called because of changes in the entity
|
|
||||||
virtual bool needsUpdateFromEntity(const EntityItemPointer& entity) const override final {
|
|
||||||
if (Parent::needsUpdateFromEntity(entity)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return needsUpdateFromTypedEntity(_typedEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
using Parent::needsRenderUpdateFromEntity;
|
using Parent::needsRenderUpdateFromEntity;
|
||||||
// Returns true if the item in question needs to have updateInScene called because of changes in the entity
|
// Returns true if the item in question needs to have updateInScene called because of changes in the entity
|
||||||
virtual bool needsRenderUpdateFromEntity(const EntityItemPointer& entity) const override final {
|
virtual bool needsRenderUpdateFromEntity(const EntityItemPointer& entity) const override final {
|
||||||
|
@ -181,11 +162,6 @@ protected:
|
||||||
doRenderUpdateSynchronousTyped(scene, transaction, _typedEntity);
|
doRenderUpdateSynchronousTyped(scene, transaction, _typedEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void doUpdate(const ScenePointer& scene, Transaction& transaction, const EntityItemPointer& entity) override final {
|
|
||||||
Parent::doUpdate(scene, transaction, entity);
|
|
||||||
doUpdateTyped(scene, transaction, _typedEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void doRenderUpdateAsynchronous(const EntityItemPointer& entity) override final {
|
virtual void doRenderUpdateAsynchronous(const EntityItemPointer& entity) override final {
|
||||||
Parent::doRenderUpdateAsynchronous(entity);
|
Parent::doRenderUpdateAsynchronous(entity);
|
||||||
doRenderUpdateAsynchronousTyped(_typedEntity);
|
doRenderUpdateAsynchronousTyped(_typedEntity);
|
||||||
|
@ -194,8 +170,6 @@ protected:
|
||||||
virtual bool needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const { return false; }
|
virtual bool needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const { return false; }
|
||||||
virtual void doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) { }
|
virtual void doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) { }
|
||||||
virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) { }
|
virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) { }
|
||||||
virtual bool needsUpdateFromTypedEntity(const TypedEntityPointer& entity) const { return false; }
|
|
||||||
virtual void doUpdateTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) { }
|
|
||||||
virtual void onAddToSceneTyped(const TypedEntityPointer& entity) { }
|
virtual void onAddToSceneTyped(const TypedEntityPointer& entity) { }
|
||||||
virtual void onRemoveFromSceneTyped(const TypedEntityPointer& entity) { }
|
virtual void onRemoveFromSceneTyped(const TypedEntityPointer& entity) { }
|
||||||
|
|
||||||
|
|
|
@ -1026,7 +1026,7 @@ void ModelEntityRenderer::animate(const TypedEntityPointer& entity) {
|
||||||
entity->copyAnimationJointDataToModel();
|
entity->copyAnimationJointDataToModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModelEntityRenderer::needsUpdate() const {
|
bool ModelEntityRenderer::needsRenderUpdate() const {
|
||||||
ModelPointer model;
|
ModelPointer model;
|
||||||
withReadLock([&] {
|
withReadLock([&] {
|
||||||
model = _model;
|
model = _model;
|
||||||
|
@ -1061,10 +1061,10 @@ bool ModelEntityRenderer::needsUpdate() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Parent::needsUpdate();
|
return Parent::needsRenderUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModelEntityRenderer::needsUpdateFromTypedEntity(const TypedEntityPointer& entity) const {
|
bool ModelEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const {
|
||||||
if (resultWithReadLock<bool>([&] {
|
if (resultWithReadLock<bool>([&] {
|
||||||
if (entity->hasModel() != _hasModel) {
|
if (entity->hasModel() != _hasModel) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1126,7 +1126,7 @@ bool ModelEntityRenderer::needsUpdateFromTypedEntity(const TypedEntityPointer& e
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelEntityRenderer::doUpdateTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) {
|
void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) {
|
||||||
if (_hasModel != entity->hasModel()) {
|
if (_hasModel != entity->hasModel()) {
|
||||||
_hasModel = entity->hasModel();
|
_hasModel = entity->hasModel();
|
||||||
}
|
}
|
||||||
|
@ -1250,6 +1250,7 @@ void ModelEntityRenderer::doUpdateTyped(const ScenePointer& scene, Transaction&
|
||||||
void ModelEntityRenderer::handleModelLoaded(bool success) {
|
void ModelEntityRenderer::handleModelLoaded(bool success) {
|
||||||
if (success) {
|
if (success) {
|
||||||
_modelJustLoaded = true;
|
_modelJustLoaded = true;
|
||||||
|
emit requestRenderUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,10 +138,10 @@ protected:
|
||||||
virtual ItemKey getKey() override;
|
virtual ItemKey getKey() override;
|
||||||
virtual uint32_t metaFetchMetaSubItems(ItemIDs& subItems) override;
|
virtual uint32_t metaFetchMetaSubItems(ItemIDs& subItems) override;
|
||||||
|
|
||||||
virtual bool needsUpdateFromTypedEntity(const TypedEntityPointer& entity) const override;
|
virtual bool needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const override;
|
||||||
virtual bool needsUpdate() const override;
|
virtual bool needsRenderUpdate() const override;
|
||||||
virtual void doRender(RenderArgs* args) override;
|
virtual void doRender(RenderArgs* args) override;
|
||||||
virtual void doUpdateTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) override;
|
virtual void doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void animate(const TypedEntityPointer& entity);
|
void animate(const TypedEntityPointer& entity);
|
||||||
|
|
Loading…
Reference in a new issue