… | |
… | |
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, fs, fc; // angle |
167 | GLfloat f, fs1, fc; // 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 | fs = sinf (f); |
173 | fs1 = 1.F / sinf (f); |
174 | fc = cosf (f); |
174 | fc = cosf (f); |
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 u = c.p - c.a * (s.r / c.fs); |
180 | vec3 d = s.p - c.p + c.a * (s.r * c.fs1); |
181 | vec3 d = s.p - u; |
|
|
182 | return dot (c.a, d) >= length (d) * c.fc; |
181 | return dot (c.a, d) >= length (d) * c.fc; |
183 | } |
182 | } |
184 | |
183 | |
185 | void renormalize (sector &s, point &p); |
184 | void renormalize (sector &s, point &p); |
186 | |
185 | |