Added Equal operators to Gravity struct

== & !=
This commit is contained in:
Dander7BD 2014-01-15 10:44:20 +01:00
parent 8c7a17ff8f
commit 7a48e058da
2 changed files with 96 additions and 2 deletions

View File

@ -353,6 +353,26 @@ namespace Oyster
return *this;
}
inline bool GravityWell::operator == ( const GravityWell &gravity ) const
{
if( this->position == gravity.position )
if( this->mass == gravity.mass )
{
return true;
}
return false;
}
inline bool GravityWell::operator != ( const GravityWell &gravity ) const
{
if( this->position == gravity.position )
if( this->mass == gravity.mass )
{
return false;
}
return true;
}
inline GravityDirected::GravityDirected( )
{
this->impulse = ::Oyster::Math::Float3::null;
@ -370,6 +390,16 @@ namespace Oyster
return *this;
}
inline bool GravityDirected::operator == ( const GravityDirected &gravity ) const
{
return this->impulse == gravity.impulse;
}
inline bool GravityDirected::operator != ( const GravityDirected &gravity ) const
{
return this->impulse != gravity.impulse;
}
inline GravityDirectedField::GravityDirectedField( )
{
this->normalizedDirection = ::Oyster::Math::Float3::null;
@ -393,6 +423,28 @@ namespace Oyster
return *this;
}
inline bool GravityDirectedField::operator == ( const GravityDirectedField &gravity ) const
{
if( this->normalizedDirection == gravity.normalizedDirection )
if( this->mass == gravity.mass )
if( this->magnitude == gravity.magnitude )
{
return true;
}
return false;
}
inline bool GravityDirectedField::operator != ( const GravityDirectedField &gravity ) const
{
if( this->normalizedDirection == gravity.normalizedDirection )
if( this->mass == gravity.mass )
if( this->magnitude == gravity.magnitude )
{
return false;
}
return true;
}
inline Gravity::Gravity()
{
this->gravityType = GravityType_Undefined;
@ -437,6 +489,36 @@ namespace Oyster
return *this;
}
inline bool Gravity::operator == ( const Gravity &gravity ) const
{
if( this->gravityType == gravity.gravityType )
{
switch( this->gravityType )
{
case GravityType_Well: return this->well == gravity.well;
case GravityType_Directed: return this->directed == gravity.directed;
case GravityType_DirectedField: return this->directedField == gravity.directedField;
default: return true;
}
}
return false;
}
inline bool Gravity::operator != ( const Gravity &gravity ) const
{
if( this->gravityType == gravity.gravityType )
{
switch( this->gravityType )
{
case GravityType_Well: return this->well != gravity.well;
case GravityType_Directed: return this->directed != gravity.directed;
case GravityType_DirectedField: return this->directedField != gravity.directedField;
default: return false;
}
}
return true;
}
}
}
}

View File

@ -123,7 +123,10 @@ namespace Oyster { namespace Physics
GravityWell( );
GravityWell( const GravityWell &gravityWell );
GravityWell& operator=( const GravityWell &gravityWell );
GravityWell & operator = ( const GravityWell &gravityWell );
bool operator == ( const GravityWell &gravity ) const;
bool operator != ( const GravityWell &gravity ) const;
};
struct GravityDirected
@ -133,6 +136,9 @@ namespace Oyster { namespace Physics
GravityDirected( );
GravityDirected( const GravityDirected &gravityDirected );
GravityDirected & operator = ( const GravityDirected &gravityDirected );
bool operator == ( const GravityDirected &gravity ) const;
bool operator != ( const GravityDirected &gravity ) const;
};
struct GravityDirectedField
@ -143,7 +149,10 @@ namespace Oyster { namespace Physics
GravityDirectedField( );
GravityDirectedField( const GravityDirectedField &gravityDirectedField );
GravityDirectedField & operator=( const GravityDirectedField &gravityDirectedField );
GravityDirectedField & operator = ( const GravityDirectedField &gravityDirectedField );
bool operator == ( const GravityDirectedField &gravity ) const;
bool operator != ( const GravityDirectedField &gravity ) const;
};
struct Gravity
@ -177,6 +186,9 @@ namespace Oyster { namespace Physics
Gravity( );
Gravity( const Gravity &gravity );
Gravity & operator = ( const Gravity &gravity );
bool operator == ( const Gravity &gravity ) const;
bool operator != ( const Gravity &gravity ) const;
};
}
} }