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

◆ Intersects() [9/9]

void Microsoft.Xna.Framework.BoundingBox.Intersects ( ref Ray ray,
out float? result )
inline

Definition at line 341 of file BoundingBox.cs.

342 {
343 result = null;
344 float num = 0f;
345 float num2 = float.MaxValue;
346 if (Math.Abs(ray.Direction.X) < 1E-06f)
347 {
348 if (ray.Position.X < Min.X || ray.Position.X > Max.X)
349 {
350 return;
351 }
352 }
353 else
354 {
355 float num3 = 1f / ray.Direction.X;
356 float num4 = (Min.X - ray.Position.X) * num3;
357 float num5 = (Max.X - ray.Position.X) * num3;
358 if (num4 > num5)
359 {
360 float num6 = num4;
361 num4 = num5;
362 num5 = num6;
363 }
364 num = MathHelper.Max(num4, num);
365 num2 = MathHelper.Min(num5, num2);
366 if (num > num2)
367 {
368 return;
369 }
370 }
371 if (Math.Abs(ray.Direction.Y) < 1E-06f)
372 {
373 if (ray.Position.Y < Min.Y || ray.Position.Y > Max.Y)
374 {
375 return;
376 }
377 }
378 else
379 {
380 float num7 = 1f / ray.Direction.Y;
381 float num8 = (Min.Y - ray.Position.Y) * num7;
382 float num9 = (Max.Y - ray.Position.Y) * num7;
383 if (num8 > num9)
384 {
385 float num10 = num8;
386 num8 = num9;
387 num9 = num10;
388 }
389 num = MathHelper.Max(num8, num);
390 num2 = MathHelper.Min(num9, num2);
391 if (num > num2)
392 {
393 return;
394 }
395 }
396 if (Math.Abs(ray.Direction.Z) < 1E-06f)
397 {
398 if (ray.Position.Z < Min.Z || ray.Position.Z > Max.Z)
399 {
400 return;
401 }
402 }
403 else
404 {
405 float num11 = 1f / ray.Direction.Z;
406 float num12 = (Min.Z - ray.Position.Z) * num11;
407 float num13 = (Max.Z - ray.Position.Z) * num11;
408 if (num12 > num13)
409 {
410 float num14 = num12;
411 num12 = num13;
412 num13 = num14;
413 }
414 num = MathHelper.Max(num12, num);
415 num2 = MathHelper.Min(num13, num2);
416 if (num > num2)
417 {
418 return;
419 }
420 }
421 result = num;
422 }
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.