collision::Constraints Class Reference

#include <collision.hpp>

List of all members.

Public Member Functions

 Constraints ()
bool has_constraints () const
void constrain_left (float position, float velocity)
void constrain_right (float position, float velocity)
void constrain_top (float position, float velocity)
void constrain_bottom (float position, float velocity)
float get_position_left (void) const
float get_position_right (void) const
float get_position_top (void) const
float get_position_bottom (void) const
float get_height (void) const
float get_width (void) const
float get_x_midpoint (void) const

Public Attributes

Vector ground_movement
CollisionHit hit

Private Attributes

float position_left
float position_right
float position_top
float position_bottom
float speed_left
float speed_right
float speed_top
float speed_bottom


Detailed Description

Definition at line 30 of file collision.hpp.


Constructor & Destructor Documentation

collision::Constraints::Constraints (  )  [inline]

Definition at line 33 of file collision.hpp.

References position_bottom, position_left, position_right, position_top, speed_bottom, speed_left, speed_right, and speed_top.

00033                 :
00034     ground_movement(),
00035     hit(),
00036     position_left(),
00037     position_right(),
00038     position_top(),
00039     position_bottom(),
00040     speed_left(),
00041     speed_right(),
00042     speed_top(),
00043     speed_bottom()
00044   {
00045     float infinity = (std::numeric_limits<float>::has_infinity ? 
00046                       std::numeric_limits<float>::infinity() : 
00047                       std::numeric_limits<float>::max());
00048     position_left = -infinity;
00049     position_right = infinity;
00050     position_top = -infinity;
00051     position_bottom = infinity;
00052 
00053     speed_left = -infinity;
00054     speed_right = infinity;
00055     speed_top = -infinity;
00056     speed_bottom = infinity;
00057   }


Member Function Documentation

bool collision::Constraints::has_constraints (  )  const [inline]

Definition at line 59 of file collision.hpp.

References position_bottom, position_left, position_right, and position_top.

00060   {
00061     float infinity = (std::numeric_limits<float>::has_infinity ?
00062                       std::numeric_limits<float>::infinity() : 
00063                       std::numeric_limits<float>::max());
00064     return
00065       position_left   > -infinity || 
00066       position_right  <  infinity || 
00067       position_top    > -infinity || 
00068       position_bottom <  infinity;
00069   }

void collision::Constraints::constrain_left ( float  position,
float  velocity 
) [inline]

Definition at line 73 of file collision.hpp.

References position_left, and speed_left.

Referenced by check_collisions(), collision::rectangle_aatriangle(), and collision::set_rectangle_rectangle_constraints().

00074   {
00075     position_left = std::max (position_left, position);
00076     speed_left = std::max (speed_left, velocity);
00077   }

void collision::Constraints::constrain_right ( float  position,
float  velocity 
) [inline]

Definition at line 79 of file collision.hpp.

References position_right, and speed_right.

Referenced by check_collisions(), collision::rectangle_aatriangle(), and collision::set_rectangle_rectangle_constraints().

00080   {
00081     position_right = std::min (position_right, position);
00082     speed_right = std::min (speed_right, velocity);
00083   }

void collision::Constraints::constrain_top ( float  position,
float  velocity 
) [inline]

Definition at line 85 of file collision.hpp.

References position_top, and speed_top.

Referenced by check_collisions(), collision::rectangle_aatriangle(), and collision::set_rectangle_rectangle_constraints().

00086   {
00087     position_top = std::max (position_top, position);
00088     speed_top = std::max (speed_top, velocity);
00089   }

void collision::Constraints::constrain_bottom ( float  position,
float  velocity 
) [inline]

Definition at line 91 of file collision.hpp.

References position_bottom, and speed_bottom.

Referenced by check_collisions(), collision::rectangle_aatriangle(), and collision::set_rectangle_rectangle_constraints().

00092   {
00093     position_bottom = std::min (position_bottom, position);
00094     speed_bottom = std::min (speed_bottom, velocity);
00095   }

float collision::Constraints::get_position_left ( void   )  const [inline]

Definition at line 97 of file collision.hpp.

References position_left.

00097 { return position_left;   }

float collision::Constraints::get_position_right ( void   )  const [inline]

Definition at line 98 of file collision.hpp.

References position_right.

00098 { return position_right;  }

float collision::Constraints::get_position_top ( void   )  const [inline]

Definition at line 99 of file collision.hpp.

References position_top.

00099 { return position_top;    }

float collision::Constraints::get_position_bottom ( void   )  const [inline]

Definition at line 100 of file collision.hpp.

References position_bottom.

00100 { return position_bottom; }

float collision::Constraints::get_height ( void   )  const [inline]

Definition at line 102 of file collision.hpp.

References position_bottom, and position_top.

00102 { return (position_bottom - position_top); }

float collision::Constraints::get_width ( void   )  const [inline]

Definition at line 103 of file collision.hpp.

References position_left, and position_right.

00103 { return (position_right - position_left); }

float collision::Constraints::get_x_midpoint ( void   )  const [inline]

Definition at line 105 of file collision.hpp.

References position_left, and position_right.

00105 { return (.5f * (position_left + position_right)); }


Member Data Documentation

Vector collision::Constraints::ground_movement

Definition at line 107 of file collision.hpp.

Referenced by check_collisions(), collision::rectangle_aatriangle(), and collision::set_rectangle_rectangle_constraints().

CollisionHit collision::Constraints::hit

Definition at line 108 of file collision.hpp.

Referenced by check_collisions(), collision::rectangle_aatriangle(), and collision::set_rectangle_rectangle_constraints().

float collision::Constraints::position_left [private]

Definition at line 111 of file collision.hpp.

Referenced by constrain_left(), Constraints(), get_position_left(), get_width(), get_x_midpoint(), and has_constraints().

float collision::Constraints::position_right [private]

Definition at line 112 of file collision.hpp.

Referenced by constrain_right(), Constraints(), get_position_right(), get_width(), get_x_midpoint(), and has_constraints().

float collision::Constraints::position_top [private]

Definition at line 113 of file collision.hpp.

Referenced by constrain_top(), Constraints(), get_height(), get_position_top(), and has_constraints().

float collision::Constraints::position_bottom [private]

Definition at line 114 of file collision.hpp.

Referenced by constrain_bottom(), Constraints(), get_height(), get_position_bottom(), and has_constraints().

float collision::Constraints::speed_left [private]

Definition at line 116 of file collision.hpp.

Referenced by constrain_left(), and Constraints().

float collision::Constraints::speed_right [private]

Definition at line 117 of file collision.hpp.

Referenced by constrain_right(), and Constraints().

float collision::Constraints::speed_top [private]

Definition at line 118 of file collision.hpp.

Referenced by constrain_top(), and Constraints().

float collision::Constraints::speed_bottom [private]

Definition at line 119 of file collision.hpp.

Referenced by constrain_bottom(), and Constraints().


The documentation for this class was generated from the following file:
Generated on Mon Apr 14 03:38:48 2014 for SuperTux by  doxygen 1.5.1