2013-11-21 17:22:13 +01:00
|
|
|
#include "SimpleRigidBody.h"
|
2013-11-25 16:35:56 +01:00
|
|
|
#include "PhysicsAPI_Impl.h"
|
2013-11-21 17:22:13 +01:00
|
|
|
|
|
|
|
using namespace ::Oyster::Physics;
|
2013-11-28 11:58:46 +01:00
|
|
|
using namespace ::Oyster::Physics3D;
|
2013-11-25 16:35:56 +01:00
|
|
|
using namespace ::Oyster::Math3D;
|
2013-11-21 17:22:13 +01:00
|
|
|
using namespace ::Oyster::Collision3D;
|
|
|
|
using namespace ::Utility::DynamicMemory;
|
2013-11-25 16:35:56 +01:00
|
|
|
using namespace ::Utility::Value;
|
2013-11-21 17:22:13 +01:00
|
|
|
|
2013-12-19 14:01:02 +01:00
|
|
|
namespace Private
|
|
|
|
{
|
|
|
|
const Float epsilon = (const Float)1e-20;
|
|
|
|
|
|
|
|
// Float calculations can suffer roundingerrors. Which is where epsilon = 1e-20 comes into the picture
|
|
|
|
inline bool EqualsZero( const Float &value )
|
|
|
|
{ // by Dan Andersson
|
|
|
|
return Abs( value ) < epsilon;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Contains( const Plane &container, const Float4 &pos )
|
|
|
|
{ // by Dan Andersson
|
|
|
|
return EqualsZero( container.normal.Dot( pos ) + container.phasing );
|
|
|
|
}
|
|
|
|
|
|
|
|
// revision of Ray Vs Plane intersect test, there ray is more of an axis
|
|
|
|
bool Intersects( const Ray &axis, const Plane &plane, Float &connectDistance )
|
|
|
|
{ // by Dan Andersson
|
|
|
|
Float c = plane.normal.Dot(axis.direction);
|
|
|
|
if( EqualsZero(c) )
|
|
|
|
{ // axis is parallell with the plane. (axis direction orthogonal with the planar normal)
|
|
|
|
connectDistance = 0.0f;
|
|
|
|
return Contains( plane, axis.origin );
|
|
|
|
}
|
|
|
|
|
|
|
|
connectDistance = -plane.phasing;
|
|
|
|
connectDistance -= plane.normal.Dot( axis.origin );
|
|
|
|
connectDistance /= c;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-26 13:27:34 +01:00
|
|
|
SimpleRigidBody::SimpleRigidBody()
|
2013-11-28 11:58:46 +01:00
|
|
|
{
|
2013-12-19 21:39:20 +01:00
|
|
|
this->rigid = RigidBody();
|
|
|
|
this->rigid.SetMass_KeepMomentum( 16.0f );
|
2013-11-28 11:58:46 +01:00
|
|
|
this->gravityNormal = Float3::null;
|
2014-01-17 16:07:25 +01:00
|
|
|
this->onCollision = Default::EventAction_Collision;
|
2014-01-22 13:50:54 +01:00
|
|
|
this->onCollisionResponse = Default::EventAction_CollisionResponse;
|
2014-01-17 16:07:25 +01:00
|
|
|
this->onMovement = Default::EventAction_Move;
|
2013-12-19 10:53:55 +01:00
|
|
|
this->scene = nullptr;
|
2014-01-20 13:44:12 +01:00
|
|
|
this->customTag = nullptr;
|
|
|
|
this->ignoreGravity = this->isForwarded = false;
|
2013-11-28 11:58:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SimpleRigidBody::SimpleRigidBody( const API::SimpleBodyDescription &desc )
|
|
|
|
{
|
2013-12-19 21:39:20 +01:00
|
|
|
this->rigid.SetRotation( desc.rotation );
|
|
|
|
this->rigid.centerPos = desc.centerPosition;
|
|
|
|
this->rigid.SetSize( desc.size );
|
|
|
|
this->rigid.SetMass_KeepMomentum( desc.mass );
|
|
|
|
this->rigid.SetMomentOfInertia_KeepMomentum( desc.inertiaTensor );
|
2013-12-20 11:15:43 +01:00
|
|
|
this->deltaPos = Float4::null;
|
|
|
|
this->deltaAxis = Float4::null;
|
2013-12-19 21:39:20 +01:00
|
|
|
|
2013-11-28 11:58:46 +01:00
|
|
|
this->gravityNormal = Float3::null;
|
|
|
|
|
2014-01-17 16:07:25 +01:00
|
|
|
if( desc.subscription_onCollision )
|
2013-11-28 11:58:46 +01:00
|
|
|
{
|
2014-01-17 16:07:25 +01:00
|
|
|
this->onCollision = desc.subscription_onCollision;
|
2013-11-28 11:58:46 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-17 16:07:25 +01:00
|
|
|
this->onCollision = Default::EventAction_Collision;
|
|
|
|
}
|
|
|
|
|
2014-01-22 13:50:54 +01:00
|
|
|
if( desc.subscription_onCollisionResponse )
|
|
|
|
{
|
|
|
|
this->onCollisionResponse = desc.subscription_onCollisionResponse;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->onCollisionResponse = Default::EventAction_CollisionResponse;
|
|
|
|
}
|
|
|
|
|
2014-01-17 16:07:25 +01:00
|
|
|
if( desc.subscription_onMovement )
|
|
|
|
{
|
|
|
|
this->onMovement= desc.subscription_onMovement;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->onMovement = Default::EventAction_Move;
|
2013-11-28 11:58:46 +01:00
|
|
|
}
|
|
|
|
|
2013-12-19 10:53:55 +01:00
|
|
|
this->scene = nullptr;
|
2014-01-20 13:44:12 +01:00
|
|
|
this->customTag = nullptr;
|
|
|
|
this->ignoreGravity = desc.ignoreGravity;
|
2013-11-28 11:58:46 +01:00
|
|
|
}
|
2013-11-21 17:22:13 +01:00
|
|
|
|
2013-11-25 16:35:56 +01:00
|
|
|
SimpleRigidBody::~SimpleRigidBody() {}
|
2013-11-21 17:22:13 +01:00
|
|
|
|
|
|
|
UniquePointer<ICustomBody> SimpleRigidBody::Clone() const
|
|
|
|
{
|
|
|
|
return new SimpleRigidBody( *this );
|
|
|
|
}
|
|
|
|
|
2013-12-06 09:46:30 +01:00
|
|
|
SimpleRigidBody::State SimpleRigidBody::GetState() const
|
|
|
|
{
|
2013-12-19 10:03:56 +01:00
|
|
|
return State( this->rigid.GetMass(), this->rigid.restitutionCoeff,
|
|
|
|
this->rigid.frictionCoeff_Static, this->rigid.frictionCoeff_Kinetic,
|
2013-12-19 21:39:20 +01:00
|
|
|
this->rigid.GetMomentOfInertia(), this->rigid.boundingReach,
|
|
|
|
this->rigid.centerPos, this->rigid.axis,
|
2014-01-21 14:56:34 +01:00
|
|
|
this->rigid.momentum_Linear, this->rigid.momentum_Angular,
|
|
|
|
this->rigid.gravityNormal );
|
2013-12-06 09:46:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SimpleRigidBody::State & SimpleRigidBody::GetState( SimpleRigidBody::State &targetMem ) const
|
|
|
|
{
|
2013-12-19 10:03:56 +01:00
|
|
|
return targetMem = State( this->rigid.GetMass(), this->rigid.restitutionCoeff,
|
|
|
|
this->rigid.frictionCoeff_Static, this->rigid.frictionCoeff_Kinetic,
|
2013-12-19 21:39:20 +01:00
|
|
|
this->rigid.GetMomentOfInertia(), this->rigid.boundingReach,
|
|
|
|
this->rigid.centerPos, this->rigid.axis,
|
2014-01-21 14:56:34 +01:00
|
|
|
this->rigid.momentum_Linear, this->rigid.momentum_Angular,
|
|
|
|
this->rigid.gravityNormal );
|
2013-12-06 09:46:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SimpleRigidBody::SetState( const SimpleRigidBody::State &state )
|
2013-12-19 10:53:55 +01:00
|
|
|
{
|
2013-12-19 21:39:20 +01:00
|
|
|
this->rigid.centerPos = state.GetCenterPosition();
|
2014-01-20 15:31:19 +01:00
|
|
|
//this->rigid.SetRotation( state.GetRotation() ); //! HACK: @todo Rotation temporary disabled
|
2013-12-19 21:39:20 +01:00
|
|
|
this->rigid.boundingReach = state.GetReach();
|
|
|
|
this->rigid.momentum_Linear = state.GetLinearMomentum();
|
|
|
|
this->rigid.momentum_Angular = state.GetAngularMomentum();
|
|
|
|
this->rigid.impulse_Linear += state.GetLinearImpulse();
|
|
|
|
this->rigid.impulse_Angular += state.GetAngularImpulse();
|
|
|
|
this->rigid.restitutionCoeff = state.GetRestitutionCoeff();
|
|
|
|
this->rigid.frictionCoeff_Static = state.GetFrictionCoeff_Static();
|
2013-12-19 10:53:55 +01:00
|
|
|
this->rigid.frictionCoeff_Kinetic = state.GetFrictionCoeff_Kinetic();
|
2014-01-14 11:58:53 +01:00
|
|
|
this->rigid.SetMass_KeepMomentum( state.GetMass() );
|
|
|
|
this->rigid.SetMomentOfInertia_KeepMomentum( state.GetMomentOfInertia() );
|
2014-01-21 14:56:34 +01:00
|
|
|
this->rigid.gravityNormal = state.GetGravityNormal();
|
2013-12-19 10:53:55 +01:00
|
|
|
|
2013-12-20 11:15:43 +01:00
|
|
|
if( state.IsForwarded() )
|
|
|
|
{
|
|
|
|
this->deltaPos += state.GetForward_DeltaPos();
|
|
|
|
this->deltaAxis += state.GetForward_DeltaAxis();
|
|
|
|
this->isForwarded;
|
|
|
|
}
|
|
|
|
|
2013-12-19 10:53:55 +01:00
|
|
|
if( this->scene )
|
|
|
|
{
|
|
|
|
if( state.IsSpatiallyAltered() )
|
|
|
|
{
|
|
|
|
unsigned int tempRef = this->scene->GetTemporaryReferenceOf( this );
|
|
|
|
this->scene->SetAsAltered( tempRef );
|
|
|
|
this->scene->EvaluatePosition( tempRef );
|
|
|
|
}
|
|
|
|
else if( state.IsDisturbed() )
|
|
|
|
{
|
|
|
|
this->scene->SetAsAltered( this->scene->GetTemporaryReferenceOf(this) );
|
|
|
|
}
|
|
|
|
}
|
2013-12-06 09:46:30 +01:00
|
|
|
}
|
|
|
|
|
2014-01-17 16:07:25 +01:00
|
|
|
ICustomBody::SubscriptMessage SimpleRigidBody::CallSubscription_Collision( const ICustomBody *deuter )
|
|
|
|
{
|
|
|
|
return this->onCollision( this, deuter );
|
|
|
|
}
|
|
|
|
|
2014-01-22 13:50:54 +01:00
|
|
|
void SimpleRigidBody::CallSubscription_CollisionResponse( const ICustomBody *deuter, Float kineticEnergyLoss )
|
|
|
|
{
|
|
|
|
return this->onCollisionResponse( this, deuter, kineticEnergyLoss );
|
|
|
|
}
|
|
|
|
|
2014-01-17 16:07:25 +01:00
|
|
|
void SimpleRigidBody::CallSubscription_Move()
|
2013-11-29 09:21:44 +01:00
|
|
|
{
|
2014-01-17 16:07:25 +01:00
|
|
|
this->onMovement( this );
|
2013-11-29 09:21:44 +01:00
|
|
|
}
|
|
|
|
|
2013-11-26 13:27:34 +01:00
|
|
|
bool SimpleRigidBody::IsAffectedByGravity() const
|
|
|
|
{
|
|
|
|
return !this->ignoreGravity;
|
2013-11-21 17:22:13 +01:00
|
|
|
}
|
|
|
|
|
2013-12-18 08:57:27 +01:00
|
|
|
bool SimpleRigidBody::Intersects( const ICollideable &shape ) const
|
2013-11-21 17:22:13 +01:00
|
|
|
{
|
2013-12-19 21:39:20 +01:00
|
|
|
return Box( this->rigid.GetRotationMatrix(), this->rigid.centerPos, this->rigid.GetSize() ).Intersects( shape );
|
2013-11-21 17:22:13 +01:00
|
|
|
}
|
|
|
|
|
2013-12-18 08:57:27 +01:00
|
|
|
bool SimpleRigidBody::Intersects( const ICollideable &shape, Float4 &worldPointOfContact ) const
|
2013-11-21 17:22:13 +01:00
|
|
|
{
|
2013-12-19 21:39:20 +01:00
|
|
|
return Box( this->rigid.GetRotationMatrix(), this->rigid.centerPos, this->rigid.GetSize() ).Intersects( shape, worldPointOfContact );
|
2013-12-18 08:57:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SimpleRigidBody::Intersects( const ICustomBody &object, Float4 &worldPointOfContact ) const
|
|
|
|
{
|
2013-12-19 21:39:20 +01:00
|
|
|
return object.Intersects( Box(this->rigid.GetRotationMatrix(), this->rigid.centerPos, this->rigid.GetSize()), worldPointOfContact );
|
2013-11-21 17:22:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Sphere & SimpleRigidBody::GetBoundingSphere( Sphere &targetMem ) const
|
|
|
|
{
|
2013-12-19 21:39:20 +01:00
|
|
|
return targetMem = Sphere( this->rigid.centerPos, this->rigid.boundingReach.GetMagnitude() );
|
2013-11-21 17:22:13 +01:00
|
|
|
}
|
|
|
|
|
2013-12-18 08:57:27 +01:00
|
|
|
Float4 & SimpleRigidBody::GetNormalAt( const Float4 &worldPos, Float4 &targetMem ) const
|
2013-11-21 17:22:13 +01:00
|
|
|
{
|
2013-12-19 21:39:20 +01:00
|
|
|
Float4 offset = worldPos - this->rigid.centerPos;
|
2013-12-18 14:49:47 +01:00
|
|
|
Float distance = offset.Dot( offset );
|
2013-12-19 11:21:14 +01:00
|
|
|
Float3 normal = Float3::null;
|
2013-12-18 14:49:47 +01:00
|
|
|
|
|
|
|
if( distance != 0.0f )
|
2013-12-19 11:21:14 +01:00
|
|
|
{ // sanity check
|
2013-12-19 14:01:02 +01:00
|
|
|
Ray axis( Float4::standard_unit_w, offset / (Float)::std::sqrt(distance) );
|
2013-12-18 14:49:47 +01:00
|
|
|
Float minDistance = numeric_limits<Float>::max();
|
2013-12-19 21:39:20 +01:00
|
|
|
Float4x4 rotationMatrix = this->rigid.GetRotationMatrix();
|
|
|
|
|
|
|
|
if( Private::Intersects(axis, Plane(rotationMatrix.v[0], -this->rigid.boundingReach.x), axis.collisionDistance) )
|
2013-12-18 14:49:47 +01:00
|
|
|
{ // check along x-axis
|
2013-12-19 14:01:02 +01:00
|
|
|
if( axis.collisionDistance < 0.0f )
|
2013-12-19 21:39:20 +01:00
|
|
|
normal = -rotationMatrix.v[0].xyz;
|
2013-12-18 14:49:47 +01:00
|
|
|
else
|
2013-12-19 21:39:20 +01:00
|
|
|
normal = rotationMatrix.v[0].xyz;
|
2013-12-18 14:49:47 +01:00
|
|
|
|
2013-12-19 14:01:02 +01:00
|
|
|
minDistance = Abs( axis.collisionDistance );
|
2013-12-18 14:49:47 +01:00
|
|
|
}
|
|
|
|
|
2013-12-19 21:39:20 +01:00
|
|
|
if( Private::Intersects(axis, Plane(rotationMatrix.v[1], -this->rigid.boundingReach.y), axis.collisionDistance) )
|
2013-12-18 14:49:47 +01:00
|
|
|
{ // check along y-axis
|
2013-12-19 14:01:02 +01:00
|
|
|
distance = Abs( axis.collisionDistance ); // recycling memory
|
2013-12-18 14:49:47 +01:00
|
|
|
if( minDistance > distance )
|
|
|
|
{
|
2013-12-19 14:01:02 +01:00
|
|
|
if( axis.collisionDistance < 0.0f )
|
2013-12-19 21:39:20 +01:00
|
|
|
normal = -rotationMatrix.v[1].xyz;
|
2013-12-18 14:49:47 +01:00
|
|
|
else
|
2013-12-19 21:39:20 +01:00
|
|
|
normal = rotationMatrix.v[1].xyz;
|
2013-12-18 14:49:47 +01:00
|
|
|
|
|
|
|
minDistance = distance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-19 21:39:20 +01:00
|
|
|
if( Private::Intersects(axis, Plane(rotationMatrix.v[2], -this->rigid.boundingReach.z), axis.collisionDistance) )
|
2013-12-18 14:49:47 +01:00
|
|
|
{ // check along z-axis
|
2013-12-19 14:01:02 +01:00
|
|
|
if( minDistance > Abs( axis.collisionDistance ) )
|
2013-12-18 14:49:47 +01:00
|
|
|
{
|
2013-12-19 14:01:02 +01:00
|
|
|
if( axis.collisionDistance < 0.0f )
|
2013-12-19 21:39:20 +01:00
|
|
|
normal = -rotationMatrix.v[2].xyz;
|
2013-12-18 14:49:47 +01:00
|
|
|
else
|
2013-12-19 21:39:20 +01:00
|
|
|
normal = rotationMatrix.v[2].xyz;
|
2013-12-18 14:49:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
targetMem.xyz = normal;
|
2013-12-19 11:21:14 +01:00
|
|
|
targetMem.w = 0.0f;
|
2013-12-18 14:49:47 +01:00
|
|
|
return targetMem;
|
2013-11-21 17:22:13 +01:00
|
|
|
}
|
|
|
|
|
2013-11-26 13:27:34 +01:00
|
|
|
Float3 & SimpleRigidBody::GetGravityNormal( Float3 &targetMem ) const
|
|
|
|
{
|
|
|
|
return targetMem = this->gravityNormal;
|
|
|
|
}
|
|
|
|
|
2014-01-20 13:44:12 +01:00
|
|
|
void * SimpleRigidBody::GetCustomTag() const
|
|
|
|
{
|
|
|
|
return this->customTag;
|
|
|
|
}
|
|
|
|
|
2013-12-18 14:16:13 +01:00
|
|
|
//Float3 & SimpleRigidBody::GetCenter( Float3 &targetMem ) const
|
|
|
|
//{
|
2013-12-19 21:39:20 +01:00
|
|
|
// return targetMem = this->rigid.centerPos;
|
2013-12-18 14:16:13 +01:00
|
|
|
//}
|
|
|
|
//
|
|
|
|
//Float4x4 & SimpleRigidBody::GetRotation( Float4x4 &targetMem ) const
|
|
|
|
//{
|
|
|
|
// return targetMem = this->rigid.box.rotation;
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//Float4x4 & SimpleRigidBody::GetOrientation( Float4x4 &targetMem ) const
|
|
|
|
//{
|
|
|
|
// return targetMem = this->rigid.GetOrientation();
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//Float4x4 & SimpleRigidBody::GetView( Float4x4 &targetMem ) const
|
|
|
|
//{
|
|
|
|
// return targetMem = this->rigid.GetView();
|
|
|
|
//}
|
2013-11-21 17:22:13 +01:00
|
|
|
|
2013-12-20 12:13:12 +01:00
|
|
|
//Float3 SimpleRigidBody::GetRigidLinearVelocity() const
|
|
|
|
//{
|
|
|
|
// return this->rigid.GetLinearVelocity();
|
|
|
|
//}
|
2013-12-12 10:02:35 +01:00
|
|
|
|
|
|
|
|
2013-11-21 17:22:13 +01:00
|
|
|
UpdateState SimpleRigidBody::Update( Float timeStepLength )
|
|
|
|
{
|
2013-12-20 11:15:43 +01:00
|
|
|
if( this->isForwarded )
|
|
|
|
{
|
2013-12-20 11:21:18 +01:00
|
|
|
this->rigid.Move( this->deltaPos, this->deltaAxis );
|
|
|
|
this->deltaPos = Float4::null;
|
|
|
|
this->deltaAxis = Float4::null;
|
|
|
|
this->isForwarded = false;
|
2013-12-20 11:15:43 +01:00
|
|
|
}
|
|
|
|
|
2013-11-28 11:58:46 +01:00
|
|
|
this->rigid.Update_LeapFrog( timeStepLength );
|
2013-11-25 16:35:56 +01:00
|
|
|
|
2013-12-20 11:21:18 +01:00
|
|
|
//! @todo TODO: compare previous and new state and return result
|
2013-11-28 11:58:46 +01:00
|
|
|
//return this->current == this->previous ? UpdateState_resting : UpdateState_altered;
|
|
|
|
return UpdateState_altered;
|
2013-11-28 10:26:29 +01:00
|
|
|
}
|
|
|
|
|
2013-12-20 11:30:11 +01:00
|
|
|
void SimpleRigidBody::Predict( Float4 &outDeltaPos, Float4 &outDeltaAxis, const Float4 &actingLinearImpulse, const Float4 &actingAngularImpulse, Float deltaTime )
|
|
|
|
{
|
|
|
|
this->rigid.Predict_LeapFrog( outDeltaPos, outDeltaAxis, actingLinearImpulse, actingAngularImpulse, deltaTime );
|
|
|
|
}
|
|
|
|
|
2013-12-19 10:53:55 +01:00
|
|
|
void SimpleRigidBody::SetScene( void *scene )
|
|
|
|
{
|
|
|
|
this->scene = (Octree*)scene;
|
|
|
|
}
|
|
|
|
|
2013-11-28 10:26:29 +01:00
|
|
|
void SimpleRigidBody::SetSubscription( ICustomBody::EventAction_Collision functionPointer )
|
|
|
|
{
|
|
|
|
if( functionPointer )
|
|
|
|
{
|
2014-01-17 16:07:25 +01:00
|
|
|
this->onCollision = functionPointer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->onCollision = Default::EventAction_Collision;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-22 13:50:54 +01:00
|
|
|
void SimpleRigidBody::SetSubscription( ICustomBody::EventAction_CollisionResponse functionPointer )
|
|
|
|
{
|
|
|
|
if( functionPointer )
|
|
|
|
{
|
|
|
|
this->onCollisionResponse = functionPointer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->onCollisionResponse = Default::EventAction_CollisionResponse;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-17 16:07:25 +01:00
|
|
|
void SimpleRigidBody::SetSubscription( ICustomBody::EventAction_Move functionPointer )
|
|
|
|
{
|
|
|
|
if( functionPointer )
|
|
|
|
{
|
|
|
|
this->onMovement = functionPointer;
|
2013-11-28 10:26:29 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-17 16:07:25 +01:00
|
|
|
this->onMovement = Default::EventAction_Move;
|
2013-11-28 10:26:29 +01:00
|
|
|
}
|
2013-11-21 17:22:13 +01:00
|
|
|
}
|
|
|
|
|
2013-11-26 13:27:34 +01:00
|
|
|
void SimpleRigidBody::SetGravity( bool ignore)
|
|
|
|
{
|
|
|
|
this->ignoreGravity = ignore;
|
|
|
|
this->gravityNormal = Float3::null;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimpleRigidBody::SetGravityNormal( const Float3 &normalizedVector )
|
|
|
|
{
|
|
|
|
this->gravityNormal = normalizedVector;
|
2014-01-21 14:56:34 +01:00
|
|
|
this->rigid.gravityNormal = Float4( this->gravityNormal, 0 );
|
2013-11-26 13:27:34 +01:00
|
|
|
}
|
|
|
|
|
2014-01-20 13:44:12 +01:00
|
|
|
void SimpleRigidBody::SetCustomTag( void *ref )
|
|
|
|
{
|
|
|
|
this->customTag = ref;
|
|
|
|
}
|
|
|
|
|
2013-12-18 14:16:13 +01:00
|
|
|
//void SimpleRigidBody::SetMomentOfInertiaTensor_KeepVelocity( const Float4x4 &localI )
|
|
|
|
//{
|
|
|
|
// this->rigid.SetMomentOfInertia_KeepVelocity( localI );
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//void SimpleRigidBody::SetMomentOfInertiaTensor_KeepMomentum( const Float4x4 &localI )
|
|
|
|
//{
|
|
|
|
// this->rigid.SetMomentOfInertia_KeepMomentum( localI );
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//void SimpleRigidBody::SetMass_KeepVelocity( Float m )
|
|
|
|
//{
|
|
|
|
// this->rigid.SetMass_KeepVelocity( m );
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//void SimpleRigidBody::SetMass_KeepMomentum( Float m )
|
|
|
|
//{
|
|
|
|
// this->rigid.SetMass_KeepMomentum( m );
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//void SimpleRigidBody::SetCenter( const Float3 &worldPos )
|
|
|
|
//{
|
|
|
|
// this->rigid.SetCenter( worldPos );
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//void SimpleRigidBody::SetRotation( const Float4x4 &rotation )
|
|
|
|
//{
|
|
|
|
// this->rigid.SetRotation( rotation );
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//void SimpleRigidBody::SetOrientation( const Float4x4 &orientation )
|
|
|
|
//{
|
|
|
|
// this->rigid.SetOrientation( orientation );
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//void SimpleRigidBody::SetSize( const Float3 &size )
|
|
|
|
//{
|
|
|
|
// this->rigid.SetSize( size );
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//void SimpleRigidBody::SetMomentum( const Float3 &worldG )
|
|
|
|
//{
|
|
|
|
// this->rigid.SetLinearMomentum( worldG );
|
|
|
|
//}
|