mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 12:37:51 +02:00
Merge pull request #15037 from amerhifi/quest-demo
case 21447: fixed quest debug crash when a case of _widths = 0 for polyline
This commit is contained in:
commit
fd46296e8c
1 changed files with 10 additions and 8 deletions
|
@ -183,18 +183,19 @@ void PolyLineEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPo
|
||||||
|
|
||||||
void PolyLineEntityRenderer::updateGeometry() {
|
void PolyLineEntityRenderer::updateGeometry() {
|
||||||
int maxNumVertices = std::min(_points.length(), _normals.length());
|
int maxNumVertices = std::min(_points.length(), _normals.length());
|
||||||
|
|
||||||
bool doesStrokeWidthVary = false;
|
bool doesStrokeWidthVary = false;
|
||||||
if (_widths.size() >= 0) {
|
if (_widths.size() > 0) {
|
||||||
|
float prevWidth = _widths[0];
|
||||||
for (int i = 1; i < maxNumVertices; i++) {
|
for (int i = 1; i < maxNumVertices; i++) {
|
||||||
float width = PolyLineEntityItem::DEFAULT_LINE_WIDTH;
|
float width = i < _widths.length() ? _widths[i] : PolyLineEntityItem::DEFAULT_LINE_WIDTH;
|
||||||
if (i < _widths.length()) {
|
if (width != prevWidth) {
|
||||||
width = _widths[i];
|
|
||||||
}
|
|
||||||
if (width != _widths[i - 1]) {
|
|
||||||
doesStrokeWidthVary = true;
|
doesStrokeWidthVary = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (i > _widths.length() + 1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
prevWidth = width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,12 +207,13 @@ void PolyLineEntityRenderer::updateGeometry() {
|
||||||
|
|
||||||
std::vector<PolylineVertex> vertices;
|
std::vector<PolylineVertex> vertices;
|
||||||
vertices.reserve(maxNumVertices);
|
vertices.reserve(maxNumVertices);
|
||||||
|
|
||||||
for (int i = 0; i < maxNumVertices; i++) {
|
for (int i = 0; i < maxNumVertices; i++) {
|
||||||
// Position
|
// Position
|
||||||
glm::vec3 point = _points[i];
|
glm::vec3 point = _points[i];
|
||||||
|
|
||||||
// uCoord
|
// uCoord
|
||||||
float width = i < _widths.size() ? _widths[i] : PolyLineEntityItem::DEFAULT_LINE_WIDTH;
|
float width = i < _widths.size() ? _widths[i] : PolyLineEntityItem::DEFAULT_LINE_WIDTH;
|
||||||
|
|
||||||
if (i > 0) { // First uCoord is 0.0f
|
if (i > 0) { // First uCoord is 0.0f
|
||||||
if (!_isUVModeStretch) {
|
if (!_isUVModeStretch) {
|
||||||
accumulatedDistance += glm::distance(point, _points[i - 1]);
|
accumulatedDistance += glm::distance(point, _points[i - 1]);
|
||||||
|
|
Loading…
Reference in a new issue