Ejemplo n.º 1
0
        public Vector3 intersects(CollisionCylinder other)
        {
            float yDiff = this.position.Y - other.position.Y;
            float combinedHeight = this.Height + other.Height;
            float combinedRadius = this.Radius + other.Radius;

            //first check if height intersects
            if (Math.Abs(yDiff) < combinedHeight )
            {
                Vector2 xzDiff = new Vector2(this.position.X - other.position.X,this.position.Z - other.position.Z);
                if (xzDiff.LengthSquared() < combinedRadius * combinedRadius)
                {
                    float intersectY = combinedHeight - yDiff;
                    Vector2 intersectXZ = Vector2.Normalize(xzDiff) * (combinedRadius - xzDiff.Length());

                    if (intersectY * intersectY < intersectXZ.LengthSquared())
                    {
                        return  Vector3.Up * (combinedHeight - yDiff);
                    }
                    else
                    {
                        return new Vector3(intersectXZ.X,0f, intersectXZ.Y);
                    }
                }

            }
            return Vector3.Zero;
        }
Ejemplo n.º 2
0
 public Vector3 intersects(CollisionCylinder other)
 {
     Console.Out.WriteLine("Don't use me!");
                 //TODO: Fix this to account for rotation too
     return Vector3.Zero;
 }