浏览代码

Merge common serialized field into SerializedHDProbe

/main
RSlysz 6 年前
当前提交
ac3b41f9
共有 7 个文件被更改,包括 163 次插入155 次删除
  1. 12
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Handles.cs
  2. 24
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.cs
  3. 22
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeUI.Drawers.cs
  4. 78
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDReflectionProbe.cs
  5. 81
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedPlanarReflectionProbe.cs
  6. 90
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDProbe.cs
  7. 11
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDProbe.cs.meta

12
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Handles.cs


if (!s.sceneViewEditing)
return;
var mat = Matrix4x4.TRS(p.target.transform.position, p.target.transform.rotation, Vector3.one);
var mat = Matrix4x4.TRS(p.targetLegacy.transform.position, p.targetLegacy.transform.rotation, Vector3.one);
EditorGUI.BeginChangeCheck();

case EditMode.SceneViewEditMode.ReflectionProbeBox:
InfluenceVolumeUI.DrawHandles_EditBase(s.influenceVolume, p.targetData.influenceVolume, o, mat, p.targetData);
InfluenceVolumeUI.DrawHandles_EditBase(s.influenceVolume, p.target.influenceVolume, o, mat, p.target);
InfluenceVolumeUI.DrawHandles_EditInfluence(s.influenceVolume, p.targetData.influenceVolume, o, mat, p.targetData);
InfluenceVolumeUI.DrawHandles_EditInfluence(s.influenceVolume, p.target.influenceVolume, o, mat, p.target);
InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(s.influenceVolume, p.targetData.influenceVolume, o, mat, p.targetData);
InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(s.influenceVolume, p.target.influenceVolume, o, mat, p.target);
break;
// Origin editing
case EditMode.SceneViewEditMode.ReflectionProbeOrigin:

static void Handle_OriginEditing(HDReflectionProbeUI s, SerializedHDReflectionProbe sp, Editor o)
{
var p = (ReflectionProbe)sp.so.targetObject;
var p = (ReflectionProbe)sp.serializedLegacyObject.targetObject;
var transformPosition = p.transform.position;
var size = p.size;

24
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.cs


}
var hash = 0;
for (var i = 0; i < sp.so.targetObjects.Length; i++)
for (var i = 0; i < sp.serializedLegacyObject.targetObjects.Length; i++)
var p = (ReflectionProbe)sp.so.targetObjects[i];
var p = (ReflectionProbe)sp.serializedLegacyObject.targetObjects[i];
var tr = p.GetComponent<Transform>();
hash ^= tr.position.GetHashCode();
}

m_PositionHash = hash;
for (var i = 0; i < sp.so.targetObjects.Length; i++)
for (var i = 0; i < sp.serializedLegacyObject.targetObjects.Length; i++)
var p = (ReflectionProbe)sp.so.targetObjects[i];
var p = (ReflectionProbe)sp.serializedLegacyObject.targetObjects[i];
p.RenderProbe();
}
}

case InfluenceShape.Box:
{
var maxBlendDistance = sp.influenceVolume.boxSize.vector3Value;
sp.targetData.influenceVolume.boxBlendDistancePositive = Vector3.Min(sp.targetData.influenceVolume.boxBlendDistancePositive, maxBlendDistance);
sp.targetData.influenceVolume.boxBlendDistanceNegative = Vector3.Min(sp.targetData.influenceVolume.boxBlendDistanceNegative, maxBlendDistance);
sp.targetData.influenceVolume.boxBlendNormalDistancePositive = Vector3.Min(sp.targetData.influenceVolume.boxBlendNormalDistancePositive, maxBlendDistance);
sp.targetData.influenceVolume.boxBlendNormalDistanceNegative = Vector3.Min(sp.targetData.influenceVolume.boxBlendNormalDistanceNegative, maxBlendDistance);
sp.target.influenceVolume.boxBlendDistancePositive = Vector3.Min(sp.target.influenceVolume.boxBlendDistancePositive, maxBlendDistance);
sp.target.influenceVolume.boxBlendDistanceNegative = Vector3.Min(sp.target.influenceVolume.boxBlendDistanceNegative, maxBlendDistance);
sp.target.influenceVolume.boxBlendNormalDistancePositive = Vector3.Min(sp.target.influenceVolume.boxBlendNormalDistancePositive, maxBlendDistance);
sp.target.influenceVolume.boxBlendNormalDistanceNegative = Vector3.Min(sp.target.influenceVolume.boxBlendNormalDistanceNegative, maxBlendDistance);
sp.targetData.influenceVolume.boxBlendDistancePositive = Vector3.Min(sp.targetData.influenceVolume.boxBlendDistancePositive, maxBlendDistance);
sp.targetData.influenceVolume.boxBlendDistanceNegative = Vector3.Min(sp.targetData.influenceVolume.boxBlendDistanceNegative, maxBlendDistance);
sp.targetData.influenceVolume.boxBlendNormalDistancePositive = Vector3.Min(sp.targetData.influenceVolume.boxBlendNormalDistancePositive, maxBlendDistance);
sp.targetData.influenceVolume.boxBlendNormalDistanceNegative = Vector3.Min(sp.targetData.influenceVolume.boxBlendNormalDistanceNegative, maxBlendDistance);
sp.target.influenceVolume.boxBlendDistancePositive = Vector3.Min(sp.target.influenceVolume.boxBlendDistancePositive, maxBlendDistance);
sp.target.influenceVolume.boxBlendDistanceNegative = Vector3.Min(sp.target.influenceVolume.boxBlendDistanceNegative, maxBlendDistance);
sp.target.influenceVolume.boxBlendNormalDistancePositive = Vector3.Min(sp.target.influenceVolume.boxBlendNormalDistancePositive, maxBlendDistance);
sp.target.influenceVolume.boxBlendNormalDistanceNegative = Vector3.Min(sp.target.influenceVolume.boxBlendNormalDistanceNegative, maxBlendDistance);
break;
}
}

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


if (EditorGUI.EndChangeCheck())
p.multiplier.floatValue = Mathf.Max(0.0f, p.multiplier.floatValue);
if (p.so.targetObjects.Length == 1)
if (p.serializedLegacyObject.targetObjects.Length == 1)
var probe = p.target;
var probe = p.targetLegacy;
if (probe.mode == ReflectionProbeMode.Custom && probe.customBakedTexture != null)
{
var cubemap = probe.customBakedTexture as Cubemap;

static void Drawer_BakeActions(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorReflectionSystemGUI.DrawBakeButton((ReflectionProbeMode)p.mode.intValue, p.target);
EditorReflectionSystemGUI.DrawBakeButton((ReflectionProbeMode)p.mode.intValue, p.targetLegacy);
EditorGUILayout.PropertyField(p.proxyVolumeComponent, _.GetContent("Proxy Volume"));
EditorGUILayout.PropertyField(p.proxyVolumeReference, _.GetContent("Proxy Volume"));
if (p.proxyVolumeComponent.objectReferenceValue == null)
if (p.proxyVolumeReference.objectReferenceValue == null)
{
EditorGUILayout.HelpBox(
"When no Proxy setted, Influence shape will be used as Proxy shape too.",

#region Influence Volume
static void Drawer_InfluenceProxyMissmatch(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
if (p.proxyVolumeComponent.objectReferenceValue != null)
if (p.proxyVolumeReference.objectReferenceValue != null)
var proxy = (ReflectionProxyVolumeComponent)p.proxyVolumeComponent.objectReferenceValue;
var proxy = (ReflectionProxyVolumeComponent)p.proxyVolumeReference.objectReferenceValue;
if ((int)proxy.proxyVolume.shape != p.influenceVolume.shape.enumValueIndex)
EditorGUILayout.HelpBox(
"Proxy volume and influence volume have different shape types, this is not supported.",

{
var center = p.boxOffset.vector3Value;
var size = p.boxSize.vector3Value;
if (HDReflectionProbeEditorUtility.ValidateAABB(p.target, ref center, ref size))
if (HDReflectionProbeEditorUtility.ValidateAABB(p.targetLegacy, ref center, ref size))
{
//clamp to contains object center instead of resizing
Vector3 projector = (center - p.boxOffset.vector3Value).normalized;

}
static void Drawer_Toolbar(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
if (p.so.targetObjects.Length > 1)
if (p.serializedLegacyObject.targetObjects.Length > 1)
return;
// Show the master tool selector

switch (EditMode.editMode)
{
case EditMode.SceneViewEditMode.ReflectionProbeOrigin:
s.UpdateOldLocalSpace(p.target);
s.UpdateOldLocalSpace(p.targetLegacy);
break;
}
}

return () =>
{
var bounds = new Bounds();
foreach (var targetObject in p.so.targetObjects)
foreach (var targetObject in p.serializedLegacyObject.targetObjects)
{
var rp = (ReflectionProbe)targetObject;
var b = rp.bounds;

78
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDReflectionProbe.cs


namespace UnityEditor.Experimental.Rendering.HDPipeline
{
internal class SerializedHDReflectionProbe
internal class SerializedHDReflectionProbe : SerializedHDProbe
internal ReflectionProbe target;
internal HDAdditionalReflectionData targetData;
internal SerializedObject so;
internal SerializedObject addso;
internal SerializedObject serializedLegacyObject;
internal SerializedProperty mode;
internal SerializedProperty refreshMode;
internal SerializedProperty resolution;
internal SerializedProperty shadowDistance;
internal SerializedProperty cullingMask;
internal SerializedProperty useOcclusionCulling;
internal SerializedProperty nearClip;
internal SerializedProperty farClip;
internal SerializedProperty weight;
internal SerializedProperty multiplier;
internal SerializedProperty proxyVolumeComponent;
internal new HDAdditionalReflectionData target { get { return serializedObject.targetObject as HDAdditionalReflectionData; } }
internal ReflectionProbe targetLegacy { get { return serializedLegacyObject.targetObject as ReflectionProbe; } }
internal SerializedInfluenceVolume influenceVolume;
public SerializedHDReflectionProbe(SerializedObject so, SerializedObject addso)
public SerializedHDReflectionProbe(SerializedObject legacyProbe, SerializedObject additionalData) : base(additionalData)
this.so = so;
this.addso = addso;
proxyVolumeComponent = addso.Find((HDAdditionalReflectionData d) => d.proxyVolume);
influenceVolume = new SerializedInfluenceVolume(addso.Find((HDAdditionalReflectionData d) => d.influenceVolume));
target = (ReflectionProbe)so.targetObject;
targetData = target.GetComponent<HDAdditionalReflectionData>();
mode = so.FindProperty("m_Mode");
customBakedTexture = so.FindProperty("m_CustomBakedTexture");
renderDynamicObjects = so.FindProperty("m_RenderDynamicObjects");
refreshMode = so.FindProperty("m_RefreshMode");
timeSlicingMode = so.FindProperty("m_TimeSlicingMode");
intensityMultiplier = so.FindProperty("m_IntensityMultiplier");
boxSize = so.FindProperty("m_BoxSize");
boxOffset = so.FindProperty("m_BoxOffset");
resolution = so.FindProperty("m_Resolution");
shadowDistance = so.FindProperty("m_ShadowDistance");
cullingMask = so.FindProperty("m_CullingMask");
useOcclusionCulling = so.FindProperty("m_UseOcclusionCulling");
nearClip = so.FindProperty("m_NearClip");
farClip = so.FindProperty("m_FarClip");
boxProjection = so.FindProperty("m_BoxProjection");
legacyBlendDistance = so.FindProperty("m_BlendDistance");
serializedLegacyObject = legacyProbe;
weight = addso.Find((HDAdditionalReflectionData d) => d.weight);
multiplier = addso.Find((HDAdditionalReflectionData d) => d.multiplier);
customBakedTexture = legacyProbe.FindProperty("m_CustomBakedTexture");
renderDynamicObjects = legacyProbe.FindProperty("m_RenderDynamicObjects");
timeSlicingMode = legacyProbe.FindProperty("m_TimeSlicingMode");
intensityMultiplier = legacyProbe.FindProperty("m_IntensityMultiplier");
boxSize = legacyProbe.FindProperty("m_BoxSize");
boxOffset = legacyProbe.FindProperty("m_BoxOffset");
resolution = legacyProbe.FindProperty("m_Resolution");
shadowDistance = legacyProbe.FindProperty("m_ShadowDistance");
cullingMask = legacyProbe.FindProperty("m_CullingMask");
useOcclusionCulling = legacyProbe.FindProperty("m_UseOcclusionCulling");
nearClip = legacyProbe.FindProperty("m_NearClip");
farClip = legacyProbe.FindProperty("m_FarClip");
boxProjection = legacyProbe.FindProperty("m_BoxProjection");
legacyBlendDistance = legacyProbe.FindProperty("m_BlendDistance");
public void Update()
internal override void Update()
so.Update();
addso.Update();
//InfluenceVolume does not have Update. Add it here if it have in the futur.
serializedLegacyObject.Update();
base.Update();
// Set the legacy blend distance to 0 so the legacy culling system use the probe extent
legacyBlendDistance.floatValue = 0;

{
so.ApplyModifiedProperties();
addso.ApplyModifiedProperties();
serializedLegacyObject.ApplyModifiedProperties();
serializedObject.ApplyModifiedProperties();
}
}
}

81
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedPlanarReflectionProbe.cs


namespace UnityEditor.Experimental.Rendering.HDPipeline
{
internal class SerializedPlanarReflectionProbe
internal class SerializedPlanarReflectionProbe : SerializedHDProbe
internal SerializedObject serializedObject;
internal SerializedProperty proxyVolumeReference;
internal SerializedReflectionProxyVolumeComponent reflectionProxyVolume;
internal SerializedInfluenceVolume influenceVolume;
internal SerializedProperty captureNearPlane;
internal SerializedProperty captureFarPlane;
internal SerializedProperty weight;
internal SerializedProperty multiplier;
internal SerializedProperty mode;
internal SerializedProperty refreshMode;
internal SerializedFrameSettings frameSettings;
internal PlanarReflectionProbe target { get { return serializedObject.targetObject as PlanarReflectionProbe; } }
internal new PlanarReflectionProbe target { get { return serializedObject.targetObject as PlanarReflectionProbe; } }
internal bool isMirrored
{

}
}
internal SerializedPlanarReflectionProbe(SerializedObject serializedObject)
internal SerializedPlanarReflectionProbe(SerializedObject serializedObject) : base(serializedObject)
this.serializedObject = serializedObject;
proxyVolumeReference = serializedObject.Find((PlanarReflectionProbe p) => p.proxyVolume);
influenceVolume = new SerializedInfluenceVolume(serializedObject.Find((PlanarReflectionProbe p) => p.influenceVolume));
captureNearPlane = serializedObject.Find((PlanarReflectionProbe p) => p.captureNearPlane);
captureFarPlane = serializedObject.Find((PlanarReflectionProbe p) => p.captureFarPlane);
nearClip = serializedObject.Find((PlanarReflectionProbe p) => p.captureNearPlane);
farClip = serializedObject.Find((PlanarReflectionProbe p) => p.captureFarPlane);
weight = serializedObject.Find((PlanarReflectionProbe p) => p.weight);
multiplier = serializedObject.Find((PlanarReflectionProbe p) => p.multiplier);
mode = serializedObject.Find((PlanarReflectionProbe p) => p.mode);
refreshMode = serializedObject.Find((PlanarReflectionProbe p) => p.refreshMode);
frameSettings = new SerializedFrameSettings(serializedObject.Find((PlanarReflectionProbe p) => p.frameSettings));
InstantiateProxyVolume(serializedObject);
void InstantiateProxyVolume(SerializedObject serializedObject)
{
var objs = new List<Object>();
for (var i = 0; i < serializedObject.targetObjects.Length; i++)
{
var p = ((PlanarReflectionProbe)serializedObject.targetObjects[i]).proxyVolume;
if (p != null)
objs.Add(p);
}
reflectionProxyVolume = objs.Count > 0
? new SerializedReflectionProxyVolumeComponent(new SerializedObject(objs.ToArray()))
: null;
}
public void Update()
internal override void Update()
serializedObject.Update();
base.Update();
//temporarily force value until other mode are supported
var updateProxyVolume = reflectionProxyVolume != null
&& serializedObject.targetObjects.Length != reflectionProxyVolume.serializedObject.targetObjects.Length;
if (!updateProxyVolume && reflectionProxyVolume != null)
{
var proxyVolumeTargets = reflectionProxyVolume.serializedObject.targetObjects;
for (var i = 0; i < serializedObject.targetObjects.Length; i++)
{
if (proxyVolumeTargets[i] != ((PlanarReflectionProbe)serializedObject.targetObjects[i]).proxyVolume)
{
updateProxyVolume = true;
break;
}
}
}
if (updateProxyVolume)
InstantiateProxyVolume(serializedObject);
public void Apply()
{
serializedObject.ApplyModifiedProperties();
if (reflectionProxyVolume != null)
reflectionProxyVolume.Apply();
}
}
}

90
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDProbe.cs


using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
internal abstract class SerializedHDProbe
{
internal SerializedObject serializedObject;
internal SerializedReflectionProxyVolumeComponent proxyVolumeComponent;
internal SerializedProperty proxyVolumeReference;
internal SerializedInfluenceVolume influenceVolume;
internal SerializedFrameSettings frameSettings;
internal SerializedProperty weight;
internal SerializedProperty multiplier;
internal SerializedProperty mode;
internal SerializedProperty refreshMode;
internal SerializedProperty resolution;
internal SerializedProperty shadowDistance;
internal SerializedProperty cullingMask;
internal SerializedProperty useOcclusionCulling;
internal SerializedProperty nearClip;
internal SerializedProperty farClip;
internal HDProbe target { get { return serializedObject.targetObject as HDProbe; } }
internal SerializedHDProbe(SerializedObject serializedObject)
{
this.serializedObject = serializedObject;
proxyVolumeReference = serializedObject.Find((HDProbe p) => p.proxyVolume);
influenceVolume = new SerializedInfluenceVolume(serializedObject.Find((HDProbe p) => p.influenceVolume));
frameSettings = new SerializedFrameSettings(serializedObject.Find((HDProbe p) => p.frameSettings));
weight = serializedObject.Find((HDProbe p) => p.weight);
multiplier = serializedObject.Find((HDProbe p) => p.multiplier);
mode = serializedObject.Find((HDProbe p) => p.mode);
refreshMode = serializedObject.Find((HDProbe p) => p.refreshMode);
}
//void InstantiateProxyVolume(SerializedObject serializedObject)
//{
// var objs = new List<Object>();
// for (var i = 0; i < serializedObject.targetObjects.Length; i++)
// {
// var p = ((HDProbe)serializedObject.targetObjects[i]).proxyVolume;
// if (p != null)
// objs.Add(p);
// }
// proxyVolumeComponent = objs.Count > 0
// ? new SerializedReflectionProxyVolumeComponent(new SerializedObject(objs.ToArray()))
// : null;
//}
internal virtual void Update()
{
serializedObject.Update();
//InfluenceVolume does not have Update. Add it here if it have in the future.
////Force SerializedReflectionProxyVolumeComponent to refresh
//var updateProxyVolume = proxyVolumeComponent != null
// && serializedObject.targetObjects.Length != proxyVolumeComponent.serializedObject.targetObjects.Length;
//if (!updateProxyVolume && proxyVolumeComponent != null)
//{
// var proxyVolumeTargets = proxyVolumeComponent.serializedObject.targetObjects;
// for (var i = 0; i < serializedObject.targetObjects.Length; i++)
// {
// if (proxyVolumeTargets[i] != ((PlanarReflectionProbe)serializedObject.targetObjects[i]).proxyVolume)
// {
// updateProxyVolume = true;
// break;
// }
// }
//}
//if (updateProxyVolume)
// InstantiateProxyVolume(serializedObject);
}
internal virtual void Apply()
{
serializedObject.ApplyModifiedProperties();
}
}
}

11
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDProbe.cs.meta


fileFormatVersion: 2
guid: fe06aab2f0da27148b61819e1ce565a1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存