post merge + minor edits

derepetifified code in struct Gravity
and some cosmetic consistency edits.
This commit is contained in:
Dander7BD 2014-01-09 11:36:55 +01:00
parent c39e2fe791
commit 938447879f
3 changed files with 244 additions and 234 deletions

View File

@ -1,6 +1,22 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<ShowAllFiles>true</ShowAllFiles> <ShowAllFiles>false</ShowAllFiles>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -12,8 +12,8 @@ namespace Oyster
inline SimpleBodyDescription::SimpleBodyDescription() inline SimpleBodyDescription::SimpleBodyDescription()
{ {
this->rotation = ::Oyster::Math::Float4x4::identity; this->rotation = ::Oyster::Math::Float4x4::identity;
this->centerPosition = ::Oyster::Math::Float4::null; this->centerPosition = ::Oyster::Math::Float4::standard_unit_w;
this->size = ::Oyster::Math::Float4( 1.0f ); this->size = ::Oyster::Math::Float4( 1.0f );
this->mass = 12.0f; this->mass = 12.0f;
this->inertiaTensor = ::Oyster::Math::Float4x4::identity; this->inertiaTensor = ::Oyster::Math::Float4x4::identity;
this->subscription = NULL; this->subscription = NULL;
@ -23,76 +23,76 @@ namespace Oyster
inline SphericalBodyDescription::SphericalBodyDescription() inline SphericalBodyDescription::SphericalBodyDescription()
{ {
this->rotation = ::Oyster::Math::Float4x4::identity; this->rotation = ::Oyster::Math::Float4x4::identity;
this->centerPosition = ::Oyster::Math::Float4::null; this->centerPosition = ::Oyster::Math::Float4::standard_unit_w;
this->radius = 0.5f; this->radius = 0.5f;
this->mass = 10.0f; this->mass = 10.0f;
this->subscription = NULL; this->subscription = NULL;
this->ignoreGravity = false; this->ignoreGravity = false;
} }
inline CustomBodyState::CustomBodyState( ::Oyster::Math::Float mass, ::Oyster::Math::Float restitutionCoeff, ::Oyster::Math::Float staticFrictionCoeff, ::Oyster::Math::Float kineticFrictionCoeff, const ::Oyster::Math::Float4x4 &inertiaTensor, const ::Oyster::Math::Float4 &reach, const ::Oyster::Math::Float4 &centerPos, const ::Oyster::Math::Float4 &rotation, const ::Oyster::Math::Float4 &linearMomentum, const ::Oyster::Math::Float4 &angularMomentum ) inline CustomBodyState::CustomBodyState( ::Oyster::Math::Float mass, ::Oyster::Math::Float restitutionCoeff, ::Oyster::Math::Float staticFrictionCoeff, ::Oyster::Math::Float kineticFrictionCoeff, const ::Oyster::Math::Float4x4 &inertiaTensor, const ::Oyster::Math::Float4 &reach, const ::Oyster::Math::Float4 &centerPos, const ::Oyster::Math::Float4 &rotation, const ::Oyster::Math::Float4 &linearMomentum, const ::Oyster::Math::Float4 &angularMomentum )
{ {
this->mass = mass; this->mass = mass;
this->restitutionCoeff = restitutionCoeff; this->restitutionCoeff = restitutionCoeff;
this->staticFrictionCoeff = staticFrictionCoeff; this->staticFrictionCoeff = staticFrictionCoeff;
this->kineticFrictionCoeff = kineticFrictionCoeff; this->kineticFrictionCoeff = kineticFrictionCoeff;
this->inertiaTensor = inertiaTensor; this->inertiaTensor = inertiaTensor;
this->reach = reach; this->reach = reach;
this->centerPos = centerPos; this->centerPos = centerPos;
this->angularAxis = rotation; this->angularAxis = rotation;
this->linearMomentum = linearMomentum; this->linearMomentum = linearMomentum;
this->angularMomentum = angularMomentum; this->angularMomentum = angularMomentum;
this->linearImpulse = this->angularImpulse = ::Oyster::Math::Float4::null; this->linearImpulse = this->angularImpulse = ::Oyster::Math::Float4::null;
this->deltaPos = this->deltaAxis = ::Oyster::Math::Float4::null; this->deltaPos = this->deltaAxis = ::Oyster::Math::Float4::null;
this->isSpatiallyAltered = this->isDisturbed = this->isForwarded = false; this->isSpatiallyAltered = this->isDisturbed = this->isForwarded = false;
} }
inline CustomBodyState & CustomBodyState::operator = ( const CustomBodyState &state ) inline CustomBodyState & CustomBodyState::operator = ( const CustomBodyState &state )
{ {
this->mass = state.mass; this->mass = state.mass;
this->restitutionCoeff = state.restitutionCoeff; this->restitutionCoeff = state.restitutionCoeff;
this->staticFrictionCoeff = state.staticFrictionCoeff; this->staticFrictionCoeff = state.staticFrictionCoeff;
this->kineticFrictionCoeff = state.kineticFrictionCoeff; this->kineticFrictionCoeff = state.kineticFrictionCoeff;
this->inertiaTensor = state.inertiaTensor; this->inertiaTensor = state.inertiaTensor;
this->reach = state.reach; this->reach = state.reach;
this->centerPos = state.centerPos; this->centerPos = state.centerPos;
this->angularAxis = state.angularAxis; this->angularAxis = state.angularAxis;
this->linearMomentum = state.linearMomentum; this->linearMomentum = state.linearMomentum;
this->angularMomentum = state.angularMomentum; this->angularMomentum = state.angularMomentum;
this->linearImpulse = state.linearImpulse; this->linearImpulse = state.linearImpulse;
this->angularImpulse = state.angularImpulse; this->angularImpulse = state.angularImpulse;
this->deltaPos = state.deltaPos; this->deltaPos = state.deltaPos;
this->deltaAxis = state.deltaAxis; this->deltaAxis = state.deltaAxis;
this->isSpatiallyAltered = state.isSpatiallyAltered; this->isSpatiallyAltered = state.isSpatiallyAltered;
this->isDisturbed = state.isDisturbed; this->isDisturbed = state.isDisturbed;
this->isForwarded = state.isForwarded; this->isForwarded = state.isForwarded;
return *this; return *this;
} }
inline const ::Oyster::Math::Float CustomBodyState::GetMass() const inline const ::Oyster::Math::Float CustomBodyState::GetMass() const
{ {
return this->mass; return this->mass;
} }
inline const ::Oyster::Math::Float CustomBodyState::GetRestitutionCoeff() const inline const ::Oyster::Math::Float CustomBodyState::GetRestitutionCoeff() const
{ {
return this->restitutionCoeff; return this->restitutionCoeff;
} }
inline const ::Oyster::Math::Float CustomBodyState::GetFrictionCoeff_Static() const inline const ::Oyster::Math::Float CustomBodyState::GetFrictionCoeff_Static() const
{ {
return this->staticFrictionCoeff; return this->staticFrictionCoeff;
} }
inline const ::Oyster::Math::Float CustomBodyState::GetFrictionCoeff_Kinetic() const inline const ::Oyster::Math::Float CustomBodyState::GetFrictionCoeff_Kinetic() const
{ {
return this->kineticFrictionCoeff; return this->kineticFrictionCoeff;
} }
inline const ::Oyster::Math::Float4x4 & CustomBodyState::GetMomentOfInertia() const inline const ::Oyster::Math::Float4x4 & CustomBodyState::GetMomentOfInertia() const
{ {
return this->inertiaTensor; return this->inertiaTensor;
} }
inline const ::Oyster::Math::Float4 & CustomBodyState::GetReach() const inline const ::Oyster::Math::Float4 & CustomBodyState::GetReach() const
{ {
@ -119,126 +119,126 @@ namespace Oyster
return ::Oyster::Math3D::RotationMatrix( this->GetAngularAxis().xyz ); return ::Oyster::Math3D::RotationMatrix( this->GetAngularAxis().xyz );
} }
inline ::Oyster::Math::Float4x4 CustomBodyState::GetOrientation() const inline ::Oyster::Math::Float4x4 CustomBodyState::GetOrientation() const
{ {
return ::Oyster::Math3D::OrientationMatrix( this->angularAxis.xyz, this->centerPos.xyz ); return ::Oyster::Math3D::OrientationMatrix( this->angularAxis.xyz, this->centerPos.xyz );
} }
inline ::Oyster::Math::Float4x4 CustomBodyState::GetOrientation( const ::Oyster::Math::Float4 &offset ) const inline ::Oyster::Math::Float4x4 CustomBodyState::GetOrientation( const ::Oyster::Math::Float4 &offset ) const
{ {
return ::Oyster::Math3D::OrientationMatrix( this->angularAxis.xyz, (this->centerPos + offset).xyz ); return ::Oyster::Math3D::OrientationMatrix( this->angularAxis.xyz, (this->centerPos + offset).xyz );
} }
inline ::Oyster::Math::Float4x4 CustomBodyState::GetView() const inline ::Oyster::Math::Float4x4 CustomBodyState::GetView() const
{ {
return ::Oyster::Math3D::ViewMatrix( this->angularAxis.xyz, this->centerPos.xyz ); return ::Oyster::Math3D::ViewMatrix( this->angularAxis.xyz, this->centerPos.xyz );
} }
inline ::Oyster::Math::Float4x4 CustomBodyState::GetView( const ::Oyster::Math::Float4 &offset ) const inline ::Oyster::Math::Float4x4 CustomBodyState::GetView( const ::Oyster::Math::Float4 &offset ) const
{ {
return ::Oyster::Math3D::ViewMatrix( this->angularAxis.xyz, (this->centerPos + offset).xyz ); return ::Oyster::Math3D::ViewMatrix( this->angularAxis.xyz, (this->centerPos + offset).xyz );
} }
inline const ::Oyster::Math::Float4 & CustomBodyState::GetLinearMomentum() const inline const ::Oyster::Math::Float4 & CustomBodyState::GetLinearMomentum() const
{ {
return this->linearMomentum; return this->linearMomentum;
} }
inline ::Oyster::Math::Float4 CustomBodyState::GetLinearMomentum( const ::Oyster::Math::Float4 &at ) const inline ::Oyster::Math::Float4 CustomBodyState::GetLinearMomentum( const ::Oyster::Math::Float4 &at ) const
{ {
//return this->linearMomentum + ::Oyster::Physics3D::Formula::TangentialLinearMomentum( this->angularMomentum, at - this->centerPos ); // C3083 error? //return this->linearMomentum + ::Oyster::Physics3D::Formula::TangentialLinearMomentum( this->angularMomentum, at - this->centerPos ); // C3083 error?
return this->linearMomentum + ::Oyster::Math::Float4( this->angularMomentum.xyz.Cross((at - this->centerPos).xyz), 0.0f ); return this->linearMomentum + ::Oyster::Math::Float4( this->angularMomentum.xyz.Cross((at - this->centerPos).xyz), 0.0f );
} }
inline const ::Oyster::Math::Float4 & CustomBodyState::GetAngularMomentum() const inline const ::Oyster::Math::Float4 & CustomBodyState::GetAngularMomentum() const
{ {
return this->angularMomentum; return this->angularMomentum;
} }
inline const ::Oyster::Math::Float4 & CustomBodyState::GetLinearImpulse() const inline const ::Oyster::Math::Float4 & CustomBodyState::GetLinearImpulse() const
{ {
return this->linearImpulse; return this->linearImpulse;
} }
inline const ::Oyster::Math::Float4 & CustomBodyState::GetAngularImpulse() const inline const ::Oyster::Math::Float4 & CustomBodyState::GetAngularImpulse() const
{ {
return this->angularImpulse; return this->angularImpulse;
} }
inline const ::Oyster::Math::Float4 & CustomBodyState::GetForward_DeltaPos() const inline const ::Oyster::Math::Float4 & CustomBodyState::GetForward_DeltaPos() const
{ {
return this->deltaPos; return this->deltaPos;
} }
inline const ::Oyster::Math::Float4 & CustomBodyState::GetForward_DeltaAxis() const inline const ::Oyster::Math::Float4 & CustomBodyState::GetForward_DeltaAxis() const
{ {
return this->deltaAxis; return this->deltaAxis;
} }
inline void CustomBodyState::SetMass_KeepMomentum( ::Oyster::Math::Float m ) inline void CustomBodyState::SetMass_KeepMomentum( ::Oyster::Math::Float m )
{ {
this->mass = m;
}
inline void CustomBodyState::SetMass_KeepVelocity( ::Oyster::Math::Float m )
{
if( m != 0.0f )
{ // sanity block!
// Formula::LinearMomentum( m, Formula::LinearVelocity(this->mass, this->linearMomentum) )
// is the same as (this->linearMomentum / this->mass) * m = (m / this->mass) * this->linearMomentum
this->linearMomentum *= (m / this->mass);
this->mass = m; this->mass = m;
} }
}
inline void CustomBodyState::SetRestitutionCoeff( ::Oyster::Math::Float e ) inline void CustomBodyState::SetMass_KeepVelocity( ::Oyster::Math::Float m )
{ {
this->restitutionCoeff = e; if( m != 0.0f )
} { // sanity block!
// Formula::LinearMomentum( m, Formula::LinearVelocity(this->mass, this->linearMomentum) )
inline void CustomBodyState::SetFrictionCoeff( ::Oyster::Math::Float staticU, ::Oyster::Math::Float kineticU ) // is the same as (this->linearMomentum / this->mass) * m = (m / this->mass) * this->linearMomentum
{ this->linearMomentum *= (m / this->mass);
this->staticFrictionCoeff = staticU; this->mass = m;
this->kineticFrictionCoeff = kineticU; }
} }
inline void CustomBodyState::SetMomentOfInertia_KeepMomentum( const ::Oyster::Math::Float4x4 &tensor ) inline void CustomBodyState::SetRestitutionCoeff( ::Oyster::Math::Float e )
{ {
this->inertiaTensor = tensor; this->restitutionCoeff = e;
} }
inline void CustomBodyState::SetMomentOfInertia_KeepVelocity( const ::Oyster::Math::Float4x4 &tensor ) inline void CustomBodyState::SetFrictionCoeff( ::Oyster::Math::Float staticU, ::Oyster::Math::Float kineticU )
{ {
if( tensor.GetDeterminant() != 0.0f ) this->staticFrictionCoeff = staticU;
{ // sanity block! this->kineticFrictionCoeff = kineticU;
::Oyster::Math::Float4x4 rotation = ::Oyster::Math3D::RotationMatrix(this->angularAxis.xyz); }
//::Oyster::Math::Float4 w = ::Oyster::Physics3D::Formula::AngularVelocity( (rotation * this->inertiaTensor).GetInverse(), this->angularMomentum ); // C3083 error?
::Oyster::Math::Float4 w = (rotation * this->inertiaTensor).GetInverse() * this->angularMomentum; inline void CustomBodyState::SetMomentOfInertia_KeepMomentum( const ::Oyster::Math::Float4x4 &tensor )
this->inertiaTensor = tensor; {
//this->angularMomentum = ::Oyster::Physics3D::Formula::AngularMomentum( rotation * tensor, w ); // C3083 error? this->inertiaTensor = tensor;
this->angularMomentum = rotation * tensor * w; }
inline void CustomBodyState::SetMomentOfInertia_KeepVelocity( const ::Oyster::Math::Float4x4 &tensor )
{
if( tensor.GetDeterminant() != 0.0f )
{ // sanity block!
::Oyster::Math::Float4x4 rotation = ::Oyster::Math3D::RotationMatrix(this->angularAxis.xyz);
//::Oyster::Math::Float4 w = ::Oyster::Physics3D::Formula::AngularVelocity( (rotation * this->inertiaTensor).GetInverse(), this->angularMomentum ); // C3083 error?
::Oyster::Math::Float4 w = (rotation * this->inertiaTensor).GetInverse() * this->angularMomentum;
this->inertiaTensor = tensor;
//this->angularMomentum = ::Oyster::Physics3D::Formula::AngularMomentum( rotation * tensor, w ); // C3083 error?
this->angularMomentum = rotation * tensor * w;
}
} }
}
inline void CustomBodyState::SetSize( const ::Oyster::Math::Float4 &size ) inline void CustomBodyState::SetSize( const ::Oyster::Math::Float4 &size )
{ {
this->SetReach( 0.5f * size ); this->SetReach( 0.5f * size );
} }
inline void CustomBodyState::SetReach( const ::Oyster::Math::Float4 &halfSize ) inline void CustomBodyState::SetReach( const ::Oyster::Math::Float4 &halfSize )
{ {
this->reach.xyz = halfSize; this->reach.xyz = halfSize;
this->reach = ::Utility::Value::Max( this->reach, ::Oyster::Math::Float4::null ); this->reach = ::Utility::Value::Max( this->reach, ::Oyster::Math::Float4::null );
this->isSpatiallyAltered = this->isDisturbed = true; this->isSpatiallyAltered = this->isDisturbed = true;
} }
inline void CustomBodyState::SetCenterPosition( const ::Oyster::Math::Float4 &centerPos ) inline void CustomBodyState::SetCenterPosition( const ::Oyster::Math::Float4 &centerPos )
{ {
this->centerPos.xyz = centerPos; this->centerPos.xyz = centerPos;
this->isSpatiallyAltered = this->isDisturbed = true; this->isSpatiallyAltered = this->isDisturbed = true;
} }
inline void CustomBodyState::SetRotation( const ::Oyster::Math::Float4 &angularAxis ) inline void CustomBodyState::SetRotation( const ::Oyster::Math::Float4 &angularAxis )
{ {
this->angularAxis.xyz = angularAxis; this->angularAxis.xyz = angularAxis;
this->isSpatiallyAltered = this->isDisturbed = true; this->isSpatiallyAltered = this->isDisturbed = true;
@ -246,78 +246,78 @@ namespace Oyster
inline void CustomBodyState::SetRotation( const ::Oyster::Math::Float4x4 &rotation ) inline void CustomBodyState::SetRotation( const ::Oyster::Math::Float4x4 &rotation )
{ {
this->SetRotation( ::Oyster::Math3D::AngularAxis(rotation) ); this->SetRotation( ::Oyster::Math3D::AngularAxis(rotation) );
} }
inline void CustomBodyState::SetOrientation( const ::Oyster::Math::Float4x4 &orientation ) inline void CustomBodyState::SetOrientation( const ::Oyster::Math::Float4x4 &orientation )
{ {
this->SetRotation( ::Oyster::Math3D::ExtractAngularAxis(orientation) ); this->SetRotation( ::Oyster::Math3D::ExtractAngularAxis(orientation) );
this->SetCenterPosition( orientation.v[3] ); this->SetCenterPosition( orientation.v[3] );
} }
inline void CustomBodyState::SetLinearMomentum( const ::Oyster::Math::Float4 &g ) inline void CustomBodyState::SetLinearMomentum( const ::Oyster::Math::Float4 &g )
{ {
this->linearMomentum.xyz = g; this->linearMomentum.xyz = g;
this->isDisturbed = true; this->isDisturbed = true;
} }
inline void CustomBodyState::SetAngularMomentum( const ::Oyster::Math::Float4 &h ) inline void CustomBodyState::SetAngularMomentum( const ::Oyster::Math::Float4 &h )
{ {
this->angularMomentum.xyz = h; this->angularMomentum.xyz = h;
this->isDisturbed = true; this->isDisturbed = true;
} }
inline void CustomBodyState::SetLinearImpulse( const ::Oyster::Math::Float4 &j ) inline void CustomBodyState::SetLinearImpulse( const ::Oyster::Math::Float4 &j )
{ {
this->linearImpulse.xyz = j; this->linearImpulse.xyz = j;
this->isDisturbed = true; this->isDisturbed = true;
} }
inline void CustomBodyState::SetAngularImpulse( const ::Oyster::Math::Float4 &j ) inline void CustomBodyState::SetAngularImpulse( const ::Oyster::Math::Float4 &j )
{ {
this->angularImpulse.xyz = j; this->angularImpulse.xyz = j;
this->isDisturbed = true; this->isDisturbed = true;
} }
inline void CustomBodyState::AddRotation( const ::Oyster::Math::Float4 &angularAxis ) inline void CustomBodyState::AddRotation( const ::Oyster::Math::Float4 &angularAxis )
{ {
this->angularAxis += angularAxis; this->angularAxis += angularAxis;
this->isSpatiallyAltered = this->isDisturbed = true; this->isSpatiallyAltered = this->isDisturbed = true;
} }
inline void CustomBodyState::AddTranslation( const ::Oyster::Math::Float4 &deltaPos ) inline void CustomBodyState::AddTranslation( const ::Oyster::Math::Float4 &deltaPos )
{ {
this->centerPos += deltaPos; this->centerPos += deltaPos;
this->isSpatiallyAltered = this->isDisturbed = true; this->isSpatiallyAltered = this->isDisturbed = true;
} }
inline void CustomBodyState::ApplyLinearImpulse( const ::Oyster::Math::Float4 &j ) inline void CustomBodyState::ApplyLinearImpulse( const ::Oyster::Math::Float4 &j )
{ {
this->linearImpulse += j; this->linearImpulse += j;
this->isDisturbed = true; this->isDisturbed = true;
} }
inline void CustomBodyState::ApplyAngularImpulse( const ::Oyster::Math::Float4 &j ) inline void CustomBodyState::ApplyAngularImpulse( const ::Oyster::Math::Float4 &j )
{ {
this->angularImpulse += j; this->angularImpulse += j;
this->isDisturbed = true; this->isDisturbed = true;
} }
inline void CustomBodyState::ApplyImpulse( const ::Oyster::Math::Float4 &j, const ::Oyster::Math::Float4 &at, const ::Oyster::Math::Float4 &normal ) inline void CustomBodyState::ApplyImpulse( const ::Oyster::Math::Float4 &j, const ::Oyster::Math::Float4 &at, const ::Oyster::Math::Float4 &normal )
{ {
//::Oyster::Math::Float4 tangentialImpulse = ::Oyster::Physics3D::Formula::AngularMomentum( j, at - this->centerPos ); // C3083 error? //::Oyster::Math::Float4 tangentialImpulse = ::Oyster::Physics3D::Formula::AngularMomentum( j, at - this->centerPos ); // C3083 error?
::Oyster::Math::Float4 tangentialImpulse = ::Oyster::Math::Float4( (at - this->centerPos).xyz.Cross(j.xyz), 0.0f ); ::Oyster::Math::Float4 tangentialImpulse = ::Oyster::Math::Float4( (at - this->centerPos).xyz.Cross(j.xyz), 0.0f );
this->linearImpulse += j - tangentialImpulse; this->linearImpulse += j - tangentialImpulse;
this->angularImpulse += tangentialImpulse; this->angularImpulse += tangentialImpulse;
this->isDisturbed = true; this->isDisturbed = true;
} }
inline void CustomBodyState::ApplyForwarding( const ::Oyster::Math::Float4 &deltaPos, const ::Oyster::Math::Float4 &deltaAxis ) inline void CustomBodyState::ApplyForwarding( const ::Oyster::Math::Float4 &deltaPos, const ::Oyster::Math::Float4 &deltaAxis )
{ {
this->deltaPos += deltaPos; this->deltaPos += deltaPos;
this->deltaAxis += deltaAxis; this->deltaAxis += deltaAxis;
this->isDisturbed = this->isForwarded = true; this->isDisturbed = this->isForwarded = true;
} }
inline bool CustomBodyState::IsSpatiallyAltered() const inline bool CustomBodyState::IsSpatiallyAltered() const
@ -328,11 +328,11 @@ namespace Oyster
inline bool CustomBodyState::IsDisturbed() const inline bool CustomBodyState::IsDisturbed() const
{ {
return this->isDisturbed; return this->isDisturbed;
} }
inline bool CustomBodyState::IsForwarded() const inline bool CustomBodyState::IsForwarded() const
{ {
return this->isForwarded; return this->isForwarded;
} }
inline GravityWell::GravityWell( ) inline GravityWell::GravityWell( )
@ -341,13 +341,13 @@ namespace Oyster
this->mass = 0.0f; this->mass = 0.0f;
} }
inline GravityWell::GravityWell( const GravityWell& gravityWell ) inline GravityWell::GravityWell( const GravityWell &gravityWell )
{ {
this->position = gravityWell.position; this->position = gravityWell.position;
this->mass = gravityWell.mass; this->mass = gravityWell.mass;
} }
GravityWell& GravityWell::operator=( const GravityWell& gravityWell ) GravityWell & GravityWell::operator = ( const GravityWell &gravityWell )
{ {
this->position = gravityWell.position; this->position = gravityWell.position;
this->mass = gravityWell.mass; this->mass = gravityWell.mass;
@ -360,12 +360,12 @@ namespace Oyster
this->impulse = ::Oyster::Math::Float3::null; this->impulse = ::Oyster::Math::Float3::null;
} }
inline GravityDirected::GravityDirected( const GravityDirected& gravityDirected ) inline GravityDirected::GravityDirected( const GravityDirected &gravityDirected )
{ {
this->impulse = gravityDirected.impulse; this->impulse = gravityDirected.impulse;
} }
inline GravityDirected& GravityDirected::operator=( const GravityDirected& gravityDirected ) inline GravityDirected & GravityDirected::operator = ( const GravityDirected &gravityDirected )
{ {
this->impulse = gravityDirected.impulse; this->impulse = gravityDirected.impulse;
@ -379,13 +379,14 @@ namespace Oyster
this->magnitude = 0.0f; this->magnitude = 0.0f;
} }
inline GravityDirectedField::GravityDirectedField( const GravityDirectedField& gravityDirectedField ) inline GravityDirectedField::GravityDirectedField( const GravityDirectedField &gravityDirectedField )
{ {
this->normalizedDirection = gravityDirectedField.normalizedDirection; this->normalizedDirection = gravityDirectedField.normalizedDirection;
this->mass = gravityDirectedField.mass; this->mass = gravityDirectedField.mass;
this->magnitude = gravityDirectedField.magnitude; this->magnitude = gravityDirectedField.magnitude;
} }
inline GravityDirectedField& GravityDirectedField::operator=( const GravityDirectedField& gravityDirectedField )
inline GravityDirectedField& GravityDirectedField::operator = ( const GravityDirectedField &gravityDirectedField )
{ {
this->normalizedDirection = gravityDirectedField.normalizedDirection; this->normalizedDirection = gravityDirectedField.normalizedDirection;
this->mass = gravityDirectedField.mass; this->mass = gravityDirectedField.mass;
@ -399,40 +400,34 @@ namespace Oyster
this->gravityType = GravityType_Undefined; this->gravityType = GravityType_Undefined;
} }
inline Gravity::Gravity( const Gravity& gravity ) inline Gravity::Gravity( const Gravity &gravity )
{ {
switch(gravity.gravityType) switch( gravity.gravityType )
{ {
case GravityType_Well: case GravityType_Well:
this->well.position = gravity.well.position; this->well = gravity.well;
this->well.mass = gravity.well.mass;
break; break;
case GravityType_Directed: case GravityType_Directed:
this->directed.impulse = gravity.directed.impulse; this->directed = gravity.directed;
break; break;
case GravityType_DirectedField: case GravityType_DirectedField:
this->directedField.normalizedDirection = gravity.directedField.normalizedDirection; this->directedField = gravity.directedField;
this->directedField.magnitude = gravity.directedField.magnitude;
this->directedField.mass = gravity.directedField.mass;
break; break;
} }
} }
inline Gravity& Gravity::operator=( const Gravity& gravity ) inline Gravity & Gravity::operator = ( const Gravity &gravity )
{ {
switch(gravity.gravityType) switch( gravity.gravityType )
{ {
case GravityType_Well: case GravityType_Well:
this->well.position = gravity.well.position; this->well = gravity.well;
this->well.mass = gravity.well.mass;
break; break;
case GravityType_Directed: case GravityType_Directed:
this->directed.impulse = gravity.directed.impulse; this->directed = gravity.directed;
break; break;
case GravityType_DirectedField: case GravityType_DirectedField:
this->directedField.normalizedDirection = gravity.directedField.normalizedDirection; this->directedField = gravity.directedField;
this->directedField.magnitude = gravity.directedField.magnitude;
this->directedField.mass = gravity.directedField.mass;
break; break;
} }

View File

@ -122,8 +122,8 @@ namespace Oyster { namespace Physics
::Oyster::Math::Float mass; ::Oyster::Math::Float mass;
GravityWell( ); GravityWell( );
GravityWell( const GravityWell& gravityWell ); GravityWell( const GravityWell &gravityWell );
GravityWell& operator=( const GravityWell& gravityWell ); GravityWell& operator=( const GravityWell &gravityWell );
}; };
struct GravityDirected struct GravityDirected
@ -131,8 +131,8 @@ namespace Oyster { namespace Physics
::Oyster::Math::Float3 impulse; ::Oyster::Math::Float3 impulse;
GravityDirected( ); GravityDirected( );
GravityDirected( const GravityDirected& gravityDirected ); GravityDirected( const GravityDirected &gravityDirected );
GravityDirected& operator=( const GravityDirected& gravityDirected ); GravityDirected & operator = ( const GravityDirected &gravityDirected );
}; };
struct GravityDirectedField struct GravityDirectedField
@ -142,8 +142,8 @@ namespace Oyster { namespace Physics
::Oyster::Math::Float magnitude; ::Oyster::Math::Float magnitude;
GravityDirectedField( ); GravityDirectedField( );
GravityDirectedField( const GravityDirectedField& gravityDirectedField ); GravityDirectedField( const GravityDirectedField &gravityDirectedField );
GravityDirectedField& operator=( const GravityDirectedField& gravityDirectedField ); GravityDirectedField & operator=( const GravityDirectedField &gravityDirectedField );
}; };
struct Gravity struct Gravity
@ -175,9 +175,8 @@ namespace Oyster { namespace Physics
}; };
Gravity( ); Gravity( );
Gravity( const Gravity& gravity ); Gravity( const Gravity &gravity );
Gravity& operator=( const Gravity& gravity ); Gravity & operator = ( const Gravity &gravity );
}; };
} }
} } } }