コード例 #1
0
        internal static void DrawHandles(HDProbeUI s, SerializedHDProbe d, Editor o)
        {
            HDProbe probe = d.target as HDProbe;
            var     mat   = Matrix4x4.TRS(probe.transform.position, probe.transform.rotation, Vector3.one);

            switch (EditMode.editMode)
            {
            case EditBaseShape:
                //important: following will init the container for box.
                //This must be done before drawing the contained handles
                if (o is PlanarReflectionProbeEditor && (InfluenceShape)d.influenceVolume.shape.intValue == InfluenceShape.Box)
                {
                    //Planar need to update its transform position.
                    //Let PlanarReflectionProbeUI.Handle do this work.
                    break;
                }
                InfluenceVolumeUI.DrawHandles_EditBase(s.influenceVolume, d.influenceVolume, o, mat, probe);
                break;

            case EditInfluenceShape:
                InfluenceVolumeUI.DrawHandles_EditInfluence(s.influenceVolume, d.influenceVolume, o, mat, probe);
                break;

            case EditInfluenceNormalShape:
                InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(s.influenceVolume, d.influenceVolume, o, mat, probe);
                break;

            case EditCenter:
            {
                if (o is PlanarReflectionProbeEditor && (InfluenceShape)d.influenceVolume.shape.intValue == InfluenceShape.Box)
                {
                    //Planar need to update its transform position.
                    //Let PlanarReflectionProbeUI.Handle do this work.
                    break;
                }
                using (new Handles.DrawingScope(Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one)))
                {
                    EditorGUI.BeginChangeCheck();
                    var newCapturePosition = Handles.PositionHandle(probe.transform.position, probe.transform.rotation);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Vector3 newOffset = Quaternion.Inverse(probe.transform.rotation) * (newCapturePosition - probe.transform.position);
                        Undo.RecordObjects(new Object[] { probe, probe.transform }, "Translate Influence Position");
                        Vector3   delta           = newCapturePosition - probe.transform.position;
                        Matrix4x4 oldLocalToWorld = Matrix4x4.TRS(probe.transform.position, probe.transform.rotation, Vector3.one);

                        //call modification to legacy ReflectionProbe
                        probe.influenceVolume.offset = newOffset;

                        probe.transform.position = newCapturePosition;
                        d.influenceVolume.offset.vector3Value -= oldLocalToWorld.inverse.MultiplyVector(delta);
                        d.influenceVolume.Apply();
                    }
                }
                break;
            }
            }
        }
コード例 #2
0
        void OnSceneGUI()
        {
            var s = m_UIState;
            var p = m_SerializedHdReflectionProbe;
            var o = this;

            BakeRealtimeProbeIfPositionChanged(s, p, o);

            HDReflectionProbeUI.DoShortcutKey(p, o);

            if (!s.sceneViewEditing)
            {
                return;
            }

            var mat = p.target.transform.localToWorldMatrix;

            EditorGUI.BeginChangeCheck();

            switch (EditMode.editMode)
            {
            // Influence editing
            case EditMode.SceneViewEditMode.ReflectionProbeBox:
                InfluenceVolumeUI.DrawHandles_EditBase(s.influenceVolume, p.targetData.influenceVolume, o, mat, p.targetData);
                break;

            // Influence fade editing
            case EditMode.SceneViewEditMode.GridBox:
                InfluenceVolumeUI.DrawHandles_EditInfluence(s.influenceVolume, p.targetData.influenceVolume, o, mat, p.targetData);
                break;

            // Influence normal fade editing
            case EditMode.SceneViewEditMode.Collider:
                InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(s.influenceVolume, p.targetData.influenceVolume, o, mat, p.targetData);
                break;

            // Origin editing
            case EditMode.SceneViewEditMode.ReflectionProbeOrigin:
                Handle_OriginEditing(s, p, o);
                break;
            }

            if (EditorGUI.EndChangeCheck())
            {
                Repaint();
            }
        }
コード例 #3
0
        internal static void DrawHandles(HDProbeUI s, SerializedHDProbe d, Editor o)
        {
            HDProbe probe = d.target as HDProbe;
            var     mat   = Matrix4x4.TRS(probe.transform.position, probe.transform.rotation, Vector3.one);

            switch (EditMode.editMode)
            {
            case EditBaseShape:
                InfluenceVolumeUI.DrawHandles_EditBase(s.influenceVolume, d.influenceVolume, o, mat, probe);
                break;

            case EditInfluenceShape:
                InfluenceVolumeUI.DrawHandles_EditInfluence(s.influenceVolume, d.influenceVolume, o, mat, probe);
                break;

            case EditInfluenceNormalShape:
                InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(s.influenceVolume, d.influenceVolume, o, mat, probe);
                break;

            case EditCenter:
            {
                using (new Handles.DrawingScope(Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one)))
                {
                    //Vector3 offsetWorld = probe.transform.position + probe.transform.rotation * probe.influenceVolume.offset;
                    EditorGUI.BeginChangeCheck();
                    var newCapturePosition = Handles.PositionHandle(probe.transform.position, probe.transform.rotation);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Vector3 newOffset = Quaternion.Inverse(probe.transform.rotation) * (newCapturePosition - probe.transform.position);
                        Undo.RecordObjects(new Object[] { probe, probe.transform }, "Translate Influence Position");
                        Vector3   delta           = newCapturePosition - probe.transform.position;
                        Matrix4x4 oldLocalToWorld = Matrix4x4.TRS(probe.transform.position, probe.transform.rotation, Vector3.one);

                        //call modification to legacy ReflectionProbe
                        probe.influenceVolume.offset = newOffset;

                        probe.transform.position = newCapturePosition;
                        d.influenceVolume.offset.vector3Value -= oldLocalToWorld.inverse.MultiplyVector(delta);
                        d.influenceVolume.Apply();
                    }
                }
                break;
            }
            }
        }
コード例 #4
0
        internal static void DrawHandles(SerializedHDProbe serialized, Editor owner)
        {
            var probe = serialized.target;

            switch (EditMode.editMode)
            {
            case EditBaseShape:
                InfluenceVolumeUI.DrawHandles_EditBase(serialized.probeSettings.influence, owner, probe.transform);
                break;

            case EditInfluenceShape:
                InfluenceVolumeUI.DrawHandles_EditInfluence(serialized.probeSettings.influence, owner, probe.transform);
                break;

            case EditInfluenceNormalShape:
                InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(serialized.probeSettings.influence, owner, probe.transform);
                break;

            case EditCapturePosition:
            case EditMirrorPosition:
            {
                var proxyToWorldMatrix = probe.proxyToWorld;

                SerializedProperty target;
                switch (EditMode.editMode)
                {
                case EditCapturePosition: target = serialized.probeSettings.proxyCapturePositionProxySpace; break;

                case EditMirrorPosition: target = serialized.probeSettings.proxyMirrorPositionProxySpace; break;

                default: throw new ArgumentOutOfRangeException();
                }

                var position = proxyToWorldMatrix.MultiplyPoint(target.vector3Value);
                EditorGUI.BeginChangeCheck();
                position = Handles.PositionHandle(position, proxyToWorldMatrix.rotation);
                if (EditorGUI.EndChangeCheck())
                {
                    target.vector3Value = proxyToWorldMatrix.inverse.MultiplyPoint(position);
                }
                break;
            }

            case EditMirrorRotation:
            {
                var proxyToWorldMatrix = probe.proxyToWorld;

                var target   = serialized.probeSettings.proxyMirrorRotationProxySpace;
                var position = serialized.probeSettings.proxyMirrorPositionProxySpace.vector3Value;

                using (new Handles.DrawingScope(proxyToWorldMatrix))
                {
                    var rotation = target.quaternionValue;
                    EditorGUI.BeginChangeCheck();
                    rotation = Handles.RotationHandle(rotation, position);
                    if (EditorGUI.EndChangeCheck())
                    {
                        target.quaternionValue = rotation;
                    }
                }
                break;
            }
            }
        }
        public static void DrawHandles(PlanarReflectionProbeUI s, PlanarReflectionProbe d, Editor o)
        {
            var mat = d.transform.localToWorldMatrix;

            switch (EditMode.editMode)
            {
            case EditBaseShape:
                InfluenceVolumeUI.DrawHandles_EditBase(s.influenceVolume, d.influenceVolume, o, mat, d);
                break;

            case EditInfluenceShape:
                InfluenceVolumeUI.DrawHandles_EditInfluence(s.influenceVolume, d.influenceVolume, o, mat, d);
                break;

            case EditInfluenceNormalShape:
                InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(s.influenceVolume, d.influenceVolume, o, mat, d);
                break;

            case EditMirrorPosition:
            {
                EditorGUI.BeginChangeCheck();
                var m = Handles.matrix;
                Handles.matrix = mat;
                var p = Handles.PositionHandle(d.captureMirrorPlaneLocalPosition, d.transform.rotation);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(d, "Translate Mirror Plane");
                    d.captureMirrorPlaneLocalPosition = p;
                    EditorUtility.SetDirty(d);
                }
                Handles.matrix = m;
                break;
            }

            case EditMirrorRotation:
            {
                EditorGUI.BeginChangeCheck();
                var m = Handles.matrix;
                Handles.matrix = mat;
                var q = Quaternion.LookRotation(d.captureMirrorPlaneLocalNormal, Vector3.up);
                q = Handles.RotationHandle(q, d.captureMirrorPlaneLocalPosition);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(d, "Rotate Mirror Plane");
                    d.captureMirrorPlaneLocalNormal = q * Vector3.forward;
                    EditorUtility.SetDirty(d);
                }
                Handles.matrix = m;
                break;
            }

            case EditCenter:
            {
                EditorGUI.BeginChangeCheck();
                var m = Handles.matrix;
                Handles.matrix = mat;
                var p = Handles.PositionHandle(d.captureLocalPosition, d.transform.rotation);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(d, "Translate Capture Position");
                    d.captureLocalPosition = p;
                    EditorUtility.SetDirty(d);
                }
                Handles.matrix = m;
                break;
            }
            }

            if (d.useMirrorPlane)
            {
                var m = Handles.matrix;
                Handles.matrix = mat;
                Handles.color  = k_GizmoMirrorPlaneCamera;
                Handles.ArrowHandleCap(
                    0,
                    d.captureMirrorPlaneLocalPosition,
                    Quaternion.LookRotation(d.captureMirrorPlaneLocalNormal),
                    HandleUtility.GetHandleSize(d.captureMirrorPlaneLocalPosition),
                    Event.current.type
                    );
                Handles.matrix = m;
            }

            if (d.proxyVolumeReference != null)
            {
                ReflectionProxyVolumeComponentUI.DrawHandles_EditNone(s.reflectionProxyVolume, d.proxyVolumeReference);
            }
        }