]> git.tdb.fi Git - libs/game.git/blobdiff - examples/bassteroids/source/physics.cpp
Allow external forces and torques to be added on rigid bodies
[libs/game.git] / examples / bassteroids / source / physics.cpp
index a8d49ec4d0331cb98437c07a24264a6c724b88a8..0fb43260f4cff7b82f57e39eb6fed6aa72b3b954 100644 (file)
@@ -76,6 +76,8 @@ void Physics::copy_in(SimulatedEntity &entity)
                Game::Handle<RigidBody> body = entity.entity->get_body();
                entity.inverse_mass = 1.0f/body->get_mass();
                entity.moment_of_inertia = body->get_moment_of_inertia();
+               entity.external_force = body->get_force();
+               entity.external_torque = body->get_torque();
                entity.velocity = body->get_velocity();
                entity.angular_velocity = body->get_angular_velocity();
        }
@@ -93,6 +95,7 @@ void Physics::copy_out(SimulatedEntity &entity)
                Game::Handle<RigidBody> body = entity.entity->get_body();
                body->set_velocity(entity.velocity);
                body->set_angular_velocity(entity.angular_velocity);
+               body->clear_forces();
        }
 }