Skip to content

Commit 33799c6

Browse files
RSlyszsebastienlagarde
authored andcommitted
Hdrp/fix hierarchicalbox gizmo symetry and homothety mode ensuring face faces outside #1228
1 parent 4ab10ca commit 33799c6

File tree

4 files changed

+102
-16
lines changed

4 files changed

+102
-16
lines changed

com.unity.render-pipelines.core/CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ All notable changes to this package will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
- Fix hierarchicalbox gizmo outside facing check in symetry or homothety mode no longer move the center
8+
79
## [7.5.1] - 2020-06-08
810

9-
Version Updated
10-
The version number for this package has increased due to a version update of a related graphics package.
11+
### Fixed
12+
- Fix hierarchicalbox gizmo outside facing check in symetry or homothety mode no longer move the center
13+
14+
## [7.4.3] - 2020-08-06
1115

1216
### Fixed
1317
- Fixed an issue where only unique names of cameras could be added to the camera stack.

com.unity.render-pipelines.core/Editor/Gizmo/HierarchicalBox.cs

Lines changed: 88 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,7 @@ public void DrawHandle()
244244

245245
for (int i = 0, count = m_ControlIDs.Length; i < count; ++i)
246246
m_ControlIDs[i] = GUIUtility.GetControlID("HierarchicalBox".GetHashCode() + i, FocusType.Passive);
247-
248-
EditorGUI.BeginChangeCheck();
249-
247+
250248
var leftPosition = center + size.x * .5f * Vector3.left;
251249
var rightPosition = center + size.x * .5f * Vector3.right;
252250
var topPosition = center + size.y * .5f * Vector3.up;
@@ -256,6 +254,8 @@ public void DrawHandle()
256254

257255
var theChangedFace = NamedFace.None;
258256

257+
EditorGUI.BeginChangeCheck();
258+
259259
EditorGUI.BeginChangeCheck();
260260
Slider1D(m_ControlIDs[(int)NamedFace.Left], ref leftPosition, Vector3.left, EditorSnapSettings.scale, GetHandleColor(NamedFace.Left));
261261
if (EditorGUI.EndChangeCheck())
@@ -338,6 +338,27 @@ public void DrawHandle()
338338
case NamedFace.Front: backPosition.z += delta; break;
339339
case NamedFace.Back: frontPosition.z -= delta; break;
340340
}
341+
342+
//ensure that the box face are still facing outside
343+
switch (theChangedFace)
344+
{
345+
case NamedFace.Left:
346+
case NamedFace.Right:
347+
if (rightPosition.x < leftPosition.x)
348+
rightPosition.x = leftPosition.x = center.x;
349+
break;
350+
case NamedFace.Top:
351+
case NamedFace.Bottom:
352+
if (topPosition.y < bottomPosition.y)
353+
topPosition.y = bottomPosition.y = center.y;
354+
break;
355+
case NamedFace.Front:
356+
case NamedFace.Back:
357+
if (frontPosition.z < backPosition.z)
358+
frontPosition.z = backPosition.z = center.z;
359+
break;
360+
}
361+
341362
}
342363

343364
if (useHomothety)
@@ -367,21 +388,77 @@ public void DrawHandle()
367388
topPosition.y -= halfDelta;
368389
break;
369390
}
391+
392+
//ensure that the box face are still facing outside
393+
switch (theChangedFace)
394+
{
395+
case NamedFace.Left:
396+
if (rightPosition.x < leftPosition.x)
397+
leftPosition.x = rightPosition.x;
398+
if (topPosition.y < bottomPosition.y)
399+
topPosition.y = bottomPosition.y = center.y;
400+
if (frontPosition.z < backPosition.z)
401+
frontPosition.z = backPosition.z = center.z;
402+
break;
403+
case NamedFace.Right:
404+
if (rightPosition.x < leftPosition.x)
405+
rightPosition.x = leftPosition.x;
406+
if (topPosition.y < bottomPosition.y)
407+
topPosition.y = bottomPosition.y = center.y;
408+
if (frontPosition.z < backPosition.z)
409+
frontPosition.z = backPosition.z = center.z;
410+
break;
411+
case NamedFace.Top:
412+
if (topPosition.y < bottomPosition.y)
413+
topPosition.y = bottomPosition.y;
414+
if (rightPosition.x < leftPosition.x)
415+
rightPosition.x = leftPosition.x = center.x;
416+
if (frontPosition.z < backPosition.z)
417+
frontPosition.z = backPosition.z = center.z;
418+
break;
419+
case NamedFace.Bottom:
420+
if (topPosition.y < bottomPosition.y)
421+
bottomPosition.y = topPosition.y;
422+
if (rightPosition.x < leftPosition.x)
423+
rightPosition.x = leftPosition.x = center.x;
424+
if (frontPosition.z < backPosition.z)
425+
frontPosition.z = backPosition.z = center.z;
426+
break;
427+
case NamedFace.Front:
428+
if (frontPosition.z < backPosition.z)
429+
frontPosition.z = backPosition.z;
430+
if (rightPosition.x < leftPosition.x)
431+
rightPosition.x = leftPosition.x = center.x;
432+
if (topPosition.y < bottomPosition.y)
433+
topPosition.y = bottomPosition.y = center.y;
434+
break;
435+
case NamedFace.Back:
436+
if (frontPosition.z < backPosition.z)
437+
backPosition.z = frontPosition.z;
438+
if (rightPosition.x < leftPosition.x)
439+
rightPosition.x = leftPosition.x = center.x;
440+
if (topPosition.y < bottomPosition.y)
441+
topPosition.y = bottomPosition.y = center.y;
442+
break;
443+
}
370444
}
371445

372446
var max = new Vector3(rightPosition.x, topPosition.y, frontPosition.z);
373447
var min = new Vector3(leftPosition.x, bottomPosition.y, backPosition.z);
374448

375-
//ensure that the box face are still facing outside
376-
for (int axis = 0; axis < 3; ++axis)
449+
if (!useSymetry && !useHomothety)
377450
{
378-
if (min[axis] > max[axis])
451+
//ensure that the box face are still facing outside
452+
for (int axis = 0; axis < 3; ++axis)
379453
{
380-
// Control IDs in m_ControlIDs[0-3[ are for positive axes
381-
if (GUIUtility.hotControl == m_ControlIDs[axis])
382-
max[axis] = min[axis];
383-
else
384-
min[axis] = max[axis];
454+
if (min[axis] > max[axis])
455+
{
456+
// Control IDs in m_ControlIDs[0-3[ are for positive axes
457+
if (GUIUtility.hotControl == m_ControlIDs[axis])
458+
max[axis] = min[axis];
459+
else
460+
min[axis] = max[axis];
461+
}
385462
}
386463
}
387464

com.unity.render-pipelines.high-definition/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1212
- Fixed fallback for ray tracing and light layers (1258837).
1313
- Fixed Sorting Priority not displayed correctly in the DrawRenderers custom pass UI.
1414
- Fixed default frame settings MSAA toggle for reflection probes (case 1247631)
15-
15+
- Fixed regression where moving face of the probe gizmo was not moving its position anymore.
16+
1617
### Changed
1718
- The `CustomPassLoadCameraColor` and `CustomPassSampleCameraColor` functions now returns the correct color buffer when used in after post process instead of the color pyramid (which didn't had post processes).
1819

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,23 @@ public static void DrawHandles_EditInfluenceNormal(SerializedInfluenceVolume ser
102102
break;
103103
}
104104
}
105-
105+
106106
static void DrawBoxHandle(SerializedInfluenceVolume serialized, Editor owner, Transform transform, HierarchicalBox box)
107107
{
108108
using (new Handles.DrawingScope(Matrix4x4.TRS(Vector3.zero, transform.rotation, Vector3.one)))
109109
{
110-
box.center = Quaternion.Inverse(transform.rotation)*transform.position;
110+
box.center = Quaternion.Inverse(transform.rotation) * transform.position;
111111
box.size = serialized.boxSize.vector3Value;
112112

113113
EditorGUI.BeginChangeCheck();
114114
box.DrawHull(true);
115115
box.DrawHandle();
116116
if (EditorGUI.EndChangeCheck())
117117
{
118+
var newPosition = transform.rotation * box.center;
119+
Undo.RecordObject(transform, "Moving Influence");
120+
transform.position = newPosition;
121+
118122
// Clamp blend distances
119123
var blendPositive = serialized.boxBlendDistancePositive.vector3Value;
120124
var blendNegative = serialized.boxBlendDistanceNegative.vector3Value;

0 commit comments

Comments
 (0)