parent
80c835be58
commit
a8c87273e2
|
@ -163,7 +163,7 @@ void API_Impl::Update()
|
||||||
for( ; proto != updateList.end(); ++proto )
|
for( ; proto != updateList.end(); ++proto )
|
||||||
{
|
{
|
||||||
// Step 1: Apply Gravity
|
// Step 1: Apply Gravity
|
||||||
(*proto)->GetState( state );
|
Float4 gravityImpulse = Float4::null;
|
||||||
for( ::std::vector<Gravity>::size_type i = 0; i < this->gravity.size(); ++i )
|
for( ::std::vector<Gravity>::size_type i = 0; i < this->gravity.size(); ++i )
|
||||||
{
|
{
|
||||||
switch( this->gravity[i].gravityType )
|
switch( this->gravity[i].gravityType )
|
||||||
|
@ -175,12 +175,12 @@ void API_Impl::Update()
|
||||||
if( rSquared != 0.0 )
|
if( rSquared != 0.0 )
|
||||||
{
|
{
|
||||||
Float force = Physics3D::Formula::ForceField( this->gravityConstant, state.GetMass(), this->gravity[i].well.mass, rSquared );
|
Float force = Physics3D::Formula::ForceField( this->gravityConstant, state.GetMass(), this->gravity[i].well.mass, rSquared );
|
||||||
state.ApplyLinearImpulse( (this->updateFrameLength * force / ::std::sqrt(rSquared)) * d );
|
gravityImpulse += (this->updateFrameLength * force / ::std::sqrt(rSquared)) * d;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Gravity::GravityType_Directed:
|
case Gravity::GravityType_Directed:
|
||||||
state.ApplyLinearImpulse( Float4(this->gravity[i].directed.impulse, 0.0f) );
|
gravityImpulse += Float4( this->gravity[i].directed.impulse, 0.0f );
|
||||||
break;
|
break;
|
||||||
// case Gravity::GravityType_DirectedField:
|
// case Gravity::GravityType_DirectedField:
|
||||||
// //this->gravity[i].directedField.
|
// //this->gravity[i].directedField.
|
||||||
|
@ -189,7 +189,14 @@ void API_Impl::Update()
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(*proto)->SetState( state );
|
|
||||||
|
if( gravityImpulse != Float4::null )
|
||||||
|
{
|
||||||
|
(*proto)->GetState( state );
|
||||||
|
state.ApplyLinearImpulse( gravityImpulse );
|
||||||
|
(*proto)->SetGravityNormal( gravityImpulse.GetNormalized().xyz );
|
||||||
|
(*proto)->SetState( state );
|
||||||
|
}
|
||||||
|
|
||||||
// Step 2: Apply Collision Response
|
// Step 2: Apply Collision Response
|
||||||
this->worldScene.Visit( *proto, OnPossibleCollision );
|
this->worldScene.Visit( *proto, OnPossibleCollision );
|
||||||
|
|
|
@ -32,8 +32,8 @@ namespace Oyster
|
||||||
::Utility::DynamicMemory::UniquePointer<ICustomBody> ExtractObject( const ICustomBody* objRef );
|
::Utility::DynamicMemory::UniquePointer<ICustomBody> ExtractObject( const ICustomBody* objRef );
|
||||||
void DestroyObject( const ICustomBody* objRef );
|
void DestroyObject( const ICustomBody* objRef );
|
||||||
|
|
||||||
void AddGravity( const Gravity &g );
|
void AddGravity( const API::Gravity &g );
|
||||||
void RemoveGravity( const Gravity &g );
|
void RemoveGravity( const API::Gravity &g );
|
||||||
|
|
||||||
//void ApplyForceAt( const ICustomBody* objRef, const ::Oyster::Math::Float3 &worldPos, const ::Oyster::Math::Float3 &worldF );
|
//void ApplyForceAt( const ICustomBody* objRef, const ::Oyster::Math::Float3 &worldPos, const ::Oyster::Math::Float3 &worldF );
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ namespace Oyster
|
||||||
private:
|
private:
|
||||||
::Oyster::Math::Float gravityConstant, updateFrameLength;
|
::Oyster::Math::Float gravityConstant, updateFrameLength;
|
||||||
EventAction_Destruction destructionAction;
|
EventAction_Destruction destructionAction;
|
||||||
::std::vector<Gravity> gravity;
|
::std::vector<API::Gravity> gravity;
|
||||||
Octree worldScene;
|
Octree worldScene;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -129,12 +129,12 @@ namespace Oyster
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* TODO: @todo doc
|
* TODO: @todo doc
|
||||||
********************************************************/
|
********************************************************/
|
||||||
virtual void AddGravity( const Gravity &g ) = 0;
|
virtual void AddGravity( const API::Gravity &g ) = 0;
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* TODO: @todo doc
|
* TODO: @todo doc
|
||||||
********************************************************/
|
********************************************************/
|
||||||
virtual void RemoveGravity( const Gravity &g ) = 0;
|
virtual void RemoveGravity( const API::Gravity &g ) = 0;
|
||||||
|
|
||||||
///********************************************************
|
///********************************************************
|
||||||
// * Apply force on an object.
|
// * Apply force on an object.
|
||||||
|
|
Loading…
Reference in New Issue