| 179 | |
| 180 | |
| 181 | void duAppendCylinderWire(struct duDebugDraw* dd, float minx, float miny, float minz, |
| 182 | float maxx, float maxy, float maxz, unsigned int col) |
| 183 | { |
| 184 | if (!dd) return; |
| 185 | |
| 186 | static const int NUM_SEG = 16; |
| 187 | static float dir[NUM_SEG*2]; |
| 188 | static bool init = false; |
| 189 | if (!init) |
| 190 | { |
| 191 | init = true; |
| 192 | for (int i = 0; i < NUM_SEG; ++i) |
| 193 | { |
| 194 | const float a = (float)i/(float)NUM_SEG*DU_PI*2; |
| 195 | dir[i*2] = dtMathCosf(a); |
| 196 | dir[i*2+1] = dtMathSinf(a); |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | const float cx = (maxx + minx)/2; |
| 201 | const float cz = (maxz + minz)/2; |
| 202 | const float rx = (maxx - minx)/2; |
| 203 | const float rz = (maxz - minz)/2; |
| 204 | |
| 205 | for (int i = 0, j = NUM_SEG-1; i < NUM_SEG; j = i++) |
| 206 | { |
| 207 | dd->vertex(cx+dir[j*2+0]*rx, miny, cz+dir[j*2+1]*rz, col); |
| 208 | dd->vertex(cx+dir[i*2+0]*rx, miny, cz+dir[i*2+1]*rz, col); |
| 209 | dd->vertex(cx+dir[j*2+0]*rx, maxy, cz+dir[j*2+1]*rz, col); |
| 210 | dd->vertex(cx+dir[i*2+0]*rx, maxy, cz+dir[i*2+1]*rz, col); |
| 211 | } |
| 212 | for (int i = 0; i < NUM_SEG; i += NUM_SEG/4) |
| 213 | { |
| 214 | dd->vertex(cx+dir[i*2+0]*rx, miny, cz+dir[i*2+1]*rz, col); |
| 215 | dd->vertex(cx+dir[i*2+0]*rx, maxy, cz+dir[i*2+1]*rz, col); |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | void duAppendBoxWire(struct duDebugDraw* dd, float minx, float miny, float minz, |
| 220 | float maxx, float maxy, float maxz, unsigned int col) |
no test coverage detected