public void Emit()
 {
     var p = new Particle(.8f, .5f, ttl);
     p.Position = this.Position;
     p.Velocity = this.Target * this.Velocity;
     pe.AddSpirit(p);
 }
        public FlameBall(Vector2 pos, Vector2 vel, float maxAge)
        {
            PolyBody = new Particle(.8f, .5f, maxAge);
            PolyBody.Position = pos;
            PolyBody.Velocity = vel;
            PolyBody.Deleted += new PhysicsEventHandler(p_Deleted);
            Scale = 1f;

            PolyBody.Rotation = ((float)(new Random()).NextDouble()) * 2f * (float)Math.PI;

            Load();
        }
        public static bool TestCollisionPartiPoly(Particle p, PolyBody bod, out Vector2 axis, out float disp)
        {
            axis = new Vector2();
            disp = float.MinValue;

            var norms = bod.GetNormals().ToList();

            Vector2 closeV = Vector2.Zero;
            var verts = bod.GetTransformedVertices();
            float min = float.MaxValue;
            foreach (var v in verts)
            {
                var d = (p.Position - v).LengthSquared();
                if (d < min)
                {
                    d = min;
                    closeV = v;
                }
            }
            if (closeV != Vector2.Zero && p.Position - closeV != Vector2.Zero)
            {
                var pNorm = Vector2.Normalize(p.Position - closeV);
                norms.Add(pNorm);
            }

            //
            //Col test
            //
            foreach (Vector2 ax in norms)
            {
                float d = Projection.IntervalDist(p.Project(ax), bod.Project(ax));

                if (d > 0) //no collision if even 1 separating axis found
                {
                    disp = 0;
                    return false;
                }
                else if (d > disp) //return disp w/ lowset overlap (ie: highest separation)
                {
                    disp = d;
                    axis = ax;
                }

            }

            if (Vector2.Dot(p.Position - bod.Position, axis) < 0) //make sure the normal always points from p->bod. (should this use .GetCentroid() instead of position?)
                axis = -axis;
            return true;
        }