Commit to Dennis
This commit is contained in:
parent
b225c53611
commit
1633129a2c
|
@ -353,7 +353,7 @@ void GameState::readKeyInput(InputClass* KeyInput)
|
||||||
}
|
}
|
||||||
|
|
||||||
//send delta mouse movement
|
//send delta mouse movement
|
||||||
if (KeyInput->IsMousePressed())
|
//if (KeyInput->IsMousePressed())
|
||||||
{
|
{
|
||||||
camera->Yaw(-KeyInput->GetYaw());
|
camera->Yaw(-KeyInput->GetYaw());
|
||||||
camera->Pitch(KeyInput->GetPitch());
|
camera->Pitch(KeyInput->GetPitch());
|
||||||
|
|
|
@ -375,20 +375,21 @@ float API_Impl::GetFrameTimeLength() const
|
||||||
void API_Impl::Update()
|
void API_Impl::Update()
|
||||||
{ /** @todo TODO: Update is a temporary solution .*/
|
{ /** @todo TODO: Update is a temporary solution .*/
|
||||||
::std::vector<ICustomBody*> updateList;
|
::std::vector<ICustomBody*> updateList;
|
||||||
auto proto = this->worldScene.Sample( Universe(), updateList ).begin();
|
this->worldScene.Sample( Universe(), updateList );
|
||||||
ICustomBody::State state;
|
ICustomBody::State state;
|
||||||
for( ; proto != updateList.end(); ++proto )
|
for( int i = 0; i < updateList.size(); i++ )
|
||||||
{
|
{
|
||||||
|
auto proto = updateList[i];
|
||||||
// Step 1: Apply Gravity
|
// Step 1: Apply Gravity
|
||||||
Float4 gravityImpulse = Float4::null;
|
Float4 gravityImpulse = Float4::null;
|
||||||
(*proto)->GetState( state );
|
proto->GetState( state );
|
||||||
for( ::std::vector<Gravity>::size_type i = 0; i < this->gravity.size(); ++i )
|
for( int j = 0; j < this->gravity.size(); ++j )
|
||||||
{
|
{
|
||||||
switch( this->gravity[i].gravityType )
|
switch( this->gravity[j].gravityType )
|
||||||
{
|
{
|
||||||
case Gravity::GravityType_Well:
|
case Gravity::GravityType_Well:
|
||||||
{
|
{
|
||||||
Float4 d = Float4( this->gravity[i].well.position, 1.0f ) - Float4( state.GetCenterPosition(), 1.0f );
|
Float4 d = Float4( this->gravity[j].well.position, 1.0f ) - Float4( state.GetCenterPosition(), 1.0f );
|
||||||
Float rSquared = d.Dot( d );
|
Float rSquared = d.Dot( d );
|
||||||
if( rSquared != 0.0 )
|
if( rSquared != 0.0 )
|
||||||
{
|
{
|
||||||
|
@ -402,7 +403,7 @@ void API_Impl::Update()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Gravity::GravityType_Directed:
|
case Gravity::GravityType_Directed:
|
||||||
gravityImpulse += Float4( this->gravity[i].directed.impulse, 0.0f );
|
gravityImpulse += Float4( this->gravity[j].directed.impulse, 0.0f );
|
||||||
break;
|
break;
|
||||||
// case Gravity::GravityType_DirectedField:
|
// case Gravity::GravityType_DirectedField:
|
||||||
// //this->gravity[i].directedField.
|
// //this->gravity[i].directedField.
|
||||||
|
@ -419,20 +420,21 @@ void API_Impl::Update()
|
||||||
{
|
{
|
||||||
state.ApplyLinearImpulse( gravityImpulse.xyz );
|
state.ApplyLinearImpulse( gravityImpulse.xyz );
|
||||||
state.SetGravityNormal( gravityImpulse.GetNormalized().xyz );
|
state.SetGravityNormal( gravityImpulse.GetNormalized().xyz );
|
||||||
(*proto)->SetState( state );
|
proto->SetState( state );
|
||||||
}
|
}
|
||||||
if(state.GetMass() == 70)
|
if(state.GetMass() == 70)
|
||||||
{
|
{
|
||||||
const char *breakpoint = "STOP";
|
const char *breakpoint = "STOP";
|
||||||
}
|
}
|
||||||
// Step 2: Apply Collision Response
|
// Step 2: Apply Collision Response
|
||||||
this->worldScene.Visit( *proto, OnPossibleCollision );
|
this->worldScene.Visit( proto, OnPossibleCollision );
|
||||||
}
|
}
|
||||||
|
|
||||||
proto = updateList.begin();
|
|
||||||
for( ; proto != updateList.end(); ++proto )
|
for( int i = 0; i < updateList.size(); i++ )
|
||||||
{
|
{
|
||||||
(*proto)->GetState( state );
|
auto proto = updateList[i];
|
||||||
|
proto->GetState( state );
|
||||||
Float3 lM = state.GetLinearMomentum();
|
Float3 lM = state.GetLinearMomentum();
|
||||||
|
|
||||||
//LinearAlgebra3D::InterpolateAxisYToNormal_UsingNlerp(state.SetOrientation(, Float4(state.GetGravityNormal(), 0.0f), 1.0f);
|
//LinearAlgebra3D::InterpolateAxisYToNormal_UsingNlerp(state.SetOrientation(, Float4(state.GetGravityNormal(), 0.0f), 1.0f);
|
||||||
|
@ -451,13 +453,13 @@ void API_Impl::Update()
|
||||||
state.linearMomentum.z = 0;
|
state.linearMomentum.z = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*proto)->SetState( state );
|
proto->SetState( state );
|
||||||
|
|
||||||
switch( (*proto)->Update(this->updateFrameLength) )
|
switch( proto->Update(this->updateFrameLength) )
|
||||||
{
|
{
|
||||||
case UpdateState_altered:
|
case UpdateState_altered:
|
||||||
this->worldScene.SetAsAltered( this->worldScene.GetTemporaryReferenceOf(*proto) );
|
this->worldScene.SetAsAltered( this->worldScene.GetTemporaryReferenceOf(proto) );
|
||||||
(*proto)->CallSubscription_Move();
|
proto->CallSubscription_Move();
|
||||||
case UpdateState_resting:
|
case UpdateState_resting:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -51,8 +51,8 @@ void RigidBody::Update_LeapFrog( Float updateFrameLength )
|
||||||
// updating the linear
|
// updating the linear
|
||||||
//Decrease momentum with 1% as "fall-off"
|
//Decrease momentum with 1% as "fall-off"
|
||||||
//! HACK: @todo Add real solution with fluid drag
|
//! HACK: @todo Add real solution with fluid drag
|
||||||
//this->momentum_Linear = this->momentum_Linear*0.99f;
|
this->momentum_Linear = this->momentum_Linear*0.99f;
|
||||||
//this->momentum_Angular = this->momentum_Angular*0.99f;
|
this->momentum_Angular = this->momentum_Angular*0.99f;
|
||||||
|
|
||||||
// ds = dt * Formula::LinearVelocity( m, avg_G ) = dt * avg_G / m = (dt / m) * avg_G
|
// ds = dt * Formula::LinearVelocity( m, avg_G ) = dt * avg_G / m = (dt / m) * avg_G
|
||||||
Float3 delta = AverageWithDelta( this->momentum_Linear, this->impulse_Linear );
|
Float3 delta = AverageWithDelta( this->momentum_Linear, this->impulse_Linear );
|
||||||
|
@ -66,14 +66,14 @@ void RigidBody::Update_LeapFrog( Float updateFrameLength )
|
||||||
|
|
||||||
// updating the angular
|
// updating the angular
|
||||||
// dO = dt * Formula::AngularVelocity( (RI)^-1, avg_H ) = dt * (RI)^-1 * avg_H
|
// dO = dt * Formula::AngularVelocity( (RI)^-1, avg_H ) = dt * (RI)^-1 * avg_H
|
||||||
//this->axis += updateFrameLength * this->momentOfInertiaTensor.CalculateAngularVelocity( this->rotation, AverageWithDelta(this->momentum_Angular, this->impulse_Angular) );
|
this->axis += updateFrameLength * this->momentOfInertiaTensor.CalculateAngularVelocity( this->rotation, AverageWithDelta(this->momentum_Angular, this->impulse_Angular) );
|
||||||
//this->rotation = Rotation( this->axis );
|
this->rotation = Rotation( this->axis );
|
||||||
|
|
||||||
// update momentums and clear impulse_Linear and impulse_Angular
|
// update momentums and clear impulse_Linear and impulse_Angular
|
||||||
this->momentum_Linear += this->impulse_Linear;
|
this->momentum_Linear += this->impulse_Linear;
|
||||||
this->impulse_Linear = Float4::null;
|
this->impulse_Linear = Float4::null;
|
||||||
|
|
||||||
//this->momentum_Angular += this->impulse_Angular; //! HACK: @todo Rotation temporary disabled
|
this->momentum_Angular += this->impulse_Angular; //! HACK: @todo Rotation temporary disabled
|
||||||
this->impulse_Angular = Float4::null;
|
this->impulse_Angular = Float4::null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue