54 void log(
const char*
string, ...)
57 va_start(args,
string);
58 std::vprintf(
string, args);
67 log(
"Body** bodies = (Body**)Alloc(%d * sizeof(Body*));\n",
size(bodies));
68 auto i = std::size_t{0};
69 for (
auto&& body: bodies)
71 const auto& b =
GetRef(body);
77 log(
"Joint** joints = (Joint**)Alloc(%d * sizeof(Joint*));\n",
size(joints));
79 for (
auto&& j: joints)
87 log(
"Free(joints);\n");
88 log(
"Free(bodies);\n");
89 log(
"joints = nullptr;\n");
90 log(
"bodies = nullptr;\n");
93 void Dump(
const Body& body, std::size_t bodyIndex)
96 log(
" BodyConf bd;\n");
97 log(
" bd.type = BodyType(%d);\n", body.
GetType());
98 log(
" bd.position = Vec2(%.15lef, %.15lef);\n",
102 log(
" bd.linearVelocity = Vec2(%.15lef, %.15lef);\n",
105 log(
" bd.angularVelocity = %.15lef;\n",
107 log(
" bd.linearDamping = %.15lef;\n",
109 log(
" bd.angularDamping = %.15lef;\n",
112 log(
" bd.awake = bool(%d);\n", body.
IsAwake());
116 log(
" bodies[%d] = m_world->CreateBody(bd);\n", bodyIndex);
172 log(
" FixtureConf fd;\n");
173 log(
" fd.friction = %.15lef;\n",
static_cast<double>(fixture.
GetFriction()));
174 log(
" fd.restitution = %.15lef;\n",
static_cast<double>(fixture.
GetRestitution()));
175 log(
" fd.density = %.15lef;\n",
177 log(
" fd.isSensor = bool(%d);\n", fixture.
IsSensor());
178 log(
" fd.filter.categoryBits = Filter::bits_type(%u);\n",
180 log(
" fd.filter.maskBits = Filter::bits_type(%u);\n",
182 log(
" fd.filter.groupIndex = Filter::index_type(%d);\n",
185 const auto shape = fixture.
GetShape();
186 std::ostringstream os;
188 log(os.str().c_str());
191 log(
" fd.shape = &shape;\n");
193 log(
" bodies[%d]->CreateFixture(fd);\n", bodyIndex);
198 log(
" DistanceJointConf jd;\n");
202 log(
" jd.localAnchorA = Vec2(%.15lef, %.15lef);\n",
205 log(
" jd.localAnchorB = Vec2(%.15lef, %.15lef);\n",
208 log(
" jd.length = %.15lef;\n",
210 log(
" jd.frequency = %.15lef;\n",
213 log(
" joints[%d] = m_world->CreateJoint(jd);\n", index);
218 log(
" FrictionJointConf jd;\n");
222 log(
" jd.localAnchorA = Vec2(%.15lef, %.15lef);\n",
225 log(
" jd.localAnchorB = Vec2(%.15lef, %.15lef);\n",
228 log(
" jd.maxForce = %.15lef;\n",
230 log(
" jd.maxTorque = %.15lef;\n",
232 log(
" joints[%d] = m_world->CreateJoint(jd);\n", index);
237 log(
" GearJointConf jd;\n");
244 log(
" joints[%d] = m_world->CreateJoint(jd);\n", index);
249 log(
" MotorJointConf jd;\n");
253 log(
" jd.linearOffset = Vec2(%.15lef, %.15lef);\n",
256 log(
" jd.angularOffset = %.15lef;\n",
258 log(
" jd.maxForce = %.15lef;\n",
260 log(
" jd.maxTorque = %.15lef;\n",
263 log(
" joints[%d] = m_world->CreateJoint(jd);\n", index);
268 log(
" TargetJointConf jd;\n");
272 log(
" jd.localAnchorB = Vec2(%.15lef, %.15lef);\n",
275 log(
" jd.frequency = %.15lef;\n",
278 log(
" jd.maxForce = %.15lef;\n",
280 log(
" joints[%d] = m_world->CreateJoint(jd);\n", index);
285 log(
" PrismaticJointConf jd;\n");
289 log(
" jd.localAnchorA = Vec2(%.15lef, %.15lef);\n",
292 log(
" jd.localAnchorB = Vec2(%.15lef, %.15lef);\n",
295 log(
" jd.localAxisA = Vec2(%.15lef, %.15lef);\n",
297 log(
" jd.referenceAngle = %.15lef;\n",
300 log(
" jd.lowerTranslation = %.15lef;\n",
302 log(
" jd.upperTranslation = %.15lef;\n",
305 log(
" jd.motorSpeed = %.15lef;\n",
307 log(
" jd.maxMotorForce = %.15lef;\n",
309 log(
" joints[%d] = m_world->CreateJoint(jd);\n", index);
314 log(
" PulleyJointConf jd;\n");
318 log(
" jd.groundAnchorA = Vec2(%.15lef, %.15lef);\n",
321 log(
" jd.groundAnchorB = Vec2(%.15lef, %.15lef);\n",
324 log(
" jd.localAnchorA = Vec2(%.15lef, %.15lef);\n",
327 log(
" jd.localAnchorB = Vec2(%.15lef, %.15lef);\n",
330 log(
" jd.lengthA = %.15lef;\n",
332 log(
" jd.lengthB = %.15lef;\n",
335 log(
" joints[%d] = m_world->CreateJoint(jd);\n", index);
340 log(
" RevoluteJointConf jd;\n");
344 log(
" jd.localAnchorA = Vec2(%.15lef, %.15lef);\n",
347 log(
" jd.localAnchorB = Vec2(%.15lef, %.15lef);\n",
350 log(
" jd.referenceAngle = %.15lef;\n",
353 log(
" jd.lowerAngle = %.15lef;\n",
355 log(
" jd.upperAngle = %.15lef;\n",
358 log(
" jd.motorSpeed = %.15lef;\n",
360 log(
" jd.maxMotorTorque = %.15lef;\n",
362 log(
" joints[%d] = m_world->CreateJoint(jd);\n", index);
367 log(
" RopeJointConf jd;\n");
371 log(
" jd.localAnchorA = Vec2(%.15lef, %.15lef);\n",
374 log(
" jd.localAnchorB = Vec2(%.15lef, %.15lef);\n",
377 log(
" jd.maxLength = %.15lef;\n",
379 log(
" joints[%d] = m_world->CreateJoint(jd);\n", index);
384 log(
" WeldJointConf jd;\n");
388 log(
" jd.localAnchorA = Vec2(%.15lef, %.15lef);\n",
391 log(
" jd.localAnchorB = Vec2(%.15lef, %.15lef);\n",
394 log(
" jd.referenceAngle = %.15lef;\n",
396 log(
" jd.frequency = %.15lef;\n",
399 log(
" joints[%d] = m_world->CreateJoint(jd);\n", index);
404 log(
" WheelJointConf jd;\n");
408 log(
" jd.localAnchorA = Vec2(%.15lef, %.15lef);\n",
411 log(
" jd.localAnchorB = Vec2(%.15lef, %.15lef);\n",
414 log(
" jd.localAxisA = Vec2(%.15lef, %.15lef);\n",
418 log(
" jd.motorSpeed = %.15lef;\n",
420 log(
" jd.maxMotorTorque = %.15lef;\n",
422 log(
" jd.frequency = %.15lef;\n",
425 log(
" joints[%d] = m_world->CreateJoint(jd);\n", index);