diff options
Diffstat (limited to 'source/blender/freestyle')
-rw-r--r-- | source/blender/freestyle/intern/stroke/StrokeRep.cpp | 117 |
1 files changed, 61 insertions, 56 deletions
diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.cpp b/source/blender/freestyle/intern/stroke/StrokeRep.cpp index 4cfdd860d20..4eee050c689 100644 --- a/source/blender/freestyle/intern/stroke/StrokeRep.cpp +++ b/source/blender/freestyle/intern/stroke/StrokeRep.cpp @@ -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; - } + 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; + // 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 |