Mercurial > projects > openmelee
comparison ai/steer.d @ 20:6efd0830715b
ai work
author | zzzzrrr <mason.green@gmail.com> |
---|---|
date | Wed, 25 Mar 2009 15:25:25 -0400 |
parents | 08ddf9e71b88 |
children | cad384ad349e |
comparison
equal
deleted
inserted
replaced
19:08ddf9e71b88 | 20:6efd0830715b |
---|---|
157 for (bzBody o = obstacles; o; o = o.next) { | 157 for (bzBody o = obstacles; o; o = o.next) { |
158 | 158 |
159 if(o is m_body) continue; | 159 if(o is m_body) continue; |
160 | 160 |
161 // This code which presumes the obstacle is spherical | 161 // This code which presumes the obstacle is spherical |
162 findNextIntersectionWithSphere(o, next); | 162 findNextIntersectionWithSphere(o, next, minDistanceToCollision); |
163 | 163 |
164 if (!nearest.intersect || (next.intersect && next.distance < nearest.distance)) { | 164 if (!nearest.intersect || (next.intersect && next.distance < nearest.distance)) { |
165 nearest = next; | 165 nearest = next; |
166 } | 166 } |
167 } | 167 } |
182 | 182 |
183 return avoidance; | 183 return avoidance; |
184 } | 184 } |
185 | 185 |
186 void findNextIntersectionWithSphere(bzBody obs, | 186 void findNextIntersectionWithSphere(bzBody obs, |
187 inout PathIntersection intersection) { | 187 inout PathIntersection intersection, float mdc) { |
188 | 188 |
189 // This routine is based on the Paul Bourke's derivation in: | 189 // This routine is based on the Paul Bourke's derivation in: |
190 // Intersection of a Line and a Sphere (or circle) | 190 // Intersection of a Line and a Sphere (or circle) |
191 // http://www.swin.edu.au/astronomy/pbourke/geometry/sphereline/ | 191 // http://www.swin.edu.au/astronomy/pbourke/geometry/sphereline/ |
192 | 192 |
209 if(shape.sweepRadius > obsRadius) { | 209 if(shape.sweepRadius > obsRadius) { |
210 obsRadius = shape.sweepRadius; | 210 obsRadius = shape.sweepRadius; |
211 } | 211 } |
212 } | 212 } |
213 | 213 |
214 c = square(lc.x) + square(lc.y) - square(obsRadius + m_radius); | 214 c = square(lc.x) + square(lc.y) - square(obsRadius + m_radius+mdc); |
215 d = (b * b) - (4 * c); | 215 d = (b * b) - (4 * c); |
216 | 216 |
217 // when the path does not intersect the sphere | 217 // when the path does not intersect the sphere |
218 if (d < 0) return; | 218 if (d < 0) return; |
219 | 219 |