1 #ifndef __GNUC__
2 #pragma once
3 #endif
4 #ifndef __XR_RECT_H__
5 #define __XR_RECT_H__
6 
7 #include "xr_limits.h"
8 #include "xr_vector2.h"
9 
10 namespace xray_re {
11 
12 template<typename T> struct _rect {
13 	_rect<T>&	invalidate();
14 	_rect<T>&	extend(const _vector2<T>& v);
15 	union {
16 		struct {
17 			_vector2<T>	lt;
18 			_vector2<T>	rb;
19 		};
20 		struct {
21 			T		x1, y1;
22 			T		x2, y2;
23 		};
24 		struct {
25 			T		left, top;
26 			T		right, bottom;
27 		};
28 	};
29 };
30 
31 typedef _rect<float> frect;
32 typedef _rect<int> irect;
33 
invalidate()34 template<typename T> _rect<T>& _rect<T>::invalidate()
35 {
36 	x1 = y1 = xr_numeric_limits<T>::max();
37 	x2 = y2 = xr_numeric_limits<T>::real_min();
38 	return *this;
39 }
40 
extend(const _vector2<T> & v)41 template<typename T> _rect<T>& _rect<T>::extend(const _vector2<T>& v)
42 {
43 	lt.min(v);
44 	rb.max(v);
45 	return *this;
46 }
47 
48 } // end of namespace xray_re
49 
50 #endif
51