diff --git a/src/modules/graphics/opengl/Polyline.cpp b/src/modules/graphics/opengl/Polyline.cpp index 552f92894..edf67a357 100644 --- a/src/modules/graphics/opengl/Polyline.cpp +++ b/src/modules/graphics/opengl/Polyline.cpp @@ -18,7 +18,7 @@ * 3. This notice may not be removed or altered from any source distribution. **/ -#include +#include // LOVE #include "Polyline.h" @@ -26,8 +26,8 @@ // OpenGL #include "OpenGL.h" -// treat adjacent segments with angles between their normals <7 degree as straight -static const float LINES_PARALLEL_EPS = 0.15; +// treat adjacent segments with angles between their directions <5 degree as straight +static const float LINES_PARALLEL_EPS = 0.05; namespace love { @@ -123,19 +123,19 @@ void NoneJoinPolyline::renderEdge(std::vector &anchors, std::vector (p-q) + lambda * s - mu * t = (nt - ns) * w/2 - * <=> (lambda - 1) * s - mu * t = (nt - ns) * w/2 + * q + w/2 * ns + lambda * s - (q + w/2 * nt + mu * t) = 0 (u1) + * <=> q-q + lambda * s - mu * t = (nt - ns) * w/2 + * <=> lambda * s - mu * t = (nt - ns) * w/2 * * the intersection points can be efficiently calculated using Cramer's rule. */ @@ -151,7 +151,7 @@ void MiterJoinPolyline::renderEdge(std::vector &anchors, std::vector 0) { // lines parallel, compute as u1 = q + ns * w/2, u2 = q - ns * w/2 normals.push_back(ns); @@ -196,7 +196,7 @@ void BevelJoinPolyline::renderEdge(std::vector &anchors, std::vector 0) { // lines parallel, compute as u1 = q + ns * w/2, u2 = q - ns * w/2 Vector n = t.getNormal(hw / len_t); @@ -338,8 +338,6 @@ void Polyline::draw() if (overdraw) { // prepare colors: - // even indices in overdraw* point to inner vertices => alpha = current-alpha, - // odd indices point to outer vertices => alpha = 0. Color c = gl.getColor(); Color *colors = new Color[overdraw_vertex_count]; fill_color_array(colors, c); @@ -374,8 +372,7 @@ void NoneJoinPolyline::fill_color_array(Color *colors, const Color &c) { colors[i] = c; // if (i % 4 == 1 || i % 4 == 2) colors[i].a = 0 - size_t k = i % 4; - colors[i].a *= GLubyte(k != 1 && k != 2); + colors[i].a *= GLubyte((i+1) % 4 < 2); } }