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