Ejemplo n.º 1
0
        /// <summary>
        /// Absorb the contents of another fragment, emptying it, and applying an adjustment transform.
        /// </summary>
        /// <param name="other">The fragment to lose all its contents to this.</param>
        /// <param name="adjustment">Pose adjustment to apply to contents of other on transition.</param>
        public void AbsorbOtherFragment(Fragment other, Pose adjustment)
        {
            Debug.Assert(other != this, $"Trying to merge to and from the same fragment {FragmentId}");
            int otherCount = other.attachmentList.Count;

            for (int i = 0; i < otherCount; ++i)
            {
                AttachmentPoint att = other.attachmentList[i];
                att.Set(FragmentId, att.CachedPosition, att.AnchorId, att.LocationFromAnchor);
                att.HandlePoseAdjustment(adjustment);
                if (att.StateHandler != null)
                {
                    updateStateAllAttachments += att.StateHandler;
                }
                att.HandleStateChange(State);
                attachmentList.Add(att);
            }
            other.ReleaseAll();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Run through all attachment points, get their adjustments from the plugin and apply them.
        /// </summary>
        /// <remarks>
        /// This must be called between plugin.Refreeze() and plugin.RefreezeFinish().
        /// </remarks>
        public void AdjustAll(IPlugin plugin)
        {
            int count = attachmentList.Count;

            for (int i = 0; i < count; ++i)
            {
                AttachmentPoint attach = attachmentList[i];

                AnchorId newAnchorId;
                Vector3  newLocationFromAnchor;
                Pose     adjustment;
                if (plugin.ComputeAttachmentPointAdjustment(attach.AnchorId, attach.LocationFromAnchor,
                                                            out newAnchorId, out newLocationFromAnchor, out adjustment))
                {
                    attach.Set(FragmentId, attach.CachedPosition, newAnchorId, newLocationFromAnchor);

                    attach.HandlePoseAdjustment(adjustment);
                }
                else
                {
                    Debug.Log($"No adjustment during refreeze for {attach.AnchorId.ToString()}");
                }
            }
        }