예제 #1
0
        public override void StopInteraction()
        {
            if (IsDragged)
            {
                destroyMeasuringBands();
                IsDragged = false;

                if (collision == false && !planeSnap)
                {
                    Extrudable.MoveTo(
                        AssociatedFaceID,
                        extrudingFaces.ToArray(),
                        transform.localPosition, translateSnap && isExtruding, tickState);
                }
                else if (!planeSnap)
                //else if (extrudingFaces.Count == 1) // yes/no maybe
                {
                    Debug.Log("Attempting face bridging");
                    if (true)//(hasDistinctAdjacentFaces(collidedFaceHandle))
                    {
                        //collidedFaceHandleVertexPositions = controlsManager.GetVertexPositionsFromFaces(new List<int> { collidedFaceID });
                        collidedFaceHandleVertexPositions = initialManifold.GetVertexPositionsFromFace(collidedFaceID);

                        if (collidedFaceHandleVertexPositions.Count() == initialVertexPositions.Count() && extrudingFaces.Count == 1)
                        {
                            var matches = faceBridgingVertexAssignment(initialVertexPositions, collidedFaceHandleVertexPositions);

                            if (/*facingFaces(matches, AssociatedFaceID, initialVertexPositions, collidedFaceID, collidedFaceHandleVertexPositions)*/ true)
                            {
                                Extrudable.ChangeManifold(initialManifold.Copy());
                                Debug.Log("Applying face bridging");
                                if (matches.Length == 6)
                                {
                                    Extrudable.bridgeFaces(AssociatedFaceID, collidedFaceID, new int[] { matches[0], matches[1], matches[2] }, new int[] { matches[3], matches[4], matches[5] }, 3);
                                    ControlsManager.Instance.UpdateControls();
                                }
                                else if (matches.Length == 8)
                                {
                                    Extrudable.bridgeFaces(AssociatedFaceID, collidedFaceID, new int[] { matches[0], matches[1], matches[2], matches[3] }, new int[] { matches[4], matches[5], matches[6], matches[7] }, 4);
                                    ControlsManager.Instance.UpdateControls();
                                }
                            }
                        }
                    }
                    collidedFaceHandleVertexPositions = null;
                }


                MergeWithCollidingFaces(); //Merge extrusion if done up against other faces.

                //Check if mesh is valid
                extrudingFaces = new List <int>(); // create new list (may be referenced by other hand)

                int collapsed = Extrudable.CollapseShortEdges(0.019f);
                Extrudable.TriangulateAndDrawManifold(); // needed for collision detection in isValidMesh



                if (Extrudable.isValidMesh())
                {
                    ControlsManager.Instance.DestroyInvalidObjects();
                    ControlsManager.Instance.Extrudable.rebuild = true;
                    //ControlsManager.Instance.UpdateControls();
                    ControlsManager.FireUndoEndEvent(mesh, this, initialPosition, initialRotation);
                }
                else
                {
                    Extrudable.ChangeManifold(initialManifold);
                }

/*
 *              if (collapsed > 0)
 *              {
 *
 *              }
 *              else if (Extrudable.isValidMesh())
 *              {
 *                  //ControlsManager.Instance.DestroyInvalidObjects();
 *                  ControlsManager.Instance.Extrudable.rebuild = true;
 *                  //ControlsManager.Instance.UpdateControls();
 *                  ControlsManager.FireUndoEndEvent(mesh, this, initialPosition, initialRotation);
 *
 *
 *
 *
 *              }
 *              else
 *              {
 *                  Extrudable.ChangeManifold(initialManifold);
 *              }*/
                DisableSBSPlane();
            }
        }
예제 #2
0
        public override void StopInteraction()
        {
            updateInFrame = Time.frameCount;
            //if (activeControllers.Count == 1)
            //{
            //    activeControllers[0].ChangeInteraction(InteractionMode.SINGLE);
            //}
            //else
            if (mode == InteractionMode.SINGLE)
            {
                activeControllers.Remove(this);
                if (IsDragged)
                {
                    IsDragged = false;

                    int collapsed = Extrudable.CollapseShortEdges(0.019f);
                    if (collapsed > 0)
                    {
                        Extrudable.TriangulateAndDrawManifold();
                        if (Extrudable.isValidMesh())
                        {
                            ControlsManager.Instance.DestroyInvalidObjects();
                            ControlsManager.Instance.Extrudable.rebuild = true;
                            //ControlsManager.Instance.UpdateControls();
                            ControlsManager.FireUndoEndEvent(mesh, this, initialPosition, initialRotation);
                        }
                        else
                        {
                            Extrudable.ChangeManifold(initialManifold);
                        }
                    }
                    else if (Extrudable.isValidMesh())
                    {
                        ControlsManager.Instance.Extrudable.rebuild = true;
                        //ControlsManager.Instance.UpdateControls();
                        ControlsManager.FireUndoEndEvent(mesh, this, initialPosition, initialRotation);
                    }
                    else
                    {
                        Extrudable.ChangeManifold(initialManifold);
                    }
                }
            }
            else
            {
                if (mode == InteractionMode.DUAL && refinementActive)
                {
                    if (refinementMode == RefinementMode.LOOP)
                    {
                        // This or TriangulateAndDraw + ControlsManager.Instance.the function that clears and updates
                        //Extrudable._manifold = splitManifold;
                        //Extrudable.UpdateMesh();
                        Extrudable.ChangeManifold(splitManifold);
                        ControlsManager.FireUndoEndEvent(mesh, this, initialPosition, initialRotation);
                    }

                    if (activeControllers.Count == 2)
                    {
                        // Do the refinement and clear the splitManifold
                        //ShowRefinement(activeControllers[0].AssociatedVertexID, activeControllers[1].AssociatedVertexID);
                        activeControllers.Remove(this);

                        activeControllers[0].ChangeInteraction(InteractionMode.SINGLE);
                        activeControllers[0].EndHighlight();
                        activeControllers[0].IsDragged = false;
                        activeControllers[0].StopInteraction();
                    }

                    GameObject refinePreview = GameObject.FindGameObjectWithTag("RefinePreview");
                    refinePreview.GetComponent <MeshRenderer>().enabled = false;

                    ChangeInteraction(InteractionMode.SINGLE);
                    refinementMode = RefinementMode.NO;
                }
            }
            //ControlsManager.Instance.UpdateControls();

            if (edgebar)
            {
                Destroy(edgebar);
            }

            DisableSBSLine();
        }