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

Comparing libgender/util.h (file contents):
Revision 1.27 by root, Thu Oct 7 23:39:43 2004 UTC vs.
Revision 1.28 by root, Fri Oct 8 09:45:25 2004 UTC

107}; 107};
108 108
109struct sector { 109struct sector {
110 soffs x, y, z; 110 soffs x, y, z;
111 111
112 sector (soffs x = 0, soffs y = 0, soffs z = 0) : x(x), y(y), z(z) { }; 112 sector (soffs x, soffs y, soffs z) : x(x), y(y), z(z) { };
113 sector (soffs xyz = 0) : x(xyz), y(xyz), z(xyz) { };
113 114
114 void offset (int subindex, uoffs extent) 115 void offset (int subindex, uoffs extent)
115 { 116 {
116 if (subindex & 1) x += extent; 117 if (subindex & 1) x += extent;
117 if (subindex & 2) y += extent; 118 if (subindex & 2) y += extent;
118 if (subindex & 4) z += extent; 119 if (subindex & 4) z += extent;
119 } 120 }
120}; 121};
121 122
122inline const sector operator +(const sector &a, const sector &b) 123inline sector operator +(const sector &a, const sector &b)
123{ 124{
124 return sector (a.x + b.x, a.y + b.y, a.z + b.z); 125 return sector (a.x + b.x, a.y + b.y, a.z + b.z);
125} 126}
126 127
127inline const sector operator -(const sector &a, const sector &b) 128inline sector operator -(const sector &a, const sector &b)
128{ 129{
129 return sector (a.x - b.x, a.y - b.y, a.z - b.z); 130 return sector (a.x - b.x, a.y - b.y, a.z - b.z);
130} 131}
131 132
133inline sector operator /(const sector &a, soffs b)
134{
135 return sector (a.x / b, a.y / b, a.z / b);
136}
137
138inline bool operator <=(const sector &a, const sector &b)
139{
140 return a.x <= b.x && a.y <= b.y && a.z <= b.z;
141}
142
132inline const sector translate (const sector &p, const sector &src, const sector &dst) 143inline sector translate (const sector &p, const sector &src, const sector &dst)
133{ 144{
134 return p + (dst - src); 145 return p + (dst - src);
146}
147
148inline sector abs (const sector &s)
149{
150 return sector (abs (s.x), abs (s.y), abs (s.z));
135} 151}
136 152
137void renormalize (sector &s, point &p); 153void renormalize (sector &s, point &p);
138 154
139struct colour { 155struct colour {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines