Exemplo n.º 1
0
    public void DropLoopMarker(RoadMarker Mrkr)
    {
        //Now we look backwards then forwards til we find a non-hairpin and adjust all these
        int PrevNoHPin = Bez.CtrlPts.Count - 3;
        int NxtNoHPin  = Mrkr.Index + 1;

        //Find the previous non-hairpin
        do
        {
            float A = Bez.Angle(PrevNoHPin);
            //Debug.Log("CtrlPt" + PrevNoHPin.ToString() + " Angle = " + A);
            if (Mathf.Abs(Bez.Angle(PrevNoHPin)) > 80)
            {
                PrevNoHPin++; break;
            }
            PrevNoHPin--;
        } while (true);
        //Find the next non-hairpin
        do
        {
            float A = Bez.Angle(NxtNoHPin);
            if (Mathf.Abs(Bez.Angle(NxtNoHPin)) > 80)
            {
                break;
            }
            NxtNoHPin++;
        } while (true);

        //Recalc the XSecs
        for (int CtrlPtId = 1; CtrlPtId <= NxtNoHPin; CtrlPtId++)     //Between the non-hairpin markers
        {
            XSecCalculator.CalcXSecs(CtrlPtId, RoadWidth);
        }

        for (int CtrlPtId = PrevNoHPin + 1; CtrlPtId < Bez.CtrlPts.Count - 1; CtrlPtId++)     //Between the non-hairpin markers
        {
            XSecCalculator.CalcXSecs(CtrlPtId, RoadWidth);
        }


        //Add to the build queue
        Rd.Sectns[Bez.CtrlPts.Count - 3].CalcVisibleFenceVerts();
        BuildQueue.Enqueue(Bez.CtrlPts.Count - 3);
        Rd.Sectns[Mrkr.Index].CalcVisibleFenceVerts();
        BuildQueue.Enqueue(Mrkr.Index);
        Rd.Sectns[Mrkr.Index + 1].CalcVisibleFenceVerts();
        BuildQueue.Enqueue(Mrkr.Index + 1);

        Mrkr.DroppedPosition = Mrkr.transform.position;
    }