Fix T40020: Freestyle: dashed lines crashes blender.
The crash was due to an out-of-range vertex index reference that occured while computing texture coordinates of strokes with tips.
This commit is contained in:
parent
620901426c
commit
047c3aa728
Notes:
blender-bot
2023-02-14 11:21:43 +01:00
Referenced by issue #40020, Freestyle: dashed lines crashes blender
|
@ -552,35 +552,37 @@ void Strip::computeTexCoordWithTips (const vector<StrokeVertex*>& iStrokeVertice
|
|||
uPrev = u;
|
||||
}
|
||||
|
||||
// first transition vertex
|
||||
if (fabs(u - uPrev) > ZERO)
|
||||
t = (0.25 - uPrev) / (u - uPrev);
|
||||
else
|
||||
t = 0;
|
||||
for (int k = 0; k < 2; k++) {
|
||||
tvRep[k] = new StrokeVertexRep((1 - t) * _vertices[i - 2]->point2d() + t * _vertices[i]->point2d());
|
||||
tvRep[k]->setTexCoord((1 - t) * _vertices[i - 2]->texCoord() + t * _vertices[i]->texCoord());
|
||||
// v coord is 0.5 for tvRep[0], 1.0 for tvRep[1]
|
||||
tvRep[k]->setTexCoord(Vec2r(0.25, 0.5 * (k + 1)), true);
|
||||
tvRep[k]->setColor((1 - t) * _vertices[i - 2]->color() + t * Vec3r(sv->attribute().getColorRGB()));
|
||||
tvRep[k]->setAlpha((1 - t) * _vertices[i - 2]->alpha() + t * sv->attribute().getAlpha());
|
||||
i++;
|
||||
}
|
||||
for (int k = 0; k < 2; k++) {
|
||||
currentSV = _vertices.insert(currentSV, tvRep[k]);
|
||||
++currentSV;
|
||||
}
|
||||
if (i >= 2) {
|
||||
// first transition vertex
|
||||
if (fabs(u - uPrev) > ZERO)
|
||||
t = (0.25 - uPrev) / (u - uPrev);
|
||||
else
|
||||
t = 0;
|
||||
for (int k = 0; k < 2; k++) {
|
||||
tvRep[k] = new StrokeVertexRep((1 - t) * _vertices[i - 2]->point2d() + t * _vertices[i]->point2d());
|
||||
tvRep[k]->setTexCoord((1 - t) * _vertices[i - 2]->texCoord() + t * _vertices[i]->texCoord());
|
||||
// v coord is 0.5 for tvRep[0], 1.0 for tvRep[1]
|
||||
tvRep[k]->setTexCoord(Vec2r(0.25, 0.5 * (k + 1)), true);
|
||||
tvRep[k]->setColor((1 - t) * _vertices[i - 2]->color() + t * Vec3r(sv->attribute().getColorRGB()));
|
||||
tvRep[k]->setAlpha((1 - t) * _vertices[i - 2]->alpha() + t * sv->attribute().getAlpha());
|
||||
i++;
|
||||
}
|
||||
for (int k = 0; k < 2; k++) {
|
||||
currentSV = _vertices.insert(currentSV, tvRep[k]);
|
||||
++currentSV;
|
||||
}
|
||||
|
||||
// copy the vertices with different texture coordinates
|
||||
for (int k = 0; k < 2; k++) {
|
||||
tvRep[k] = new StrokeVertexRep(*(_vertices[i - 2]));
|
||||
// v coord is 0.0 for tvRep[0], 0.5 for tvRep[1]
|
||||
tvRep[k]->setTexCoord(Vec2r(0.0, 0.5 * k), true); // FIXED u coord
|
||||
i++;
|
||||
}
|
||||
for (int k = 0; k < 2; k++) {
|
||||
currentSV = _vertices.insert(currentSV, tvRep[k]);
|
||||
++currentSV;
|
||||
// copy the vertices with different texture coordinates
|
||||
for (int k = 0; k < 2; k++) {
|
||||
tvRep[k] = new StrokeVertexRep(*(_vertices[i - 2]));
|
||||
// v coord is 0.0 for tvRep[0], 0.5 for tvRep[1]
|
||||
tvRep[k]->setTexCoord(Vec2r(0.0, 0.5 * k), true); // FIXED u coord
|
||||
i++;
|
||||
}
|
||||
for (int k = 0; k < 2; k++) {
|
||||
currentSV = _vertices.insert(currentSV, tvRep[k]);
|
||||
++currentSV;
|
||||
}
|
||||
}
|
||||
}
|
||||
uPrev = 0;
|
||||
|
@ -604,36 +606,39 @@ void Strip::computeTexCoordWithTips (const vector<StrokeVertex*>& iStrokeVertice
|
|||
|
||||
uPrev = u;
|
||||
}
|
||||
if (tipEnd) {
|
||||
// second transition vertex
|
||||
if (fabs(u - uPrev) > ZERO)
|
||||
t = (float(tiles) - uPrev) / (u - uPrev);
|
||||
else
|
||||
t = 0;
|
||||
for (int k = 0; k < 2; k++) {
|
||||
tvRep[k] = new StrokeVertexRep((1 - t) * _vertices[i - 2]->point2d() + t * _vertices[i]->point2d());
|
||||
tvRep[k]->setTexCoord((1 - t) * _vertices[i - 2]->texCoord() + t * _vertices[i]->texCoord());
|
||||
// v coord is 0.0 for tvRep[0], 0.5 for tvRep[1]
|
||||
tvRep[k]->setTexCoord(Vec2r((real)tiles, 0.5 * k), true); // FIXED u coord
|
||||
tvRep[k]->setColor((1 - t) * _vertices[i - 2]->color() + t * Vec3r(sv->attribute().getColorRGB()));
|
||||
tvRep[k]->setAlpha((1 - t) * _vertices[i - 2]->alpha() + t * sv->attribute().getAlpha());
|
||||
i++;
|
||||
}
|
||||
for (int k = 0; k < 2; k++) {
|
||||
currentSV = _vertices.insert(currentSV, tvRep[k]);
|
||||
++currentSV;
|
||||
}
|
||||
|
||||
// copy the vertices with different texture coordinates
|
||||
for (int k = 0; k < 2; k++) {
|
||||
tvRep[k] = new StrokeVertexRep(*(_vertices[i - 2]));
|
||||
// v coord is 0.5 for tvRep[0], 1.0 for tvRep[1]
|
||||
tvRep[k]->setTexCoord(Vec2r(0.75, 0.5 * (k + 1)), true);
|
||||
i++;
|
||||
}
|
||||
for (int k = 0; k < 2; k++) {
|
||||
currentSV = _vertices.insert(currentSV, tvRep[k]);
|
||||
++currentSV;
|
||||
if (tipEnd) {
|
||||
if (i >= 2) {
|
||||
// second transition vertex
|
||||
if (fabs(u - uPrev) > ZERO)
|
||||
t = (float(tiles) - uPrev) / (u - uPrev);
|
||||
else
|
||||
t = 0;
|
||||
for (int k = 0; k < 2; k++) {
|
||||
tvRep[k] = new StrokeVertexRep((1 - t) * _vertices[i - 2]->point2d() + t * _vertices[i]->point2d());
|
||||
tvRep[k]->setTexCoord((1 - t) * _vertices[i - 2]->texCoord() + t * _vertices[i]->texCoord());
|
||||
// v coord is 0.0 for tvRep[0], 0.5 for tvRep[1]
|
||||
tvRep[k]->setTexCoord(Vec2r((real)tiles, 0.5 * k), true); // FIXED u coord
|
||||
tvRep[k]->setColor((1 - t) * _vertices[i - 2]->color() + t * Vec3r(sv->attribute().getColorRGB()));
|
||||
tvRep[k]->setAlpha((1 - t) * _vertices[i - 2]->alpha() + t * sv->attribute().getAlpha());
|
||||
i++;
|
||||
}
|
||||
for (int k = 0; k < 2; k++) {
|
||||
currentSV = _vertices.insert(currentSV, tvRep[k]);
|
||||
++currentSV;
|
||||
}
|
||||
|
||||
// copy the vertices with different texture coordinates
|
||||
for (int k = 0; k < 2; k++) {
|
||||
tvRep[k] = new StrokeVertexRep(*(_vertices[i - 2]));
|
||||
// v coord is 0.5 for tvRep[0], 1.0 for tvRep[1]
|
||||
tvRep[k]->setTexCoord(Vec2r(0.75, 0.5 * (k + 1)), true);
|
||||
i++;
|
||||
}
|
||||
for (int k = 0; k < 2; k++) {
|
||||
currentSV = _vertices.insert(currentSV, tvRep[k]);
|
||||
++currentSV;
|
||||
}
|
||||
}
|
||||
|
||||
// end tip
|
||||
|
|
Loading…
Reference in New Issue