Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
body_2d.h
Go to the documentation of this file.
1#pragma once
2
3#include <box2d/box2d.h>
8
9#include <vector>
10
16struct Shape2D {
17 b2ShapeId id{};
18 b2ShapeType type{};
19};
20
26struct Body2D {
27 b2BodyId id{};
28 std::vector<Shape2D> shapes;
29
36 static struct Body2DTransform get_body_transform(const Body2D& body);
37
44 static struct Body2DTransform get_pixel_transform(const Body2D& body);
45
54 static void set_body_transform(const struct Body2DTransform& transform,
55 bool in_pixels = false);
56
62 static void set_body_type(const Body2D& body, BodyType2D::Type type);
63
69 static void set_body_gravity_scale(const Body2D& body, float scale);
70
76 static void set_body_mass(const Body2D& body, float mass);
77
83 static void set_body_size(const Body2D& body, const Vector3& size,
84 Point offset);
85
91 static void set_body_radius(const Body2D& body, float radius, Point offset);
92
99 static void set_body_bounciness(const Body2D& body, float bounciness,
100 ShapeType2D::Type type);
101
108 static void set_body_friction(const Body2D& body, float friction,
109 ShapeType2D::Type type);
110
116 static void set_body_velocity(const Body2D& body,
117 const Vector3& velocity) noexcept;
118
124 static void apply_force(const Body2D& body, const Vector3& force) noexcept;
125
131 static void apply_impulse(const Body2D& body,
132 const Vector3& impulse) noexcept;
133
139 static Vector3 get_body_velocity(const Body2D& body) noexcept;
140};
141
Represents a point in 2D space.
Definition point.h:6
Represents a 3D vector with x, y, and z components. This class provides basic vector operations such ...
Definition vector3.h:8
Structure representing a 2D physics body.
Definition body_2d.h:26
static void set_body_type(const Body2D &body, BodyType2D::Type type)
Sets the type of the specified body.
static void set_body_mass(const Body2D &body, float mass)
Sets the mass of the specified body.
static struct Body2DTransform get_body_transform(const Body2D &body)
Retrieves the transform of the specified body.
static void set_body_velocity(const Body2D &body, const Vector3 &velocity) noexcept
Sets the velocity of the specified body.
static void set_body_transform(const struct Body2DTransform &transform, bool in_pixels=false)
Sets the transform of the specified body.
static void set_body_gravity_scale(const Body2D &body, float scale)
Sets the size of the specified body.
static void apply_impulse(const Body2D &body, const Vector3 &impulse) noexcept
Applies an impulse to the specified body.
static Vector3 get_body_velocity(const Body2D &body) noexcept
Retrieves the current velocity of the specified body.
static void apply_force(const Body2D &body, const Vector3 &force) noexcept
Applies a force to the specified body.
static void set_body_size(const Body2D &body, const Vector3 &size, Point offset)
Sets the size of the specified body.
static void set_body_friction(const Body2D &body, float friction, ShapeType2D::Type type)
Sets the friction of the specified body for a given shape type.
static struct Body2DTransform get_pixel_transform(const Body2D &body)
Retrieves the pixel transform of the specified body.
static void set_body_bounciness(const Body2D &body, float bounciness, ShapeType2D::Type type)
Sets the bounciness of the specified body for a given shape type.
static void set_body_radius(const Body2D &body, float radius, Point offset)
Sets the radius of the specified body.
std::vector< Shape2D > shapes
Definition body_2d.h:28
Structure representing the transform of a 2D physics body.
Definition body_2d.h:147
Body2D body
Definition body_2d.h:148
Vector3 center_of_mass
Definition body_2d.h:151
float rotation
Definition body_2d.h:150
Vector3 position
Definition body_2d.h:149
Type
Definition body_type_2d.h:14
Structure representing a 2D physics shape.
Definition body_2d.h:16
b2ShapeType type
Definition body_2d.h:18
Type
Definition shape_type_2d.h:14