comparison engine/core/util/structures/utilstructures.i @ 622:c0c3f64bfc2d

* Templatized Rect to extend it's functionality beyond integers * Added some typedefs: Rect, FloatRect, DoubleRect * Removed the Rect class from the fife_math extensions * Modified the shooter demo to use the FIFE rect template class
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 01 Oct 2010 15:32:55 +0000
parents 90005975cdbb
children 291ba2946c73
comparison
equal deleted inserted replaced
621:356634098bd9 622:c0c3f64bfc2d
79 typedef PointType3D<double> DoublePoint3D; 79 typedef PointType3D<double> DoublePoint3D;
80 80
81 %template(Point3D) PointType3D<int>; 81 %template(Point3D) PointType3D<int>;
82 %template(DoublePoint3D) PointType3D<double>; 82 %template(DoublePoint3D) PointType3D<double>;
83 83
84 class Rect { 84 template <typename T> class RectType {
85 public: 85 public:
86 int x; 86 T x;
87 int y; 87 T y;
88 int w; 88 T w;
89 int h; 89 T h;
90 explicit Rect(int x = 0, int y = 0, unsigned int width = 0, unsigned int height = 0); 90 explicit RectType(T x = 0, T y = 0, T width = 0, T height = 0);
91 int right() const; 91 T right() const;
92 int bottom() const; 92 T bottom() const;
93 bool operator==(const Rect& rect ) const; 93 bool operator==(const RectType<T>& rect ) const;
94 bool contains( const Point& point ) const; 94 bool contains( const PointType2D<T>& point ) const;
95 bool intersects( const Rect& rect ) const; 95 bool intersects( const RectType<T>& rect ) const;
96 bool intersectInplace( const Rect& rect ); 96 bool intersectInplace( const RectType<T>& rect );
97 }; 97 };
98 std::ostream& operator<<(std::ostream&, const Rect&); 98
99 template<typename T>
100 std::ostream& operator<<(std::ostream&, const RectType<T>&);
101
102 typedef RectType<int> Rect;
103 typedef RectType<float> FloatRect;
104 typedef RectType<double> DoubleRect;
105
106 %template(Rect) RectType<int>;
107 %template(FloatRect) RectType<float>;
108 %template(DoubleRect) RectType<double>;
99 } 109 }