MCPcopy Create free account
hub / github.com/axmolengine/axmol / duAppendCylinderWire

Function duAppendCylinderWire

3rdparty/recast/DebugDraw.cpp:181–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179
180
181void 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
219void duAppendBoxWire(struct duDebugDraw* dd, float minx, float miny, float minz,
220 float maxx, float maxy, float maxz, unsigned int col)

Callers 1

duDebugDrawCylinderWireFunction · 0.85

Calls 3

dtMathCosfFunction · 0.85
dtMathSinfFunction · 0.85
vertexMethod · 0.45

Tested by

no test coverage detected