Merge branch 'GamePhysics' of https://github.com/dean11/Danbias into GameLogic
This commit is contained in:
commit
398be8361b
|
@ -26,6 +26,9 @@ API_Impl::API_Impl()
|
||||||
this->dynamicsWorld = NULL;
|
this->dynamicsWorld = NULL;
|
||||||
|
|
||||||
this->timeStep = 1.0f/120.0f;
|
this->timeStep = 1.0f/120.0f;
|
||||||
|
|
||||||
|
this->gravityPoint = Float3(0.0f, 0.0f, 0.0f);
|
||||||
|
this->gravity = 10.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
API_Impl::~API_Impl()
|
API_Impl::~API_Impl()
|
||||||
|
@ -48,6 +51,16 @@ API_Impl::~API_Impl()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void API_Impl::SetGravityPoint(::Oyster::Math::Float3 gravityPoint)
|
||||||
|
{
|
||||||
|
this->gravityPoint = gravityPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
void API_Impl::SetGravity(float gravity)
|
||||||
|
{
|
||||||
|
this->gravity = gravity;
|
||||||
|
}
|
||||||
|
|
||||||
// Bullet physics
|
// Bullet physics
|
||||||
ICustomBody* API_Impl::AddCollisionSphere(float radius, ::Oyster::Math::Float4 rotation, ::Oyster::Math::Float3 position, float mass, float restitution, float staticFriction, float dynamicFriction)
|
ICustomBody* API_Impl::AddCollisionSphere(float radius, ::Oyster::Math::Float4 rotation, ::Oyster::Math::Float3 position, float mass, float restitution, float staticFriction, float dynamicFriction)
|
||||||
{
|
{
|
||||||
|
@ -173,6 +186,11 @@ void API_Impl::SetTimeStep(float timeStep)
|
||||||
|
|
||||||
void API_Impl::UpdateWorld()
|
void API_Impl::UpdateWorld()
|
||||||
{
|
{
|
||||||
|
for(unsigned int i = 0; i < this->customBodies.size(); i++ )
|
||||||
|
{
|
||||||
|
this->customBodies[i]->SetGravity(-(this->customBodies[i]->GetState().centerPos - this->gravityPoint).GetNormalized()*this->gravity);
|
||||||
|
}
|
||||||
|
|
||||||
this->dynamicsWorld->stepSimulation(this->timeStep, 1, this->timeStep);
|
this->dynamicsWorld->stepSimulation(this->timeStep, 1, this->timeStep);
|
||||||
|
|
||||||
ICustomBody::State state;
|
ICustomBody::State state;
|
||||||
|
|
|
@ -21,6 +21,9 @@ namespace Oyster
|
||||||
void MoveToLimbo( const ICustomBody* objRef );
|
void MoveToLimbo( const ICustomBody* objRef );
|
||||||
void ReleaseFromLimbo( const ICustomBody* objRef );
|
void ReleaseFromLimbo( const ICustomBody* objRef );
|
||||||
|
|
||||||
|
void SetGravityPoint(::Oyster::Math::Float3 gravityPoint);
|
||||||
|
void SetGravity(float gravity);
|
||||||
|
|
||||||
// Bullet physics
|
// Bullet physics
|
||||||
ICustomBody* AddCollisionSphere(float radius, ::Oyster::Math::Float4 rotation, ::Oyster::Math::Float3 position, float mass, float restitution, float staticFriction, float dynamicFriction);
|
ICustomBody* AddCollisionSphere(float radius, ::Oyster::Math::Float4 rotation, ::Oyster::Math::Float3 position, float mass, float restitution, float staticFriction, float dynamicFriction);
|
||||||
ICustomBody* AddCollisionBox(::Oyster::Math::Float3 halfSize, ::Oyster::Math::Float4 rotation, ::Oyster::Math::Float3 position, float mass, float restitution, float staticFriction, float dynamicFriction);
|
ICustomBody* AddCollisionBox(::Oyster::Math::Float3 halfSize, ::Oyster::Math::Float4 rotation, ::Oyster::Math::Float3 position, float mass, float restitution, float staticFriction, float dynamicFriction);
|
||||||
|
@ -41,6 +44,9 @@ namespace Oyster
|
||||||
std::vector<ICustomBody*> customBodies;
|
std::vector<ICustomBody*> customBodies;
|
||||||
|
|
||||||
float timeStep;
|
float timeStep;
|
||||||
|
|
||||||
|
::Oyster::Math::Float3 gravityPoint;
|
||||||
|
float gravity;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Default
|
namespace Default
|
||||||
|
|
|
@ -78,6 +78,8 @@ namespace Oyster
|
||||||
********************************************************/
|
********************************************************/
|
||||||
virtual void ReleaseFromLimbo( const ICustomBody* objRef ) = 0;
|
virtual void ReleaseFromLimbo( const ICustomBody* objRef ) = 0;
|
||||||
|
|
||||||
|
virtual void SetGravityPoint(::Oyster::Math::Float3 gravityPoint) = 0;
|
||||||
|
virtual void SetGravity(float gravity) = 0;
|
||||||
|
|
||||||
// Bullet physics
|
// Bullet physics
|
||||||
virtual ICustomBody* AddCollisionSphere(float radius, ::Oyster::Math::Float4 rotation, ::Oyster::Math::Float3 position, float mass, float restitution, float staticFriction, float dynamicFriction) = 0;
|
virtual ICustomBody* AddCollisionSphere(float radius, ::Oyster::Math::Float4 rotation, ::Oyster::Math::Float3 position, float mass, float restitution, float staticFriction, float dynamicFriction) = 0;
|
||||||
|
|
Loading…
Reference in New Issue