2 #include <msp/game/entity.h>
3 #include <msp/game/transform.h>
7 RigidBody::RigidBody(Game::Handle<Game::Entity> e, const Setup &s):
8 BufferedComponent<RigidBodyData>(e),
12 void RigidBody::set_velocity(const LinAl::Vector<float, 2> &v)
17 void RigidBody::set_angular_velocity(Geometry::Angle<float> as)
19 write().angular_velocity = as;
22 void RigidBody::add_force(const LinAl::Vector<float, 2> &f)
27 void RigidBody::add_force(const LinAl::Vector<float, 2> &f, const LinAl::Vector<float, 2> &p)
31 LinAl::Vector<float, 2> r = p-entity->get_transform()->get_position().slice<2>(0);
32 d.torque += r.x*f.y-r.y*f.x;
35 void RigidBody::add_torque(float t)
40 void RigidBody::clear_forces()
43 d.force = LinAl::Vector<float, 2>();