Ember
A C++ 20 'game engine' built with SDL3 with wide platform support.
|
2D rigid body with physics properties. More...
#include <rigidbody_node.h>
Public Member Functions | |
void | ready () override |
void | process (double delta_time) override |
void | draw (Renderer *renderer) override |
void | apply_impulse (const glm::vec2 &impulse) const |
void | apply_force (const glm::vec2 &force) const |
void | set_velocity (const glm::vec2 &velocity) const |
glm::vec2 | get_velocity () const |
bool | is_on_ground () const |
void | input (const InputManager *input) override |
void | draw_inspector () override |
void | draw_hierarchy () override |
~RigidBody2D () override | |
![]() | |
PhysicsObject2D () | |
void | set_layer (uint8_t new_layer) |
void | set_collision_mask (uint8_t mask) |
void | add_collision_layer (uint8_t target_layer) |
void | remove_collision_layer (uint8_t target_layer) |
void | set_collision_layers (const std::initializer_list< uint8_t > &layers) |
uint8_t | get_collision_layer () const |
uint16_t | get_collision_mask () const |
~PhysicsObject2D () override | |
void | on_body_entered (const std::function< void(Node2D *)> &callback) |
void | on_body_exited (const std::function< void(Node2D *)> &callback) |
![]() | |
Node2D () | |
Node2D (std::string name) | |
void | set_z_index (int index) |
int | get_z_index () const |
int | get_effective_z_index () const |
void | print_tree (int indent=0) const |
void | change_visibility (bool visible) |
void | translate (float dx, float dy) |
void | rotate (float radians) |
void | scale (float sx, float sy) |
Transform2D | get_global_transform () const |
Transform2D | get_transform () const |
void | set_transform (const Transform2D &transform) |
void | add_child (const std::string &base_name, Node2D *node) |
Node2D * | get_node (const std::string &path) |
template<typename T > | |
T * | get_node () |
void | queue_free () |
virtual | ~Node2D () |
const std::string & | get_name () const |
bool | is_visible () const |
bool | is_effective_visible () const |
HashMap< std::string, Node2D * > & | get_tree () |
bool | is_alive () const |
Public Attributes | |
float | friction = 0.3f |
float | density = 1.0f |
float | restitution = 0.0f |
bool | is_sensor = false |
bool | is_fixed_rotation = false |
![]() | |
std::unordered_set< PhysicsObject2D * > | overlapping |
std::vector< std::function< void(Node2D *)> > | on_enter_callbacks |
std::vector< std::function< void(Node2D *)> > | on_exit_callbacks |
b2BodyId | body_id = b2_nullBodyId |
std::unique_ptr< CollisionShape > | collision_shape |
Additional Inherited Members | |
![]() | |
bool | is_disabled = false |
glm::vec4 | color = glm::vec4(1, 0, 0, 0.5f) |
![]() | |
Transform2D | _transform = {} |
std::string | _name = "Node" |
int | _z_index = 0 |
bool | _is_visible = true |
bool | _is_ready = false |
bool | _to_free = false |
2D rigid body with physics properties.
|
override |
void RigidBody2D::apply_force | ( | const glm::vec2 & | force | ) | const |
void RigidBody2D::apply_impulse | ( | const glm::vec2 & | impulse | ) | const |
|
overridevirtual |
Implements PhysicsObject2D.
|
overridevirtual |
Reimplemented from Node2D.
|
overridevirtual |
Reimplemented from Node2D.
glm::vec2 RigidBody2D::get_velocity | ( | ) | const |
|
overridevirtual |
Reimplemented from Node2D.
bool RigidBody2D::is_on_ground | ( | ) | const |
|
overridevirtual |
Implements PhysicsObject2D.
|
overridevirtual |
Implements PhysicsObject2D.
void RigidBody2D::set_velocity | ( | const glm::vec2 & | velocity | ) | const |
float RigidBody2D::density = 1.0f |
float RigidBody2D::friction = 0.3f |
bool RigidBody2D::is_fixed_rotation = false |
bool RigidBody2D::is_sensor = false |
float RigidBody2D::restitution = 0.0f |