GameLogic - Merged with Sprint2.5, fixed physics errors

This commit is contained in:
Dennis Andersen 2014-01-20 16:09:58 +01:00
commit 7cdfa726ea
5 changed files with 49 additions and 10 deletions

View File

@ -48,8 +48,9 @@ SimpleRigidBody::SimpleRigidBody()
this->gravityNormal = Float3::null;
this->onCollision = Default::EventAction_Collision;
this->onMovement = Default::EventAction_Move;
this->ignoreGravity = this->isForwarded = false;
this->scene = nullptr;
this->customTag = nullptr;
this->ignoreGravity = this->isForwarded = false;
}
SimpleRigidBody::SimpleRigidBody( const API::SimpleBodyDescription &desc )
@ -82,8 +83,9 @@ SimpleRigidBody::SimpleRigidBody( const API::SimpleBodyDescription &desc )
this->onMovement = Default::EventAction_Move;
}
this->ignoreGravity = desc.ignoreGravity;
this->scene = nullptr;
this->customTag = nullptr;
this->ignoreGravity = desc.ignoreGravity;
}
SimpleRigidBody::~SimpleRigidBody() {}
@ -240,6 +242,11 @@ Float3 & SimpleRigidBody::GetGravityNormal( Float3 &targetMem ) const
return targetMem = this->gravityNormal;
}
void * SimpleRigidBody::GetCustomTag() const
{
return this->customTag;
}
//Float3 & SimpleRigidBody::GetCenter( Float3 &targetMem ) const
//{
// return targetMem = this->rigid.centerPos;
@ -328,6 +335,11 @@ void SimpleRigidBody::SetGravityNormal( const Float3 &normalizedVector )
this->gravityNormal = normalizedVector;
}
void SimpleRigidBody::SetCustomTag( void *ref )
{
this->customTag = ref;
}
//void SimpleRigidBody::SetMomentOfInertiaTensor_KeepVelocity( const Float4x4 &localI )
//{
// this->rigid.SetMomentOfInertia_KeepVelocity( localI );

View File

@ -32,6 +32,7 @@ namespace Oyster { namespace Physics
::Oyster::Collision3D::Sphere & GetBoundingSphere( ::Oyster::Collision3D::Sphere &targetMem = ::Oyster::Collision3D::Sphere() ) const;
::Oyster::Math::Float4 & GetNormalAt( const ::Oyster::Math::Float4 &worldPos, ::Oyster::Math::Float4 &targetMem = ::Oyster::Math::Float4() ) const;
::Oyster::Math::Float3 & GetGravityNormal( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
void * GetCustomTag() const;
//::Oyster::Math::Float3 & GetCenter( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
//::Oyster::Math::Float4x4 & GetRotation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
//::Oyster::Math::Float4x4 & GetOrientation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
@ -47,6 +48,7 @@ namespace Oyster { namespace Physics
void SetGravity( bool ignore);
void SetGravityNormal( const ::Oyster::Math::Float3 &normalizedVector );
void SetCustomTag( void *ref );
//void SetMomentOfInertiaTensor_KeepVelocity( const ::Oyster::Math::Float4x4 &localI );
//void SetMomentOfInertiaTensor_KeepMomentum( const ::Oyster::Math::Float4x4 &localI );
//void SetMass_KeepVelocity( ::Oyster::Math::Float m );
@ -64,6 +66,7 @@ namespace Oyster { namespace Physics
EventAction_Collision onCollision;
EventAction_Move onMovement;
Octree *scene;
void *customTag;
bool ignoreGravity, isForwarded;
};
} }

View File

@ -15,9 +15,9 @@ SphericalRigidBody::SphericalRigidBody()
this->gravityNormal = Float3::null;
this->onCollision = Default::EventAction_Collision;
this->onMovement = Default::EventAction_Move;
this->ignoreGravity = this->isForwarded = false;
this->scene = nullptr;
this->body = Sphere( Float3::null, 0.5f );
this->customTag = nullptr;
this->ignoreGravity = this->isForwarded = false;
}
SphericalRigidBody::SphericalRigidBody( const API::SphericalBodyDescription &desc )
@ -51,9 +51,9 @@ SphericalRigidBody::SphericalRigidBody( const API::SphericalBodyDescription &des
this->onMovement = Default::EventAction_Move;
}
this->ignoreGravity = desc.ignoreGravity;
this->scene = nullptr;
this->body = Sphere( desc.centerPosition, desc.radius );
this->customTag = nullptr;
this->ignoreGravity = desc.ignoreGravity;
}
SphericalRigidBody::~SphericalRigidBody() {}
@ -150,7 +150,7 @@ bool SphericalRigidBody::Intersects( const ICustomBody &object, Float4 &worldPoi
Sphere & SphericalRigidBody::GetBoundingSphere( Sphere &targetMem ) const
{
return targetMem = this->body;
return targetMem = Sphere( this->rigid.centerPos, this->rigid.boundingReach.x );
}
Float4 & SphericalRigidBody::GetNormalAt( const Float4 &worldPos, Float4 &targetMem ) const
@ -170,6 +170,11 @@ Float3 & SphericalRigidBody::GetGravityNormal( Float3 &targetMem ) const
return targetMem = this->gravityNormal;
}
void * SphericalRigidBody::GetCustomTag() const
{
return this->customTag;
}
//Float3 & SphericalRigidBody::GetCenter( Float3 &targetMem ) const
//{
// return targetMem = this->rigid.centerPos;
@ -206,7 +211,6 @@ UpdateState SphericalRigidBody::Update( Float timeStepLength )
}
this->rigid.Update_LeapFrog( timeStepLength );
this->body.center = this->rigid.centerPos;
// compare previous and new state and return result
//return this->current == this->previous ? UpdateState_resting : UpdateState_altered;
@ -258,6 +262,11 @@ void SphericalRigidBody::SetGravityNormal( const Float3 &normalizedVector )
this->gravityNormal = normalizedVector;
}
void SphericalRigidBody::SetCustomTag( void *ref )
{
this->customTag = ref;
}
//void SphericalRigidBody::SetMomentOfInertiaTensor_KeepVelocity( const Float4x4 &localI )
//{
// this->rigid.SetMomentOfInertia_KeepVelocity( localI );

View File

@ -33,6 +33,7 @@ namespace Oyster { namespace Physics
::Oyster::Collision3D::Sphere & GetBoundingSphere( ::Oyster::Collision3D::Sphere &targetMem = ::Oyster::Collision3D::Sphere() ) const;
::Oyster::Math::Float4 & GetNormalAt( const ::Oyster::Math::Float4 &worldPos, ::Oyster::Math::Float4 &targetMem = ::Oyster::Math::Float4() ) const;
::Oyster::Math::Float3 & GetGravityNormal( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
void * GetCustomTag() const;
//::Oyster::Math::Float3 & GetCenter( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
//::Oyster::Math::Float4x4 & GetRotation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
//::Oyster::Math::Float4x4 & GetOrientation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
@ -48,6 +49,7 @@ namespace Oyster { namespace Physics
void SetGravity( bool ignore);
void SetGravityNormal( const ::Oyster::Math::Float3 &normalizedVector );
void SetCustomTag( void *ref );
//void SetMomentOfInertiaTensor_KeepVelocity( const ::Oyster::Math::Float4x4 &localI );
//void SetMomentOfInertiaTensor_KeepMomentum( const ::Oyster::Math::Float4x4 &localI );
//void SetMass_KeepVelocity( ::Oyster::Math::Float m );
@ -64,9 +66,9 @@ namespace Oyster { namespace Physics
::Oyster::Math::Float3 gravityNormal;
EventAction_Collision onCollision;
EventAction_Move onMovement;
bool ignoreGravity, isForwarded;
Octree *scene;
::Oyster::Collision3D::Sphere body;
void *customTag;
bool ignoreGravity, isForwarded;
};
} }

View File

@ -327,6 +327,12 @@ namespace Oyster
********************************************************/
virtual ::Oyster::Math::Float3 & GetGravityNormal( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const = 0;
/********************************************************
* @return the void pointer set by SetCustomTag.
* nullptr if none is set.
********************************************************/
virtual void * GetCustomTag() const = 0;
///********************************************************
// * The world position of this center of gravity.
// * @param targetMem: Provided memory that written into and then returned.
@ -395,6 +401,13 @@ namespace Oyster
********************************************************/
virtual void SetGravityNormal( const ::Oyster::Math::Float3 &normalizedVector ) = 0;
/********************************************************
* Not used by the engine itself. Just a quality of life feature
* for developers who want to tag something to the objects.
* @param ref: Anything castable to a void pointer, the engine won't care.
********************************************************/
virtual void SetCustomTag( void *ref ) = 0;
///********************************************************
// * To not be called if is in Engine
// * Use API::SetMomentOfInertiaTensor_KeepVelocity(...) instead