test.cpp
Go to the documentation of this file.
1 // MIT License
2 
3 // Copyright (c) 2019 Erin Catto
4 
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 
23 #include "test.h"
24 #include "settings.h"
25 #include <stdio.h>
26 
28 {
29  if (test->m_mouseJoint == joint)
30  {
31  test->m_mouseJoint = NULL;
32  }
33  else
34  {
35  test->JointDestroyed(joint);
36  }
37 }
38 
40 {
41  b2Vec2 gravity;
42  gravity.Set(0.0f, -10.0f);
43  m_world = new b2World(gravity);
44  m_bomb = NULL;
45  m_textLine = 30;
46  m_textIncrement = 13;
48  m_pointCount = 0;
49 
54 
55  m_bombSpawning = false;
56 
57  m_stepCount = 0;
58 
59  b2BodyDef bodyDef;
60  m_groundBody = m_world->CreateBody(&bodyDef);
61 
62  memset(&m_maxProfile, 0, sizeof(b2Profile));
63  memset(&m_totalProfile, 0, sizeof(b2Profile));
64 }
65 
67 {
68  // By deleting the world, we delete the bomb, mouse joint, etc.
69  delete m_world;
70  m_world = NULL;
71 }
72 
73 void Test::PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
74 {
75  const b2Manifold* manifold = contact->GetManifold();
76 
77  if (manifold->pointCount == 0)
78  {
79  return;
80  }
81 
82  b2Fixture* fixtureA = contact->GetFixtureA();
83  b2Fixture* fixtureB = contact->GetFixtureB();
84 
86  b2GetPointStates(state1, state2, oldManifold, manifold);
87 
88  b2WorldManifold worldManifold;
89  contact->GetWorldManifold(&worldManifold);
90 
91  for (int32 i = 0; i < manifold->pointCount && m_pointCount < k_maxContactPoints; ++i)
92  {
94  cp->fixtureA = fixtureA;
95  cp->fixtureB = fixtureB;
96  cp->position = worldManifold.points[i];
97  cp->normal = worldManifold.normal;
98  cp->state = state2[i];
99  cp->normalImpulse = manifold->points[i].normalImpulse;
100  cp->tangentImpulse = manifold->points[i].tangentImpulse;
101  cp->separation = worldManifold.separations[i];
102  ++m_pointCount;
103  }
104 }
105 
106 void Test::DrawTitle(const char *string)
107 {
108  g_debugDraw.DrawString(5, 5, string);
109  m_textLine = int32(26.0f);
110 }
111 
113 {
114 public:
115  QueryCallback(const b2Vec2& point)
116  {
117  m_point = point;
118  m_fixture = NULL;
119  }
120 
121  bool ReportFixture(b2Fixture* fixture) override
122  {
123  b2Body* body = fixture->GetBody();
124  if (body->GetType() == b2_dynamicBody)
125  {
126  bool inside = fixture->TestPoint(m_point);
127  if (inside)
128  {
129  m_fixture = fixture;
130 
131  // We are done, terminate the query.
132  return false;
133  }
134  }
135 
136  // Continue the query.
137  return true;
138  }
139 
142 };
143 
144 void Test::MouseDown(const b2Vec2& p)
145 {
146  m_mouseWorld = p;
147 
148  if (m_mouseJoint != NULL)
149  {
150  return;
151  }
152 
153  // Make a small box.
154  b2AABB aabb;
155  b2Vec2 d;
156  d.Set(0.001f, 0.001f);
157  aabb.lowerBound = p - d;
158  aabb.upperBound = p + d;
159 
160  // Query the world for overlapping shapes.
161  QueryCallback callback(p);
162  m_world->QueryAABB(&callback, aabb);
163 
164  if (callback.m_fixture)
165  {
166  float frequencyHz = 5.0f;
167  float dampingRatio = 0.7f;
168 
169  b2Body* body = callback.m_fixture->GetBody();
170  b2MouseJointDef jd;
171  jd.bodyA = m_groundBody;
172  jd.bodyB = body;
173  jd.target = p;
174  jd.maxForce = 1000.0f * body->GetMass();
175  b2LinearStiffness(jd.stiffness, jd.damping, frequencyHz, dampingRatio, jd.bodyA, jd.bodyB);
176 
178  body->SetAwake(true);
179  }
180 }
181 
182 void Test::SpawnBomb(const b2Vec2& worldPt)
183 {
184  m_bombSpawnPoint = worldPt;
185  m_bombSpawning = true;
186 }
187 
189 {
190  if (m_bombSpawning == false)
191  {
192  return;
193  }
194 
195  const float multiplier = 30.0f;
196  b2Vec2 vel = m_bombSpawnPoint - p;
197  vel *= multiplier;
199  m_bombSpawning = false;
200 }
201 
203 {
204  m_mouseWorld = p;
205 
206  if (m_mouseJoint != NULL)
207  {
208  return;
209  }
210 
211  SpawnBomb(p);
212 }
213 
214 void Test::MouseUp(const b2Vec2& p)
215 {
216  if (m_mouseJoint)
217  {
219  m_mouseJoint = NULL;
220  }
221 
222  if (m_bombSpawning)
223  {
225  }
226 }
227 
228 void Test::MouseMove(const b2Vec2& p)
229 {
230  m_mouseWorld = p;
231 
232  if (m_mouseJoint)
233  {
235  }
236 }
237 
239 {
240  b2Vec2 p(RandomFloat(-15.0f, 15.0f), 30.0f);
241  b2Vec2 v = -5.0f * p;
242  LaunchBomb(p, v);
243 }
244 
245 void Test::LaunchBomb(const b2Vec2& position, const b2Vec2& velocity)
246 {
247  if (m_bomb)
248  {
250  m_bomb = NULL;
251  }
252 
253  b2BodyDef bd;
254  bd.type = b2_dynamicBody;
255  bd.position = position;
256  bd.bullet = true;
257  m_bomb = m_world->CreateBody(&bd);
258  m_bomb->SetLinearVelocity(velocity);
259 
260  b2CircleShape circle;
261  circle.m_radius = 0.3f;
262 
263  b2FixtureDef fd;
264  fd.shape = &circle;
265  fd.density = 20.0f;
266  fd.restitution = 0.0f;
267 
268  b2Vec2 minV = position - b2Vec2(0.3f,0.3f);
269  b2Vec2 maxV = position + b2Vec2(0.3f,0.3f);
270 
271  b2AABB aabb;
272  aabb.lowerBound = minV;
273  aabb.upperBound = maxV;
274 
275  m_bomb->CreateFixture(&fd);
276 }
277 
278 void Test::Step(Settings& settings)
279 {
280  float timeStep = settings.m_hertz > 0.0f ? 1.0f / settings.m_hertz : float(0.0f);
281 
282  if (settings.m_pause)
283  {
284  if (settings.m_singleStep)
285  {
286  settings.m_singleStep = 0;
287  }
288  else
289  {
290  timeStep = 0.0f;
291  }
292 
293  g_debugDraw.DrawString(5, m_textLine, "****PAUSED****");
295  }
296 
297  uint32 flags = 0;
298  flags += settings.m_drawShapes * b2Draw::e_shapeBit;
299  flags += settings.m_drawJoints * b2Draw::e_jointBit;
300  flags += settings.m_drawAABBs * b2Draw::e_aabbBit;
301  flags += settings.m_drawCOMs * b2Draw::e_centerOfMassBit;
302  g_debugDraw.SetFlags(flags);
303 
308 
309  m_pointCount = 0;
310 
311  m_world->Step(timeStep, settings.m_velocityIterations, settings.m_positionIterations);
312 
313  m_world->DebugDraw();
314  g_debugDraw.Flush();
315 
316  if (timeStep > 0.0f)
317  {
318  ++m_stepCount;
319  }
320 
321  if (settings.m_drawStats)
322  {
323  int32 bodyCount = m_world->GetBodyCount();
324  int32 contactCount = m_world->GetContactCount();
325  int32 jointCount = m_world->GetJointCount();
326  g_debugDraw.DrawString(5, m_textLine, "bodies/contacts/joints = %d/%d/%d", bodyCount, contactCount, jointCount);
328 
329  int32 proxyCount = m_world->GetProxyCount();
330  int32 height = m_world->GetTreeHeight();
331  int32 balance = m_world->GetTreeBalance();
332  float quality = m_world->GetTreeQuality();
333  g_debugDraw.DrawString(5, m_textLine, "proxies/height/balance/quality = %d/%d/%d/%g", proxyCount, height, balance, quality);
335  }
336 
337  // Track maximum profile times
338  {
339  const b2Profile& p = m_world->GetProfile();
348 
349  m_totalProfile.step += p.step;
357  }
358 
359  if (settings.m_drawProfile)
360  {
361  const b2Profile& p = m_world->GetProfile();
362 
363  b2Profile aveProfile;
364  memset(&aveProfile, 0, sizeof(b2Profile));
365  if (m_stepCount > 0)
366  {
367  float scale = 1.0f / m_stepCount;
368  aveProfile.step = scale * m_totalProfile.step;
369  aveProfile.collide = scale * m_totalProfile.collide;
370  aveProfile.solve = scale * m_totalProfile.solve;
371  aveProfile.solveInit = scale * m_totalProfile.solveInit;
372  aveProfile.solveVelocity = scale * m_totalProfile.solveVelocity;
373  aveProfile.solvePosition = scale * m_totalProfile.solvePosition;
374  aveProfile.solveTOI = scale * m_totalProfile.solveTOI;
375  aveProfile.broadphase = scale * m_totalProfile.broadphase;
376  }
377 
378  g_debugDraw.DrawString(5, m_textLine, "step [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.step, aveProfile.step, m_maxProfile.step);
380  g_debugDraw.DrawString(5, m_textLine, "collide [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.collide, aveProfile.collide, m_maxProfile.collide);
382  g_debugDraw.DrawString(5, m_textLine, "solve [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solve, aveProfile.solve, m_maxProfile.solve);
384  g_debugDraw.DrawString(5, m_textLine, "solve init [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solveInit, aveProfile.solveInit, m_maxProfile.solveInit);
386  g_debugDraw.DrawString(5, m_textLine, "solve velocity [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solveVelocity, aveProfile.solveVelocity, m_maxProfile.solveVelocity);
388  g_debugDraw.DrawString(5, m_textLine, "solve position [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solvePosition, aveProfile.solvePosition, m_maxProfile.solvePosition);
390  g_debugDraw.DrawString(5, m_textLine, "solveTOI [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solveTOI, aveProfile.solveTOI, m_maxProfile.solveTOI);
392  g_debugDraw.DrawString(5, m_textLine, "broad-phase [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.broadphase, aveProfile.broadphase, m_maxProfile.broadphase);
394  }
395 
396  if (m_bombSpawning)
397  {
398  b2Color c;
399  c.Set(0.0f, 0.0f, 1.0f);
401 
402  c.Set(0.8f, 0.8f, 0.8f);
404  }
405 
406  if (settings.m_drawContactPoints)
407  {
408  const float k_impulseScale = 0.1f;
409  const float k_axisScale = 0.3f;
410 
411  for (int32 i = 0; i < m_pointCount; ++i)
412  {
413  ContactPoint* point = m_points + i;
414 
415  if (point->state == b2_addState)
416  {
417  // Add
418  g_debugDraw.DrawPoint(point->position, 10.0f, b2Color(0.3f, 0.95f, 0.3f));
419  }
420  else if (point->state == b2_persistState)
421  {
422  // Persist
423  g_debugDraw.DrawPoint(point->position, 5.0f, b2Color(0.3f, 0.3f, 0.95f));
424  }
425 
426  if (settings.m_drawContactNormals == 1)
427  {
428  b2Vec2 p1 = point->position;
429  b2Vec2 p2 = p1 + k_axisScale * point->normal;
430  g_debugDraw.DrawSegment(p1, p2, b2Color(0.9f, 0.9f, 0.9f));
431  }
432  else if (settings.m_drawContactImpulse == 1)
433  {
434  b2Vec2 p1 = point->position;
435  b2Vec2 p2 = p1 + k_impulseScale * point->normalImpulse * point->normal;
436  g_debugDraw.DrawSegment(p1, p2, b2Color(0.9f, 0.9f, 0.3f));
437  }
438 
439  if (settings.m_drawFrictionImpulse == 1)
440  {
441  b2Vec2 tangent = b2Cross(point->normal, 1.0f);
442  b2Vec2 p1 = point->position;
443  b2Vec2 p2 = p1 + k_impulseScale * point->tangentImpulse * tangent;
444  g_debugDraw.DrawSegment(p1, p2, b2Color(0.9f, 0.9f, 0.3f));
445  }
446  }
447  }
448 }
449 
450 void Test::ShiftOrigin(const b2Vec2& newOrigin)
451 {
452  m_world->ShiftOrigin(newOrigin);
453 }
454 
456 int g_testCount = 0;
457 
458 int RegisterTest(const char* category, const char* name, TestCreateFcn* fcn)
459 {
460  int index = g_testCount;
461  if (index < MAX_TESTS)
462  {
463  g_testEntries[index] = { category, name, fcn };
464  ++g_testCount;
465  return index;
466  }
467 
468  return -1;
469 }
Settings::m_drawContactImpulse
bool m_drawContactImpulse
Definition: settings.h:72
b2World::SetDebugDraw
void SetDebugDraw(b2Draw *debugDraw)
Definition: b2_world.cpp:110
b2Cross
float b2Cross(const b2Vec2 &a, const b2Vec2 &b)
Perform the cross product on two vectors. In 2D this produces a scalar.
Definition: b2_math.h:401
uint32
unsigned int uint32
Definition: b2_types.h:31
Settings::m_drawShapes
bool m_drawShapes
Definition: settings.h:67
b2Profile::solve
float solve
Definition: b2_time_step.h:33
Test::m_textIncrement
int32 m_textIncrement
Definition: test.h:135
Settings::m_drawStats
bool m_drawStats
Definition: settings.h:75
b2_addState
@ b2_addState
point was added in the update
Definition: b2_collision.h:135
b2Profile::broadphase
float broadphase
Definition: b2_time_step.h:37
b2BodyDef::bullet
bool bullet
Definition: b2_body.h:115
Test::ShiftOrigin
void ShiftOrigin(const b2Vec2 &newOrigin)
Definition: test.cpp:450
g_debugDraw
DebugDraw g_debugDraw
Definition: draw.cpp:32
b2Body::SetAwake
void SetAwake(bool flag)
Definition: b2_body.h:638
TestCreateFcn
Test * TestCreateFcn()
Definition: test.h:140
b2World::QueryAABB
void QueryAABB(b2QueryCallback *callback, const b2AABB &aabb) const
Definition: b2_world.cpp:994
b2Body::GetType
b2BodyType GetType() const
Get the type of this body.
Definition: b2_body.h:474
Test::m_points
ContactPoint m_points[k_maxContactPoints]
Definition: test.h:124
NULL
#define NULL
b2Profile::solveVelocity
float solveVelocity
Definition: b2_time_step.h:35
MAX_TESTS
#define MAX_TESTS
Definition: test.h:152
b2_persistState
@ b2_persistState
point persisted across the update
Definition: b2_collision.h:136
b2World::SetSubStepping
void SetSubStepping(bool flag)
Enable/disable single stepped continuous physics. For testing.
Definition: b2_world.h:162
b2World::GetBodyCount
int32 GetBodyCount() const
Get the number of bodies.
Definition: b2_world.h:294
settings.h
b2LinearStiffness
B2_API void b2LinearStiffness(float &stiffness, float &damping, float frequencyHertz, float dampingRatio, const b2Body *bodyA, const b2Body *bodyB)
Utility to compute linear stiffness values from frequency and damping ratio.
Definition: b2_joint.cpp:40
Test::m_stepCount
int32 m_stepCount
Definition: test.h:134
Settings::m_drawCOMs
bool m_drawCOMs
Definition: settings.h:74
Settings::m_drawFrictionImpulse
bool m_drawFrictionImpulse
Definition: settings.h:73
Test::ShiftMouseDown
void ShiftMouseDown(const b2Vec2 &p)
Definition: test.cpp:202
ContactPoint::normalImpulse
float normalImpulse
Definition: test.h:75
ContactPoint::tangentImpulse
float tangentImpulse
Definition: test.h:76
Test::m_destructionListener
DestructionListener m_destructionListener
Definition: test.h:126
Test::m_mouseWorld
b2Vec2 m_mouseWorld
Definition: test.h:133
b2MouseJointDef::damping
float damping
The linear damping in N*s/m.
Definition: b2_mouse_joint.h:55
b2Fixture::TestPoint
bool TestPoint(const b2Vec2 &p) const
Definition: b2_fixture.h:344
ContactPoint::position
b2Vec2 position
Definition: test.h:73
b2World::DebugDraw
void DebugDraw()
Call this to draw shapes and other debug draw data. This is intentionally non-const.
Definition: b2_world.cpp:1107
Settings::m_enableSleep
bool m_enableSleep
Definition: settings.h:80
TestEntry
Definition: test.h:145
DebugDraw::DrawSegment
void DrawSegment(const b2Vec2 &p1, const b2Vec2 &p2, const b2Color &color) override
Draw a line segment.
Definition: draw.cpp:742
Test::m_bomb
b2Body * m_bomb
Definition: test.h:129
b2Body
A rigid body. These are created via b2World::CreateBody.
Definition: b2_body.h:128
b2CircleShape
A solid circle shape.
Definition: b2_circle_shape.h:30
Settings::m_enableSubStepping
bool m_enableSubStepping
Definition: settings.h:79
b2World::DestroyJoint
void DestroyJoint(b2Joint *joint)
Definition: b2_world.cpp:280
b2Draw::e_shapeBit
@ e_shapeBit
draw shapes
Definition: b2_draw.h:57
b2FixtureDef
Definition: b2_fixture.h:61
b2MouseJoint::SetTarget
void SetTarget(const b2Vec2 &target)
Use this to update the target point.
Definition: b2_mouse_joint.cpp:49
b2Vec2::Set
void Set(float x_, float y_)
Set this vector to some specified coordinates.
Definition: b2_math.h:53
Test::MouseDown
virtual void MouseDown(const b2Vec2 &p)
Definition: test.cpp:144
Settings::m_drawContactPoints
bool m_drawContactPoints
Definition: settings.h:70
b2AABB::upperBound
b2Vec2 upperBound
the upper vertex
Definition: b2_collision.h:221
b2World::GetProfile
const b2Profile & GetProfile() const
Get the current profile.
Definition: b2_world.h:340
b2Vec2
A 2D column vector.
Definition: b2_math.h:41
Settings::m_velocityIterations
int m_velocityIterations
Definition: settings.h:65
b2Body::SetLinearVelocity
void SetLinearVelocity(const b2Vec2 &v)
Definition: b2_body.h:504
Settings::m_singleStep
bool m_singleStep
Definition: settings.h:82
DestructionListener::SayGoodbye
void SayGoodbye(b2Fixture *fixture) override
Definition: test.h:60
f
f
Test::MouseMove
virtual void MouseMove(const b2Vec2 &p)
Definition: test.cpp:228
Settings::m_drawContactNormals
bool m_drawContactNormals
Definition: settings.h:71
b2World::Step
void Step(float timeStep, int32 velocityIterations, int32 positionIterations)
Definition: b2_world.cpp:905
b2Max
T b2Max(T a, T b)
Definition: b2_math.h:637
test
Test::Test
Test()
Definition: test.cpp:39
Settings::m_positionIterations
int m_positionIterations
Definition: settings.h:66
QueryCallback::ReportFixture
bool ReportFixture(b2Fixture *fixture) override
Definition: test.cpp:121
b2PointState
b2PointState
This is used for determining the state of contact points.
Definition: b2_collision.h:132
b2World::GetJointCount
int32 GetJointCount() const
Get the number of joints.
Definition: b2_world.h:299
ContactPoint
Definition: test.h:68
b2BodyDef::type
b2BodyType type
Definition: b2_body.h:74
b2Contact::GetWorldManifold
void GetWorldManifold(b2WorldManifold *worldManifold) const
Get the world manifold.
Definition: b2_contact.h:254
b2WorldManifold::normal
b2Vec2 normal
world vector pointing from A to B
Definition: b2_collision.h:126
b2WorldManifold::points
b2Vec2 points[b2_maxManifoldPoints]
world contact point (point of intersection)
Definition: b2_collision.h:127
b2Draw::e_centerOfMassBit
@ e_centerOfMassBit
draw center of mass frame
Definition: b2_draw.h:61
b2Manifold::pointCount
int32 pointCount
the number of manifold points
Definition: b2_collision.h:112
b2World::GetProxyCount
int32 GetProxyCount() const
Get the number of broad-phase proxies.
Definition: b2_world.cpp:1217
b2Joint
Definition: b2_joint.h:110
b2World::CreateJoint
b2Joint * CreateJoint(const b2JointDef *def)
Definition: b2_world.cpp:220
b2MouseJointDef::target
b2Vec2 target
Definition: b2_mouse_joint.h:44
Test::~Test
virtual ~Test()
Definition: test.cpp:66
ContactPoint::separation
float separation
Definition: test.h:77
b2FixtureDef::restitution
float restitution
The restitution (elasticity) usually in the range [0,1].
Definition: b2_fixture.h:85
Test::m_groundBody
b2Body * m_groundBody
Definition: test.h:122
b2ManifoldPoint::tangentImpulse
float tangentImpulse
the friction impulse
Definition: b2_collision.h:79
b2Contact
Definition: b2_contact.h:88
b2_maxManifoldPoints
#define b2_maxManifoldPoints
Definition: b2_common.h:51
ContactPoint::normal
b2Vec2 normal
Definition: test.h:72
Settings::m_drawJoints
bool m_drawJoints
Definition: settings.h:68
b2_dynamicBody
@ b2_dynamicBody
Definition: b2_body.h:47
DebugDraw::DrawString
void DrawString(int x, int y, const char *string,...)
Definition: draw.cpp:772
k_maxContactPoints
const int32 k_maxContactPoints
Definition: test.h:66
Test::CompleteBombSpawn
void CompleteBombSpawn(const b2Vec2 &p)
Definition: test.cpp:188
b2World::GetContactCount
int32 GetContactCount() const
Get the number of contacts (each may have 0 or more contact points).
Definition: b2_world.h:304
b2World::ShiftOrigin
void ShiftOrigin(const b2Vec2 &newOrigin)
Definition: b2_world.cpp:1237
b2Profile::solveTOI
float solveTOI
Definition: b2_time_step.h:38
b2Shape::m_radius
float m_radius
Definition: b2_shape.h:102
Settings::m_enableWarmStarting
bool m_enableWarmStarting
Definition: settings.h:77
Test::m_maxProfile
b2Profile m_maxProfile
Definition: test.h:136
Settings::m_hertz
float m_hertz
Definition: settings.h:64
b2Fixture
Definition: b2_fixture.h:116
b2Color
Color for debug drawing. Each value has the range [0,1].
Definition: b2_draw.h:30
b2ManifoldPoint::normalImpulse
float normalImpulse
the non-penetration impulse
Definition: b2_collision.h:78
d
d
RandomFloat
float RandomFloat()
Random number in range [-1,1].
Definition: test.h:37
b2MouseJointDef
Definition: b2_mouse_joint.h:31
b2Draw::e_jointBit
@ e_jointBit
draw joint connections
Definition: b2_draw.h:58
DestructionListener::test
Test * test
Definition: test.h:63
b2FixtureDef::density
float density
The density, usually in kg/m^2.
Definition: b2_fixture.h:92
b2Profile::solvePosition
float solvePosition
Definition: b2_time_step.h:36
test.h
Test::DrawTitle
void DrawTitle(const char *string)
Definition: test.cpp:106
b2GetPointStates
B2_API void b2GetPointStates(b2PointState state1[b2_maxManifoldPoints], b2PointState state2[b2_maxManifoldPoints], const b2Manifold *manifold1, const b2Manifold *manifold2)
Definition: b2_collision.cpp:92
Test::m_pointCount
int32 m_pointCount
Definition: test.h:125
Test::m_bombSpawnPoint
b2Vec2 m_bombSpawnPoint
Definition: test.h:131
b2World::GetTreeBalance
int32 GetTreeBalance() const
Get the balance of the dynamic tree.
Definition: b2_world.cpp:1227
Test::LaunchBomb
void LaunchBomb()
Definition: test.cpp:238
b2BodyDef
Definition: b2_body.h:52
b2WorldManifold
This is used to compute the current state of a contact manifold.
Definition: b2_collision.h:116
QueryCallback::m_fixture
b2Fixture * m_fixture
Definition: test.cpp:141
Settings::m_pause
bool m_pause
Definition: settings.h:81
DebugDraw::DrawPoint
void DrawPoint(const b2Vec2 &p, float size, const b2Color &color) override
Draw a point.
Definition: draw.cpp:766
Settings
Definition: settings.h:25
b2FixtureDef::shape
const b2Shape * shape
Definition: b2_fixture.h:76
g_testCount
int g_testCount
Definition: test.cpp:456
ContactPoint::fixtureA
b2Fixture * fixtureA
Definition: test.h:70
QueryCallback::QueryCallback
QueryCallback(const b2Vec2 &point)
Definition: test.cpp:115
b2Manifold
Definition: b2_collision.h:99
b2MouseJointDef::stiffness
float stiffness
The linear stiffness in N/m.
Definition: b2_mouse_joint.h:52
g_testEntries
TestEntry g_testEntries[MAX_TESTS]
Definition: test.cpp:455
Settings::m_drawProfile
bool m_drawProfile
Definition: settings.h:76
ContactPoint::fixtureB
b2Fixture * fixtureB
Definition: test.h:71
b2Profile::step
float step
Definition: b2_time_step.h:31
b2AABB
An axis aligned bounding box.
Definition: b2_collision.h:168
b2World::CreateBody
b2Body * CreateBody(const b2BodyDef *def)
Definition: b2_world.cpp:115
b2World::SetWarmStarting
void SetWarmStarting(bool flag)
Enable/disable warm starting. For testing.
Definition: b2_world.h:154
RegisterTest
int RegisterTest(const char *category, const char *name, TestCreateFcn *fcn)
Definition: test.cpp:458
b2Contact::GetManifold
b2Manifold * GetManifold()
Definition: b2_contact.h:244
Test::m_textLine
int32 m_textLine
Definition: test.h:127
b2Profile
Profiling data. Times are in milliseconds.
Definition: b2_time_step.h:29
b2World::DestroyBody
void DestroyBody(b2Body *body)
Definition: b2_world.cpp:139
b2Contact::GetFixtureB
b2Fixture * GetFixtureB()
Get fixture B in this contact.
Definition: b2_contact.h:306
b2Profile::solveInit
float solveInit
Definition: b2_time_step.h:34
Test::PreSolve
virtual void PreSolve(b2Contact *contact, const b2Manifold *oldManifold) override
Definition: test.cpp:73
Settings::m_drawAABBs
bool m_drawAABBs
Definition: settings.h:69
b2MouseJointDef::maxForce
float maxForce
Definition: b2_mouse_joint.h:49
b2Draw::e_aabbBit
@ e_aabbBit
draw axis aligned bounding boxes
Definition: b2_draw.h:59
Test::SpawnBomb
void SpawnBomb(const b2Vec2 &worldPt)
Definition: test.cpp:182
b2World::SetContactListener
void SetContactListener(b2ContactListener *listener)
Definition: b2_world.cpp:105
Settings::m_enableContinuous
bool m_enableContinuous
Definition: settings.h:78
int32
signed int int32
Definition: b2_types.h:28
b2World::GetTreeHeight
int32 GetTreeHeight() const
Get the height of the dynamic tree.
Definition: b2_world.cpp:1222
b2BodyDef::position
b2Vec2 position
Definition: b2_body.h:78
Test::m_totalProfile
b2Profile m_totalProfile
Definition: test.h:137
b2World
Definition: b2_world.h:46
b2WorldManifold::separations
float separations[b2_maxManifoldPoints]
a negative value indicates overlap, in meters
Definition: b2_collision.h:128
Test::m_bombSpawning
bool m_bombSpawning
Definition: test.h:132
b2Profile::collide
float collide
Definition: b2_time_step.h:32
b2Manifold::points
b2ManifoldPoint points[b2_maxManifoldPoints]
the points of contact
Definition: b2_collision.h:108
b2World::SetDestructionListener
void SetDestructionListener(b2DestructionListener *listener)
Definition: b2_world.cpp:95
b2Draw::SetFlags
void SetFlags(uint32 flags)
Set the drawing flags.
Definition: b2_draw.cpp:29
Test::Step
virtual void Step(Settings &settings)
Definition: test.cpp:278
b2Body::GetMass
float GetMass() const
Definition: b2_body.h:544
b2MouseJoint
Definition: b2_mouse_joint.h:65
Test::m_mouseJoint
b2MouseJoint * m_mouseJoint
Definition: test.h:130
b2Fixture::GetBody
b2Body * GetBody()
Definition: b2_fixture.h:283
b2QueryCallback
Definition: b2_world_callbacks.h:128
QueryCallback
Definition: test.cpp:112
DebugDraw::Flush
void Flush()
Definition: draw.cpp:824
b2JointDef::bodyA
b2Body * bodyA
The first attached body.
Definition: b2_joint.h:89
Test::m_world
b2World * m_world
Definition: test.h:128
b2AABB::lowerBound
b2Vec2 lowerBound
the lower vertex
Definition: b2_collision.h:220
ContactPoint::state
b2PointState state
Definition: test.h:74
QueryCallback::m_point
b2Vec2 m_point
Definition: test.cpp:140
b2World::SetAllowSleeping
void SetAllowSleeping(bool flag)
Enable/disable sleep.
Definition: b2_world.cpp:376
b2Contact::GetFixtureA
b2Fixture * GetFixtureA()
Get fixture A in this contact.
Definition: b2_contact.h:296
b2World::SetContinuousPhysics
void SetContinuousPhysics(bool flag)
Enable/disable continuous physics. For testing.
Definition: b2_world.h:158
b2Color::Set
void Set(float rIn, float gIn, float bIn, float aIn=1.0f)
Definition: b2_draw.h:38
Test::MouseUp
virtual void MouseUp(const b2Vec2 &p)
Definition: test.cpp:214
b2Body::CreateFixture
b2Fixture * CreateFixture(const b2FixtureDef *def)
Definition: b2_body.cpp:165
b2World::GetTreeQuality
float GetTreeQuality() const
Definition: b2_world.cpp:1232
b2JointDef::bodyB
b2Body * bodyB
The second attached body.
Definition: b2_joint.h:92


mvsim
Author(s):
autogenerated on Wed May 28 2025 02:13:08