浏览代码

Some fixes

/feature-ReflectionProbeFit
Frédéric Vauchelles 7 年前
当前提交
351fde8f
共有 5 个文件被更改,包括 223 次插入11 次删除
  1. 16
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Data.cs
  2. 6
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Drawers.cs
  3. 13
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.cs
  4. 188
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Handles.cs
  5. 11
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Handles.cs.meta

16
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Data.cs


using System;
using UnityEditor.AnimatedValues;
using UnityEditor.Experimental.Rendering;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;

public void ClearOperation(Operation op) { operations &= ~op; }
public void AddOperation(Operation op) { operations |= op; }
public BoxBoundsHandle boxInfluenceBoundsHandle = new BoxBoundsHandle();
public BoxBoundsHandle boxProjectionBoundsHandle = new BoxBoundsHandle();
public BoxBoundsHandle boxBlendHandle = new BoxBoundsHandle();
public SphereBoundsHandle influenceSphereHandle = new SphereBoundsHandle();
public SphereBoundsHandle projectionSphereHandle = new SphereBoundsHandle();
public SphereBoundsHandle sphereBlendHandle = new SphereBoundsHandle();
public Matrix4x4 oldLocalSpace = Matrix4x4.identity;
public bool HasAndClearOperation(Operation op)
{
var has = HasOperation(op);

{
return editMode == EditMode.SceneViewEditMode.ReflectionProbeBox || editMode == EditMode.SceneViewEditMode.Collider || editMode == EditMode.SceneViewEditMode.GridBox ||
editMode == EditMode.SceneViewEditMode.ReflectionProbeOrigin;
}
internal void UpdateOldLocalSpace(ReflectionProbe target)
{
oldLocalSpace = GetLocalSpace(target);
}
}
}

6
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Drawers.cs


"Influence volume settings",
(s, p, o) => p.blendDistance,
true,
CED.Action(Drawer_DistanceBlend),
CED.FadeGroup(
(s, p, o, i) => s.GetShapeFaded((ReflectionInfluenceShape)i),
false,

}
#region Influence Volume
static void Drawer_DistanceBlend(UIState s, SerializedReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.blendDistance, CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes."));
}
static void Drawer_InfluenceBoxSettings(UIState s, SerializedReflectionProbe p, Editor owner)
{
EditorGUI.BeginChangeCheck();

13
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.cs


SerializedObject m_AdditionalDataSerializedObject;
UIState m_UIState = new UIState();
Matrix4x4 m_OldLocalSpace = Matrix4x4.identity;
void OnEnable()
{
var additionalData = CoreEditorUtils.GetAdditionalData<HDAdditionalReflectionData>(targets);

HideAdditionalComponents(false);
}
void PerformOperations(UIState s, SerializedReflectionProbe p, HDReflectionProbeEditor o)
static void PerformOperations(UIState s, SerializedReflectionProbe p, HDReflectionProbeEditor o)
UpdateOldLocalSpace();
s.UpdateOldLocalSpace((ReflectionProbe)p.so.targetObject);
}
void HideAdditionalComponents(bool visible)

}
}
void UpdateOldLocalSpace()
{
m_OldLocalSpace = GetLocalSpace((ReflectionProbe)target);
}
Vector3 t = probe.transform.position;
var t = probe.transform.position;
return Matrix4x4.TRS(t, GetLocalSpaceRotation(probe), Vector3.one);
}

188
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Handles.cs


using UnityEditor.IMGUI.Controls;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
namespace UnityEditor.Experimental.Rendering
{
partial class HDReflectionProbeEditor
{
void OnSceneGUI()
{
serializedObject.Update();
m_AdditionalDataSerializedObject.Update();
var s = m_UIState;
var p = m_SerializedReflectionProbe;
var o = this;
if (!s.sceneViewEditing)
return;
EditorGUI.BeginChangeCheck();
switch (EditMode.editMode)
{
case EditMode.SceneViewEditMode.ReflectionProbeBox:
if (p.influenceShape.enumValueIndex == 0)
DoInfluenceBoxEditing(s, p, o);
if (p.influenceShape.enumValueIndex == 1)
DoInfluenceSphereEditing(s, p, o);
break;
case EditMode.SceneViewEditMode.GridBox:
if (p.influenceShape.enumValueIndex == 0)
DoProjectionBoxEditing(s, p, o);
if (p.influenceShape.enumValueIndex == 1)
DoProjectionSphereEditing(s, p, o);
break;
case EditMode.SceneViewEditMode.ReflectionProbeOrigin:
DoOriginEditing(s, p, o);
break;
}
if (EditorGUI.EndChangeCheck())
Repaint();
serializedObject.ApplyModifiedProperties();
m_AdditionalDataSerializedObject.ApplyModifiedProperties();
}
static void DoInfluenceBoxEditing(UIState s, SerializedReflectionProbe sp, Editor o)
{
var p = (ReflectionProbe)sp.so.targetObject;
using (new Handles.DrawingScope(GetLocalSpace(p)))
{
s.boxInfluenceBoundsHandle.center = p.center;
s.boxInfluenceBoundsHandle.size = p.size;
s.boxBlendHandle.center = p.center;
s.boxBlendHandle.size = p.size - Vector3.one * p.blendDistance * 2;
EditorGUI.BeginChangeCheck();
s.boxInfluenceBoundsHandle.DrawHandle();
s.boxBlendHandle.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(p, "Modified Reflection Probe AABB");
var center = s.boxInfluenceBoundsHandle.center;
var size = s.boxInfluenceBoundsHandle.size;
var blendDistance = ((p.size.x - s.boxBlendHandle.size.x) / 2 + (p.size.y - s.boxBlendHandle.size.y) / 2 + (p.size.z - s.boxBlendHandle.size.z) / 2) / 3;
ValidateAABB(p, ref center, ref size);
p.center = center;
p.size = size;
p.blendDistance = Mathf.Max(blendDistance, 0);
EditorUtility.SetDirty(p);
}
}
}
static void DoProjectionBoxEditing(UIState s, SerializedReflectionProbe sp, Editor o)
{
var p = (ReflectionProbe)sp.so.targetObject;
var reflectionData = p.GetComponent<HDAdditionalReflectionData>();
using (new Handles.DrawingScope(GetLocalSpace(p)))
{
s.boxProjectionBoundsHandle.center = reflectionData.m_BoxReprojectionVolumeCenter;
s.boxProjectionBoundsHandle.size = reflectionData.m_BoxReprojectionVolumeSize;
EditorGUI.BeginChangeCheck();
s.boxProjectionBoundsHandle.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(reflectionData, "Modified Reflection Probe AABB");
var center = s.boxProjectionBoundsHandle.center;
var size = s.boxProjectionBoundsHandle.size;
ValidateAABB(p, ref center, ref size);
reflectionData.m_BoxReprojectionVolumeCenter = center;
reflectionData.m_BoxReprojectionVolumeSize = size;
EditorUtility.SetDirty(reflectionData);
}
}
}
static void DoInfluenceSphereEditing(UIState s, SerializedReflectionProbe sp, Editor o)
{
var p = (ReflectionProbe)sp.so.targetObject;
var reflectionData = p.GetComponent<HDAdditionalReflectionData>();
using (new Handles.DrawingScope(GetLocalSpace(p)))
{
s.influenceSphereHandle.center = p.center;
s.influenceSphereHandle.radius = reflectionData.m_InfluenceSphereRadius;
s.sphereBlendHandle.center = p.center;
s.sphereBlendHandle.radius = Mathf.Min(reflectionData.m_InfluenceSphereRadius - p.blendDistance * 2, reflectionData.m_InfluenceSphereRadius);
EditorGUI.BeginChangeCheck();
s.influenceSphereHandle.DrawHandle();
s.sphereBlendHandle.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(reflectionData, "Modified Reflection influence volume");
var center = s.influenceSphereHandle.center;
var radius = new Vector3(s.influenceSphereHandle.radius, s.influenceSphereHandle.radius, s.influenceSphereHandle.radius);
var blendDistance = (s.influenceSphereHandle.radius - s.sphereBlendHandle.radius) / 2;
ValidateAABB(p, ref center, ref radius);
reflectionData.m_InfluenceSphereRadius = radius.x;
p.blendDistance = blendDistance;
EditorUtility.SetDirty(p);
EditorUtility.SetDirty(reflectionData);
}
}
}
static void DoProjectionSphereEditing(UIState s, SerializedReflectionProbe sp, Editor o)
{
var p = (ReflectionProbe)sp.so.targetObject;
var reflectionData = p.GetComponent<HDAdditionalReflectionData>();
using (new Handles.DrawingScope(GetLocalSpace(p)))
{
s.projectionSphereHandle.center = p.center;
s.projectionSphereHandle.radius = reflectionData.m_SphereReprojectionVolumeRadius;
EditorGUI.BeginChangeCheck();
s.projectionSphereHandle.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(reflectionData, "Modified Reflection Probe projection volume");
var center = s.projectionSphereHandle.center;
var radius = s.projectionSphereHandle.radius;
//ValidateAABB(ref center, ref radius);
reflectionData.m_SphereReprojectionVolumeRadius = radius;
EditorUtility.SetDirty(reflectionData);
}
}
}
static void DoOriginEditing(UIState s, SerializedReflectionProbe sp, Editor o)
{
var p = (ReflectionProbe)sp.so.targetObject;
var transformPosition = p.transform.position;
var size = p.size;
EditorGUI.BeginChangeCheck();
var newPostion = Handles.PositionHandle(transformPosition, GetLocalSpaceRotation(p));
var changed = EditorGUI.EndChangeCheck();
if (changed || s.oldLocalSpace != GetLocalSpace(p))
{
Vector3 localNewPosition = s.oldLocalSpace.inverse.MultiplyPoint3x4(newPostion);
Bounds b = new Bounds(p.center, size);
localNewPosition = b.ClosestPoint(localNewPosition);
Undo.RecordObject(p.transform, "Modified Reflection Probe Origin");
p.transform.position = s.oldLocalSpace.MultiplyPoint3x4(localNewPosition);
Undo.RecordObject(p, "Modified Reflection Probe Origin");
p.center = GetLocalSpace(p).inverse.MultiplyPoint3x4(s.oldLocalSpace.MultiplyPoint3x4(p.center));
EditorUtility.SetDirty(p);
s.AddOperation(Operation.UpdateOldLocalSpace);
}
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Handles.cs.meta


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