public void Clear(bool clearmesh = false)
 {
     mLines.Clear();
     mIntersections.Clear();
     if (clearmesh && (mLinesToRender != null))
     {
         mLinesToRender.Clear();
     }
 }
Ejemplo n.º 2
0
 public void Clear()
 {
     mEventQ      = new RBTree <LineEvent>(mCompareEvents);
     mActiveLines = new RBTree <LineSegment>(mCompareLines);
     if (mLineMesh != null)
     {
         mLineMesh.Clear();
     }
     if (mPointMesh != null)
     {
         mPointMesh.Clear();
     }
 }
Ejemplo n.º 3
0
    private void Update()
    {
        if (New)
        {
            New                 = false;
            Triangle.NextID     = 1;
            DebugLog.DebugLevel = DebugLevel;
            mSaved              = NewTriangles(mBounds, TriangleCount * 3);
            mRuns               = 0;
            Debug.unityLogger.Log("NEW SET OF " + TriangleCount.ToString() + " TRIANGLES");
            DumpTris();
            mClipMesh.Clear();
            mLinesToRender.Clear();
            mIntersections.Clear();
            mTriMesh.GenerateMesh(mSaved);
        }
        else if (Test > 0)
        {
            int      test = Test;
            Triangle t1;
            Triangle t2;
            Triangle t3;
            Triangle t4;
            mSaved = new List <Triangle>();
            DebugLog.DebugLevel = DebugLevel;
            Debug.unityLogger.Log("TEST " + test.ToString());
            mRuns           = 0;
            Test            = 0;
            Triangle.NextID = 1;
            switch (test)
            {
            default:
                t1 = new Triangle(new Vector3(-1.7f, 3, 0),
                                  new Vector3(-1.7f, -0.7f, 0),
                                  new Vector3(1, 1.3f, 0));
                mSaved.Add(t1);
                t2 = new Triangle(new Vector3(-1.3f, 2, 0),
                                  new Vector3(-1.3f, -1.3f, 0),
                                  new Vector3(0, 1, 0));
                mSaved.Add(t2);
                t4 = new Triangle(new Vector3(-2.66f, -1, 0),
                                  new Vector3(-1.3f, 0.5f, 0),
                                  new Vector3(-0.5f, -1.5f, 0));
                mSaved.Add(t4);
                break;

            case 8:
                t1 = new Triangle(new Vector3(-2.1f, 2.2f, 0),
                                  new Vector3(-1.7f, -1.3f, 0),
                                  new Vector3(2, 0.6f, 0));
                t2 = new Triangle(new Vector3(0.8f, -2.7f, 0),
                                  new Vector3(2.3f, 0.6f, 0),
                                  new Vector3(2.6f, -1.9f, 0));
                t3 = new Triangle(new Vector3(-2.2f, 2.3f, 0),
                                  new Vector3(0.4f, 0.6f, 0),
                                  new Vector3(1.8f, -2.7f, 0));
                t4 = new Triangle(new Vector3(-2.9f, -2.8f, 0),
                                  new Vector3(-1.3f, -1.1f, 0),
                                  new Vector3(1, -2.3f, 0));
                mSaved.Add(t1);
                mSaved.Add(t2);
                mSaved.Add(t3);
                mSaved.Add(t4);
                break;

            case 7:
                t1 = new Triangle(new Vector3(-3, -0.5f, 0),
                                  new Vector3(-1.3f, 3, 0),
                                  new Vector3(-0.8f, -0.5f, 0));
                t2 = new Triangle(new Vector3(-2.4f, 1.5f, 0),
                                  new Vector3(0, 1.5f, 0),
                                  new Vector3(2.5f, -1.5f, 0));
                t3 = new Triangle(new Vector3(-3, -1, 0),
                                  new Vector3(-1.5f, 2, 0),
                                  new Vector3(-0.5f, 0.5f, 0));
                mSaved.Add(t1);
                mSaved.Add(t2);
                mSaved.Add(t3);
                break;

            case 6:
                t1 = new Triangle(new Vector3(-2.6f, 1.8f, 0),
                                  new Vector3(-0.25f, -2, 0),
                                  new Vector3(1.65f, 0.25f, 0));
                t2 = new Triangle(new Vector3(1, 2.6f, 0),
                                  new Vector3(1.5f, 1.3f, 0),
                                  new Vector3(2.85f, 2, 0));
                t3 = new Triangle(new Vector3(-1, -0.26f, 0),
                                  new Vector3(-0.3f, -2.3f, 0),
                                  new Vector3(0.16f, -1.3f, 0));
                t4 = new Triangle(new Vector3(-1.5f, 1, 0),
                                  new Vector3(0.6f, 2f, 0),
                                  new Vector3(2, -2.75f, 0));
                mSaved.Add(t1);
                mSaved.Add(t2);
                mSaved.Add(t3);
                mSaved.Add(t4);
                break;

            case 5:
                t1 = new Triangle(new Vector3(-1.3f, 1.8f, 0),
                                  new Vector3(-1, -2, 0),
                                  new Vector3(1, -1.4f, 0));
                t2 = new Triangle(new Vector3(-1.7f, 2.5f, 0),
                                  new Vector3(0.5f, -0.1f, 0),
                                  new Vector3(-0.6f, -1, 0));
                t3 = new Triangle(new Vector3(-2.2f, 1.2f, 0),
                                  new Vector3(-0.7f, 2.6f, 0),
                                  new Vector3(2, 0.5f, 0));
                mSaved.Add(t1);
                mSaved.Add(t2);
                mSaved.Add(t3);
                break;

            case 4:
                t1 = new Triangle(new Vector3(-1.5f, -1.5f, 0),
                                  new Vector3(0, 1.5f, 0),
                                  new Vector3(2.5f, -2, 0));
                mSaved.Add(t1);
                t2 = new Triangle(new Vector3(-1, -2.5f, 0),
                                  new Vector3(-1, 2, 0),
                                  new Vector3(1, 0, 0));
                mSaved.Add(t2);
                break;

            case 3:
                t1 = new Triangle(new Vector3(-0.7f, 0.4f, 0),
                                  new Vector3(2.2f, -1.2f, 0),
                                  new Vector3(2.5f, 2.9f, 0));
                t2 = new Triangle(new Vector3(-1.7f, 2.1f, 0),
                                  new Vector3(1.1f, -1.9f, 0),
                                  new Vector3(1.4f, 0.2f, 0));
                mSaved.Add(t1);
                mSaved.Add(t2);
                break;

            case 2:
                t1 = new Triangle(new Vector3(0.7f, -0.7f, 0),
                                  new Vector3(2.3f, 2.9f, 0),
                                  new Vector3(2.5f, 0.3f, 0));
                t2 = new Triangle(new Vector3(-2.0f, -2.6f, 0),
                                  new Vector3(-0.8f, 1.7f, 0),
                                  new Vector3(0.9f, -2.4f, 0));
                t3 = new Triangle(new Vector3(-1.9f, -0.6f, 0),
                                  new Vector3(-1.0f, 2.3f, 0),
                                  new Vector3(2.9f, 2.4f, 0));
                mSaved.Add(t1);
                mSaved.Add(t2);
                mSaved.Add(t3);
                break;

            case 1:
                t1 = new Triangle(new Vector3(-1.5f, -1.0f, 0),
                                  new Vector3(2.5f, 2f, 0),
                                  new Vector3(4f, -1.4f, 0));
                t2 = new Triangle(new Vector3(-2.5f, -2f, 0),
                                  new Vector3(0.5f, 2.50f, 0),
                                  new Vector3(1.4f, 0.4f, 0));
                mSaved.Add(t1);
                mSaved.Add(t2);
                break;
            }
            mClipMesh.Clear();
            mIntersections.Clear();
            TriangleCount        = mSaved.Count;
            mTriMesh.VertexCount = TriangleCount * 3;
            mTriMesh.GenerateMesh(mSaved);
            mClipMesh.VertexCount = TriangleCount * 3;
        }
        else if (PlaneSweep)
        {
            DebugLog.DebugLevel = DebugLevel;
            PlaneSweep          = false;
            TriangleCount       = mSaved.Count;
            Debug.unityLogger.Log("PLANESWEEEP RUN " + (++mRuns).ToString());
            StartCoroutine(PlaneSweepArea());
        }
    }