Beispiel #1
0
 private void RemoveLastPoint()
 {
     _SegmentPositionTopBuffer.Dequeue();
     _SegmentPositionBottomBuffer.Dequeue();
     _SegmentSubsectionsBuffer.Dequeue();
     _SegmentTimesBuffer.Dequeue();
     if (_SegmentSubsectionsBuffer.Count > 0)
     {
         _TotalSubsections -= _SegmentSubsectionsBuffer.Peek();
     }
     //EB.Debug.Log("_TotalSubsections !!!! " + _TotalSubsections);
 }
Beispiel #2
0
    private void UpdateSections(Vector3 currentTopPosition, Vector3 currentBottomPosition, float time)
    {
        //EB.Debug.Log("Updating sections " +_SegmentPositionTopBuffer.Count + " " + _SegmentPositionBottomBuffer.Count);
        if (_SegmentPositionTopBuffer.Count == 0 || _SegmentPositionBottomBuffer.Count == 0)
        {
            if (_IgnoreZ)
            {
                avgZ = (currentBottomPosition.z + currentTopPosition.z) / 2;
                currentBottomPosition = new Vector3(currentBottomPosition.x, currentBottomPosition.y, avgZ);
                currentTopPosition    = new Vector3(currentTopPosition.x, currentTopPosition.y, avgZ);
            }
            _LastAddedBottomPoint = currentBottomPosition;
            _LastAddedTopPoint    = currentTopPosition;

            InsertPoints(currentTopPosition, currentBottomPosition, time);

            return;
        }

        if (_IgnoreZ)
        {
            currentBottomPosition = new Vector3(currentBottomPosition.x, currentBottomPosition.y, avgZ);
            currentTopPosition    = new Vector3(currentTopPosition.x, currentTopPosition.y, avgZ);
        }
        float distanceBottom = Vector3.Distance(currentBottomPosition, _LastAddedBottomPoint);
        float distanceTop    = Vector3.Distance(currentTopPosition, _LastAddedTopPoint);
        float maxDistance    = Mathf.Max(distanceTop, distanceBottom);

        //EB.Debug.Log("distanceTop " +distanceTop + "distanceBottom " + distanceBottom);
        if (maxDistance > _DistanceThreshold)
        {
            int segments = Mathf.CeilToInt(Mathf.Min(distanceTop, distanceBottom) / _SegmentLength);
            //Debug.g("SEGMENT DIS " +segments);
            InsertPoints(currentTopPosition, currentBottomPosition, time, segments);
            _LastAddedBottomPoint = currentBottomPosition;
            _LastAddedTopPoint    = currentTopPosition;
        }

        while (_SegmentPositionTopBuffer.Count > 0)
        {
            //EB.Debug.Log("time " + time + " _TrailTime " + _TrailTime + "_SegmentTimesBuffer.Peek() " +_SegmentTimesBuffer.Peek());
            if (time - _TrailTime > _SegmentTimesBuffer.Peek())
            {
                RemoveLastPoint();
            }
            else
            {
                break;
            }
        }
    }