From 754199441976eb214097e263c20c8f9af71b00ba Mon Sep 17 00:00:00 2001 From: Robin Engman Date: Wed, 12 Feb 2014 08:50:10 +0100 Subject: [PATCH] Added support for applying impulse --- Code/GamePhysics/Implementation/SimpleRigidBody.cpp | 5 +++++ Code/GamePhysics/Implementation/SimpleRigidBody.h | 2 ++ Code/GamePhysics/PhysicsAPI.h | 2 ++ 3 files changed, 9 insertions(+) diff --git a/Code/GamePhysics/Implementation/SimpleRigidBody.cpp b/Code/GamePhysics/Implementation/SimpleRigidBody.cpp index 58f598ed..7cd2f2b6 100644 --- a/Code/GamePhysics/Implementation/SimpleRigidBody.cpp +++ b/Code/GamePhysics/Implementation/SimpleRigidBody.cpp @@ -67,6 +67,11 @@ void SimpleRigidBody::SetState( const SimpleRigidBody::State &state ) this->state = state; } +void SimpleRigidBody::ApplyImpulse(Float3 impulse) +{ + this->rigidBody->applyImpulse(btVector3(impulse.x, impulse.y, impulse.z), btVector3(0.0f, 0.0f, 0.0f)); +} + void SimpleRigidBody::SetCollisionShape(btCollisionShape* shape) { this->collisionShape = shape; diff --git a/Code/GamePhysics/Implementation/SimpleRigidBody.h b/Code/GamePhysics/Implementation/SimpleRigidBody.h index 039345eb..3663c45c 100644 --- a/Code/GamePhysics/Implementation/SimpleRigidBody.h +++ b/Code/GamePhysics/Implementation/SimpleRigidBody.h @@ -18,6 +18,8 @@ namespace Oyster State& GetState( State &targetMem ) const; void SetState( const State &state ); + void ApplyImpulse(Math::Float3 impulse); + void SetCollisionShape(btCollisionShape* shape); void SetMotionState(btDefaultMotionState* motionState); void SetRigidBody(btRigidBody* rigidBody); diff --git a/Code/GamePhysics/PhysicsAPI.h b/Code/GamePhysics/PhysicsAPI.h index 46f663d7..d971fe79 100644 --- a/Code/GamePhysics/PhysicsAPI.h +++ b/Code/GamePhysics/PhysicsAPI.h @@ -134,6 +134,8 @@ namespace Oyster virtual void SetSubscription(EventAction_AfterCollisionResponse function) = 0; virtual void SetSubscription(EventAction_Move function) = 0; + virtual void ApplyImpulse(::Oyster::Math::Float3 impulse) = 0; + virtual void SetLinearVelocity(::Oyster::Math::Float3 velocity) = 0; virtual void SetPosition(::Oyster::Math::Float3 position) = 0; virtual void SetRotation(::Oyster::Math::Float4 quaternion) = 0;