Exemplo n.º 1
0
        internal override bool GetCollisionCircle(CollisionCircle obj)
        {
            //float rd2 = Pow2(obj.Radius + Width);
            //Vector2 ao = obj.Position - Position;
            //Vector2 bo = obj.Position - End;

            //if (ao.LengthSquared() <= rd2 || bo.LengthSquared() <= rd2) return true;
            //if (!(Vector2.Dot(-Line, ao) * Vector2.Dot(Line, bo) >= 0)) return false;
            //if ((Line.Y * obj.Position.X + Line.X * obj.Position.Y + Position.X * Line.Y - Position.Y * Line.X)
            //    / Line.LengthSquared() <= rd2) return true;
            if (System.Math.Abs(MathUtilXNA.Cross(obj.Position - Begin, Line) / (Line.Length())) > obj.Radius) return false;
            if (Vector2.Dot(Line, obj.Position - Begin) * Vector2.Dot(-Line, obj.Position - End) <= 0) return true;
            if (obj.GetCollision(new CollisionPoint(Begin)) || obj.GetCollision(new CollisionPoint(End))) return true;
            return false;
        }
Exemplo n.º 2
0
 internal override bool GetCollisionCircle(CollisionCircle obj)
 {
     return obj.GetCollision(this);
 }