diff options
Diffstat (limited to 'src/vg/Path.cpp')
-rw-r--r-- | src/vg/Path.cpp | 250 |
1 files changed, 124 insertions, 126 deletions
diff --git a/src/vg/Path.cpp b/src/vg/Path.cpp index 71469f5..6cdad9b 100644 --- a/src/vg/Path.cpp +++ b/src/vg/Path.cpp @@ -58,9 +58,9 @@ static const Vector2 unitAverage(const Vector2& u0, const Vector2& u1, bool cw) Vector2 u = 0.5f * (u0 + u1); Vector2 n0 = perpendicularCCW(u0); - if( dot(u, u) > 0.25f ) + if( u.dot(u) > 0.25f ) { //the average is long enough and thus reliable - if( dot(n0, u1) < 0.0f ) + if( n0.dot(u1) < 0.0f ) u = -u; //choose the larger angle } else @@ -87,12 +87,12 @@ static const Vector2 unitAverage(const Vector2& u0, const Vector2& u1) { Vector2 u = 0.5f * (u0 + u1); - if( dot(u, u) < 0.25f ) + if( u.dot(u) < 0.25f ) { // the average is unreliable, use the average of the normals to the vectors instead Vector2 n0 = perpendicularCCW(u0); Vector2 n1 = perpendicularCW(u1); u = 0.5f * (n0 + n1); - if( dot(n1, u0) < 0.0f ) + if( n1.dot(u0) < 0.0f ) u = -u; } @@ -485,7 +485,7 @@ void Path::transform(const Path* srcPath, const Matrix3x3& matrix) { RI_ASSERT(srcPath); RI_ASSERT(m_referenceCount > 0 && srcPath->m_referenceCount > 0); - RI_ASSERT(matrix.isAffine()); + RI_ASSERT(isAffine(matrix)); if(!srcPath->m_segments.size()) return; @@ -551,8 +551,8 @@ void Path::transform(const Path* srcPath, const Matrix3x3& matrix) c += o; } - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.x); - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.y); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc(0)); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc(1)); s = c; o = c; break; @@ -572,8 +572,8 @@ void Path::transform(const Path* srcPath, const Matrix3x3& matrix) c += o; } - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.x); - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.y); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc(0)); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc(1)); o = c; break; } @@ -586,7 +586,7 @@ void Path::transform(const Path* srcPath, const Matrix3x3& matrix) if (absRel == VG_ABSOLUTE) { - c.y = o.y; + c(1) = o(1); tc = affineTransform(matrix, c); } else @@ -595,8 +595,8 @@ void Path::transform(const Path* srcPath, const Matrix3x3& matrix) c += o; } - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.x); - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.y); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc(0)); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc(1)); o = c; segment = VG_LINE_TO; break; @@ -610,7 +610,7 @@ void Path::transform(const Path* srcPath, const Matrix3x3& matrix) if (absRel == VG_ABSOLUTE) { - c.x = o.x; + c(0) = o(0); tc = affineTransform(matrix, c); } else @@ -619,8 +619,8 @@ void Path::transform(const Path* srcPath, const Matrix3x3& matrix) c += o; } - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.x); - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.y); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc(0)); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc(1)); o = c; segment = VG_LINE_TO; break; @@ -645,10 +645,10 @@ void Path::transform(const Path* srcPath, const Matrix3x3& matrix) c1 += o; } - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc0.x); - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc0.y); - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.x); - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.y); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc0(0)); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc0(1)); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1(0)); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1(1)); o = c1; break; } @@ -675,12 +675,12 @@ void Path::transform(const Path* srcPath, const Matrix3x3& matrix) c2 += o; } - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc0.x); - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc0.y); - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.x); - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.y); - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc2.x); - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc2.y); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc0(0)); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc0(1)); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1(0)); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1(1)); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc2(0)); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc2(1)); o = c2; break; } @@ -699,8 +699,8 @@ void Path::transform(const Path* srcPath, const Matrix3x3& matrix) c1 += o; } - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.x); - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.y); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1(0)); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1(1)); o = c1; break; } @@ -724,10 +724,10 @@ void Path::transform(const Path* srcPath, const Matrix3x3& matrix) c2 += o; } - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.x); - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.y); - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc2.x); - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc2.y); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1(0)); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1(1)); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc2(0)); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc2(1)); o = c2; break; } @@ -743,21 +743,22 @@ void Path::transform(const Path* srcPath, const Matrix3x3& matrix) Vector2 c(srcPath->getCoordinate(srcCoord+3), srcPath->getCoordinate(srcCoord+4)); rot = RI_DEG_TO_RAD(rot); - Matrix3x3 u((RIfloat)cos(rot)*rh, -(RIfloat)sin(rot)*rv, 0, + Matrix3x3 u; + u << (RIfloat)cos(rot)*rh, -(RIfloat)sin(rot)*rv, 0, (RIfloat)sin(rot)*rh, (RIfloat)cos(rot)*rv, 0, - 0, 0, 1); + 0, 0, 1; u = matrix * u; - u[2].set(0,0,1); //force affinity + u(2,0) = 0.0f; u(2,1)=0.0f; u(2,2)=1.0f; // force affinity //u maps from the unit circle to transformed ellipse //compute new rh, rv and rot - Vector2 p(u[0][0], u[1][0]); - Vector2 q(u[1][1], -u[0][1]); + Vector2 p(u(0,0), u(1,0)); + Vector2 q(u(1,1), -u(0,1)); bool swapped = false; - if(dot(p,p) < dot(q,q)) + if(p.dot(p) < q.dot(q)) { - RI_SWAP(p.x,q.x); - RI_SWAP(p.y,q.y); + RI_SWAP(p(0),q(0)); + RI_SWAP(p(1),q(1)); swapped = true; } Vector2 h = (p+q) * 0.5f; @@ -767,14 +768,14 @@ void Path::transform(const Path* srcPath, const Matrix3x3& matrix) rh = hlen + hplen; rv = hlen - hplen; h = hplen * h + hlen * hp; - hlen = dot(h,h); + hlen = h.dot(h); if(hlen == 0.0f) rot = 0.0f; else { h.normalize(); - rot = (RIfloat)acos(h.x); - if(h.y < 0.0f) + rot = (RIfloat)acos(h(0)); + if(h(1) < 0.0f) rot = 2.0f*PI - rot; } if(swapped) @@ -792,8 +793,8 @@ void Path::transform(const Path* srcPath, const Matrix3x3& matrix) setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, rh); setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, rv); setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, RI_RAD_TO_DEG(rot)); - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.x); - setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.y); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc(0)); + setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc(1)); o = c; //flip winding if the determinant is negative @@ -907,8 +908,8 @@ void Path::normalizeForInterpolation(const Path* srcPath) Vector2 c(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1)); if(absRel == VG_RELATIVE) c += o; - setCoordinate(dstCoord++, c.x); - setCoordinate(dstCoord++, c.y); + setCoordinate(dstCoord++, c(0)); + setCoordinate(dstCoord++, c(1)); s = c; p = c; o = c; @@ -921,8 +922,8 @@ void Path::normalizeForInterpolation(const Path* srcPath) Vector2 c(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1)); if(absRel == VG_RELATIVE) c += o; - setCoordinate(dstCoord++, c.x); - setCoordinate(dstCoord++, c.y); + setCoordinate(dstCoord++, c(0)); + setCoordinate(dstCoord++, c(1)); p = c; o = c; break; @@ -931,11 +932,11 @@ void Path::normalizeForInterpolation(const Path* srcPath) case VG_HLINE_TO: { RI_ASSERT(coords == 1); - Vector2 c(srcPath->getCoordinate(srcCoord+0), o.y); + Vector2 c(srcPath->getCoordinate(srcCoord+0), o(1)); if(absRel == VG_RELATIVE) - c.x += o.x; - setCoordinate(dstCoord++, c.x); - setCoordinate(dstCoord++, c.y); + c(0) += o(0); + setCoordinate(dstCoord++, c(0)); + setCoordinate(dstCoord++, c(1)); p = c; o = c; segment = VG_LINE_TO; @@ -945,11 +946,11 @@ void Path::normalizeForInterpolation(const Path* srcPath) case VG_VLINE_TO: { RI_ASSERT(coords == 1); - Vector2 c(o.x, srcPath->getCoordinate(srcCoord+0)); + Vector2 c(o(0), srcPath->getCoordinate(srcCoord+0)); if(absRel == VG_RELATIVE) - c.y += o.y; - setCoordinate(dstCoord++, c.x); - setCoordinate(dstCoord++, c.y); + c(1) += o(1); + setCoordinate(dstCoord++, c(0)); + setCoordinate(dstCoord++, c(1)); p = c; o = c; segment = VG_LINE_TO; @@ -968,12 +969,12 @@ void Path::normalizeForInterpolation(const Path* srcPath) } Vector2 d0 = (1.0f/3.0f) * (o + 2.0f * c0); Vector2 d1 = (1.0f/3.0f) * (c1 + 2.0f * c0); - setCoordinate(dstCoord++, d0.x); - setCoordinate(dstCoord++, d0.y); - setCoordinate(dstCoord++, d1.x); - setCoordinate(dstCoord++, d1.y); - setCoordinate(dstCoord++, c1.x); - setCoordinate(dstCoord++, c1.y); + setCoordinate(dstCoord++, d0(0)); + setCoordinate(dstCoord++, d0(1)); + setCoordinate(dstCoord++, d1(0)); + setCoordinate(dstCoord++, d1(1)); + setCoordinate(dstCoord++, c1(0)); + setCoordinate(dstCoord++, c1(1)); p = c0; o = c1; segment = VG_CUBIC_TO; @@ -992,12 +993,12 @@ void Path::normalizeForInterpolation(const Path* srcPath) c1 += o; c2 += o; } - setCoordinate(dstCoord++, c0.x); - setCoordinate(dstCoord++, c0.y); - setCoordinate(dstCoord++, c1.x); - setCoordinate(dstCoord++, c1.y); - setCoordinate(dstCoord++, c2.x); - setCoordinate(dstCoord++, c2.y); + setCoordinate(dstCoord++, c0(0)); + setCoordinate(dstCoord++, c0(1)); + setCoordinate(dstCoord++, c1(0)); + setCoordinate(dstCoord++, c1(1)); + setCoordinate(dstCoord++, c2(0)); + setCoordinate(dstCoord++, c2(1)); p = c1; o = c2; break; @@ -1012,12 +1013,12 @@ void Path::normalizeForInterpolation(const Path* srcPath) c1 += o; Vector2 d0 = (1.0f/3.0f) * (o + 2.0f * c0); Vector2 d1 = (1.0f/3.0f) * (c1 + 2.0f * c0); - setCoordinate(dstCoord++, d0.x); - setCoordinate(dstCoord++, d0.y); - setCoordinate(dstCoord++, d1.x); - setCoordinate(dstCoord++, d1.y); - setCoordinate(dstCoord++, c1.x); - setCoordinate(dstCoord++, c1.y); + setCoordinate(dstCoord++, d0(0)); + setCoordinate(dstCoord++, d0(1)); + setCoordinate(dstCoord++, d1(0)); + setCoordinate(dstCoord++, d1(1)); + setCoordinate(dstCoord++, c1(0)); + setCoordinate(dstCoord++, c1(1)); p = c0; o = c1; segment = VG_CUBIC_TO; @@ -1035,12 +1036,12 @@ void Path::normalizeForInterpolation(const Path* srcPath) c1 += o; c2 += o; } - setCoordinate(dstCoord++, c0.x); - setCoordinate(dstCoord++, c0.y); - setCoordinate(dstCoord++, c1.x); - setCoordinate(dstCoord++, c1.y); - setCoordinate(dstCoord++, c2.x); - setCoordinate(dstCoord++, c2.y); + setCoordinate(dstCoord++, c0(0)); + setCoordinate(dstCoord++, c0(1)); + setCoordinate(dstCoord++, c1(0)); + setCoordinate(dstCoord++, c1(1)); + setCoordinate(dstCoord++, c2(0)); + setCoordinate(dstCoord++, c2(1)); p = c1; o = c2; segment = VG_CUBIC_TO; @@ -1061,8 +1062,8 @@ void Path::normalizeForInterpolation(const Path* srcPath) setCoordinate(dstCoord++, rh); setCoordinate(dstCoord++, rv); setCoordinate(dstCoord++, rot); - setCoordinate(dstCoord++, c.x); - setCoordinate(dstCoord++, c.y); + setCoordinate(dstCoord++, c(0)); + setCoordinate(dstCoord++, c(1)); p = c; o = c; break; @@ -1212,7 +1213,7 @@ void Path::interpolateStroke(const Matrix3x3& pathToSurface, Rasterizer& rasteri const RIfloat tessellationAngle = 5.0f; - RIfloat angle = RI_RAD_TO_DEG((RIfloat)acos(RI_CLAMP(dot(v0.t, v1.t), -1.0f, 1.0f))) / tessellationAngle; + RIfloat angle = RI_RAD_TO_DEG((RIfloat)acos(RI_CLAMP(v0.t.dot(v1.t), -1.0f, 1.0f))) / tessellationAngle; int samples = RI_INT_MAX((int)ceil(angle), 1); for(int j=0;j<samples-1;j++) @@ -1337,7 +1338,7 @@ void Path::doJoin(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const rasterizer.clear(); - if( dot(tccw, v0.t) > 0.0f ) + if( tccw.dot(v0.t) > 0.0f ) { //draw ccw miter (draw from point 0 to 1) s = ccw0t; e = ccw1t; @@ -1366,7 +1367,7 @@ void Path::doJoin(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const { case VG_JOIN_MITER: { - RIfloat theta = (RIfloat)acos(RI_CLAMP(dot(v0.t, -v1.t), -1.0f, 1.0f)); + RIfloat theta = (RIfloat)acos(RI_CLAMP(v0.t.dot(-v1.t), -1.0f, 1.0f)); RIfloat miterLengthPerStrokeWidth = 1.0f / (RIfloat)sin(theta*0.5f); if( miterLengthPerStrokeWidth < miterLimit ) { //miter @@ -1389,7 +1390,7 @@ void Path::doJoin(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const const RIfloat tessellationAngle = 5.0f; Vector2 prev = s; - RIfloat angle = RI_RAD_TO_DEG((RIfloat)acos(RI_CLAMP(dot(st, et), -1.0f, 1.0f))) / tessellationAngle; + RIfloat angle = RI_RAD_TO_DEG((RIfloat)acos(RI_CLAMP(st.dot(et), -1.0f, 1.0f))) / tessellationAngle; int samples = (int)ceil(angle); if( samples ) { @@ -1524,8 +1525,8 @@ void Path::stroke(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const { StrokeVertex vi = vs; vi.t = -vi.t; - RI_SWAP(vi.ccw.x, vi.cw.x); - RI_SWAP(vi.ccw.y, vi.cw.y); + RI_SWAP(vi.ccw(0), vi.cw(0)); + RI_SWAP(vi.ccw(1), vi.cw(1)); doCap(pathToSurface, rasterizer, vi, strokeWidth, capStyle); //start cap //throws bad_alloc } } @@ -1570,8 +1571,8 @@ void Path::stroke(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const { //prevDashVertex is not the start vertex of the segment, cap it (start vertex has already been joined or capped) StrokeVertex vi = prevDashVertex; vi.t = -vi.t; - RI_SWAP(vi.ccw.x, vi.cw.x); - RI_SWAP(vi.ccw.y, vi.cw.y); + RI_SWAP(vi.ccw(0), vi.cw(0)); + RI_SWAP(vi.ccw(1), vi.cw(1)); doCap(pathToSurface, rasterizer, vi, strokeWidth, capStyle); //throws bad_alloc } interpolateStroke(pathToSurface, rasterizer, prevDashVertex, nextDashVertex, strokeWidth); //throws bad_alloc @@ -1600,8 +1601,8 @@ void Path::stroke(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const { //prevDashVertex is not the start vertex of the segment, cap it (start vertex has already been joined or capped) StrokeVertex vi = prevDashVertex; vi.t = -vi.t; - RI_SWAP(vi.ccw.x, vi.cw.x); - RI_SWAP(vi.ccw.y, vi.cw.y); + RI_SWAP(vi.ccw(0), vi.cw(0)); + RI_SWAP(vi.ccw(1), vi.cw(1)); doCap(pathToSurface, rasterizer, vi, strokeWidth, capStyle); //throws bad_alloc } interpolateStroke(pathToSurface, rasterizer, prevDashVertex, v1, strokeWidth); //throws bad_alloc @@ -1627,8 +1628,8 @@ void Path::stroke(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const { StrokeVertex vi = vs; vi.t = -vi.t; - RI_SWAP(vi.ccw.x, vi.cw.x); - RI_SWAP(vi.ccw.y, vi.cw.y); + RI_SWAP(vi.ccw(0), vi.cw(0)); + RI_SWAP(vi.ccw(1), vi.cw(1)); doCap(pathToSurface, rasterizer, vi, strokeWidth, capStyle); //start cap //throws bad_alloc } } @@ -1678,8 +1679,8 @@ void Path::getPointAlong(int startIndex, int numSegments, RIfloat distance, Vect // empty path? if (!m_vertices.size() || !numSegments) { - p.set(0,0); - t.set(1,0); + p << 0,0; + t << 1,0; return; } @@ -1693,7 +1694,7 @@ void Path::getPointAlong(int startIndex, int numSegments, RIfloat distance, Vect if (startVertex >= endVertex) { p = m_vertices[startVertex].userPosition; - t.set(1,0); + t << 1,0; return; } @@ -1847,10 +1848,10 @@ void Path::getPathTransformedBounds(const Matrix3x3& pathToSurface, RIfloat& min p2 = pathToSurface * p2; p3 = pathToSurface * p3; - minx = RI_MIN(RI_MIN(RI_MIN(p0.x, p1.x), p2.x), p3.x); - miny = RI_MIN(RI_MIN(RI_MIN(p0.y, p1.y), p2.y), p3.y); - maxx = RI_MAX(RI_MAX(RI_MAX(p0.x, p1.x), p2.x), p3.x); - maxy = RI_MAX(RI_MAX(RI_MAX(p0.y, p1.y), p2.y), p3.y); + minx = RI_MIN(RI_MIN(RI_MIN(p0(0), p1(0)), p2(0)), p3(0)); + miny = RI_MIN(RI_MIN(RI_MIN(p0(1), p1(1)), p2(1)), p3(1)); + maxx = RI_MAX(RI_MAX(RI_MAX(p0(0), p1(0)), p2(0)), p3(0)); + maxy = RI_MAX(RI_MAX(RI_MAX(p0(1), p1(1)), p2(1)), p3(1)); } else { @@ -1878,10 +1879,10 @@ void Path::addVertex(const Vector2& p, const Vector2& t, RIfloat pathLength, uns m_vertices.push_back(v); //throws bad_alloc m_numTessVertices++; - m_userMinx = RI_MIN(m_userMinx, v.userPosition.x); - m_userMiny = RI_MIN(m_userMiny, v.userPosition.y); - m_userMaxx = RI_MAX(m_userMaxx, v.userPosition.x); - m_userMaxy = RI_MAX(m_userMaxy, v.userPosition.y); + m_userMinx = RI_MIN(m_userMinx, v.userPosition(0)); + m_userMiny = RI_MIN(m_userMiny, v.userPosition(1)); + m_userMaxx = RI_MAX(m_userMaxx, v.userPosition(0)); + m_userMaxy = RI_MAX(m_userMaxy, v.userPosition(1)); } /*-------------------------------------------------------------------*//*! @@ -2119,14 +2120,14 @@ static bool findEllipses(RIfloat rh, RIfloat rv, RIfloat rot, const Vector2& p0, return false; //degenerate ellipse rot = RI_DEG_TO_RAD(rot); - unitCircleToEllipse.set((RIfloat)cos(rot)*rh, -(RIfloat)sin(rot)*rv, 0, + unitCircleToEllipse << (RIfloat)cos(rot)*rh, -(RIfloat)sin(rot)*rv, 0, (RIfloat)sin(rot)*rh, (RIfloat)cos(rot)*rv, 0, - 0, 0, 1); + 0, 0, 1; Matrix3x3 ellipseToUnitCircle = invert(unitCircleToEllipse); //force affinity - ellipseToUnitCircle[2][0] = 0.0f; - ellipseToUnitCircle[2][1] = 0.0f; - ellipseToUnitCircle[2][2] = 1.0f; + ellipseToUnitCircle(2,0) = 0.0f; + ellipseToUnitCircle(2,1) = 0.0f; + ellipseToUnitCircle(2,2) = 1.0f; // Transform p0 and p1 into unit space u0 = affineTransform(ellipseToUnitCircle, p0); @@ -2135,7 +2136,7 @@ static bool findEllipses(RIfloat rh, RIfloat rv, RIfloat rot, const Vector2& p0, Vector2 m = 0.5f * (u0 + u1); Vector2 d = u0 - u1; - RIfloat lsq = (RIfloat)dot(d,d); + RIfloat lsq = (RIfloat)d.dot(d); if(lsq <= 0.0f) return false; //the points are coincident @@ -2147,14 +2148,14 @@ static bool findEllipses(RIfloat rh, RIfloat rv, RIfloat rot, const Vector2& p0, rv *= 0.5f * l; //redo the computation with scaled axes - unitCircleToEllipse.set((RIfloat)cos(rot)*rh, -(RIfloat)sin(rot)*rv, 0, + unitCircleToEllipse <<(RIfloat)cos(rot)*rh, -(RIfloat)sin(rot)*rv, 0, (RIfloat)sin(rot)*rh, (RIfloat)cos(rot)*rv, 0, - 0, 0, 1); + 0, 0, 1; ellipseToUnitCircle = invert(unitCircleToEllipse); //force affinity - ellipseToUnitCircle[2][0] = 0.0f; - ellipseToUnitCircle[2][1] = 0.0f; - ellipseToUnitCircle[2][2] = 1.0f; + ellipseToUnitCircle(2,0) = 0.0f; + ellipseToUnitCircle(2,1) = 0.0f; + ellipseToUnitCircle(2,2) = 1.0f; // Transform p0 and p1 into unit space u0 = affineTransform(ellipseToUnitCircle, p0); @@ -2164,7 +2165,7 @@ static bool findEllipses(RIfloat rh, RIfloat rv, RIfloat rot, const Vector2& p0, d = u0 - u1; m = 0.5f * (u0 + u1); - lsq = dot(d,d); + lsq = d.dot(d); if(lsq <= 0.0f) return false; //the points are coincident @@ -2196,8 +2197,8 @@ static bool findEllipses(RIfloat rh, RIfloat rv, RIfloat rot, const Vector2& p0, //transform back to the original coordinate space cp = affineTransform(unitCircleToEllipse, cp); - unitCircleToEllipse[0][2] = cp.x; - unitCircleToEllipse[1][2] = cp.y; + unitCircleToEllipse(0,2) = cp(0); + unitCircleToEllipse(1,2) = cp(1); return true; } @@ -2298,9 +2299,6 @@ void Path::tessellate(const Matrix3x3& pathToSurface, float strokeWidth) //tessellate the path segments coordIndex = 0; - s.set(0,0); - o.set(0,0); - p.set(0,0); bool subpathHasGeometry = false; VGPathSegment prevSegment = VG_MOVE_TO; for(int i=0;i<m_segments.size();i++) @@ -2353,9 +2351,9 @@ void Path::tessellate(const Matrix3x3& pathToSurface, float strokeWidth) case VG_HLINE_TO: { RI_ASSERT(coords == 1); - Vector2 c(getCoordinate(coordIndex+0), o.y); + Vector2 c(getCoordinate(coordIndex+0), o(1)); if(absRel == VG_RELATIVE) - c.x += o.x; + c(0) += o(0); if(addLineTo(pathToSurface, o, c, subpathHasGeometry)) subpathHasGeometry = true; p = c; @@ -2366,9 +2364,9 @@ void Path::tessellate(const Matrix3x3& pathToSurface, float strokeWidth) case VG_VLINE_TO: { RI_ASSERT(coords == 1); - Vector2 c(o.x, getCoordinate(coordIndex+0)); + Vector2 c(o(0), getCoordinate(coordIndex+0)); if(absRel == VG_RELATIVE) - c.y += o.y; + c(1) += o(1); if(addLineTo(pathToSurface, o, c, subpathHasGeometry)) subpathHasGeometry = true; p = c; |