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

A named rigid body with state, material properties, geometry, and forces. More...

#include <Entity.h>

Collaboration diagram for FxEntity:

Public Member Functions

bool is_sleeping () const
void wake ()
void sleep ()
void tick_sleep (float dt)
 FxEntity (const std::string &entityName)
const std::string & get_name () const
uint32_t get_entity_id () const
void set_entity_id (uint32_t id)
int32_t broad_phase_node () const
void set_broad_phase_node (int32_t node)
int32_t packed_index () const
void set_packed_index (int32_t index)
void reset ()
void set_state (const FxVec3f &o_pose, const FxVec3f &o_velocity)
void set_mass (const float &mass)
void set_inertia ()
void set_inertia (const float &inertia)
float mass () const
float inertia () const
float inv_mass () const
float inv_inertia () const
void set_init_pose (const FxVec3f &o_pose)
void set_init_velocity (const FxVec3f &o_velocity)
void enable_external_forces (bool enable)
void set_visual_geometry (FxVisualShape visual)
void set_collision_geometry (FxCollisionShape collision)
const std::shared_ptr< FxVisualShape > & visual_geometry () const
const std::shared_ptr< FxCollisionShape > & collision_geometry () const
void del_visual_geometry ()
void del_collision_geometry ()
const FxArray< float > & bounding_box () const
bool aabb_overlap_check (const FxEntity &other) const
bool aabb_overlap_check (const std::shared_ptr< FxEntity > &other) const
void apply_torque (float torque)
void apply_force (const FxVec2f &force)
void apply_force (const FxVec2f &force, const FxVec2f &contact_point)
void apply_impulse (const FxVec2f &impulse)
void apply_impulse (const FxVec2f &impulse, const FxVec2f &contact_point)
FxVec2f velocity_at_world_point (const FxVec2f &position) const
FxVec2f velocity_at_local_point (const FxVec2f &local_position) const
FxVec2fArray velocity_at_world_point (const FxVec2fArray &position) const
FxVec2fArray velocity_at_local_point (const FxVec2fArray &local_position) const
FxVec2f to_world_frame (const FxVec2f &local_point) const
FxVec2f to_entity_frame (const FxVec2f &world_point) const
FxVec3f calc_acceleration ()
FxVec3f calc_acceleration (const FxVec2f &gravity)
FxVec3f apply_pose_correction (const FxVec3f &delta)
void step (const FxVec2f &gravity, const double &step_dt, bool place_shapes=true)
void hold_step_forces ()
void refresh_collision_shape ()
void refresh_world_shapes ()
 ~FxEntity ()

Public Attributes

FxVec3f pose {0, 0, 0}
FxVec3f velocity {0, 0, 0}
FxVec3f prev_pose {0, 0, 0}
FxVec3f prev_velocity {0, 0, 0}
float elasticity = 0.1f
float vel_damping = 0.0f
float gravity_scale = 1.0f
float static_friction = 0.0f
float dynamic_friction = 0.0f
bool enabled = true
bool enable_ccd = false
bool is_sensor = false
int32_t collision_group = 0
float sleep_threshold_linear = 0.01f
float sleep_threshold_angular = 0.05f
float sleep_time_required = 0.5f

Detailed Description

A named rigid body with state, material properties, geometry, and forces.

Definition at line 49 of file Entity.h.

Constructor & Destructor Documentation

◆ FxEntity()

FxEntity::FxEntity ( const std::string & entityName)
explicit

◆ ~FxEntity()

FxEntity::~FxEntity ( )
inline

Definition at line 239 of file Entity.h.

Member Function Documentation

◆ aabb_overlap_check() [1/2]

bool FxEntity::aabb_overlap_check ( const FxEntity & other) const

◆ aabb_overlap_check() [2/2]

bool FxEntity::aabb_overlap_check ( const std::shared_ptr< FxEntity > & other) const

◆ apply_force() [1/2]

void FxEntity::apply_force ( const FxVec2f & force)

◆ apply_force() [2/2]

void FxEntity::apply_force ( const FxVec2f & force,
const FxVec2f & contact_point )

◆ apply_impulse() [1/2]

void FxEntity::apply_impulse ( const FxVec2f & impulse)

◆ apply_impulse() [2/2]

void FxEntity::apply_impulse ( const FxVec2f & impulse,
const FxVec2f & contact_point )

◆ apply_pose_correction()

FxVec3f FxEntity::apply_pose_correction ( const FxVec3f & delta)

◆ apply_torque()

void FxEntity::apply_torque ( float torque)

◆ bounding_box()

const FxArray< float > & FxEntity::bounding_box ( ) const

◆ broad_phase_node()

int32_t FxEntity::broad_phase_node ( ) const
inline

Definition at line 149 of file Entity.h.

◆ calc_acceleration() [1/2]

FxVec3f FxEntity::calc_acceleration ( )

◆ calc_acceleration() [2/2]

FxVec3f FxEntity::calc_acceleration ( const FxVec2f & gravity)

◆ collision_geometry()

const std::shared_ptr< FxCollisionShape > & FxEntity::collision_geometry ( ) const
inline

Definition at line 192 of file Entity.h.

◆ del_collision_geometry()

void FxEntity::del_collision_geometry ( )
inline

Definition at line 195 of file Entity.h.

◆ del_visual_geometry()

void FxEntity::del_visual_geometry ( )
inline

Definition at line 194 of file Entity.h.

◆ enable_external_forces()

void FxEntity::enable_external_forces ( bool enable)

◆ get_entity_id()

uint32_t FxEntity::get_entity_id ( ) const
inline

Definition at line 144 of file Entity.h.

◆ get_name()

const std::string & FxEntity::get_name ( ) const
inline

Definition at line 143 of file Entity.h.

◆ hold_step_forces()

void FxEntity::hold_step_forces ( )

◆ inertia()

float FxEntity::inertia ( ) const
inline

Definition at line 166 of file Entity.h.

◆ inv_inertia()

float FxEntity::inv_inertia ( ) const
inline

Definition at line 168 of file Entity.h.

◆ inv_mass()

float FxEntity::inv_mass ( ) const
inline

Definition at line 167 of file Entity.h.

◆ is_sleeping()

bool FxEntity::is_sleeping ( ) const
inline

Definition at line 131 of file Entity.h.

◆ mass()

float FxEntity::mass ( ) const
inline

Definition at line 165 of file Entity.h.

◆ packed_index()

int32_t FxEntity::packed_index ( ) const
inline

Definition at line 151 of file Entity.h.

◆ refresh_collision_shape()

void FxEntity::refresh_collision_shape ( )

◆ refresh_world_shapes()

void FxEntity::refresh_world_shapes ( )

◆ reset()

void FxEntity::reset ( )

◆ set_broad_phase_node()

void FxEntity::set_broad_phase_node ( int32_t node)
inline

Definition at line 150 of file Entity.h.

◆ set_collision_geometry()

void FxEntity::set_collision_geometry ( FxCollisionShape collision)
inline

Definition at line 181 of file Entity.h.

◆ set_entity_id()

void FxEntity::set_entity_id ( uint32_t id)
inline

Definition at line 145 of file Entity.h.

◆ set_inertia() [1/2]

void FxEntity::set_inertia ( )

◆ set_inertia() [2/2]

void FxEntity::set_inertia ( const float & inertia)

◆ set_init_pose()

void FxEntity::set_init_pose ( const FxVec3f & o_pose)

◆ set_init_velocity()

void FxEntity::set_init_velocity ( const FxVec3f & o_velocity)

◆ set_mass()

void FxEntity::set_mass ( const float & mass)

◆ set_packed_index()

void FxEntity::set_packed_index ( int32_t index)
inline

Definition at line 152 of file Entity.h.

◆ set_state()

void FxEntity::set_state ( const FxVec3f & o_pose,
const FxVec3f & o_velocity )

◆ set_visual_geometry()

void FxEntity::set_visual_geometry ( FxVisualShape visual)
inline

Definition at line 177 of file Entity.h.

◆ sleep()

void FxEntity::sleep ( )
inline

Definition at line 136 of file Entity.h.

◆ step()

void FxEntity::step ( const FxVec2f & gravity,
const double & step_dt,
bool place_shapes = true )

◆ tick_sleep()

void FxEntity::tick_sleep ( float dt)

◆ to_entity_frame()

FxVec2f FxEntity::to_entity_frame ( const FxVec2f & world_point) const

◆ to_world_frame()

FxVec2f FxEntity::to_world_frame ( const FxVec2f & local_point) const

◆ velocity_at_local_point() [1/2]

FxVec2f FxEntity::velocity_at_local_point ( const FxVec2f & local_position) const

◆ velocity_at_local_point() [2/2]

FxVec2fArray FxEntity::velocity_at_local_point ( const FxVec2fArray & local_position) const

◆ velocity_at_world_point() [1/2]

FxVec2f FxEntity::velocity_at_world_point ( const FxVec2f & position) const

◆ velocity_at_world_point() [2/2]

FxVec2fArray FxEntity::velocity_at_world_point ( const FxVec2fArray & position) const

◆ visual_geometry()

const std::shared_ptr< FxVisualShape > & FxEntity::visual_geometry ( ) const
inline

Definition at line 191 of file Entity.h.

◆ wake()

void FxEntity::wake ( )
inline

Definition at line 132 of file Entity.h.

Member Data Documentation

◆ collision_group

int32_t FxEntity::collision_group = 0

Definition at line 124 of file Entity.h.

◆ dynamic_friction

float FxEntity::dynamic_friction = 0.0f

Definition at line 116 of file Entity.h.

◆ elasticity

float FxEntity::elasticity = 0.1f

Definition at line 111 of file Entity.h.

◆ enable_ccd

bool FxEntity::enable_ccd = false

Definition at line 121 of file Entity.h.

◆ enabled

bool FxEntity::enabled = true

Definition at line 119 of file Entity.h.

◆ gravity_scale

float FxEntity::gravity_scale = 1.0f

Definition at line 114 of file Entity.h.

◆ is_sensor

bool FxEntity::is_sensor = false

Definition at line 123 of file Entity.h.

◆ pose

FxVec3f FxEntity::pose {0, 0, 0}

Definition at line 103 of file Entity.h.

◆ prev_pose

FxVec3f FxEntity::prev_pose {0, 0, 0}

Definition at line 107 of file Entity.h.

◆ prev_velocity

FxVec3f FxEntity::prev_velocity {0, 0, 0}

Definition at line 108 of file Entity.h.

◆ sleep_threshold_angular

float FxEntity::sleep_threshold_angular = 0.05f

Definition at line 129 of file Entity.h.

◆ sleep_threshold_linear

float FxEntity::sleep_threshold_linear = 0.01f

Definition at line 128 of file Entity.h.

◆ sleep_time_required

float FxEntity::sleep_time_required = 0.5f

Definition at line 130 of file Entity.h.

◆ static_friction

float FxEntity::static_friction = 0.0f

Definition at line 115 of file Entity.h.

◆ vel_damping

float FxEntity::vel_damping = 0.0f

Definition at line 113 of file Entity.h.

◆ velocity

FxVec3f FxEntity::velocity {0, 0, 0}

Definition at line 104 of file Entity.h.


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