Exemple #1
0
    /// <summary>
    /// Call before the ZED is moved to make it so you can go back to this position by pressing Undo.
    /// If you are moving it gradually, call before the gradual movement starts and don't update during.
    /// Also clears the Redo stack as you've now branched away from it.
    /// </summary>
    private void RegisterUndoablePose(Vector3 pos, Quaternion rot)
    {
        AnchorPose pose = new AnchorPose(pos, rot);

        undoStack.Push(pose);

        //Clear the Redo stack as we've now branched away from whatever history it had.
        redoStack.Clear();
    }
 private void PreMultiplyPoses(List <AnchorPose> dstPoses, List <AnchorPose> srcPoses, Pose transform)
 {
     Assert.AreEqual(dstPoses.Count, srcPoses.Count);
     for (int i = 0; i < srcPoses.Count; ++i)
     {
         AnchorPose anchorPose = dstPoses[i];
         anchorPose.pose = transform.Multiply(srcPoses[i].pose);
         dstPoses[i]     = anchorPose;
     }
 }
Exemple #3
0
    /// <summary>
    /// Moves the ZED to the top position on the Redo stack, if any, which is added after
    /// the user calls Undo, so long as another Undo is not registered in the meantime.
    /// </summary>
    public void Redo()
    {
        if (redoStack.Count == 0)
        {
            return;                            //No action to redo.
        }
        AnchorPose redoPose = redoStack.Pop(); //Get last pose from the stack and remove it.

        //Re-apply that pose to the ZED.
        zedManager.transform.localPosition = redoPose.position;
        zedManager.transform.localRotation = redoPose.rotation;

        undoStack.Push(redoPose); //Put that action back on the undo stack so you could repeat this process again if you wanted.
    }
Exemple #4
0
    /// <summary>
    /// Moves the ZED to the top position on the Undo stack, undoing the last change.
    /// Also adds the current position to the Redo stack.
    /// </summary>
    public void Undo()
    {
        if (undoStack.Count == 0)
        {
            return;                            //No action to undo.
        }
        AnchorPose undoPose = undoStack.Pop(); //Get last pose from the stack and remove it.

        //Save the current pose to the redo stack.
        AnchorPose pose = new AnchorPose(zedManager.transform.localPosition, zedManager.transform.localRotation);

        redoStack.Push(pose);

        //Apply historical pose to the ZED.
        zedManager.transform.localPosition = undoPose.position;
        zedManager.transform.localRotation = undoPose.rotation;

        //redoStack.Push(undoPose); //Remember what you undid so it can be redone.
    }
        private void UpdateAndCheck(IPlugin plugin, int prime, List <AnchorPose> anchorPoses, List <AnchorEdge> anchorEdges, List <AnchorId> frozenIds)
        {
            AnchorPose headPose = anchorPoses[prime];

            plugin.ClearSpongyAnchors();
            plugin.Step_Init(headPose.pose);
            plugin.AddSpongyAnchors(anchorPoses);
            plugin.SetMostSignificantSpongyAnchorId(headPose.anchorId);
            plugin.AddSpongyEdges(anchorEdges);
            plugin.Step_Finish();

            FragmentId fragmentId = plugin.GetMostSignificantFragmentId();

            Debug.Log($"fragmentId={fragmentId}");

            var frozenAnchors = plugin.GetFrozenAnchors();

            Assert.AreEqual(frozenAnchors.Length, frozenIds.Count, "Unexpected difference between plugin frozen anchors and client frozen anchors counts");

            for (int i = 0; i < frozenAnchors.Length; ++i)
            {
                Assert.IsTrue(frozenIds.FindIndex(x => x == frozenAnchors[i].anchorId) >= 0, "Plugin has unexpected frozen id");
            }
        }