Skip to content

Hdrp/fix hierarchicalbox gizmo symetry and homothety mode ensuring face faces outside #1228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed null reference exception in LookDev when setting the SRP to one not implementing LookDev (case 1245086)
- Fix LookDev's undo/redo on EnvironmentLibrary (case 1234725)
- Fix a compil error on OpenGL ES2 in directional lightmap sampling shader code
- Fix hierarchicalbox gizmo outside facing check in symetry or homothety mode no longer move the center

### Changed
- Restored usage of ENABLE_VR to fix compilation errors on some platforms.
Expand Down
99 changes: 88 additions & 11 deletions com.unity.render-pipelines.core/Editor/Gizmo/HierarchicalBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,7 @@ public void DrawHandle()

for (int i = 0, count = m_ControlIDs.Length; i < count; ++i)
m_ControlIDs[i] = GUIUtility.GetControlID("HierarchicalBox".GetHashCode() + i, FocusType.Passive);

EditorGUI.BeginChangeCheck();


var leftPosition = center + size.x * .5f * Vector3.left;
var rightPosition = center + size.x * .5f * Vector3.right;
var topPosition = center + size.y * .5f * Vector3.up;
Expand All @@ -256,6 +254,8 @@ public void DrawHandle()

var theChangedFace = NamedFace.None;

EditorGUI.BeginChangeCheck();

EditorGUI.BeginChangeCheck();
Slider1D(m_ControlIDs[(int)NamedFace.Left], ref leftPosition, Vector3.left, EditorSnapSettings.scale, GetHandleColor(NamedFace.Left));
if (EditorGUI.EndChangeCheck())
Expand Down Expand Up @@ -338,6 +338,27 @@ public void DrawHandle()
case NamedFace.Front: backPosition.z += delta; break;
case NamedFace.Back: frontPosition.z -= delta; break;
}

//ensure that the box face are still facing outside
switch (theChangedFace)
{
case NamedFace.Left:
case NamedFace.Right:
if (rightPosition.x < leftPosition.x)
rightPosition.x = leftPosition.x = center.x;
break;
case NamedFace.Top:
case NamedFace.Bottom:
if (topPosition.y < bottomPosition.y)
topPosition.y = bottomPosition.y = center.y;
break;
case NamedFace.Front:
case NamedFace.Back:
if (frontPosition.z < backPosition.z)
frontPosition.z = backPosition.z = center.z;
break;
}

}

if (useHomothety)
Expand Down Expand Up @@ -367,21 +388,77 @@ public void DrawHandle()
topPosition.y -= halfDelta;
break;
}

//ensure that the box face are still facing outside
switch (theChangedFace)
{
case NamedFace.Left:
if (rightPosition.x < leftPosition.x)
leftPosition.x = rightPosition.x;
if (topPosition.y < bottomPosition.y)
topPosition.y = bottomPosition.y = center.y;
if (frontPosition.z < backPosition.z)
frontPosition.z = backPosition.z = center.z;
break;
case NamedFace.Right:
if (rightPosition.x < leftPosition.x)
rightPosition.x = leftPosition.x;
if (topPosition.y < bottomPosition.y)
topPosition.y = bottomPosition.y = center.y;
if (frontPosition.z < backPosition.z)
frontPosition.z = backPosition.z = center.z;
break;
case NamedFace.Top:
if (topPosition.y < bottomPosition.y)
topPosition.y = bottomPosition.y;
if (rightPosition.x < leftPosition.x)
rightPosition.x = leftPosition.x = center.x;
if (frontPosition.z < backPosition.z)
frontPosition.z = backPosition.z = center.z;
break;
case NamedFace.Bottom:
if (topPosition.y < bottomPosition.y)
bottomPosition.y = topPosition.y;
if (rightPosition.x < leftPosition.x)
rightPosition.x = leftPosition.x = center.x;
if (frontPosition.z < backPosition.z)
frontPosition.z = backPosition.z = center.z;
break;
case NamedFace.Front:
if (frontPosition.z < backPosition.z)
frontPosition.z = backPosition.z;
if (rightPosition.x < leftPosition.x)
rightPosition.x = leftPosition.x = center.x;
if (topPosition.y < bottomPosition.y)
topPosition.y = bottomPosition.y = center.y;
break;
case NamedFace.Back:
if (frontPosition.z < backPosition.z)
backPosition.z = frontPosition.z;
if (rightPosition.x < leftPosition.x)
rightPosition.x = leftPosition.x = center.x;
if (topPosition.y < bottomPosition.y)
topPosition.y = bottomPosition.y = center.y;
break;
}
}

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

//ensure that the box face are still facing outside
for (int axis = 0; axis < 3; ++axis)
if (!useSymetry && !useHomothety)
{
if (min[axis] > max[axis])
//ensure that the box face are still facing outside
for (int axis = 0; axis < 3; ++axis)
{
// Control IDs in m_ControlIDs[0-3[ are for positive axes
if (GUIUtility.hotControl == m_ControlIDs[axis])
max[axis] = min[axis];
else
min[axis] = max[axis];
if (min[axis] > max[axis])
{
// Control IDs in m_ControlIDs[0-3[ are for positive axes
if (GUIUtility.hotControl == m_ControlIDs[axis])
max[axis] = min[axis];
else
min[axis] = max[axis];
}
}
}

Expand Down
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed sky asserts with XR multipass
- Fixed for area light not updating baked light result when modifying with gizmo.
- Fixed robustness issue with GetOddNegativeScale() in ray tracing, which was impacting normal mapping (1261160).
- Fixed regression where moving face of the probe gizmo was not moving its position anymore.

### Changed
- Improve MIP selection for decals on Transparents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,23 @@ public static void DrawHandles_EditInfluenceNormal(SerializedInfluenceVolume ser
break;
}
}

static void DrawBoxHandle(SerializedInfluenceVolume serialized, Editor owner, Transform transform, HierarchicalBox box)
{
using (new Handles.DrawingScope(Matrix4x4.TRS(Vector3.zero, transform.rotation, Vector3.one)))
{
box.center = Quaternion.Inverse(transform.rotation)*transform.position;
box.center = Quaternion.Inverse(transform.rotation) * transform.position;
box.size = serialized.boxSize.vector3Value;

EditorGUI.BeginChangeCheck();
box.DrawHull(true);
box.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
var newPosition = transform.rotation * box.center;
Undo.RecordObject(transform, "Moving Influence");
transform.position = newPosition;

// Clamp blend distances
var blendPositive = serialized.boxBlendDistancePositive.vector3Value;
var blendNegative = serialized.boxBlendDistanceNegative.vector3Value;
Expand Down