Fx2D
A C++20 2D rigid-body physics engine
Loading...
Searching...
No Matches
FxShape Struct Reference

Unified circle, capsule, polygon, edge, and chain representation. More...

#include <Geometry.h>

+ Inheritance diagram for FxShape:
+ Collaboration diagram for FxShape:

Classes

struct  ChainTag
 

Public Member Functions

 FxShape ()
 
 FxShape (float radius)
 
 FxShape (float length, float radius)
 
 FxShape (const FxVec2f &a, const FxVec2f &b)
 
 FxShape (const FxVec2fArray &points, ChainTag)
 
 FxShape (const FxVec2fArray &vertices, float skin_radius=0.0f)
 
 FxShape (const FxVec2f &size, float skin_radius=0.0f)
 
FxShapeType shape_type () const
 
float radius () const
 
float skin_radius () const
 
const FxVec2fArray & vertices () const
 
FxVec2fArray __vertices () const
 
FxVec2f centroid () const
 
bool is_circle () const
 
bool is_capsule () const
 
bool is_polygon () const
 
bool is_chain () const
 
std::size_t segment_count () const
 
FxShape segment (std::size_t i) const
 
bool is_edge () const
 
bool contains (const FxVec2f &p) const
 
float area () const
 
float calc_inertia (float mass) const
 
void set_offset_pose (const FxVec3f &o_pose)
 
FxVec3f offset_pose () const
 
FxArray< float > set_world_pose (const FxVec3f &world_pose)
 
void set_world_pose (const FxVec3f &world_pose, FxArray< float > &out_aabb)
 
FxVec3f world_pose () const
 
void set_position (const FxVec2f &pos)
 
void set_rotation (float theta)
 
void move (const FxVec2f &delta)
 
void rotate (float delta_theta)
 
std::pair< std::size_t, float > min_projection (const FxVec2f &axis, const FxVec2f &origin) const
 
FxVec2f get_closest_vertex (const FxVec2f &point) const
 

Static Public Member Functions

static float polygon_area (const FxVec2fArray &verts)
 
static FxShape make_chain (const FxVec2fArray &points)
 

Static Protected Member Functions

static float calc_radius (const FxVec2fArray &verts)
 
static bool is_convex (const FxVec2fArray &verts)
 

Protected Attributes

FxShapeType m_shape_type
 
float m_radius
 
float m_skin_radius = 0.0f
 
FxVec2fArray m_vertices
 
FxVec3f m_offset_pose {0.0f, 0.0f, 0.0f}
 
FxVec3f m_world_pose {0.0f, 0.0f, 0.0f}
 
FxVec2f m_centroid {0.0f, 0.0f}
 
FxVec2fArray m_world_vertices
 

Detailed Description

Unified circle, capsule, polygon, edge, and chain representation.

Definition at line 46 of file Geometry.h.

Constructor & Destructor Documentation

◆ FxShape() [1/7]

FxShape::FxShape ( )
inline

Definition at line 86 of file Geometry.h.

◆ FxShape() [2/7]

FxShape::FxShape ( float  radius)
inline

Definition at line 89 of file Geometry.h.

◆ FxShape() [3/7]

FxShape::FxShape ( float  length,
float  radius 
)
inline

Definition at line 98 of file Geometry.h.

◆ FxShape() [4/7]

FxShape::FxShape ( const FxVec2f &  a,
const FxVec2f &  b 
)
inline

Definition at line 114 of file Geometry.h.

◆ FxShape() [5/7]

FxShape::FxShape ( const FxVec2fArray &  points,
ChainTag   
)
inline

Definition at line 128 of file Geometry.h.

◆ FxShape() [6/7]

FxShape::FxShape ( const FxVec2fArray &  vertices,
float  skin_radius = 0.0f 
)
inline

Definition at line 143 of file Geometry.h.

◆ FxShape() [7/7]

FxShape::FxShape ( const FxVec2f &  size,
float  skin_radius = 0.0f 
)
inline

Definition at line 163 of file Geometry.h.

Member Function Documentation

◆ __vertices()

FxVec2fArray FxShape::__vertices ( ) const
inline

Definition at line 198 of file Geometry.h.

◆ area()

float FxShape::area ( ) const
inline

Definition at line 252 of file Geometry.h.

◆ calc_inertia()

float FxShape::calc_inertia ( float  mass) const
inline

Definition at line 277 of file Geometry.h.

◆ calc_radius()

static float FxShape::calc_radius ( const FxVec2fArray &  verts)
inlinestaticprotected

Definition at line 58 of file Geometry.h.

◆ centroid()

FxVec2f FxShape::centroid ( ) const
inline

Definition at line 201 of file Geometry.h.

◆ contains()

bool FxShape::contains ( const FxVec2f &  p) const
inline

Definition at line 227 of file Geometry.h.

◆ get_closest_vertex()

FxVec2f FxShape::get_closest_vertex ( const FxVec2f &  point) const
inline

Definition at line 445 of file Geometry.h.

◆ is_capsule()

bool FxShape::is_capsule ( ) const
inline

Definition at line 206 of file Geometry.h.

◆ is_chain()

bool FxShape::is_chain ( ) const
inline

Definition at line 213 of file Geometry.h.

◆ is_circle()

bool FxShape::is_circle ( ) const
inline

Definition at line 204 of file Geometry.h.

◆ is_convex()

static bool FxShape::is_convex ( const FxVec2fArray &  verts)
inlinestaticprotected

Definition at line 69 of file Geometry.h.

◆ is_edge()

bool FxShape::is_edge ( ) const
inline

Definition at line 224 of file Geometry.h.

◆ is_polygon()

bool FxShape::is_polygon ( ) const
inline

Definition at line 208 of file Geometry.h.

◆ make_chain()

static FxShape FxShape::make_chain ( const FxVec2fArray &  points)
inlinestatic

Definition at line 211 of file Geometry.h.

◆ min_projection()

std::pair< std::size_t, float > FxShape::min_projection ( const FxVec2f &  axis,
const FxVec2f &  origin 
) const
inline

Definition at line 418 of file Geometry.h.

◆ move()

void FxShape::move ( const FxVec2f &  delta)
inline

Definition at line 404 of file Geometry.h.

◆ offset_pose()

FxVec3f FxShape::offset_pose ( ) const
inline

Definition at line 332 of file Geometry.h.

◆ polygon_area()

static float FxShape::polygon_area ( const FxVec2fArray &  verts)
inlinestatic

Definition at line 180 of file Geometry.h.

◆ radius()

float FxShape::radius ( ) const
inline

Definition at line 193 of file Geometry.h.

◆ rotate()

void FxShape::rotate ( float  delta_theta)
inline

Definition at line 410 of file Geometry.h.

◆ segment()

FxShape FxShape::segment ( std::size_t  i) const
inline

Definition at line 219 of file Geometry.h.

◆ segment_count()

std::size_t FxShape::segment_count ( ) const
inline

Definition at line 216 of file Geometry.h.

◆ set_offset_pose()

void FxShape::set_offset_pose ( const FxVec3f &  o_pose)
inline

Definition at line 331 of file Geometry.h.

◆ set_position()

void FxShape::set_position ( const FxVec2f &  pos)
inline

Definition at line 392 of file Geometry.h.

◆ set_rotation()

void FxShape::set_rotation ( float  theta)
inline

Definition at line 398 of file Geometry.h.

◆ set_world_pose() [1/2]

FxArray< float > FxShape::set_world_pose ( const FxVec3f &  world_pose)
inline

Definition at line 335 of file Geometry.h.

◆ set_world_pose() [2/2]

void FxShape::set_world_pose ( const FxVec3f &  world_pose,
FxArray< float > &  out_aabb 
)
inline

Definition at line 344 of file Geometry.h.

◆ shape_type()

FxShapeType FxShape::shape_type ( ) const
inline

Definition at line 192 of file Geometry.h.

◆ skin_radius()

float FxShape::skin_radius ( ) const
inline

Definition at line 194 of file Geometry.h.

◆ vertices()

const FxVec2fArray & FxShape::vertices ( ) const
inline

Definition at line 197 of file Geometry.h.

◆ world_pose()

FxVec3f FxShape::world_pose ( ) const
inline

Definition at line 389 of file Geometry.h.

Member Data Documentation

◆ m_centroid

FxVec2f FxShape::m_centroid {0.0f, 0.0f}
protected

Definition at line 54 of file Geometry.h.

◆ m_offset_pose

FxVec3f FxShape::m_offset_pose {0.0f, 0.0f, 0.0f}
protected

Definition at line 52 of file Geometry.h.

◆ m_radius

float FxShape::m_radius
protected

Definition at line 49 of file Geometry.h.

◆ m_shape_type

FxShapeType FxShape::m_shape_type
protected

Definition at line 48 of file Geometry.h.

◆ m_skin_radius

float FxShape::m_skin_radius = 0.0f
protected

Definition at line 50 of file Geometry.h.

◆ m_vertices

FxVec2fArray FxShape::m_vertices
protected

Definition at line 51 of file Geometry.h.

◆ m_world_pose

FxVec3f FxShape::m_world_pose {0.0f, 0.0f, 0.0f}
protected

Definition at line 53 of file Geometry.h.

◆ m_world_vertices

FxVec2fArray FxShape::m_world_vertices
protected

Definition at line 55 of file Geometry.h.


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