Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
Body2D Struct Reference

Structure representing a 2D physics body. More...

#include <body_2d.h>

Static Public Member Functions

static struct Body2DTransform get_body_transform (const Body2D &body)
 Retrieves the transform of the specified body.
 
static struct Body2DTransform get_pixel_transform (const Body2D &body)
 Retrieves the pixel transform 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_type (const Body2D &body, BodyType2D::Type type)
 Sets the type of the specified body.
 
static void set_body_gravity_scale (const Body2D &body, float scale)
 Sets the size of the specified body.
 
static void set_body_mass (const Body2D &body, float mass)
 Sets the mass of 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_radius (const Body2D &body, float radius, Point offset)
 Sets the radius 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_friction (const Body2D &body, float friction, ShapeType2D::Type type)
 Sets the friction of the specified body for a given shape type.
 
static void set_body_velocity (const Body2D &body, const Vector3 &velocity) noexcept
 Sets the 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 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.
 

Public Attributes

b2BodyId id {}
 
std::vector< Shape2Dshapes
 

Detailed Description

Structure representing a 2D physics body.

Includes the body ID and associated shapes.

Member Function Documentation

◆ apply_force()

static void Body2D::apply_force ( const Body2D body,
const Vector3 force 
)
staticnoexcept

Applies a force to the specified body.

Parameters
bodyThe Body2D instance to apply the force to.
forceThe force vector to apply.

◆ apply_impulse()

static void Body2D::apply_impulse ( const Body2D body,
const Vector3 impulse 
)
staticnoexcept

Applies an impulse to the specified body.

Parameters
bodyThe Body2D instance to apply the impulse to.
impulseThe impulse vector to apply.

◆ get_body_transform()

static struct Body2DTransform Body2D::get_body_transform ( const Body2D body)
static

Retrieves the transform of the specified body.

Parameters
bodyThe Body2D instance to get the transform for.
Returns
Body2DTransform The transform of the body.

◆ get_body_velocity()

static Vector3 Body2D::get_body_velocity ( const Body2D body)
staticnoexcept

Retrieves the current velocity of the specified body.

Parameters
bodyThe Body2D instance to get the velocity for.
Returns
Vector3 The current velocity vector.

◆ get_pixel_transform()

static struct Body2DTransform Body2D::get_pixel_transform ( const Body2D body)
static

Retrieves the pixel transform of the specified body.

Parameters
bodyThe Body2D instance to get the local transform for.
Returns
Body2DTransform The local transform of the body.

◆ set_body_bounciness()

static void Body2D::set_body_bounciness ( const Body2D body,
float  bounciness,
ShapeType2D::Type  type 
)
static

Sets the bounciness of the specified body for a given shape type.

Parameters
bodyThe Body2D instance to set the bounciness for.
bouncinessThe new bounciness value.
typeThe ShapeType2D::Type to apply the bounciness to.

◆ set_body_friction()

static void Body2D::set_body_friction ( const Body2D body,
float  friction,
ShapeType2D::Type  type 
)
static

Sets the friction of the specified body for a given shape type.

Parameters
bodyThe Body2D instance to set the friction for.
frictionThe new friction value.
typeThe ShapeType2D::Type to apply the friction to.

◆ set_body_gravity_scale()

static void Body2D::set_body_gravity_scale ( const Body2D body,
float  scale 
)
static

Sets the size of the specified body.

Parameters
bodyThe Body2D instance to set the size for.
sizeThe new size as a Vector3.

◆ set_body_mass()

static void Body2D::set_body_mass ( const Body2D body,
float  mass 
)
static

Sets the mass of the specified body.

Parameters
bodyThe Body2D instance to set the mass for.
massThe new mass value.

◆ set_body_radius()

static void Body2D::set_body_radius ( const Body2D body,
float  radius,
Point  offset 
)
static

Sets the radius of the specified body.

Parameters
bodyThe Body2D instance to set the radius for.
radiusThe new radius value.

◆ set_body_size()

static void Body2D::set_body_size ( const Body2D body,
const Vector3 size,
Point  offset 
)
static

Sets the size of the specified body.

Parameters
bodyThe Body2D instance to set the size for.
sizeThe new size as a Vector3.

◆ set_body_transform()

static void Body2D::set_body_transform ( const struct Body2DTransform transform,
bool  in_pixels = false 
)
static

Sets the transform of the specified body.

Parameters
transformThe Body2DTransform instance containing the new transform data.
in_pixelsWhether the provided transform is in pixels (true) or Box2D units (false).

◆ set_body_type()

static void Body2D::set_body_type ( const Body2D body,
BodyType2D::Type  type 
)
static

Sets the type of the specified body.

Parameters
bodyThe Body2D instance to set the type for.
typeThe BodyType2D::Type to set.

◆ set_body_velocity()

static void Body2D::set_body_velocity ( const Body2D body,
const Vector3 velocity 
)
staticnoexcept

Sets the velocity of the specified body.

Parameters
bodyThe Body2D instance to set the velocity for.
velocityThe new velocity vector.

Member Data Documentation

◆ id

b2BodyId Body2D::id {}

◆ shapes

std::vector<Shape2D> Body2D::shapes

The documentation for this struct was generated from the following file: