commit 0c4ea5639c346085bb31b6fa5d540aac0b315f99
parent 714036fffbde8bd901510ef1f6a9a64d42456d5f
Author: Yoann <yoann.b87@voila.fr>
Date: Tue, 13 Dec 2011 15:09:39 +0100
Petite factorisation et optimisation dans le code du dessin du trottoir.
Diffstat:
1 file changed, 27 insertions(+), 27 deletions(-)
diff --git a/rules/route/trottoirquadnormal.cpp b/rules/route/trottoirquadnormal.cpp
@@ -16,38 +16,38 @@ bool TrottoirQuadNormal::subdivide() {
}
void TrottoirQuadNormal::triangulation() {
- Vertex tne, tnw, tse, tsw, bne, bnw, bse, bsw;
+ Vertex h = Vertex(0,0,height);
Quad q = Quad(ne,se,sw,nw);
if(border == E) {
q.offset(E,-15);
- addTriangle(new Triangle(q.corner[0] + Vertex(0,0,height), q.corner[3] + Vertex(0,0,height), q.corner[2] + Vertex(0,0,height), 0x66, 0x66, 0x66));
- addTriangle(new Triangle(q.corner[2] + Vertex(0,0,height), q.corner[1] + Vertex(0,0,height), q.corner[0] + Vertex(0,0,height), 0x66, 0x66, 0x66));
- addTriangle(new Triangle(ne + Vertex(0,0,height),q.corner[0] + Vertex(0,0,height), q.corner[1] + Vertex(0,0,height), 0xAA, 0xAA, 0xAA));
- addTriangle(new Triangle(q.corner[1] + Vertex(0,0,height), se + Vertex(0,0,height), ne + Vertex(0,0,height), 0xAA, 0xAA, 0xAA));
-
- addTriangle(new Triangle(nw + Vertex(0,0,height), nw, sw, 0x66, 0x66, 0x66));
- addTriangle(new Triangle(sw, sw + Vertex(0,0,height), nw + Vertex(0,0,height), 0x66, 0x66, 0x66));
- addTriangle(new Triangle(ne, ne + Vertex(0,0,height), se + Vertex(0,0,height), 0xAA, 0xAA, 0xAA));
- addTriangle(new Triangle(se + Vertex(0,0,height), se, ne, 0xAA, 0xAA, 0xAA));
-
- addTriangle(new Triangle(ne + Vertex(0,0,height), ne, nw, 0x66, 0x66, 0x66));
- addTriangle(new Triangle(nw, nw + Vertex(0,0,height), ne + Vertex(0,0,height), 0x66, 0x66, 0x66));
- addTriangle(new Triangle(sw, sw + Vertex(0,0,height), se + Vertex(0,0,height), 0x66, 0x66, 0x66));
- addTriangle(new Triangle(se + Vertex(0,0,height), se, sw, 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(q.corner[0] + h, q.corner[3] + h, q.corner[2] + h, 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(q.corner[2] + h, q.corner[1] + h, q.corner[0] + h, 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(ne + h,q.corner[0] + h, q.corner[1] + h, 0xAA, 0xAA, 0xAA));
+ addTriangle(new Triangle(q.corner[1] + h, se + h, ne + h, 0xAA, 0xAA, 0xAA));
+
+ addTriangle(new Triangle(nw + h, nw, sw, 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(sw, sw + h, nw + h, 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(ne, ne + h, se + h, 0xAA, 0xAA, 0xAA));
+ addTriangle(new Triangle(se + h, se, ne, 0xAA, 0xAA, 0xAA));
+
+ addTriangle(new Triangle(ne + h, ne, nw, 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(nw, nw + h, ne + h, 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(sw, sw + h, se + h, 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(se + h, se, sw, 0x66, 0x66, 0x66));
}
else {
- addTriangle(new Triangle(q.corner[0] + Vertex(0,0,height), q.corner[3] + Vertex(0,0,height), q.corner[2] + Vertex(0,0,height), 0x66, 0x66, 0x66));
- addTriangle(new Triangle(q.corner[2] + Vertex(0,0,height), q.corner[1] + Vertex(0,0,height), q.corner[0] + Vertex(0,0,height), 0x66, 0x66, 0x66));
-
- addTriangle(new Triangle(nw + Vertex(0,0,height), nw, sw, 0x66, 0x66, 0x66));
- addTriangle(new Triangle(sw, sw + Vertex(0,0,height), nw + Vertex(0,0,height), 0x66, 0x66, 0x66));
- addTriangle(new Triangle(ne, ne + Vertex(0,0,height), se + Vertex(0,0,height), 0x66, 0x66, 0x66));
- addTriangle(new Triangle(se + Vertex(0,0,height), se, ne, 0x66, 0x66, 0x66));
-
- addTriangle(new Triangle(ne + Vertex(0,0,height), ne, nw, 0x66, 0x66, 0x66));
- addTriangle(new Triangle(nw, nw + Vertex(0,0,height), ne + Vertex(0,0,height), 0x66, 0x66, 0x66));
- addTriangle(new Triangle(sw, sw + Vertex(0,0,height), se + Vertex(0,0,height), 0x66, 0x66, 0x66));
- addTriangle(new Triangle(se + Vertex(0,0,height), se, sw, 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(q.corner[0] + h, q.corner[3] + h, q.corner[2] + h, 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(q.corner[2] + h, q.corner[1] + h, q.corner[0] + h, 0x66, 0x66, 0x66));
+
+ addTriangle(new Triangle(nw + h, nw, sw, 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(sw, sw + h, nw + h, 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(ne, ne + h, se + h, 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(se + h, se, ne, 0x66, 0x66, 0x66));
+
+ addTriangle(new Triangle(ne + h, ne, nw, 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(nw, nw + h, ne + h, 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(sw, sw + h, se + h, 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(se + h, se, sw, 0x66, 0x66, 0x66));
}
}