From 063f57133f40c15d8644b6536d0ba0d4f656db0e Mon Sep 17 00:00:00 2001 From: Robin Engman Date: Fri, 14 Feb 2014 08:29:49 +0100 Subject: [PATCH] Set mass added --- Code/GamePhysics/Implementation/SimpleRigidBody.cpp | 8 ++++++++ Code/GamePhysics/Implementation/SimpleRigidBody.h | 11 ++++++----- Code/GamePhysics/PhysicsAPI.h | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Code/GamePhysics/Implementation/SimpleRigidBody.cpp b/Code/GamePhysics/Implementation/SimpleRigidBody.cpp index 81d58f5b..3d9fbc4f 100644 --- a/Code/GamePhysics/Implementation/SimpleRigidBody.cpp +++ b/Code/GamePhysics/Implementation/SimpleRigidBody.cpp @@ -184,6 +184,14 @@ void SimpleRigidBody::SetAngularFactor(Float factor) this->rigidBody->setAngularFactor(factor); } +void SimpleRigidBody::SetMass(Float mass) +{ + btVector3 fallInertia(0, 0, 0); + collisionShape->calculateLocalInertia(mass, fallInertia); + this->rigidBody->setMassProps(mass, fallInertia); + this->state.mass = mass; +} + void SimpleRigidBody::SetGravity(Float3 gravity) { this->rigidBody->setGravity(btVector3(gravity.x, gravity.y, gravity.z)); diff --git a/Code/GamePhysics/Implementation/SimpleRigidBody.h b/Code/GamePhysics/Implementation/SimpleRigidBody.h index ec162860..d08fd886 100644 --- a/Code/GamePhysics/Implementation/SimpleRigidBody.h +++ b/Code/GamePhysics/Implementation/SimpleRigidBody.h @@ -29,20 +29,21 @@ namespace Oyster void SetRotation(Math::Quaternion quaternion); void SetRotation(Math::Float3 eulerAngles); void SetRotation(::Oyster::Math::Float4x4 rotation); - void SetRotationAsAngularAxis(::Oyster::Math::Float4 angularAxis); + void SetRotationAsAngularAxis(Math::Float4 angularAxis); void SetAngularFactor(Math::Float factor); + void SetMass(Math::Float mass); void SetGravity(Math::Float3 gravity); - void SetUpAndRight(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 right); - void SetUpAndForward(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 forward); - void SetUp(::Oyster::Math::Float3 up); + void SetUpAndRight(Math::Float3 up, Math::Float3 right); + void SetUpAndForward(Math::Float3 up, Math::Float3 forward); + void SetUp(Math::Float3 up); Math::Float4x4 GetRotation() const; Math::Float4 GetRotationAsAngularAxis(); Math::Float4x4 GetOrientation() const; Math::Float4x4 GetView() const; - Math::Float4x4 GetView( const ::Oyster::Math::Float3 &offset ) const; + Math::Float4x4 GetView( const Math::Float3 &offset ) const; Math::Float3 GetGravity() const; ::Oyster::Math::Float3 GetLinearVelocity() const; diff --git a/Code/GamePhysics/PhysicsAPI.h b/Code/GamePhysics/PhysicsAPI.h index 25cb7610..1c220d3e 100644 --- a/Code/GamePhysics/PhysicsAPI.h +++ b/Code/GamePhysics/PhysicsAPI.h @@ -147,6 +147,7 @@ namespace Oyster virtual void SetRotation(::Oyster::Math::Float4x4 rotation) = 0; virtual void SetRotationAsAngularAxis(::Oyster::Math::Float4 angularAxis) = 0; virtual void SetAngularFactor(::Oyster::Math::Float factor) = 0; + virtual void SetMass(::Oyster::Math::Float mass) = 0; virtual void SetGravity(::Oyster::Math::Float3 gravity) = 0;