浏览代码

[PlanarReflection] Added handles for capture mirror

/main
Frédéric Vauchelles 7 年前
当前提交
2f071063
共有 5 个文件被更改,包括 111 次插入12 次删除
  1. 42
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Drawers.cs
  2. 53
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Handles.cs
  3. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.cs
  4. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/SerializedPlanarReflectionProbe.cs
  5. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/PlanarReflectionProbe.cs

42
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Drawers.cs


const EditMode.SceneViewEditMode EditInfluenceShape = EditMode.SceneViewEditMode.GridBox;
const EditMode.SceneViewEditMode EditInfluenceNormalShape = EditMode.SceneViewEditMode.Collider;
const EditMode.SceneViewEditMode EditCenter = EditMode.SceneViewEditMode.ReflectionProbeOrigin;
const EditMode.SceneViewEditMode EditMirrorPosition = EditMode.SceneViewEditMode.GridMove;
const EditMode.SceneViewEditMode EditMirrorRotation = EditMode.SceneViewEditMode.GridSelect;
static void Drawer_SectionCaptureStatic(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{

EditBaseShape,
EditInfluenceShape,
EditInfluenceNormalShape,
//EditCenter
};
static readonly EditMode.SceneViewEditMode[] k_Toolbar_Static_SceneViewEditModes =
{
};
static readonly EditMode.SceneViewEditMode[] k_Toolbar_Mirror_SceneViewEditModes =
{
EditMirrorPosition,
EditMirrorRotation
};
static GUIContent[] s_Toolbar_Contents = null;
static GUIContent[] toolbar_Contents

EditorGUIUtility.IconContent("EditCollider", "|Modify the base shape. (SHIFT+1)"),
EditorGUIUtility.IconContent("PreMatCube", "|Modify the influence volume. (SHIFT+2)"),
EditorGUIUtility.IconContent("SceneViewOrtho", "|Modify the influence normal volume. (SHIFT+3)"),
});
}
}
static GUIContent[] s_Toolbar_Static_Contents = null;
static GUIContent[] toolbar_Static_Contents
{
get
{
return s_Toolbar_Static_Contents ?? (s_Toolbar_Static_Contents = new[]
{
static GUIContent[] s_Toolbar_Mirror_Contents = null;
static GUIContent[] toolbar_Mirror_Contents
{
get
{
return s_Toolbar_Mirror_Contents ?? (s_Toolbar_Mirror_Contents = new[]
{
EditorGUIUtility.IconContent("MoveTool", "|Move the mirror plane."),
EditorGUIUtility.IconContent("RotateTool", "|Rotate the mirror plane.")
});
}
}
static void Drawer_Toolbar(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
GUILayout.BeginHorizontal();

EditMode.DoInspectorToolbar(k_Toolbar_SceneViewEditModes, toolbar_Contents, GetBoundsGetter(o), o);
if (d.isMirrored)
EditMode.DoInspectorToolbar(k_Toolbar_Mirror_SceneViewEditModes, toolbar_Mirror_Contents, GetBoundsGetter(o), o);
else
EditMode.DoInspectorToolbar(k_Toolbar_Static_SceneViewEditModes, toolbar_Static_Contents, GetBoundsGetter(o), o);
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();

53
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Handles.cs


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, Vector3.zero);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(d, "Rotate Mirror Plane");
d.captureMirrorPlaneLocalNormal = q * Vector3.forward;
EditorUtility.SetDirty(d);
}
Handles.matrix = m;
break;
}
d.captureLocalPosition = Handles.PositionHandle(d.captureLocalPosition, d.transform.rotation);
var p = Handles.PositionHandle(d.captureLocalPosition, d.transform.rotation);
{
Undo.RecordObject(d, "Translate Capture Position");
d.captureLocalPosition = p;
}
Handles.matrix = m;
break;
}

if (d.proxyVolumeReference != null)
ProxyVolumeComponentUI.DrawGizmos_EditNone(s.proxyVolume, d.proxyVolumeReference);
if (s.showCaptureHandles
|| EditMode.editMode == EditCenter)
{
var showFrustrum = s.showCaptureHandles
|| EditMode.editMode == EditCenter;
var showCaptureMirror = (s.showCaptureHandles && d.useMirrorPlane)
|| EditMode.editMode == EditMirrorPosition
|| EditMode.editMode == EditMirrorRotation;
if (showFrustrum)
if (d.mode == ReflectionProbeMode.Realtime
&& d.refreshMode == ReflectionProbeRefreshMode.EveryFrame)
DrawGizmos_CaptureMirror(s, d);
}
if (showCaptureMirror)
DrawGizmos_CaptureMirror(s, d);
}
static void DrawGizmos_CaptureMirror(PlanarReflectionProbeUI s, PlanarReflectionProbe d)

6
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.cs


for (var i = 0; i < k_ReflectionProbeModeModeCount; i++)
m_AnimBools[i].target = i == data.mode.intValue;
isSectionExpandedCaptureMirrorSettings.target = data.refreshMode.intValue == (int)ReflectionProbeRefreshMode.EveryFrame
&& data.mode.intValue == (int)ReflectionProbeMode.Realtime
&& data.capturePositionMode.intValue == (int)PlanarReflectionProbe.CapturePositionMode.MirrorCamera;
isSectionExpandedCaptureStaticSettings.target = !isSectionExpandedCaptureMirrorSettings.target;
isSectionExpandedCaptureMirrorSettings.target = data.isMirrored;
isSectionExpandedCaptureStaticSettings.target = !data.isMirrored;
proxyVolume.Update();
frameSettings.Update();

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/SerializedPlanarReflectionProbe.cs


using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Rendering;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{

public SerializedFrameSettings frameSettings;
public PlanarReflectionProbe target { get { return serializedObject.targetObject as PlanarReflectionProbe; } }
public bool isMirrored
{
get
{
return refreshMode.intValue == (int)ReflectionProbeRefreshMode.EveryFrame
&& mode.intValue == (int)ReflectionProbeMode.Realtime
&& capturePositionMode.intValue == (int)PlanarReflectionProbe.CapturePositionMode.MirrorCamera;
}
}
public SerializedPlanarReflectionProbe(SerializedObject serializedObject)
{

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/PlanarReflectionProbe.cs


}
}
public bool infiniteProjection { get { return m_ProxyVolumeReference != null && m_ProxyVolumeReference.proxyVolume.infiniteProjection; } }
public bool useMirrorPlane
{
get
{
return mode == ReflectionProbeMode.Realtime
&& refreshMode == ReflectionProbeRefreshMode.EveryFrame
&& capturePositionMode == CapturePositionMode.MirrorCamera;
}
}
#endregion
public void RequestRealtimeRender()

正在加载...
取消
保存