132 m_points[m_count] = point;
133 m_normals[m_count] = normal;
136 if (m_count == e_maxCount)
169 b2Body* ground = m_world->CreateBody(&bd);
178 vertices[0].
Set(-0.5
f, 0.0
f);
179 vertices[1].
Set(0.5
f, 0.0
f);
180 vertices[2].
Set(0.0
f, 1.5
f);
181 m_polygons[0].Set(vertices, 3);
186 vertices[0].
Set(-0.1
f, 0.0
f);
187 vertices[1].
Set(0.1
f, 0.0
f);
188 vertices[2].
Set(0.0
f, 1.5
f);
189 m_polygons[1].Set(vertices, 3);
194 float b = w / (2.0f +
b2Sqrt(2.0
f));
198 vertices[0].
Set(0.5
f * s, 0.0
f);
199 vertices[1].
Set(0.5
f * w, b);
200 vertices[2].
Set(0.5
f * w, b + s);
201 vertices[3].
Set(0.5
f * s, w);
202 vertices[4].
Set(-0.5
f * s, w);
203 vertices[5].
Set(-0.5
f * w, b + s);
204 vertices[6].
Set(-0.5
f * w, b);
205 vertices[7].
Set(-0.5
f * s, 0.0
f);
207 m_polygons[2].Set(vertices, 8);
211 m_polygons[3].SetAsBox(0.5
f, 0.5
f);
215 m_circle.m_radius = 0.5f;
223 memset(m_bodies, 0,
sizeof(m_bodies));
232 if (m_bodies[m_bodyIndex] != NULL)
234 m_world->DestroyBody(m_bodies[m_bodyIndex]);
235 m_bodies[m_bodyIndex] = NULL;
250 m_bodies[m_bodyIndex] = m_world->CreateBody(&bd);
255 fd.
shape = m_polygons + index;
258 m_bodies[m_bodyIndex]->CreateFixture(&fd);
263 fd.
shape = &m_circle;
266 m_bodies[m_bodyIndex]->CreateFixture(&fd);
275 m_bodies[m_bodyIndex]->CreateFixture(&fd);
285 if (m_bodies[i] != NULL)
287 m_world->DestroyBody(m_bodies[i]);
349 m_textLine += m_textIncrement;
353 g_debugDraw.
DrawString(5, m_textLine,
"Ray-cast mode: closest - find closest fixture along the ray");
365 m_textLine += m_textIncrement;
370 b2Vec2 d(L * cosf(angle), L * sinf(angle));
371 b2Vec2 point2 = point1 + d;
373 if (m_mode == e_closest)
376 m_world->RayCast(&callback, point1, point2);
390 else if (m_mode == e_any)
393 m_world->RayCast(&callback, point1, point2);
407 else if (m_mode == e_multiple)
410 m_world->RayCast(&callback, point1, point2);
419 b2Vec2 head = p + 0.5f * n;
438 input.
p1.
Set(10.2725
f,1.71372
f);
439 input.
p2.
Set(10.2353
f,2.21807
f);
445 xf.position.
Set(23.0
f, 5.0
f);
449 hit = shape.
RayCast(&output, input, xf);
454 for (
int32 i = 0; i < 4; ++i)
IMGUI_API void SetNextWindowSize(const ImVec2 &size, ImGuiCond cond=0)
IMGUI_API bool RadioButton(const char *label, bool active)
b2Fixture * CreateFixture(const b2FixtureDef *def)
b2Vec2 b2Mul(const b2Mat22 &A, const b2Vec2 &v)
TF2SIMD_FORCE_INLINE tf2Scalar angle(const Quaternion &q1, const Quaternion &q2)
void DrawPoint(const b2Vec2 &p, float size, const b2Color &color) override
Draw a point.
b2FixtureUserData & GetUserData()
float RandomFloat()
Random number in range [-1,1].
void DrawPolygon(const b2Vec2 *vertices, int32 vertexCount, const b2Color &color) override
Draw a closed polygon provided in CCW order.
bool RayCast(b2RayCastOutput *output, const b2RayCastInput &input, const b2Transform &transform, int32 childIndex) const override
void SetTwoSided(const b2Vec2 &v1, const b2Vec2 &v2)
Set this as an isolated edge. Collision is two-sided.
Color for debug drawing. Each value has the range [0,1].
void SetAsBox(float hx, float hy)
float ReportFixture(b2Fixture *fixture, const b2Vec2 &point, const b2Vec2 &normal, float) override
IMGUI_API bool Begin(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
A rigid body. These are created via b2World::CreateBody.
b2Vec2 m_normals[e_maxCount]
void Step(Settings &settings) override
void Set(float x_, float y_)
Set this vector to some specified coordinates.
b2FixtureUserData userData
Use this to store application specific fixture data.
b2Vec2 m_vertices[b2_maxPolygonVertices]
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
uintptr_t pointer
For legacy compatibility.
float angle
The world angle of the body in radians.
IMGUI_API void SetNextWindowPos(const ImVec2 &pos, ImGuiCond cond=0, const ImVec2 &pivot=ImVec2(0, 0))
RayCastMultipleCallback()
IMGUI_API bool SliderFloat(const char *label, float *v, float v_min, float v_max, const char *format="%.3f", float power=1.0f)
int RegisterTest(const char *category, const char *name, TestCreateFcn *fcn)
void DrawString(int x, int y, const char *string,...)
float ReportFixture(b2Fixture *fixture, const b2Vec2 &point, const b2Vec2 &normal, float fraction) override
virtual void Step(Settings &settings)
b2Vec2 m_points[e_maxCount]
void DrawSegment(const b2Vec2 &p1, const b2Vec2 &p2, const b2Color &color) override
Draw a line segment.
float friction
The friction coefficient, usually in the range [0,1].
float ReportFixture(b2Fixture *fixture, const b2Vec2 &point, const b2Vec2 &normal, float) override