ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/util.h
(Generate patch)

Comparing libgender/util.h (file contents):
Revision 1.7 by root, Sun Oct 3 23:59:30 2004 UTC vs.
Revision 1.8 by root, Mon Oct 4 02:06:57 2004 UTC

10 10
11typedef int soffs; // 32 bit 11typedef int soffs; // 32 bit
12typedef unsigned int uoffs; 12typedef unsigned int uoffs;
13#define OFFS_BITS 31 13#define OFFS_BITS 31
14#define SOFFS_MIN (soffs)-(1 << (OFFS_BITS - 1)) 14#define SOFFS_MIN (soffs)-(1 << (OFFS_BITS - 1))
15#define SOFFS_MAX (soffs)+(1 << (OFFS_BITS - 1))
15#define MAXEXTENT ((1UL << OFFS_BITS) - 1) 16#define MAXEXTENT ((1UL << OFFS_BITS) - 1)
16 17
17#define GLFLOAT_MAX 1e30 18#define GLFLOAT_MAX 1e30
18#define GLFLOAT_MIN -1e30 19#define GLFLOAT_MIN -1e30
19 20
20struct sector { 21struct sector {
21 soffs x, y, z; 22 soffs x, y, z;
23
24 sector (soffs x = 0, soffs y = 0, soffs z = 0) : x(x), y(y), z(z) { };
22 25
23 void offset (int subindex, uoffs extent) 26 void offset (int subindex, uoffs extent)
24 { 27 {
25 if (subindex & 1) x += extent; 28 if (subindex & 1) x += extent;
26 if (subindex & 2) y += extent; 29 if (subindex & 2) y += extent;
33 36
34 point () { }; 37 point () { };
35 point (GLfloat x, GLfloat y, GLfloat z) : x(x), y(y), z(z) { }; 38 point (GLfloat x, GLfloat y, GLfloat z) : x(x), y(y), z(z) { };
36}; 39};
37 40
38inline const point translate (const point &p, const sector &src, const sector &dst) 41inline const sector translate (const sector &p, const sector &src, const sector &dst)
39{ 42{
40 point r; 43 sector r;
41 44
42 r.x = p.x + (dst.x - src.x); 45 r.x = p.x + (dst.x - src.x);
43 r.y = p.y + (dst.y - src.y); 46 r.y = p.y + (dst.y - src.y);
44 r.z = p.z + (dst.z - src.z); 47 r.z = p.z + (dst.z - src.z);
45 48
105 texc () { }; 108 texc () { };
106 texc (GLfloat s, GLfloat t) : s(s), t(t) { }; 109 texc (GLfloat s, GLfloat t) : s(s), t(t) { };
107}; 110};
108 111
109struct box { 112struct box {
110 point a, b; 113 sector a, b;
114
115 box() { };
111 116
112 void reset () 117 void reset ()
113 { 118 {
114 a = point (GLFLOAT_MAX, GLFLOAT_MAX, GLFLOAT_MAX); 119 a = sector (SOFFS_MIN, SOFFS_MIN, SOFFS_MIN);
115 b = point (GLFLOAT_MIN, GLFLOAT_MIN, GLFLOAT_MIN); 120 b = sector (SOFFS_MAX, SOFFS_MAX, SOFFS_MAX);
116 } 121 }
117 122
118 void add (const box &o); 123 void add (const box &o);
124 void add (const sector &p);
119 void add (const point &p); 125 void add (const point &p);
120}; 126};
121 127
122inline const box translate (const box &b, const sector &src, const sector &dst) 128inline const box translate (const box &b, const sector &src, const sector &dst)
123{ 129{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines