00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef AEDUPDATEMANAGER_H
00025 #define AEDUPDATEMANAGER_H
00026
00027 #include <vector>
00028 #include "SDL.h"
00029 #include "aedRect.h"
00030
00031
00032
00033
00034
00035 typedef struct Rect_Set Rect_Set;
00036 typedef struct Rect_Clips
00037 {
00038 int length;
00039 SDL_Rect rects;
00040
00041 } Rect_Clips;
00042
00043 #define _VERTICAL 0
00044 #define _HORIZONAL 1
00045
00046 #define _NOT_FOUND_ERR -1
00047 #define _NO_ERR 0
00048
00049 #define ABS(x) ((x) > 0 ? (x) : -(x))
00050 #define MAX(x, y) ((x) > (y) ? (x) : (y))
00051
00052 #define RD(value, mask) ((value) & ~(mask)) // round down a value
00053 #define RU(value, mask) (((value) + (mask)) & ~(mask)) // round up a value
00054
00055
00056
00057
00058 typedef struct _range_type
00059 {
00060 int length, size;
00061 int *points;
00062 } range_type;
00063
00064
00065 struct Rect_Set
00066 {
00067 range_type xs, ys, ms;
00068
00069 range_type xsum, ysum;
00070
00071
00072 Uint16 bits_mask;
00073
00074
00075 };
00076
00077
00078 class DLLEXPORT aedUpdateManager
00079 {
00080 public:
00081 bool addRect(aedRect & position);
00082 bool addRect(SDL_Rect & rect);
00083 bool purge(void);
00084 void printRects(void);
00085 bool updateRects(SDL_Surface * surf);
00086
00087 private:
00088 friend class DLLEXPORT aedApp;
00089
00090 aedUpdateManager();
00091 ~aedUpdateManager();
00092 void operator=(const aedUpdateManager &);
00093 aedUpdateManager(const aedUpdateManager &);
00094
00095 Sint32 checkRectForIntersections(aedRect & position);
00096 bool checkForIntersection(aedRect & rect1, aedRect & rect2);
00097
00098
00099 Rect_Set *new_rects(int bits);
00100 void free_rects(Rect_Set * rects);
00101 void clear_rects(Rect_Set * rects);
00102 void rects_union(Rect_Set * rects, Sint16 x, Sint16 y, Uint16 w, Uint16 h);
00103 void rects_subtract(Rect_Set * rects, Sint16 x, Sint16 y, Uint16 w,
00104 Uint16 h);
00105 void rects_intersect(Rect_Set * rects, Sint16 x, Sint16 y, Uint16 w,
00106 Uint16 h);
00107 int rects_intersects(Rect_Set * rects, Sint16 x, Sint16 y, Uint16 w,
00108 Uint16 h);
00109 Rect_Clips *rects_clip(Rect_Set * rs, SDL_Rect * r);
00110 void rects_print(Rect_Set * rs);
00111 int range_search(range_type * range, int value);
00112 void range_inserti(range_type * range, int pos, int value);
00113 int range_insert(range_type * range, int value, int *index);
00114 void range_removei(range_type * range, int pos);
00115 int range_remove(range_type * range, int value);
00116 int v_line_insert(Rect_Set * rs, int v);
00117 void v_line_remove(Rect_Set * rs, int v);
00118 int h_line_insert(Rect_Set * rs, int v);
00119 void h_line_remove(Rect_Set * rs, int v);
00120 int v_concentrate(Rect_Set * rs);
00121 int h_concentrate(Rect_Set * rs);
00122 void concentrate(Rect_Set * rs);
00123
00124 private:
00125 std::vector < aedRect > m_Rects;
00126
00127 Rect_Clips *m_Clips;
00128 Rect_Set *m_RectSet;
00129 };
00130
00131 #ifdef AEDGUI
00132 extern DLLEXPORT aedUpdateManager *pUpdateMgr;
00133 #endif
00134
00135 #endif