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

Function DrawCircle

core/physics/PhysicsWorld.cpp:221–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219}
220
221static void DrawCircle(cpVect p,
222 cpFloat /*a*/,
223 cpFloat r,
224 cpSpaceDebugColor outline,
225 cpSpaceDebugColor fill,
226 cpDataPointer data)
227{
228 const Color4F fillColor(fill.r, fill.g, fill.b, fill.a);
229 const Color4F outlineColor(outline.r, outline.g, outline.b, outline.a);
230 DrawNode* drawNode = static_cast<DrawNode*>(data);
231 float radius = PhysicsHelper::cpfloat2float(r);
232 Vec2 centre = PhysicsHelper::cpv2vec2(p);
233
234 static const int CIRCLE_SEG_NUM = 12;
235 Vec2 seg[CIRCLE_SEG_NUM] = {};
236
237 for (int i = 0; i < CIRCLE_SEG_NUM; ++i)
238 {
239 float angle = (float)i * M_PI / (float)CIRCLE_SEG_NUM * 2.0f;
240 Vec2 d(radius * cosf(angle), radius * sinf(angle));
241 seg[i] = centre + d;
242 }
243 drawNode->drawPolygon(seg, CIRCLE_SEG_NUM, fillColor, _debugDrawThickness, outlineColor);
244}
245
246static void DrawFatSegment(cpVect a,
247 cpVect b,

Callers

nothing calls this directly

Calls 1

drawPolygonMethod · 0.45

Tested by

no test coverage detected