From c0fb9dcf2e39452040a321844acf5d8b3b85b87a Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Wed, 6 Sep 2017 09:49:33 -0700 Subject: [PATCH 1/3] Fix polyline crash and flicker --- .../entities-renderer/src/RenderablePolyLineEntityItem.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp index 3db7fb2c30..1cecb0b036 100644 --- a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp @@ -126,6 +126,7 @@ void PolyLineEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& auto textures = entity->getTextures(); QString path = textures.isEmpty() ? PathUtils::resourcesPath() + "images/paintStroke.png" : textures; if (!_texture || _lastTextures != path) { + _lastTextures = path; _texture = DependencyManager::get()->getTexture(QUrl(path)); } } @@ -220,7 +221,7 @@ void PolyLineEntityRenderer::doRender(RenderArgs* args) { batch.setModelTransform(Transform{ _modelTransform }.setScale(vec3(1))); batch.setUniformBuffer(PAINTSTROKE_UNIFORM_SLOT, _uniformBuffer); - if (_texture->isLoaded()) { + if (_texture && _texture->isLoaded()) { batch.setResourceTexture(PAINTSTROKE_TEXTURE_SLOT, _texture->getGPUTexture()); } else { batch.setResourceTexture(PAINTSTROKE_TEXTURE_SLOT, nullptr); From 4c4df97c42b547689ff389eaeeef1a651862726f Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Wed, 6 Sep 2017 23:38:02 -0700 Subject: [PATCH 2/3] Fix transform of polylines with high update rates --- .../entities-renderer/src/RenderablePolyLineEntityItem.cpp | 6 +++++- .../entities-renderer/src/RenderablePolyLineEntityItem.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp index 1cecb0b036..50226ef8ae 100644 --- a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp @@ -141,6 +141,10 @@ void PolyLineEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPo auto normalsChanged = entity->normalsChanged(); entity->resetPolyLineChanged(); + _polylineTransform = Transform(); + _polylineTransform.setTranslation(entity->getPosition()); + _polylineTransform.setRotation(entity->getRotation()); + if (pointsChanged) { _lastPoints = entity->getLinePoints(); } @@ -218,7 +222,7 @@ void PolyLineEntityRenderer::doRender(RenderArgs* args) { Q_ASSERT(args->_batch); gpu::Batch& batch = *args->_batch; - batch.setModelTransform(Transform{ _modelTransform }.setScale(vec3(1))); + batch.setModelTransform(_polylineTransform); batch.setUniformBuffer(PAINTSTROKE_UNIFORM_SLOT, _uniformBuffer); if (_texture && _texture->isLoaded()) { diff --git a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.h b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.h index 88b5ebdb9f..b0bdcf545b 100644 --- a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.h +++ b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.h @@ -47,6 +47,7 @@ protected: void updateGeometry(const std::vector& vertices); static std::vector updateVertices(const QVector& points, const QVector& normals, const QVector& strokeWidths); + Transform _polylineTransform; QVector _lastPoints; QVector _lastNormals; QVector _lastStrokeWidths; From d3ac7a388c8cd53718aab05f6d4209a7fa54b4dc Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Thu, 14 Sep 2017 10:48:14 -0700 Subject: [PATCH 3/3] Fix polyline rendering using default texture --- .../src/RenderablePolyLineEntityItem.cpp | 14 +++++++++----- .../src/RenderablePolyLineEntityItem.h | 1 - 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp index 50226ef8ae..8c1a6318f9 100644 --- a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp @@ -121,15 +121,19 @@ bool PolyLineEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityP } void PolyLineEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) { + static const QUrl DEFAULT_POLYLINE_TEXTURE = QUrl(PathUtils::resourcesPath() + "images/paintStroke.png"); + QUrl entityTextures = DEFAULT_POLYLINE_TEXTURE; if (entity->texturesChanged()) { entity->resetTexturesChanged(); auto textures = entity->getTextures(); - QString path = textures.isEmpty() ? PathUtils::resourcesPath() + "images/paintStroke.png" : textures; - if (!_texture || _lastTextures != path) { - _lastTextures = path; - _texture = DependencyManager::get()->getTexture(QUrl(path)); + if (!textures.isEmpty()) { + entityTextures = QUrl(textures); } } + + if (!_texture || _texture->getURL() != entityTextures) { + _texture = DependencyManager::get()->getTexture(entityTextures); + } } void PolyLineEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) { @@ -228,7 +232,7 @@ void PolyLineEntityRenderer::doRender(RenderArgs* args) { if (_texture && _texture->isLoaded()) { batch.setResourceTexture(PAINTSTROKE_TEXTURE_SLOT, _texture->getGPUTexture()); } else { - batch.setResourceTexture(PAINTSTROKE_TEXTURE_SLOT, nullptr); + batch.setResourceTexture(PAINTSTROKE_TEXTURE_SLOT, DependencyManager::get()->getWhiteTexture()); } batch.setInputFormat(polylineFormat); diff --git a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.h b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.h index b0bdcf545b..610ee53cf7 100644 --- a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.h +++ b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.h @@ -55,7 +55,6 @@ protected: gpu::BufferView _uniformBuffer; uint32_t _numVertices { 0 }; bool _empty{ true }; - QString _lastTextures; NetworkTexturePointer _texture; };