internal void Enable()
 {
     //Turn everything on.
     lock (FlipLocker)
     {
         int initialCount = Math.Max(manager.entities.Count, 64);
         backBuffer  = new MotionState[initialCount];
         frontBuffer = new MotionState[initialCount];
         for (int i = 0; i < manager.entities.Count; i++)
         {
             Entity entity = manager.entities[i];
             backBuffer[i].Position        = entity.position;
             backBuffer[i].Orientation     = entity.orientation;
             backBuffer[i].LinearVelocity  = entity.linearVelocity;
             backBuffer[i].AngularVelocity = entity.angularVelocity;
         }
         Array.Copy(backBuffer, frontBuffer, backBuffer.Length);
     }
 }
        internal void Add(Entity e)
        {
            //Don't need to lock since the parent manager handles it.
            if (frontBuffer.Length <= e.BufferedStates.motionStateIndex)
            {
                var newStates = new MotionState[frontBuffer.Length * 2]; //TODO: shifty
                frontBuffer.CopyTo(newStates, 0);
                frontBuffer = newStates;
            }
            frontBuffer[e.BufferedStates.motionStateIndex].Position    = e.position;
            frontBuffer[e.BufferedStates.motionStateIndex].Orientation = e.orientation;

            if (backBuffer.Length <= e.BufferedStates.motionStateIndex)
            {
                var newStates = new MotionState[backBuffer.Length * 2]; //TODO: shifty
                backBuffer.CopyTo(newStates, 0);
                backBuffer = newStates;
            }
            backBuffer[e.BufferedStates.motionStateIndex].Position    = e.position;
            backBuffer[e.BufferedStates.motionStateIndex].Orientation = e.orientation;
        }