Beispiel #1
0
        private void RecordCurElem()
        {
            var elem = _elemPool.Get();

            elem.PointStart = PointStart.position;
            elem.PointEnd   = PointEnd.position;

            if (_snapshotList.Count < TrailLength)
            {
                _snapshotList.Insert(1, elem);
            }
            else
            {
                _elemPool.Release(_snapshotList[_snapshotList.Count - 1]);
                _snapshotList.RemoveAt(_snapshotList.Count - 1);
                _snapshotList.Insert(1, elem);
            }
        }
Beispiel #2
0
        void RecordCurElem()
        {
            //TODO: use element pool to avoid gc alloc.
            //Element elem = new Element(PointStart.position, PointEnd.position);

            Element elem = mElemPool.Get();

            elem.PointStart = PointStart.position;
            elem.PointEnd   = PointEnd.position;

            if (mSnapshotList.Count < MaxFrame)
            {
                mSnapshotList.Insert(1, elem);
            }
            else
            {
                mElemPool.Release(mSnapshotList[mSnapshotList.Count - 1]);
                mSnapshotList.RemoveAt(mSnapshotList.Count - 1);
                mSnapshotList.Insert(1, elem);
            }
        }