Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Intersects() [5/9]

float? Microsoft.Xna.Framework.BoundingBox.Intersects ( Ray ray)
inline

Definition at line 259 of file BoundingBox.cs.

260 {
261 float num = 0f;
262 float num2 = float.MaxValue;
263 if (Math.Abs(ray.Direction.X) < 1E-06f)
264 {
265 if (ray.Position.X < Min.X || ray.Position.X > Max.X)
266 {
267 return null;
268 }
269 }
270 else
271 {
272 float num3 = 1f / ray.Direction.X;
273 float num4 = (Min.X - ray.Position.X) * num3;
274 float num5 = (Max.X - ray.Position.X) * num3;
275 if (num4 > num5)
276 {
277 float num6 = num4;
278 num4 = num5;
279 num5 = num6;
280 }
281 num = MathHelper.Max(num4, num);
282 num2 = MathHelper.Min(num5, num2);
283 if (num > num2)
284 {
285 return null;
286 }
287 }
288 if (Math.Abs(ray.Direction.Y) < 1E-06f)
289 {
290 if (ray.Position.Y < Min.Y || ray.Position.Y > Max.Y)
291 {
292 return null;
293 }
294 }
295 else
296 {
297 float num7 = 1f / ray.Direction.Y;
298 float num8 = (Min.Y - ray.Position.Y) * num7;
299 float num9 = (Max.Y - ray.Position.Y) * num7;
300 if (num8 > num9)
301 {
302 float num10 = num8;
303 num8 = num9;
304 num9 = num10;
305 }
306 num = MathHelper.Max(num8, num);
307 num2 = MathHelper.Min(num9, num2);
308 if (num > num2)
309 {
310 return null;
311 }
312 }
313 if (Math.Abs(ray.Direction.Z) < 1E-06f)
314 {
315 if (ray.Position.Z < Min.Z || ray.Position.Z > Max.Z)
316 {
317 return null;
318 }
319 }
320 else
321 {
322 float num11 = 1f / ray.Direction.Z;
323 float num12 = (Min.Z - ray.Position.Z) * num11;
324 float num13 = (Max.Z - ray.Position.Z) * num11;
325 if (num12 > num13)
326 {
327 float num14 = num12;
328 num12 = num13;
329 num13 = num14;
330 }
331 num = MathHelper.Max(num12, num);
332 num2 = MathHelper.Min(num13, num2);
333 if (num > num2)
334 {
335 return null;
336 }
337 }
338 return num;
339 }
static double Abs(double value)

References System.Math.Abs(), System.E, Microsoft.Xna.Framework.BoundingBox.Max, Microsoft.Xna.Framework.MathHelper.Max(), Microsoft.Xna.Framework.BoundingBox.Min, Microsoft.Xna.Framework.MathHelper.Min(), Microsoft.Xna.Framework.Vector3.X, Microsoft.Xna.Framework.Vector3.Y, and Microsoft.Xna.Framework.Vector3.Z.