… | |
… | |
162 | } |
162 | } |
163 | |
163 | |
164 | struct cone { |
164 | struct cone { |
165 | point p; |
165 | point p; |
166 | vec3 a; // axis |
166 | vec3 a; // axis |
167 | GLfloat f, fs1, fc; // angle |
167 | GLfloat f, fs1, fc2; // angle |
168 | |
168 | |
169 | cone () { }; |
169 | cone () { }; |
170 | cone (const point &p, const vec3 &a, GLfloat f) |
170 | cone (const point &p, const vec3 &a, GLfloat f) |
171 | : p(p), a(a), f(f) |
171 | : p(p), a(a), f(f) |
172 | { |
172 | { |
173 | fs1 = 1.F / sinf (f); |
173 | fs1 = 1.F / sinf (f); |
174 | fc = cosf (f); |
174 | fc2 = cosf (f); fc2 *= fc2; |
175 | }; |
175 | }; |
176 | }; |
176 | }; |
177 | |
177 | |
178 | inline bool overlap (const cone &c, const sphere &s) |
178 | inline bool overlap (const cone &c, const sphere &s) |
179 | { |
179 | { |
180 | vec3 d = s.p - c.p + c.a * (s.r * c.fs1); |
180 | vec3 d = s.p - c.p + c.a * (s.r * c.fs1); |
181 | return dot (c.a, d) >= length (d) * c.fc; |
181 | GLfloat dd = dot (c.a, d); |
|
|
182 | return dd > 0.F && dd * dd >= length2 (d) * c.fc2; |
182 | } |
183 | } |
183 | |
184 | |
184 | void renormalize (sector &s, point &p); |
185 | void renormalize (sector &s, point &p); |
185 | |
186 | |
186 | struct colour |
187 | struct colour |