static void DrawSelectedGizmo(ReflectionProbe reflectionProbe, GizmoType gizmoType)
        {
            var e = GetEditorFor(reflectionProbe);

            if (e == null)
            {
                return;
            }

            var reflectionData = reflectionProbe.GetComponent <HDAdditionalReflectionData>();

            if (reflectionProbe == e.target)
            {
                //will draw every preview, thus no need to do it multiple times
                Gizmos_CapturePoint(e);
            }
            var mat = Matrix4x4.TRS(reflectionProbe.transform.position, reflectionProbe.transform.rotation, Vector3.one);

            InfluenceVolumeUI.DrawGizmos(e.m_UIState.influenceVolume, reflectionData.influenceVolume, mat, InfluenceVolumeUI.HandleType.None, InfluenceVolumeUI.HandleType.Base);

            if (!e.sceneViewEditing)
            {
                return;
            }



            DrawVerticalRay(reflectionProbe.transform);
        }
        public static void DrawGizmos(InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix, HandleType editedHandle, HandleType showedHandle)
        {
            if ((showedHandle & HandleType.Base) != 0)
            {
                DrawGizmos_BaseHandle(s, d, matrix, (editedHandle & HandleType.Base) != 0, k_GizmoThemeColorBase);
            }

            if ((showedHandle & HandleType.Influence) != 0)
            {
                DrawGizmos_FadeHandle(
                    s, d, matrix,
                    d.boxInfluenceOffset, d.boxInfluenceSizeOffset,
                    d.sphereInfluenceRadiusOffset,
                    (editedHandle & HandleType.Influence) != 0,
                    k_GizmoThemeColorInfluence);
            }

            if ((showedHandle & HandleType.InfluenceNormal) != 0)
            {
                DrawGizmos_FadeHandle(
                    s, d, matrix,
                    d.boxInfluenceNormalOffset, d.boxInfluenceNormalSizeOffset,
                    d.sphereInfluenceNormalRadiusOffset,
                    (editedHandle & HandleType.InfluenceNormal) != 0,
                    k_GizmoThemeColorInfluenceNormal);
            }
        }
        static void DrawBoxFadeHandle(
            InfluenceVolumeUI s, InfluenceVolume d, Editor o, Object sourceAsset,
            Func <InfluenceVolumeUI, Gizmo6FacesBox> boundsGetter,
            Vector3 baseOffset, Vector3 baseSize,
            ref Vector3 positive, ref Vector3 negative)
        {
            var b = boundsGetter(s);

            b.center = baseOffset - (positive - negative) * 0.5f;
            b.size   = baseSize - positive - negative;
            b.allHandleControledByOne = !s.data.editorAdvancedModeEnabled.boolValue;

            EditorGUI.BeginChangeCheck();
            b.DrawHandle();
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(sourceAsset, "Modified Influence Volume");

                var center        = baseOffset;
                var influenceSize = baseSize;

                var diff                  = 2 * (b.center - center);
                var sum                   = influenceSize - b.size;
                var positiveNew           = (sum - diff) * 0.5f;
                var negativeNew           = (sum + diff) * 0.5f;
                var blendDistancePositive = Vector3.Max(Vector3.zero, Vector3.Min(positiveNew, influenceSize));
                var blendDistanceNegative = Vector3.Max(Vector3.zero, Vector3.Min(negativeNew, influenceSize));

                positive = blendDistancePositive;
                negative = blendDistanceNegative;

                EditorUtility.SetDirty(sourceAsset);
            }
        }
        static void Drawer_SectionShapeBox(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o)
        {
            var maxFadeDistance = d.boxBaseSize.vector3Value * 0.5f;
            var minFadeDistance = Vector3.zero;

            EditorGUILayout.PropertyField(d.boxBaseSize, _.GetContent("Box Size"));
            EditorGUILayout.PropertyField(d.boxBaseOffset, _.GetContent("Box Offset"));

            EditorGUILayout.Space();

            _.DrawVector6Slider(
                _.GetContent("Influence Fade"),
                d.boxInfluencePositiveFade, d.boxInfluenceNegativeFade,
                minFadeDistance, maxFadeDistance);

            EditorGUILayout.Space();

            _.DrawVector6Slider(
                _.GetContent("Influence Normal Fade"),
                d.boxInfluenceNormalPositiveFade, d.boxInfluenceNormalNegativeFade,
                minFadeDistance, maxFadeDistance);

            EditorGUILayout.Space();

            _.DrawVector6Slider(
                _.GetContent("Influence Face Fade"),
                d.boxPositiveFaceFade, d.boxNegativeFaceFade,
                Vector3.zero, Vector3.one);
        }
        static void Drawer_InfluenceAdvancedSwitch(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor owner)
        {
            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();

                bool advanced = d.editorAdvancedModeEnabled.boolValue;
                advanced = !GUILayout.Toggle(!advanced, CoreEditorUtils.GetContent("Normal|Normal parameters mode (only change for box shape)."), EditorStyles.miniButtonLeft, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
                advanced = GUILayout.Toggle(advanced, CoreEditorUtils.GetContent("Advanced|Advanced parameters mode (only change for box shape)."), EditorStyles.miniButtonRight, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
                s.boxInfluenceHandle.allHandleControledByOne = s.boxInfluenceNormalHandle.allHandleControledByOne = !advanced;
                if (d.editorAdvancedModeEnabled.boolValue ^ advanced)
                {
                    d.editorAdvancedModeEnabled.boolValue = advanced;
                    if (advanced)
                    {
                        d.boxInfluencePositiveFade.vector3Value       = d.editorAdvancedModeBlendDistancePositive.vector3Value;
                        d.boxInfluenceNegativeFade.vector3Value       = d.editorAdvancedModeBlendDistanceNegative.vector3Value;
                        d.boxInfluenceNormalPositiveFade.vector3Value = d.editorAdvancedModeBlendNormalDistancePositive.vector3Value;
                        d.boxInfluenceNormalNegativeFade.vector3Value = d.editorAdvancedModeBlendNormalDistanceNegative.vector3Value;
                    }
                    else
                    {
                        d.boxInfluenceNegativeFade.vector3Value       = d.boxInfluencePositiveFade.vector3Value = Vector3.one * d.editorSimplifiedModeBlendDistance.floatValue;
                        d.boxInfluenceNormalNegativeFade.vector3Value = d.boxInfluenceNormalPositiveFade.vector3Value = Vector3.one * d.editorSimplifiedModeBlendNormalDistance.floatValue;
                    }
                    d.Apply();
                }
            }
        }
        static void Drawer_Offset(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, bool drawAllOffset)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            float y = 0f;

            if (drawAllOffset)
            {
                EditorGUILayout.PropertyField(d.offset, offsetContent);
            }
            else
            {
                y = EditorGUILayout.FloatField(yOffsetContent, d.offset.vector3Value.y);
            }
            if (EditorGUI.EndChangeCheck())
            {
                //call the offset setter as it will update legacy reflection probe
                HDProbeEditor   editor          = (HDProbeEditor)o;
                InfluenceVolume influenceVolume = editor.GetTarget(editor.target).influenceVolume;
                if (drawAllOffset)
                {
                    influenceVolume.offset = d.offset.vector3Value;
                }
                else
                {
                    influenceVolume.offset = new Vector3(0, y, 0);
                }
            }
            HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.CapturePosition, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
            EditorGUILayout.EndHorizontal();
        }
        public static void DrawGizmos(InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix, HandleType editedHandle, HandleType showedHandle)
        {
            if ((showedHandle & HandleType.Base) != 0)
            {
                DrawGizmos_BaseHandle(s, d, matrix, (editedHandle & HandleType.Base) != 0, k_GizmoThemeColorBase);
            }

            if ((showedHandle & HandleType.Influence) != 0)
            {
                DrawGizmos_FadeHandle(
                    s, d, matrix,
                    d.boxBlendOffset, d.boxBlendSize,
                    -d.sphereBlendDistance,
                    (editedHandle & HandleType.Influence) != 0,
                    k_GizmoThemeColorInfluence,
                    false);
            }

            if ((showedHandle & HandleType.InfluenceNormal) != 0)
            {
                DrawGizmos_FadeHandle(
                    s, d, matrix,
                    d.boxBlendNormalOffset, d.boxBlendNormalSize,
                    -d.sphereBlendNormalDistance,
                    (editedHandle & HandleType.InfluenceNormal) != 0,
                    k_GizmoThemeColorInfluenceNormal,
                    true);
            }
        }
Esempio n. 8
0
        static void DrawGizmos_BaseHandle(
            InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix,
            bool isSolid, Color color)
        {
            var mat = Gizmos.matrix;
            var c   = Gizmos.color;

            Gizmos.matrix = matrix;
            Gizmos.color  = color;
            switch (d.shapeType)
            {
            case ShapeType.Box:
            {
                s.boxBaseHandle.center = d.boxBaseOffset;
                s.boxBaseHandle.size   = d.boxBaseSize;
                s.boxBaseHandle.DrawHull(isSolid);
                break;
            }

            case ShapeType.Sphere:
            {
                if (isSolid)
                {
                    Gizmos.DrawSphere(d.sphereBaseOffset, d.sphereBaseRadius);
                }
                else
                {
                    Gizmos.DrawWireSphere(d.sphereBaseOffset, d.sphereBaseRadius);
                }
                break;
            }
            }
            Gizmos.matrix = mat;
            Gizmos.color  = c;
        }
        public static void DrawHandles_EditInfluenceNormal(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset)
        {
            using (new Handles.DrawingScope(k_GizmoThemeColorInfluenceNormal, matrix))
            {
                switch ((InfluenceShape)d.shape.intValue)
                {
                case InfluenceShape.Box:
                    EditorGUI.BeginChangeCheck();
                    DrawBoxFadeHandle(s, d, o, sourceAsset, s.boxInfluenceNormalHandle, d.boxBlendNormalDistancePositive, d.boxBlendNormalDistanceNegative);
                    if (EditorGUI.EndChangeCheck())
                    {
                        //save advanced/simplified saved data
                        if (d.editorAdvancedModeEnabled.boolValue)
                        {
                            d.editorAdvancedModeBlendNormalDistancePositive.vector3Value = d.boxBlendNormalDistancePositive.vector3Value;
                            d.editorAdvancedModeBlendNormalDistanceNegative.vector3Value = d.boxBlendNormalDistanceNegative.vector3Value;
                        }
                        else
                        {
                            d.editorSimplifiedModeBlendNormalDistance.floatValue = d.boxBlendNormalDistancePositive.vector3Value.x;
                        }
                        d.Apply();
                    }
                    break;

                case InfluenceShape.Sphere:
                    DrawSphereFadeHandle(s, d, o, sourceAsset, s.sphereInfluenceNormalHandle, d.sphereBlendNormalDistance);
                    break;
                }
            }
        }
        static void DrawBoxFadeHandle(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Object sourceAsset, HierarchicalBox box, SerializedProperty positive, SerializedProperty negative)
        {
            box.center     = d.offset.vector3Value - (positive.vector3Value - negative.vector3Value) * 0.5f;
            box.size       = d.boxSize.vector3Value - positive.vector3Value - negative.vector3Value;
            box.monoHandle = !d.editorAdvancedModeEnabled.boolValue;

            //set up parent box too for clamping
            s.boxBaseHandle.center = d.offset.vector3Value;
            s.boxBaseHandle.size   = d.boxSize.vector3Value;

            EditorGUI.BeginChangeCheck();
            box.DrawHandle();
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(sourceAsset, "Modified Influence Volume");

                var halfInfluenceSize     = d.boxSize.vector3Value * .5f;
                var blendDistancePositive = d.offset.vector3Value - box.center - box.size * .5f + halfInfluenceSize;
                var blendDistanceNegative = box.center - d.offset.vector3Value - box.size * .5f + halfInfluenceSize;

                positive.vector3Value = Vector3.Min(blendDistancePositive, halfInfluenceSize);
                negative.vector3Value = Vector3.Min(blendDistanceNegative, halfInfluenceSize);

                d.Apply();
            }
        }
        static void Drawer_SectionShapeSphere(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, bool drawOffset, bool drawAllOffset)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(d.sphereRadius, radiusContent);
            HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.InfluenceShape, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
            EditorGUILayout.EndHorizontal();

            Drawer_Offset(s, d, o, drawAllOffset);

            EditorGUILayout.Space();
            var maxBlendDistance = d.sphereRadius.floatValue;

            EditorGUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(d.sphereBlendDistance, blendDistanceContent);
            if (EditorGUI.EndChangeCheck())
            {
                d.sphereBlendDistance.floatValue = Mathf.Clamp(d.sphereBlendDistance.floatValue, 0, maxBlendDistance);
            }
            HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.Blend, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight + 3));
            EditorGUILayout.EndHorizontal();

            if (drawAllOffset)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(d.sphereBlendNormalDistance, blendNormalDistanceContent);
                if (EditorGUI.EndChangeCheck())
                {
                    d.sphereBlendNormalDistance.floatValue = Mathf.Clamp(d.sphereBlendNormalDistance.floatValue, 0, maxBlendDistance);
                }
                HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.NormalBlend, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight + 3));
                EditorGUILayout.EndHorizontal();
            }
        }
Esempio n. 12
0
        static PlanarReflectionProbeUI()
        {
            //copy HDProbe UI
            int max = HDProbeUI.Inspector.Length;

#pragma warning disable 618 //CED
            Inspector = new CED.IDrawer[max];
#pragma warning disable 618
            for (int i = 0; i < max; ++i)
            {
                Inspector[i] = HDProbeUI.Inspector[i];
            }

            //forbid other mode than realtime at the moment
            Inspector[1] = SectionPrimarySettings;      //lock realtime/Custom/bake on realtime
            Inspector[Inspector.Length - 1] = CED.noop; //hide bake button

            //override SectionInfluenceVolume to remove normals settings
            Inspector[3] = CED.FoldoutGroup(
                InfluenceVolumeUI.influenceVolumeHeader,
                Expandable.InfluenceVolume,
                k_ExpandedState,
                CED.Select(
                    (s, d, o) => s.influenceVolume,
                    (s, d, o) => d.influenceVolume,
                    InfluenceVolumeUI.InnerInspector(UnityEngine.Experimental.Rendering.HDPipeline.ReflectionProbeType.PlanarReflection)
                    )
                );
        }
Esempio n. 13
0
        static void RenderGizmo(ReflectionProbe reflectionProbe, GizmoType gizmoType)
        {
            var e = GetEditorFor(reflectionProbe);

            if (e == null || !e.sceneViewEditing)
            {
                return;
            }

            var reflectionData = reflectionProbe.GetComponent <HDAdditionalReflectionData>();
            var mat            = reflectionProbe.transform.localToWorldMatrix;

            switch (EditMode.editMode)
            {
            // Influence editing
            case EditMode.SceneViewEditMode.ReflectionProbeBox:
                InfluenceVolumeUI.DrawGizmos(e.m_UIState.influenceVolume, reflectionData.influenceVolume, mat, InfluenceVolumeUI.HandleType.Base, InfluenceVolumeUI.HandleType.All);
                break;

            // Influence fade editing
            case EditMode.SceneViewEditMode.GridBox:
                InfluenceVolumeUI.DrawGizmos(e.m_UIState.influenceVolume, reflectionData.influenceVolume, mat, InfluenceVolumeUI.HandleType.Influence, InfluenceVolumeUI.HandleType.All);
                break;

            // Influence normal fade editing
            case EditMode.SceneViewEditMode.Collider:
                InfluenceVolumeUI.DrawGizmos(e.m_UIState.influenceVolume, reflectionData.influenceVolume, mat, InfluenceVolumeUI.HandleType.InfluenceNormal, InfluenceVolumeUI.HandleType.All);
                break;

            default:
                InfluenceVolumeUI.DrawGizmos(e.m_UIState.influenceVolume, reflectionData.influenceVolume, mat, InfluenceVolumeUI.HandleType.None, InfluenceVolumeUI.HandleType.Base);
                break;
            }
        }
        static void Drawer_SectionShapeBox(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o)
        {
            bool advanced        = d.editorAdvancedModeEnabled.boolValue;
            var  maxFadeDistance = d.boxBaseSize.vector3Value * 0.5f;
            var  minFadeDistance = Vector3.zero;

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(d.boxBaseSize, _.GetContent("Box Size"));
            PlanarReflectionProbeUI.Drawer_ToolBarButton(0, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
            EditorGUILayout.EndHorizontal();

            //offset have no meaning for planar reflexion probe
            //EditorGUILayout.PropertyField(d.boxBaseOffset, _.GetContent("Box Offset"));

            EditorGUILayout.BeginHorizontal();
            Drawer_AdvancedBlendDistance(
                d,
                false,
                maxFadeDistance,
                CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes.")
                );
            PlanarReflectionProbeUI.Drawer_ToolBarButton(1, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 3 : 1) * (EditorGUIUtility.singleLineHeight + 3)));
            EditorGUILayout.EndHorizontal();

            if (advanced)
            {
                CoreEditorUtils.DrawVector6(
                    CoreEditorUtils.GetContent("Face fade|Fade faces of the cubemap."),
                    d.boxPositiveFaceFade, d.boxNegativeFaceFade, Vector3.zero, Vector3.one, HDReflectionProbeEditor.k_handlesColor);
            }
        }
        static void DrawBoxFadeHandle(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Object sourceAsset, Gizmo6FacesBox box, SerializedProperty positive, SerializedProperty negative)
        {
            box.center = d.offset.vector3Value - (positive.vector3Value - negative.vector3Value) * 0.5f;
            box.size   = d.boxSize.vector3Value - positive.vector3Value - negative.vector3Value;
            box.allHandleControledByOne = !d.editorAdvancedModeEnabled.boolValue;

            EditorGUI.BeginChangeCheck();
            box.DrawHandle();
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(sourceAsset, "Modified Influence Volume");

                var influenceCenter   = d.offset.vector3Value;
                var halfInfluenceSize = d.boxSize.vector3Value * .5f;

                var centerDiff            = box.center - influenceCenter;
                var halfSizeDiff          = halfInfluenceSize - box.size * .5f;
                var positiveNew           = halfSizeDiff - centerDiff;
                var negativeNew           = halfSizeDiff + centerDiff;
                var blendDistancePositive = Vector3.Max(Vector3.zero, Vector3.Min(positiveNew, halfInfluenceSize));
                var blendDistanceNegative = Vector3.Max(Vector3.zero, Vector3.Min(negativeNew, halfInfluenceSize));

                positive.vector3Value = blendDistancePositive;
                negative.vector3Value = blendDistanceNegative;

                d.Apply();
            }
        }
Esempio n. 16
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;
            }
            }
        }
Esempio n. 17
0
        internal static void DrawGizmos(HDProbe d, GizmoType gizmoType)
        {
            HDProbeUI s;

            if (!HDProbeEditor.TryGetUIStateFor(d, out s))
            {
                return;
            }

            var mat = Matrix4x4.TRS(d.transform.position, d.transform.rotation, Vector3.one);

            switch (EditMode.editMode)
            {
            case EditBaseShape:
                InfluenceVolumeUI.DrawGizmos(
                    s.influenceVolume, d.influenceVolume, mat,
                    InfluenceVolumeUI.HandleType.Base,
                    InfluenceVolumeUI.HandleType.All);
                break;

            case EditInfluenceShape:
                InfluenceVolumeUI.DrawGizmos(
                    s.influenceVolume,
                    d.influenceVolume,
                    mat,
                    InfluenceVolumeUI.HandleType.Influence,
                    InfluenceVolumeUI.HandleType.All);
                break;

            case EditInfluenceNormalShape:
                InfluenceVolumeUI.DrawGizmos(
                    s.influenceVolume,
                    d.influenceVolume,
                    mat,
                    InfluenceVolumeUI.HandleType.InfluenceNormal,
                    InfluenceVolumeUI.HandleType.All);
                break;

            default:
            {
                var showedHandles = s.influenceVolume.showInfluenceHandles
                        ? InfluenceVolumeUI.HandleType.All
                        : InfluenceVolumeUI.HandleType.Base | InfluenceVolumeUI.HandleType.Influence;
                InfluenceVolumeUI.DrawGizmos(
                    s.influenceVolume,
                    d.influenceVolume,
                    mat,
                    InfluenceVolumeUI.HandleType.None,
                    showedHandles);
                break;
            }
            }

            if (d.proxyVolume != null)
            {
                ReflectionProxyVolumeComponentUI.DrawGizmos_EditNone(d.proxyVolume);
            }
        }
Esempio n. 18
0
        static void Drawer_SectionShapeSphere(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o)
        {
            var maxFaceDistance = d.sphereBaseRadius.floatValue;

            EditorGUILayout.PropertyField(d.sphereBaseRadius, _.GetContent("Radius"));
            d.sphereBaseOffset.vector3Value = Vector3.zero;

            EditorGUILayout.Space();

            EditorGUILayout.Slider(d.sphereInfluenceFade, 0, maxFaceDistance, _.GetContent("Blend Distance"));
        }
Esempio n. 19
0
        public static void DrawGizmos(InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix, HandleType editedHandle, HandleType showedHandle)
        {
            using (new Handles.DrawingScope(matrix))
            {
                switch (d.shape)
                {
                case InfluenceShape.Box:
                    if ((showedHandle & HandleType.Base) != 0)
                    {
                        s.boxBaseHandle.center = d.offset;
                        s.boxBaseHandle.size   = d.boxSize;
                        s.boxBaseHandle.DrawHull((editedHandle & HandleType.Base) != 0);
                    }
                    if ((showedHandle & HandleType.Influence) != 0)
                    {
                        s.boxInfluenceHandle.monoHandle = !s.data.editorAdvancedModeEnabled.boolValue;
                        s.boxInfluenceHandle.center     = d.offset + d.boxBlendOffset;
                        s.boxInfluenceHandle.size       = d.boxSize + d.boxBlendSize;
                        s.boxInfluenceHandle.DrawHull((editedHandle & HandleType.Influence) != 0);
                    }
                    if ((showedHandle & HandleType.InfluenceNormal) != 0)
                    {
                        s.boxInfluenceNormalHandle.monoHandle = !s.data.editorAdvancedModeEnabled.boolValue;
                        s.boxInfluenceNormalHandle.center     = d.offset + d.boxBlendNormalOffset;
                        s.boxInfluenceNormalHandle.size       = d.boxSize + d.boxBlendNormalSize;
                        s.boxInfluenceNormalHandle.DrawHull((editedHandle & HandleType.InfluenceNormal) != 0);
                    }
                    break;

                case InfluenceShape.Sphere:
                    if ((showedHandle & HandleType.Base) != 0)
                    {
                        s.sphereBaseHandle.center = d.offset;
                        s.sphereBaseHandle.radius = d.sphereRadius;
                        s.sphereBaseHandle.DrawHull((editedHandle & HandleType.Base) != 0);
                    }
                    if ((showedHandle & HandleType.Influence) != 0)
                    {
                        s.sphereInfluenceHandle.center = d.offset;
                        s.sphereInfluenceHandle.radius = d.sphereRadius - d.sphereBlendDistance;
                        s.sphereInfluenceHandle.DrawHull((editedHandle & HandleType.Influence) != 0);
                    }
                    if ((showedHandle & HandleType.InfluenceNormal) != 0)
                    {
                        s.sphereInfluenceNormalHandle.center = d.offset;
                        s.sphereInfluenceNormalHandle.radius = d.sphereRadius - d.sphereBlendNormalDistance;
                        s.sphereInfluenceNormalHandle.DrawHull((editedHandle & HandleType.InfluenceNormal) != 0);
                    }
                    break;
                }
            }
        }
        public static void DrawHandles_EditInfluence(InfluenceVolumeUI s, InfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset)
        {
            var mat = Handles.matrix;
            var c   = Handles.color;

            Handles.matrix = matrix;
            Handles.color  = k_GizmoThemeColorInfluence;
            switch (d.shape)
            {
            case InfluenceShape.Box:
            {
                var positive = d.boxBlendDistancePositive;
                var negative = d.boxBlendDistanceNegative;
                DrawBoxFadeHandle(
                    s, d, o, sourceAsset,
                    s1 => s1.boxInfluenceHandle,
                    d.offset, d.boxSize,
                    ref positive,
                    ref negative);
                s.data.boxBlendDistancePositive.vector3Value = positive;
                s.data.boxBlendDistanceNegative.vector3Value = negative;

                //save advanced/simplified saved data
                if (s.data.editorAdvancedModeEnabled.boolValue)
                {
                    s.data.editorAdvancedModeBlendDistancePositive.vector3Value = positive;
                    s.data.editorAdvancedModeBlendDistanceNegative.vector3Value = negative;
                }
                else
                {
                    s.data.editorSimplifiedModeBlendDistance.floatValue = positive.x;
                }
                s.data.Apply();
                break;
            }

            case InfluenceShape.Sphere:
            {
                var fade = d.sphereBlendDistance;
                DrawSphereFadeHandle(
                    s, d, o, sourceAsset,
                    s1 => s1.sphereInfluenceHandle,
                    d.offset, d.sphereRadius,
                    ref fade);
                d.sphereBlendDistance = fade;
                break;
            }
            }
            Handles.matrix = mat;
            Handles.color  = c;
        }
        static void DrawSphereFadeHandle(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Object sourceAsset, SphereBoundsHandle sphere, SerializedProperty radius)
        {
            sphere.center = d.offset.vector3Value;
            sphere.radius = radius.floatValue;

            EditorGUI.BeginChangeCheck();
            sphere.DrawHandle();
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(sourceAsset, "Modified Influence volume");

                radius.floatValue = Mathf.Clamp(d.sphereRadius.floatValue - sphere.radius, 0, d.sphereRadius.floatValue);
                d.Apply();
            }
        }
        public static void DrawHandles_EditBase(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset)
        {
            using (new Handles.DrawingScope(k_GizmoThemeColorBase, matrix))
            {
                switch ((InfluenceShape)d.shape.intValue)
                {
                case InfluenceShape.Box:
                    DrawBoxHandle(s, d, o, sourceAsset, s.boxBaseHandle);
                    break;

                case InfluenceShape.Sphere:
                    DrawSphereHandle(s, d, o, sourceAsset, s.sphereBaseHandle);
                    break;
                }
            }
        }
Esempio n. 23
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();
            }
        }
Esempio n. 24
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;
            }
            }
        }
        static void DrawSphereHandle(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Object sourceAsset, SphereBoundsHandle sphere)
        {
            sphere.center = d.offset.vector3Value;
            sphere.radius = d.sphereRadius.floatValue;

            EditorGUI.BeginChangeCheck();
            sphere.DrawHandle();
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(sourceAsset, "Modified Base Volume AABB");

                float radius = sphere.radius;
                d.sphereRadius.floatValue              = radius;
                d.sphereBlendDistance.floatValue       = Mathf.Clamp(s.data.sphereBlendDistance.floatValue, 0, radius);
                d.sphereBlendNormalDistance.floatValue = Mathf.Clamp(s.data.sphereBlendNormalDistance.floatValue, 0, radius);
                d.Apply();
            }
        }
        static void DrawSphereFadeHandle(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Object sourceAsset, HierarchicalSphere sphere, SerializedProperty blend)
        {
            //init parent sphere for clamping
            s.sphereBaseHandle.center = d.offset.vector3Value;
            s.sphereBaseHandle.radius = d.sphereRadius.floatValue;
            sphere.center             = d.offset.vector3Value;
            sphere.radius             = d.sphereRadius.floatValue - blend.floatValue;

            EditorGUI.BeginChangeCheck();
            sphere.DrawHandle();
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(sourceAsset, "Modified Influence volume");

                blend.floatValue = Mathf.Clamp(d.sphereRadius.floatValue - sphere.radius, 0, d.sphereRadius.floatValue);
                d.Apply();
            }
        }
        static void DrawGizmos_FadeHandle(
            InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix,
            Vector3 boxOffset, Vector3 boxSizeOffset,
            float sphereOffset,
            bool isSolid, Color color)
        {
            var mat = Gizmos.matrix;
            var c   = Gizmos.color;

            Gizmos.matrix = matrix;
            Gizmos.color  = color;
            switch (d.shapeType)
            {
            case ShapeType.Box:
            {
                if (isSolid)
                {
                    Gizmos.DrawCube(d.boxBaseOffset + boxOffset, d.boxBaseSize + boxSizeOffset);
                }
                else
                {
                    Gizmos.DrawWireCube(d.boxBaseOffset + boxOffset, d.boxBaseSize + boxSizeOffset);
                }
                break;
            }

            case ShapeType.Sphere:
            {
                if (isSolid)
                {
                    Gizmos.DrawSphere(d.sphereBaseOffset, d.sphereBaseRadius + sphereOffset);
                }
                else
                {
                    Gizmos.DrawWireSphere(d.sphereBaseOffset, d.sphereBaseRadius + sphereOffset);
                }
                break;
            }
            }
            Gizmos.matrix = mat;
            Gizmos.color  = c;
        }
Esempio n. 28
0
        static void Drawer_InfluenceAdvancedSwitch(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor owner)
        {
            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();

                if (d.shape.intValue == (int)InfluenceShape.Sphere)
                {
                    GUI.enabled = false;
                }

                bool advanced = d.editorAdvancedModeEnabled.boolValue;
                advanced = !GUILayout.Toggle(!advanced, normalModeContent, EditorStyles.miniButtonLeft, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
                advanced = GUILayout.Toggle(advanced, advancedModeContent, EditorStyles.miniButtonRight, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
                s.boxInfluenceHandle.allHandleControledByOne = s.boxInfluenceNormalHandle.allHandleControledByOne = !advanced;
                if (d.editorAdvancedModeEnabled.boolValue ^ advanced)
                {
                    d.editorAdvancedModeEnabled.boolValue = advanced;
                    if (advanced)
                    {
                        d.boxBlendDistancePositive.vector3Value       = d.editorAdvancedModeBlendDistancePositive.vector3Value;
                        d.boxBlendDistanceNegative.vector3Value       = d.editorAdvancedModeBlendDistanceNegative.vector3Value;
                        d.boxBlendNormalDistancePositive.vector3Value = d.editorAdvancedModeBlendNormalDistancePositive.vector3Value;
                        d.boxBlendNormalDistanceNegative.vector3Value = d.editorAdvancedModeBlendNormalDistanceNegative.vector3Value;
                        d.boxSideFadePositive.vector3Value            = d.editorAdvancedModeFaceFadePositive.vector3Value;
                        d.boxSideFadeNegative.vector3Value            = d.editorAdvancedModeFaceFadeNegative.vector3Value;
                    }
                    else
                    {
                        d.boxBlendDistanceNegative.vector3Value       = d.boxBlendDistancePositive.vector3Value = Vector3.one * d.editorSimplifiedModeBlendDistance.floatValue;
                        d.boxBlendNormalDistanceNegative.vector3Value = d.boxBlendNormalDistancePositive.vector3Value = Vector3.one * d.editorSimplifiedModeBlendNormalDistance.floatValue;
                        d.boxSideFadeNegative.vector3Value            = d.boxSideFadePositive.vector3Value = Vector3.one;
                    }
                    d.Apply();
                }

                if (d.shape.intValue == (int)InfluenceShape.Sphere)
                {
                    GUI.enabled = true;
                }
            }
        }
Esempio n. 29
0
        static void DrawSelectedGizmo(PlanarReflectionProbe probe, GizmoType gizmoType)
        {
            var e = (PlanarReflectionProbeEditor)GetEditorFor(probe);

            if (e == null)
            {
                return;
            }

            var mat = Matrix4x4.TRS(probe.transform.position, probe.transform.rotation, Vector3.one);

            InfluenceVolumeUI.DrawGizmos(
                probe.influenceVolume,
                mat,
                InfluenceVolumeUI.HandleType.None,
                InfluenceVolumeUI.HandleType.Base | InfluenceVolumeUI.HandleType.Influence
                );

            DrawCapturePositionGizmo(probe);
        }
        static void Drawer_SectionShapeSphere(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, bool drawOffset, bool drawNormal)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(d.sphereRadius, _.GetContent("Radius"));
            PlanarReflectionProbeUI.Drawer_ToolBarButton(0, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
            EditorGUILayout.EndHorizontal();

            if (drawOffset)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PropertyField(d.offset, _.GetContent("Offset"));
                HDReflectionProbeUI.Drawer_ToolBarButton(3, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.Space();
            var maxBlendDistance = d.sphereRadius.floatValue;

            EditorGUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(d.sphereBlendDistance, _.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes."));
            if (EditorGUI.EndChangeCheck())
            {
                d.sphereBlendDistance.floatValue = Mathf.Clamp(d.sphereBlendDistance.floatValue, 0, maxBlendDistance);
            }
            PlanarReflectionProbeUI.Drawer_ToolBarButton(1, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight + 3));
            EditorGUILayout.EndHorizontal();

            if (drawNormal)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(d.sphereBlendNormalDistance, _.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes."));
                if (EditorGUI.EndChangeCheck())
                {
                    d.sphereBlendNormalDistance.floatValue = Mathf.Clamp(d.sphereBlendNormalDistance.floatValue, 0, maxBlendDistance);
                }
                PlanarReflectionProbeUI.Drawer_ToolBarButton(2, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight + 3));
                EditorGUILayout.EndHorizontal();
            }
        }