mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 01:17:14 +02:00
Merge pull request #12060 from SamGondelman/burp5
Reduce EntityItem access in EntityRenderer::needsRenderUpdateFromEntity
This commit is contained in:
commit
6d6aad4aa8
4 changed files with 21 additions and 5 deletions
|
@ -141,6 +141,10 @@ std::shared_ptr<T> make_renderer(const EntityItemPointer& entity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityRenderer::EntityRenderer(const EntityItemPointer& entity) : _entity(entity) {
|
EntityRenderer::EntityRenderer(const EntityItemPointer& entity) : _entity(entity) {
|
||||||
|
connect(entity.get(), &EntityItem::requestRenderUpdate, this, [&] {
|
||||||
|
_needsRenderUpdate = true;
|
||||||
|
emit requestRenderUpdate();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityRenderer::~EntityRenderer() { }
|
EntityRenderer::~EntityRenderer() { }
|
||||||
|
@ -311,6 +315,9 @@ void EntityRenderer::setSubRenderItemIDs(const render::ItemIDs& ids) {
|
||||||
// Returns true if the item needs to have updateInscene called because of internal rendering
|
// Returns true if the item needs to have updateInscene called because of internal rendering
|
||||||
// changes (animation, fading, etc)
|
// changes (animation, fading, etc)
|
||||||
bool EntityRenderer::needsRenderUpdate() const {
|
bool EntityRenderer::needsRenderUpdate() const {
|
||||||
|
if (_needsRenderUpdate) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (_prevIsTransparent != isTransparent()) {
|
if (_prevIsTransparent != isTransparent()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -331,10 +338,6 @@ bool EntityRenderer::needsRenderUpdateFromEntity(const EntityItemPointer& entity
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_visible != entity->getVisible()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_moving != entity->isMovingRelativeToParent()) {
|
if (_moving != entity->isMovingRelativeToParent()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -363,6 +366,7 @@ void EntityRenderer::doRenderUpdateSynchronous(const ScenePointer& scene, Transa
|
||||||
|
|
||||||
_moving = entity->isMovingRelativeToParent();
|
_moving = entity->isMovingRelativeToParent();
|
||||||
_visible = entity->getVisible();
|
_visible = entity->getVisible();
|
||||||
|
_needsRenderUpdate = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,6 +125,7 @@ protected:
|
||||||
bool _prevIsTransparent { false };
|
bool _prevIsTransparent { false };
|
||||||
bool _visible { false };
|
bool _visible { false };
|
||||||
bool _moving { false };
|
bool _moving { false };
|
||||||
|
bool _needsRenderUpdate { false };
|
||||||
// Only touched on the rendering thread
|
// Only touched on the rendering thread
|
||||||
bool _renderUpdateQueued{ false };
|
bool _renderUpdateQueued{ false };
|
||||||
|
|
||||||
|
|
|
@ -2715,9 +2715,17 @@ bool EntityItem::getVisible() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityItem::setVisible(bool value) {
|
void EntityItem::setVisible(bool value) {
|
||||||
|
bool changed = false;
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
_visible = value;
|
if (_visible != value) {
|
||||||
|
changed = true;
|
||||||
|
_visible = value;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (changed) {
|
||||||
|
emit requestRenderUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityItem::isChildOfMyAvatar() const {
|
bool EntityItem::isChildOfMyAvatar() const {
|
||||||
|
|
|
@ -469,6 +469,9 @@ public:
|
||||||
static QString _marketplacePublicKey;
|
static QString _marketplacePublicKey;
|
||||||
static void retrieveMarketplacePublicKey();
|
static void retrieveMarketplacePublicKey();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void requestRenderUpdate();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QHash<ChangeHandlerId, ChangeHandlerCallback> _changeHandlers;
|
QHash<ChangeHandlerId, ChangeHandlerCallback> _changeHandlers;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue