浏览代码

Clean ProxyVolume class and editor

/main
RSlysz 6 年前
当前提交
eda72143
共有 9 个文件被更改,包括 97 次插入60 次删除
  1. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeUI.Drawers.cs
  2. 4
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Drawers.cs
  3. 30
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/ProxyVolumeUI.cs
  4. 12
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/SerializedProxyVolume.cs
  5. 15
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/PlanarReflectionProbe.cs
  6. 17
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ProbeWrapper.cs
  7. 39
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/Volumes/ProxyVolume.cs
  8. 31
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/Volumes/ReflectionProxyVolumeComponent.cs
  9. 7
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/Volumes/ShapeType.cs

2
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeUI.Drawers.cs


if (p.proxyVolumeComponent.objectReferenceValue != null)
{
var proxy = (ReflectionProxyVolumeComponent)p.proxyVolumeComponent.objectReferenceValue;
if ((int)proxy.proxyVolume.shapeType != p.influenceVolume.shape.enumValueIndex)
if ((int)proxy.proxyVolume.shape != p.influenceVolume.shape.enumValueIndex)
EditorGUILayout.HelpBox(
"Proxy volume and influence volume have different shape types, this is not supported.",
MessageType.Error,

4
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Drawers.cs


static void Drawer_DifferentShapeError(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
var proxy = d.proxyVolumeReference.objectReferenceValue as ReflectionProxyVolumeComponent;
if (proxy != null && (int)proxy.proxyVolume.shapeType != d.influenceVolume.shape.enumValueIndex)
if (proxy != null && (int)proxy.proxyVolume.shape != d.influenceVolume.shape.enumValueIndex)
{
EditorGUILayout.HelpBox(
"Proxy volume and influence volume have different shape types, this is not supported.",

if (d.proxyVolumeReference.objectReferenceValue != null)
{
var proxy = (ReflectionProxyVolumeComponent)d.proxyVolumeReference.objectReferenceValue;
if ((int)proxy.proxyVolume.shapeType != d.influenceVolume.shape.enumValueIndex)
if ((int)proxy.proxyVolume.shape != d.influenceVolume.shape.enumValueIndex)
EditorGUILayout.HelpBox(
"Proxy volume and influence volume have different shape types, this is not supported.",
MessageType.Error,

30
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/ProxyVolumeUI.cs


{
base.Update();
if (data != null)
SetIsSectionExpanded_Shape((Shape)data.shapeType.intValue);
SetIsSectionExpanded_Shape((Shape)data.shape.intValue);
}
void SetIsSectionExpanded_Shape(Shape shape)

static void Drawer_FieldShapeType(ProxyVolumeUI s, SerializedProxyVolume d, Editor o)
{
EditorGUILayout.PropertyField(d.shapeType, _.GetContent("Shape Type"));
EditorGUILayout.PropertyField(d.shape, _.GetContent("Shape Type"));
EditorGUILayout.PropertyField(d.boxOffset, _.GetContent("Box Offset"));
EditorGUILayout.PropertyField(d.boxInfiniteProjection, _.GetContent("Infinite Projection"));
EditorGUILayout.PropertyField(d.sphereOffset, _.GetContent("Sphere Offset"));
EditorGUILayout.PropertyField(d.sphereInfiniteProjection, _.GetContent("Infinite Projection"));
switch (proxyVolume.shapeType)
switch (proxyVolume.shape)
case Shape.Box:
case ShapeOrInfinite.Box:
case Shape.Sphere:
case ShapeOrInfinite.Sphere:
Handles_EditBase_Sphere(transform, proxyVolume, ui, sourceAsset);
break;
}

static void Handles_EditBase_Sphere(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI s, Object sourceAsset)
{
s.sphereProjectionHandle.center = proxyVolume.sphereOffset;
s.sphereProjectionHandle.center = Vector3.zero;
s.sphereProjectionHandle.radius = proxyVolume.sphereRadius;
var mat = Handles.matrix;

{
Undo.RecordObject(sourceAsset, "Modified Projection Volume");
proxyVolume.sphereOffset = s.sphereProjectionHandle.center;
proxyVolume.sphereRadius = s.sphereProjectionHandle.radius;
EditorUtility.SetDirty(sourceAsset);

static void Handles_EditBase_Box(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI s, Object sourceAsset)
{
s.boxProjectionHandle.center = proxyVolume.boxOffset;
s.boxProjectionHandle.center = Vector3.zero;
s.boxProjectionHandle.size = proxyVolume.boxSize;
var mat = Handles.matrix;

{
Undo.RecordObject(sourceAsset, "Modified Projection Volume AABB");
proxyVolume.boxOffset = s.boxProjectionHandle.center;
proxyVolume.boxSize = s.boxProjectionHandle.size;
EditorUtility.SetDirty(sourceAsset);

public static void DrawGizmos_EditNone(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI ui, Object sourceAsset)
{
switch (proxyVolume.shapeType)
switch (proxyVolume.shape)
case Shape.Box:
case ShapeOrInfinite.Box:
case Shape.Sphere:
case ShapeOrInfinite.Sphere:
Gizmos_EditNone_Sphere(transform, proxyVolume, ui, sourceAsset);
break;
}

Gizmos.matrix = t.localToWorldMatrix;
Gizmos.color = k_GizmoThemeColorProjection;
Gizmos.DrawWireSphere(d.sphereOffset, d.sphereRadius);
Gizmos.DrawWireSphere(Vector3.zero, d.sphereRadius);
Gizmos.matrix = mat;
}

Gizmos.matrix = t.localToWorldMatrix;
Gizmos.color = k_GizmoThemeColorProjection;
Gizmos.DrawWireCube(d.boxOffset, d.boxSize);
Gizmos.DrawWireCube(Vector3.zero, d.boxSize);
Gizmos.matrix = mat;
}

12
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/SerializedProxyVolume.cs


{
public SerializedProperty root;
public SerializedProperty shapeType;
public SerializedProperty shape;
public SerializedProperty boxOffset;
public SerializedProperty boxInfiniteProjection;
public SerializedProperty sphereOffset;
public SerializedProperty sphereInfiniteProjection;
shapeType = root.Find((ProxyVolume p) => p.shapeType);
shape = root.Find((ProxyVolume p) => p.shape);
boxOffset = root.Find((ProxyVolume p) => p.boxOffset);
boxInfiniteProjection = root.Find((ProxyVolume p) => p.boxInfiniteProjection);
sphereOffset = root.Find((ProxyVolume p) => p.sphereOffset);
sphereInfiniteProjection = root.Find((ProxyVolume p) => p.sphereInfiniteProjection);
}
}
}

15
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/PlanarReflectionProbe.cs


: influenceToWorld;
}
}
public Shape proxyShape
public ShapeOrInfinite proxyShape
? proxyVolume.proxyVolume.shapeType
: influenceVolume.shape;
? proxyVolume.proxyVolume.shape
: (ShapeOrInfinite)influenceVolume.shape;
}
}
public Vector3 proxyExtents

: influenceVolume.boxSize;
}
}
public bool infiniteProjection { get { return proxyVolume != null && proxyVolume.proxyVolume.infiniteProjection; } }
public bool infiniteProjection
{
get
{
return proxyVolume != null
&& proxyVolume.proxyVolume.shape == ShapeOrInfinite.Infinite;
}
}
public bool useMirrorPlane
{

17
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ProbeWrapper.cs


}
}
protected static EnvShapeType ConvertShape(ShapeOrInfinite shape)
{
switch (shape)
{
default:
case ShapeOrInfinite.Infinite:
case ShapeOrInfinite.Box:
return EnvShapeType.Box;
case ShapeOrInfinite.Sphere:
return EnvShapeType.Sphere;
}
}
public ReflectionProbe reflectionProbe { get; protected set; }
public PlanarReflectionProbe planarReflectionProbe { get; protected set; }

get
{
return additional.proxyVolume != null
? ConvertShape(additional.proxyVolume.proxyVolume.shapeType)
? ConvertShape(additional.proxyVolume.proxyVolume.shape)
: influenceShapeType;
}
}

get
{
return additional.proxyVolume != null
? additional.proxyVolume.proxyVolume.infiniteProjection
? additional.proxyVolume.proxyVolume.shape == ShapeOrInfinite.Infinite
: probe.boxProjection == 0;
}
}

39
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/Volumes/ProxyVolume.cs


using System;
using UnityEngine.Serialization;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{

[SerializeField]
Shape m_ShapeType = Shape.Box;
[SerializeField, FormerlySerializedAs("m_ShapeType")]
ShapeOrInfinite m_Shape = ShapeOrInfinite.Box;
[SerializeField]
Vector3 m_BoxOffset;
[SerializeField]
[SerializeField, Obsolete("Kept only for compatibility. Use m_Shape instead")]
[SerializeField]
Vector3 m_SphereOffset;
[SerializeField]
[SerializeField, Obsolete("Kept only for compatibility. Use m_Shape instead")]
public Shape shapeType { get { return m_ShapeType; } }
public ShapeOrInfinite shape { get { return m_Shape; } private set { m_Shape = value; } }
public Vector3 boxOffset { get { return m_BoxOffset; } set { m_BoxOffset = value; } }
public bool boxInfiniteProjection { get { return m_BoxInfiniteProjection; } }
public Vector3 sphereOffset { get { return m_SphereOffset; } set { m_SphereOffset = value; } }
public bool sphereInfiniteProjection { get { return m_SphereInfiniteProjection; } }
public Vector3 extents
internal Vector3 extents
switch (shapeType)
switch (shape)
case Shape.Box: return m_BoxSize * 0.5f;
case Shape.Sphere: return Vector3.one * m_SphereRadius;
case ShapeOrInfinite.Box: return m_BoxSize * 0.5f;
case ShapeOrInfinite.Sphere: return Vector3.one * m_SphereRadius;
public bool infiniteProjection
internal void MigrateInfiniteProhjectionInShape()
get
#pragma warning disable CS0618 // Type or member is obsolete
if (shape == ShapeOrInfinite.Sphere && m_SphereInfiniteProjection
|| shape == ShapeOrInfinite.Box && m_BoxInfiniteProjection)
#pragma warning restore CS0618 // Type or member is obsolete
return shapeType == Shape.Box && boxInfiniteProjection
|| shapeType == Shape.Sphere && sphereInfiniteProjection;
shape = ShapeOrInfinite.Infinite;
}
}
}

31
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/Volumes/ReflectionProxyVolumeComponent.cs


namespace UnityEngine.Experimental.Rendering.HDPipeline
{
public class ReflectionProxyVolumeComponent : MonoBehaviour
public class ReflectionProxyVolumeComponent : MonoBehaviour, ISerializationCallbackReceiver
enum Version
{
First,
IncludeInfiniteInShape,
// Add new version here and they will automatically be the Current one
Max,
Current = Max - 1
}
[SerializeField]
int m_Version;
void ISerializationCallbackReceiver.OnBeforeSerialize()
{
}
void ISerializationCallbackReceiver.OnAfterDeserialize()
{
if (m_Version != (int)Version.Current)
{
// Add here data migration code
if (m_Version < (int)Version.IncludeInfiniteInShape)
{
proxyVolume.MigrateInfiniteProhjectionInShape();
}
m_Version = (int)Version.Current;
}
}
}
}

7
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/Volumes/ShapeType.cs


Box,
Sphere,
}
public enum ShapeOrInfinite
{
Box,
Sphere,
Infinite
}
}
正在加载...
取消
保存