box2d 3.0.0
A 2D physics engine for games
 
Loading...
Searching...
No Matches
geometry.h
1// SPDX-FileCopyrightText: 2023 Erin Catto
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
6#include "box2d/api.h"
7#include "box2d/constants.h"
8#include "box2d/types.h"
9
10typedef struct b2Hull b2Hull;
11typedef struct b2CastOutput b2RayCastOutput;
12typedef struct b2RayCastInput b2RayCastInput;
13
15typedef struct b2MassData
16{
18 float mass;
19
22
24 float I;
25
27
29 float minExtent;
30
32 float maxExtent;
34
36typedef struct b2Circle
37{
38 b2Vec2 point;
39 float radius;
40} b2Circle;
41
43typedef struct b2Capsule
44{
45 b2Vec2 point1, point2;
46 float radius;
47} b2Capsule;
48
55typedef struct b2Polygon
56{
59 b2Vec2 centroid;
60 float radius;
61 int32_t count;
62} b2Polygon;
63
65typedef struct b2Segment
66{
67 b2Vec2 point1, point2;
68} b2Segment;
69
84
86BOX2D_API bool b2IsValidRay(const b2RayCastInput* input);
87
89BOX2D_API b2Polygon b2MakePolygon(const b2Hull* hull, float radius);
90
92BOX2D_API b2Polygon b2MakeOffsetPolygon(const b2Hull* hull, float radius, b2Transform transform);
93
95BOX2D_API b2Polygon b2MakeSquare(float h);
96
98BOX2D_API b2Polygon b2MakeBox(float hx, float hy);
99
101BOX2D_API b2Polygon b2MakeRoundedBox(float hx, float hy, float radius);
102
104BOX2D_API b2Polygon b2MakeOffsetBox(float hx, float hy, b2Vec2 center, float angle);
105
107BOX2D_API b2Polygon b2TransformPolygon(b2Transform transform, const b2Polygon* polygon);
108
110BOX2D_API b2MassData b2ComputeCircleMass(const b2Circle* shape, float density);
111
113BOX2D_API b2MassData b2ComputeCapsuleMass(const b2Capsule* shape, float density);
114
116BOX2D_API b2MassData b2ComputePolygonMass(const b2Polygon* shape, float density);
117
119BOX2D_API b2AABB b2ComputeCircleAABB(const b2Circle* shape, b2Transform transform);
120
122BOX2D_API b2AABB b2ComputeCapsuleAABB(const b2Capsule* shape, b2Transform transform);
123
125BOX2D_API b2AABB b2ComputePolygonAABB(const b2Polygon* shape, b2Transform transform);
126
128BOX2D_API b2AABB b2ComputeSegmentAABB(const b2Segment* shape, b2Transform transform);
129
131BOX2D_API bool b2PointInCircle(b2Vec2 point, const b2Circle* shape);
132
134BOX2D_API bool b2PointInCapsule(b2Vec2 point, const b2Capsule* shape);
135
137BOX2D_API bool b2PointInPolygon(b2Vec2 point, const b2Polygon* shape);
138
140BOX2D_API b2RayCastOutput b2RayCastCircle(const b2RayCastInput* input, const b2Circle* shape);
141
143BOX2D_API b2RayCastOutput b2RayCastCapsule(const b2RayCastInput* input, const b2Capsule* shape);
144
147BOX2D_API b2RayCastOutput b2RayCastSegment(const b2RayCastInput* input, const b2Segment* shape, bool oneSided);
148
150BOX2D_API b2RayCastOutput b2RayCastPolygon(const b2RayCastInput* input, const b2Polygon* shape);
151
153BOX2D_API b2RayCastOutput b2ShapeCastCircle(const b2ShapeCastInput* input, const b2Circle* shape);
154
156BOX2D_API b2RayCastOutput b2ShapeCastCapsule(const b2ShapeCastInput* input, const b2Capsule* shape);
157
159BOX2D_API b2RayCastOutput b2ShapeCastSegment(const b2ShapeCastInput* input, const b2Segment* shape);
160
162BOX2D_API b2RayCastOutput b2ShapeCastPolygon(const b2ShapeCastInput* input, const b2Polygon* shape);
#define b2_maxPolygonVertices
Definition constants.h:47
A solid capsule.
Definition geometry.h:44
A solid circle.
Definition geometry.h:37
A convex hull. Used to create convex polygons.
Definition hull.h:12
This holds the mass data computed for a shape.
Definition geometry.h:16
b2Vec2 center
The position of the shape's centroid relative to the shape's origin.
Definition geometry.h:21
float mass
The mass of the shape, usually in kilograms.
Definition geometry.h:18
float minExtent
TODO_ERIN remove geometry info from this.
Definition geometry.h:29
float maxExtent
Distance from shape origin to furthest point on perimeter.
Definition geometry.h:32
float I
The rotational inertia of the shape about the local origin.
Definition geometry.h:24
Definition geometry.h:56
A line segment with two-sided collision.
Definition geometry.h:66
Definition geometry.h:74
b2Vec2 ghost2
The head ghost vertex.
Definition geometry.h:82
b2Segment segment
The line segment.
Definition geometry.h:79
b2Vec2 ghost1
The tail ghost vertex.
Definition geometry.h:76
types used by the Box2D API
Axis-aligned bounding box.
Definition types.h:75
Low level ray-cast input data.
Definition types.h:82
Low level ray-cast or shape-cast output data.
Definition types.h:99
Low level hape cast input in generic form.
Definition types.h:89
A 2D rigid transform.
Definition types.h:61
Definition types.h:47