void DrawParticle(ShaderResourceView shaderResourceToUse, Vector2 startPosition, Vector2 spriteSize, float uvOffset, RectangleF textureRegionToDraw, Vector2 velocity, double timeToLive, int?extraInt1, double rotationVelocity)
        {
            var factor = _spriteSize.X / spriteSize.X;

            SpriteBatchParticle p = new SpriteBatchParticle()
            {
                Position            = startPosition * factor,
                Elapsed             = 0,
                TimeToLive          = timeToLive,
                Velocity            = velocity,
                Size                = spriteSize,
                IsAlive             = true,
                TextureView         = shaderResourceToUse,
                RotationVelocity    = rotationVelocity,
                TextureRegionToDraw = textureRegionToDraw,
                ExtraInt1           = extraInt1.HasValue ? (int)extraInt1 : 0
            };


            m_particles.Add(p);
            //return p;
        }
        void DrawParticle(ShaderResourceView shaderResourceToUse, Vector2 startPosition, Vector2 spriteSize, float uvOffset, RectangleF textureRegionToDraw, Vector2 velocity, double timeToLive, int? extraInt1, double rotationVelocity)
        {
            var factor = _spriteSize.X / spriteSize.X;

            SpriteBatchParticle p = new SpriteBatchParticle()
            {
                Position = startPosition * factor,
                Elapsed = 0,
                TimeToLive = timeToLive,
                Velocity = velocity,
                Size = spriteSize,
                IsAlive = true,
                TextureView = shaderResourceToUse,
                RotationVelocity = rotationVelocity,
                TextureRegionToDraw = textureRegionToDraw,
                ExtraInt1 = extraInt1.HasValue ? (int)extraInt1 : 0
            };


            m_particles.Add(p);
            //return p;
        }
        public void End()
        {
            int pc = m_particles.Count;

            for (int i = pc - 1; i >= 0; i--)
            {
                SpriteBatchParticle p = m_particles[i];

                if (p.IsAlive)
                {
                    p.Position += p.Velocity;
                    p.Elapsed  += 15;
                    //p.RotationVelocity += 0.1;


                    if (double.IsNaN(p.TimeToLive))
                    {
                        //Sprite doesnt die and hence TimToLive is NAN and Opacity = 1
                        p.Opacity = 1.0;
                        RenderParticle(m_viewProj, p.Position, p.Size, (float)p.Opacity, m_d3dContext, p.TextureView, (float)p.RotationVelocity, p.TextureRegionToDraw);
                    }
                    else
                    {
                        //These sprites will eventually die (TimeToLive)
                        p.Opacity = Lerp(1, 0, (float)(p.Elapsed / p.TimeToLive));

                        if (p.Elapsed > p.TimeToLive)
                        {
                            p.IsAlive = false;
                        }
                        else
                        {
                            RenderParticle(m_viewProj, p.Position, p.Size, (float)p.Opacity, m_d3dContext, p.TextureView, (float)p.RotationVelocity, p.TextureRegionToDraw);
                        }
                        if (p.Opacity <= 0.1d)
                        {
                            p.IsAlive = false;
                        }
                    }
                }
            }


            //Do this expensive remove every 60 frames only
            //frameToDoRemove_60++;
            //if (frameToDoRemove_60 == 60)
            //{
            m_particles.RemoveAll(x => x.IsAlive == false);
            //    frameToDoRemove_60 = 0;
            //}



            ////DEBUGGER
            //if (debugBackEvery60Frames == 10)
            //{

            //    Messenger.Default.Send(new DebuggingRendererMessage("",
            //        "Sprites to render : " + m_particles.Where(x => x.IsAlive).Count().ToString(),
            //        string.Empty,
            //        string.Empty
            //        ) { Identifier = "SB1" });

            //    debugBackEvery60Frames = 0;
            //}
            debugBackEvery60Frames++;
        }