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

◆ Intersects() [3/7]

float? Microsoft.Xna.Framework.Ray.Intersects ( BoundingSphere sphere)
inline

Definition at line 120 of file Ray.cs.

121 {
122 float num = sphere.Center.X - Position.X;
123 float num2 = sphere.Center.Y - Position.Y;
124 float num3 = sphere.Center.Z - Position.Z;
125 float num4 = num * num + num2 * num2 + num3 * num3;
126 float num5 = sphere.Radius * sphere.Radius;
127 if (num4 <= num5)
128 {
129 return 0f;
130 }
131 float num6 = num * Direction.X + num2 * Direction.Y + num3 * Direction.Z;
132 if (num6 < 0f)
133 {
134 return null;
135 }
136 float num7 = num4 - num6 * num6;
137 if (num7 > num5)
138 {
139 return null;
140 }
141 float num8 = (float)Math.Sqrt(num5 - num7);
142 return num6 - num8;
143 }
static double Sqrt(double d)

References Microsoft.Xna.Framework.Ray.Direction, Microsoft.Xna.Framework.BoundingSphere.Radius, System.Math.Sqrt(), and Microsoft.Xna.Framework.Vector3.Z.