From 4c6bea48b2a713fce07934df97ed77b3ebd316a7 Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Tue, 26 Feb 2019 14:48:34 -0800 Subject: [PATCH 1/4] fixed a case where _widths = 0 and widths-1 is not valid. --- .../src/RenderablePolyLineEntityItem.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp index c4ea6a2fea..0ea8db7c15 100644 --- a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp @@ -184,8 +184,11 @@ void PolyLineEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPo void PolyLineEntityRenderer::updateGeometry() { int maxNumVertices = std::min(_points.length(), _normals.length()); + qDebug()<<"QQQ_ widths size: "<< _widths.size(); + qDebug()<<"QQQ_ MaxNumbVertices: "<= 0) { + if (_widths.size() > 0) { for (int i = 1; i < maxNumVertices; i++) { float width = PolyLineEntityItem::DEFAULT_LINE_WIDTH; if (i < _widths.length()) { @@ -206,12 +209,15 @@ void PolyLineEntityRenderer::updateGeometry() { std::vector vertices; vertices.reserve(maxNumVertices); + for (int i = 0; i < maxNumVertices; i++) { // Position glm::vec3 point = _points[i]; - // uCoord - float width = i < _widths.size() ? _widths[i] : PolyLineEntityItem::DEFAULT_LINE_WIDTH; + float width=PolyLineEntityItem::DEFAULT_LINE_WIDTH; + if(_widths.size()>0 && i < _widths.size()) + width = _widths[i]; + if (i > 0) { // First uCoord is 0.0f if (!_isUVModeStretch) { accumulatedDistance += glm::distance(point, _points[i - 1]); From 5a7c8c312640c4975a5b94dc6662056b8be1ea0a Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Tue, 26 Feb 2019 14:53:44 -0800 Subject: [PATCH 2/4] removed debugg helpers --- .../entities-renderer/src/RenderablePolyLineEntityItem.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp index 0ea8db7c15..ec8444ff35 100644 --- a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp @@ -183,10 +183,6 @@ void PolyLineEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPo void PolyLineEntityRenderer::updateGeometry() { int maxNumVertices = std::min(_points.length(), _normals.length()); - - qDebug()<<"QQQ_ widths size: "<< _widths.size(); - qDebug()<<"QQQ_ MaxNumbVertices: "< 0) { for (int i = 1; i < maxNumVertices; i++) { @@ -215,8 +211,9 @@ void PolyLineEntityRenderer::updateGeometry() { glm::vec3 point = _points[i]; float width=PolyLineEntityItem::DEFAULT_LINE_WIDTH; - if(_widths.size()>0 && i < _widths.size()) + if(_widths.size()>0 && i < _widths.size()) { width = _widths[i]; + } if (i > 0) { // First uCoord is 0.0f if (!_isUVModeStretch) { From f5852139f75238a3b4b79eebfb63d22ae8ec6da4 Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Tue, 26 Feb 2019 15:05:58 -0800 Subject: [PATCH 3/4] fixing comment since the original check was correct --- .../entities-renderer/src/RenderablePolyLineEntityItem.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp index ec8444ff35..44b368d827 100644 --- a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp @@ -209,11 +209,7 @@ void PolyLineEntityRenderer::updateGeometry() { for (int i = 0; i < maxNumVertices; i++) { // Position glm::vec3 point = _points[i]; - - float width=PolyLineEntityItem::DEFAULT_LINE_WIDTH; - if(_widths.size()>0 && i < _widths.size()) { - width = _widths[i]; - } + float width = i < _widths.size() ? _widths[i] : PolyLineEntityItem::DEFAULT_LINE_WIDTH; if (i > 0) { // First uCoord is 0.0f if (!_isUVModeStretch) { From 19d584f0af1a6ebc2910edfe301319b322bdbad0 Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Tue, 26 Feb 2019 15:28:28 -0800 Subject: [PATCH 4/4] added Sams suggestions to the logic --- .../src/RenderablePolyLineEntityItem.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp index 44b368d827..454e8b136a 100644 --- a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp @@ -185,15 +185,17 @@ void PolyLineEntityRenderer::updateGeometry() { int maxNumVertices = std::min(_points.length(), _normals.length()); bool doesStrokeWidthVary = false; if (_widths.size() > 0) { + float prevWidth = _widths[0]; for (int i = 1; i < maxNumVertices; i++) { - float width = PolyLineEntityItem::DEFAULT_LINE_WIDTH; - if (i < _widths.length()) { - width = _widths[i]; - } - if (width != _widths[i - 1]) { + float width = i < _widths.length() ? _widths[i] : PolyLineEntityItem::DEFAULT_LINE_WIDTH; + if (width != prevWidth) { doesStrokeWidthVary = true; break; } + if (i > _widths.length() + 1) { + break; + } + prevWidth = width; } } @@ -209,6 +211,7 @@ void PolyLineEntityRenderer::updateGeometry() { for (int i = 0; i < maxNumVertices; i++) { // Position glm::vec3 point = _points[i]; + // uCoord float width = i < _widths.size() ? _widths[i] : PolyLineEntityItem::DEFAULT_LINE_WIDTH; if (i > 0) { // First uCoord is 0.0f