public void BeginSimulation(uint tick)
        {
            lastIndex = MomentumIndexForTick(tick);
            if (!lastIndex.valid)
            {
                lastIndex = TrailIndex.zero;
            }

            if (currentIndex != lastIndex)
            {
                ClearContacts();
                ApplyMomentum(this[lastIndex]);
            }

            if (lastIndex.segment < momentums.Count - 1)
            {
                momentums.RemoveRange(
                    lastIndex.segment + 1,
                    momentums.Count - (lastIndex.segment + 1));
            }

            int nextMomI = lastIndex.momentum + 1;

            while (nextMomI < momentums[lastIndex.segment].Length &&
                   momentums[lastIndex.segment][nextMomI] != null)
            {
                Momentum2D.Release(momentums[lastIndex.segment][nextMomI++]);
                momentums[lastIndex.segment][nextMomI++] = null;
            }
        }
        public bool GoToTime(uint tick, uint keepTick = 0)
        {
            TrailIndex i = MomentumIndexForTick(tick);

            bool success = GoToIndex(i);

            uint pastTick = Math.Max(tick - keepTick, 0);
            int  pastSegI = 0;

            while (pastSegI + 1 <= i.segment &&
                   momentums[pastSegI + 1][0].tick <= pastTick)
            {
                pastSegI++;
            }

            if (pastSegI > 0)
            {
                currentIndex = new TrailIndex(
                    currentIndex.segment - pastSegI,
                    currentIndex.momentum
                    );
                lastIndex = new TrailIndex(
                    lastIndex.segment - pastSegI,
                    lastIndex.momentum
                    );

                if (!Momentum2D.IsPoolFull())
                {
                    for (int segI = 0; segI < pastSegI; segI++)
                    {
                        Momentum2D.Release(momentums[segI]);
                        if (Momentum2D.IsPoolFull())
                        {
                            break;
                        }
                    }
                }

                momentums.RemoveRange(0, pastSegI);
            }


            return(success);
        }