From 7a48e058dae48abe5a2f780ad10941c00ffd3293 Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Wed, 15 Jan 2014 10:44:20 +0100 Subject: [PATCH] Added Equal operators to Gravity struct == & != --- Code/GamePhysics/PhysicsStructs-Impl.h | 82 ++++++++++++++++++++++++++ Code/GamePhysics/PhysicsStructs.h | 16 ++++- 2 files changed, 96 insertions(+), 2 deletions(-) diff --git a/Code/GamePhysics/PhysicsStructs-Impl.h b/Code/GamePhysics/PhysicsStructs-Impl.h index c74c6537..17c18ba2 100644 --- a/Code/GamePhysics/PhysicsStructs-Impl.h +++ b/Code/GamePhysics/PhysicsStructs-Impl.h @@ -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; + } } } } diff --git a/Code/GamePhysics/PhysicsStructs.h b/Code/GamePhysics/PhysicsStructs.h index bf6c0618..7ed37c59 100644 --- a/Code/GamePhysics/PhysicsStructs.h +++ b/Code/GamePhysics/PhysicsStructs.h @@ -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; }; } } }