… | |
… | |
107 | }; |
107 | }; |
108 | |
108 | |
109 | struct sector { |
109 | struct 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 | |
122 | inline const sector operator +(const sector &a, const sector &b) |
123 | inline 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 | |
127 | inline const sector operator -(const sector &a, const sector &b) |
128 | inline 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 | |
|
|
133 | inline sector operator /(const sector &a, soffs b) |
|
|
134 | { |
|
|
135 | return sector (a.x / b, a.y / b, a.z / b); |
|
|
136 | } |
|
|
137 | |
|
|
138 | inline 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 | |
132 | inline const sector translate (const sector &p, const sector &src, const sector &dst) |
143 | inline 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 | |
|
|
148 | inline sector abs (const sector &s) |
|
|
149 | { |
|
|
150 | return sector (abs (s.x), abs (s.y), abs (s.z)); |
135 | } |
151 | } |
136 | |
152 | |
137 | void renormalize (sector &s, point &p); |
153 | void renormalize (sector &s, point &p); |
138 | |
154 | |
139 | struct colour { |
155 | struct colour { |