X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=examples%2Fbassteroids%2Fsource%2Frigidbody.h;h=b75d034ab98e03b42a4beb81cb08d21532d1f4b4;hb=bfbcfa2678c70d661cb9104b2ef677d7d7b5a637;hp=6225500237c79f69eb0367994ca4f363cd585c48;hpb=1819b186d60376a546722d99edd686e876b81d9f;p=libs%2Fgame.git diff --git a/examples/bassteroids/source/rigidbody.h b/examples/bassteroids/source/rigidbody.h index 6225500..b75d034 100644 --- a/examples/bassteroids/source/rigidbody.h +++ b/examples/bassteroids/source/rigidbody.h @@ -11,15 +11,21 @@ struct RigidBodySetup float moment_of_inertia = 0.5f; }; -class RigidBody: public Msp::Game::Component +struct RigidBodyData +{ + Msp::LinAl::Vector velocity; + Msp::Geometry::Angle angular_velocity; + Msp::LinAl::Vector force; + float torque = 0.0f; +}; + +class RigidBody: public Msp::Game::BufferedComponent { public: using Setup = RigidBodySetup; private: const Setup &setup; - Msp::LinAl::Vector velocity; - Msp::Geometry::Angle angular_velocity; public: RigidBody(Msp::Game::Handle, const Setup &); @@ -28,8 +34,14 @@ public: float get_moment_of_inertia() const { return setup.moment_of_inertia; } void set_velocity(const Msp::LinAl::Vector &); void set_angular_velocity(Msp::Geometry::Angle); - const Msp::LinAl::Vector &get_velocity() const { return velocity; } - Msp::Geometry::Angle get_angular_velocity() const { return angular_velocity; } + void add_force(const Msp::LinAl::Vector &); + void add_force(const Msp::LinAl::Vector &, const Msp::LinAl::Vector &); + void add_torque(float); + void clear_forces(); + const Msp::LinAl::Vector &get_velocity() const { return read().velocity; } + Msp::Geometry::Angle get_angular_velocity() const { return read().angular_velocity; } + const Msp::LinAl::Vector &get_force() const { return read().force; } + float get_torque() const { return read().torque; } }; #endif