Exemplo n.º 1
0
        IEnumerator proceedCut(List <CutData> objectsToCut)
        {
            bool             threadRunning = true;
            List <CutResult> cutResults    = new List <CutResult> ();

            System.Threading.Thread thread = new System.Threading.Thread(new ThreadStart(
                                                                             () =>
            {
                foreach (CutData cutData in objectsToCut)
                {
                    SimpleMesh simpleMesh = cutData.SimpleMesh;
                    CutResult cutResult   = Cutter.Cut(simpleMesh.Triangles, simpleMesh.Vertices, simpleMesh.Normals, simpleMesh.UVs, simpleMesh.CuttingPlane);
                    cutData.CutResult     = cutResult;
                    cutResults.Add(cutResult);
                }

                threadRunning = false;
            }
                                                                             ));

            thread.Start();

            yield return(new WaitWhile(() => threadRunning));

            IsBusy = false;
        }
Exemplo n.º 2
0
        void onCutTriggered(Transform planeTransform)
        {
            if (threadedCutter.IsBusy)
            {
                return;
            }

            List <CutData> cutData = new List <CutData> ();
            int            activadedChildrenCount = activatedChildren.Count;

            for (int i = 0; i < activadedChildrenCount; i++)
            {
                if (activatedChildren [i].IsTouchingBlade && deactivatedChildrenPool.Count > 0)
                {
                    Plane      cuttingPlane = new Plane(planeTransform, activatedChildren [i].transform);
                    CutData    data         = new CutData();
                    SimpleMesh simpleMesh   = new SimpleMesh();

                    simpleMesh.Create(activatedChildren [i].GetMeshFilter().mesh, cuttingPlane);
                    data.Parent       = activatedChildren [i];
                    data.Child        = deactivatedChildrenPool.Dequeue();
                    data.Plane        = cuttingPlane;
                    data.SimpleMesh   = simpleMesh;
                    data.CutDirection = planeTransform.right;

                    cutData.Add(data);

                    data.Parent.IsBusy = true;
                    data.Child.IsBusy  = true;
                }
            }

            if (cutData.Count > 0)
            {
                StartCoroutine(cutInThreadAndWaitToEnd(cutData));
            }
        }