Exemplo n.º 1
0
        public void BeginLayout()
        {
            m_HoveredBodyControlID  = m_GUIWrapper.GetControlID(kBodyHashCode, FocusType.Passive);
            m_HoveredJointControlID = m_GUIWrapper.GetControlID(kJointHashCode, FocusType.Passive);
            m_HoveredTailControlID  = m_GUIWrapper.GetControlID(kTailHashCode, FocusType.Passive);
            m_CreateBoneControlID   = m_GUIWrapper.GetControlID(kCreateBoneHashCode, FocusType.Passive);

            if (m_GUIWrapper.eventType == EventType.Layout)
            {
                m_PrevHoveredBoneID    = m_HoveredBoneID;
                m_NearestDistance      = float.MaxValue;
                m_NearestBodyDistance  = float.MaxValue;
                m_NearestJointDistance = float.MaxValue;
                m_NearestTailDistance  = float.MaxValue;
                m_NearestBodyId        = InvalidID;
                m_NearestJointId       = InvalidID;
                m_NearestTailId        = InvalidID;
                m_HoveredBoneID        = InvalidID;
                m_HoveredBodyID        = InvalidID;
                m_HoveredJointID       = InvalidID;
                m_HoveredTailID        = InvalidID;
                m_HoveredSliderData    = SliderData.zero;

                if (m_GUIWrapper.IsControlHot(0))
                {
                    m_RotateControlID          = -1;
                    m_MoveControlID            = -1;
                    m_FreeMoveControlID        = -1;
                    m_MoveJointControlID       = -1;
                    m_MoveEndPositionControlID = -1;
                    m_ChangeLengthControlID    = -1;
                    m_HotBoneID = InvalidID;
                }
            }
        }
Exemplo n.º 2
0
        public void LayoutBone(int id, Vector3 position, Vector3 endPosition, Vector3 forward, Vector3 up, Vector3 right, bool isChainEnd)
        {
            if (mode == SkeletonMode.Disabled)
            {
                return;
            }

            Debug.Assert(m_GUIWrapper.eventType == EventType.Layout);

            var sliderData = new SliderData()
            {
                position = GetMouseWorldPosition(forward, position),
                forward  = forward,
                up       = up,
                right    = right
            };

            {
                var distance = m_GUIWrapper.DistanceToSegmentClamp(position, endPosition);

                if (distance <= m_NearestDistance)
                {
                    m_NearestDistance     = distance;
                    m_NearestBodyDistance = distance;
                    m_NearestBodyId       = id;
                    m_HoveredSliderData   = sliderData;
                }
            }

            {
                var distance = m_GUIWrapper.DistanceToCircle(position, GetBoneRadiusForPicking(position) * 2f);

                if (distance <= m_NearestDistance)
                {
                    m_NearestDistance      = distance;
                    m_NearestJointDistance = distance;
                    m_NearestJointId       = id;
                    m_HoveredSliderData    = sliderData;
                }
            }

            if (isChainEnd &&
                (IsCapable(SkeletonAction.ChangeLength) ||
                 IsCapable(SkeletonAction.MoveEndPosition) ||
                 IsCapable(SkeletonAction.CreateBone)))
            {
                var distance = m_GUIWrapper.DistanceToCircle(endPosition, GetBoneRadiusForPicking(endPosition));

                if (distance <= m_NearestDistance)
                {
                    m_NearestDistance     = distance;
                    m_NearestTailDistance = distance;
                    m_NearestTailId       = id;
                    m_HoveredSliderData   = sliderData;
                }
            }
        }
Exemplo n.º 3
0
        public bool DoSlider(int id, SliderData sliderData, out Vector3 newPosition)
        {
            EditorGUI.BeginChangeCheck();

            if (HasCurrentCamera())
            {
                newPosition = Handles.Slider2D(id, sliderData.position, sliderData.forward, sliderData.right, sliderData.up, 1f, nullCap, Vector2.zero);
            }
            else
            {
                newPosition = Slider2D.Do(id, sliderData.position, null);
            }

            return(EditorGUI.EndChangeCheck());
        }
Exemplo n.º 4
0
        private bool DoSliderAction(SkeletonAction action, int controlID, ref int actionControlID, out Vector3 newPosition)
        {
            newPosition = m_HoveredSliderData.position;

            if (IsActionTriggering(action))
            {
                actionControlID = controlID;
                m_HotSliderData = m_HoveredSliderData;
                m_HotBoneID     = hoveredBoneID;
            }

            if (m_GUIWrapper.DoSlider(actionControlID, m_HotSliderData, out newPosition))
            {
                m_HotSliderData.position = newPosition;
                return(true);
            }

            return(false);
        }