| 74 | namespace |
| 75 | { |
| 76 | void _drawLine( const Point3F &p0, const Point3F &p1, const ColorI &color, F32 width ) |
| 77 | { |
| 78 | F32 x1, x2, y1, y2, z1, z2; |
| 79 | |
| 80 | x1 = p0.x; |
| 81 | y1 = p0.y; |
| 82 | z1 = p0.z; |
| 83 | x2 = p1.x; |
| 84 | y2 = p1.y; |
| 85 | z2 = p1.z; |
| 86 | |
| 87 | // |
| 88 | // Convert Line a----------b |
| 89 | // |
| 90 | // Into Quad v0---------v1 |
| 91 | // a b |
| 92 | // v2---------v3 |
| 93 | // |
| 94 | |
| 95 | Point2F start(x1, y1); |
| 96 | Point2F end(x2, y2); |
| 97 | Point2F perp, lineVec; |
| 98 | |
| 99 | // handle degenerate case where point a = b |
| 100 | if(x1 == x2 && y1 == y2) |
| 101 | { |
| 102 | perp.set(0.0f, width * 0.5f); |
| 103 | lineVec.set(0.1f, 0.0f); |
| 104 | } |
| 105 | else |
| 106 | { |
| 107 | perp.set(start.y - end.y, end.x - start.x); |
| 108 | lineVec.set(end.x - start.x, end.y - start.y); |
| 109 | perp.normalize(width * 0.5f); |
| 110 | lineVec.normalize(0.1f); |
| 111 | } |
| 112 | start -= lineVec; |
| 113 | end += lineVec; |
| 114 | |
| 115 | GFXVertexBufferHandle<GFXVertexPCT> verts(GFX, 4, GFXBufferTypeVolatile); |
| 116 | verts.lock(); |
| 117 | |
| 118 | verts[0].point.set( start.x+perp.x, start.y+perp.y, z1 ); |
| 119 | verts[1].point.set( end.x+perp.x, end.y+perp.y, z2 ); |
| 120 | verts[2].point.set( start.x-perp.x, start.y-perp.y, z1 ); |
| 121 | verts[3].point.set( end.x-perp.x, end.y-perp.y, z2 ); |
| 122 | |
| 123 | verts[0].color = color; |
| 124 | verts[1].color = color; |
| 125 | verts[2].color = color; |
| 126 | verts[3].color = color; |
| 127 | |
| 128 | verts.unlock(); |
| 129 | GFX->setVertexBuffer( verts ); |
| 130 | |
| 131 | GFXStateBlockDesc desc; |
| 132 | desc.setCullMode(GFXCullNone); |
| 133 | desc.setZReadWrite(false); |
no test coverage detected