Skip to content

Commit 8f2e5fa

Browse files
committed
Reflection Probes: Retain world-space capture position when influence volume is resized. Previously, capture position would scale with the size of the influence volume, because it is serialized in proxy space, and no special logic existed to handle its transform. (#22)
1 parent 46e6345 commit 8f2e5fa

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDProbeUI.Handles.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ internal static void DrawHandles(SerializedHDProbe serialized, Editor owner)
1515
switch (EditMode.editMode)
1616
{
1717
case EditBaseShape:
18-
InfluenceVolumeUI.DrawHandles_EditBase(serialized.probeSettings.influence, owner, probe.transform);
18+
InfluenceVolumeUI.DrawHandles_EditBase(serialized.probeSettings.influence, owner, probe.transform, serialized.probeSettings.proxyCapturePositionProxySpace);
1919
break;
2020
case EditInfluenceShape:
2121
InfluenceVolumeUI.DrawHandles_EditInfluence(serialized.probeSettings.influence, owner, probe.transform);

com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Handles.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ namespace UnityEditor.Rendering.HighDefinition
55
{
66
partial class InfluenceVolumeUI
77
{
8-
public static void DrawHandles_EditBase(SerializedInfluenceVolume serialized, Editor owner, Transform transform)
8+
public static void DrawHandles_EditBase(SerializedInfluenceVolume serialized, Editor owner, Transform transform, SerializedProperty proxyCapturePositionProxySpace)
99
{
1010
switch ((InfluenceShape)serialized.shape.intValue)
1111
{
1212
case InfluenceShape.Box:
13-
DrawBoxHandle(serialized, owner, transform, s_BoxBaseHandle);
13+
DrawBoxHandle(serialized, owner, transform, s_BoxBaseHandle, proxyCapturePositionProxySpace);
1414
break;
1515
case InfluenceShape.Sphere:
1616
using (new Handles.DrawingScope(Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one)))
@@ -103,13 +103,15 @@ public static void DrawHandles_EditInfluenceNormal(SerializedInfluenceVolume ser
103103
}
104104
}
105105

106-
static void DrawBoxHandle(SerializedInfluenceVolume serialized, Editor owner, Transform transform, HierarchicalBox box)
106+
static void DrawBoxHandle(SerializedInfluenceVolume serialized, Editor owner, Transform transform, HierarchicalBox box, SerializedProperty proxyCapturePositionProxySpace)
107107
{
108108
using (new Handles.DrawingScope(Matrix4x4.TRS(Vector3.zero, transform.rotation, Vector3.one)))
109109
{
110110
box.center = Quaternion.Inverse(transform.rotation) * transform.position;
111111
box.size = serialized.boxSize.vector3Value;
112112

113+
Vector3 proxyCapturePositionWS = transform.position + (transform.rotation * proxyCapturePositionProxySpace.vector3Value);
114+
113115
EditorGUI.BeginChangeCheck();
114116
box.DrawHull(true);
115117
box.DrawHandle();
@@ -119,6 +121,8 @@ static void DrawBoxHandle(SerializedInfluenceVolume serialized, Editor owner, Tr
119121
Undo.RecordObject(transform, "Moving Influence");
120122
transform.position = newPosition;
121123

124+
proxyCapturePositionProxySpace.vector3Value = Vector3.Max(serialized.boxSize.vector3Value * -0.5f, Vector3.Min(serialized.boxSize.vector3Value * 0.5f, Quaternion.Inverse(transform.rotation) * (proxyCapturePositionWS - transform.position)));
125+
122126
// Clamp blend distances
123127
var blendPositive = serialized.boxBlendDistancePositive.vector3Value;
124128
var blendNegative = serialized.boxBlendDistanceNegative.vector3Value;

0 commit comments

Comments
 (0)