From 7467af941a2795d70f95e0f084141dd059f00b23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20V=C3=A1zquez?= Date: Wed, 8 Sep 2021 16:27:22 +0200 Subject: [PATCH 1/5] SRP Workflows - VolumeDebugSettings to Core Package --- .../Runtime/Debugging/IVolumeDebugSettings.cs | 65 ++++++++++ .../Debugging/IVolumeDebugSettings.cs.meta | 2 +- .../Runtime/Debugging/VolumeDebugSettings.cs | 115 +++++++----------- .../Debugging/VolumeDebugSettings.cs.meta | 11 ++ .../Runtime/Debug/DebugDisplay.cs | 9 +- .../Runtime/Debug/HDVolumeDebugSettings.cs | 66 ++++++++++ .../Debug/HDVolumeDebugSettings.cs.meta | 11 ++ .../Runtime/Deprecated.cs | 14 ++- .../Camera/HDAdditionalCameraData.cs | 4 +- 9 files changed, 219 insertions(+), 78 deletions(-) create mode 100644 com.unity.render-pipelines.core/Runtime/Debugging/IVolumeDebugSettings.cs rename com.unity.render-pipelines.high-definition/Runtime/Debug/VolumeDebug.cs.meta => com.unity.render-pipelines.core/Runtime/Debugging/IVolumeDebugSettings.cs.meta (83%) rename com.unity.render-pipelines.high-definition/Runtime/Debug/VolumeDebug.cs => com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs (75%) create mode 100644 com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs.meta create mode 100644 com.unity.render-pipelines.high-definition/Runtime/Debug/HDVolumeDebugSettings.cs create mode 100644 com.unity.render-pipelines.high-definition/Runtime/Debug/HDVolumeDebugSettings.cs.meta diff --git a/com.unity.render-pipelines.core/Runtime/Debugging/IVolumeDebugSettings.cs b/com.unity.render-pipelines.core/Runtime/Debugging/IVolumeDebugSettings.cs new file mode 100644 index 00000000000..b92a09e5da8 --- /dev/null +++ b/com.unity.render-pipelines.core/Runtime/Debugging/IVolumeDebugSettings.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using UnityEditor; + +namespace UnityEngine.Rendering +{ + /// + /// Volume debug settings. + /// + public interface IVolumeDebugSettings + { + /// Selected component + int selectedComponent { get; set; } + + /// Current camera to debug. + Camera selectedCamera { get; } + + /// Returns the collection of registered cameras + IEnumerable cameras { get; } + + /// Selected camera index + int selectedCameraIndex { get; set; } + + /// Selected camera volume stack. + VolumeStack selectedCameraVolumeStack { get; } + + /// Selected camera volume layer mask. + LayerMask selectedCameraLayerMask { get; } + + /// Selected camera volume position. + Vector3 selectedCameraPosition { get; } + + /// Type of the current component to debug. + Type selectedComponentType { get; set; } + + /// + /// Obtains the Volumes + /// + /// + Volume[] GetVolumes(); + + /// + /// Return if the has influence + /// + /// to check the influence + /// If the volume has influence + bool VolumeHasInfluence(Volume volume); + + /// + /// Refreshes the volumes, fetches the stored volumes on the panel + /// + /// The list of to refresh + /// If the volumes have been refreshed + bool RefreshVolumes(Volume[] newVolumes); + + /// + /// Obtains the volume weight + /// + /// + /// The weight of the volume + float GetVolumeWeight(Volume volume); + } +} diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/VolumeDebug.cs.meta b/com.unity.render-pipelines.core/Runtime/Debugging/IVolumeDebugSettings.cs.meta similarity index 83% rename from com.unity.render-pipelines.high-definition/Runtime/Debug/VolumeDebug.cs.meta rename to com.unity.render-pipelines.core/Runtime/Debugging/IVolumeDebugSettings.cs.meta index dcfa299306f..9f428c483ee 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Debug/VolumeDebug.cs.meta +++ b/com.unity.render-pipelines.core/Runtime/Debugging/IVolumeDebugSettings.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4da21b26561b5e44e87e6293456b6b19 +guid: 9771abc6c607d7244b4ddbe608ab86fa MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/VolumeDebug.cs b/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs similarity index 75% rename from com.unity.render-pipelines.high-definition/Runtime/Debug/VolumeDebug.cs rename to com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs index f4c6bea23c4..b2106097994 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Debug/VolumeDebug.cs +++ b/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs @@ -4,26 +4,29 @@ using System.Reflection; using UnityEditor; -namespace UnityEngine.Rendering.HighDefinition +namespace UnityEngine.Rendering { /// /// Volume debug settings. /// - public class VolumeDebugSettings + public abstract class VolumeDebugSettings : IVolumeDebugSettings + where T : MonoBehaviour, IAdditionalData { /// Current volume component to debug. - internal int selectedComponent = 0; + public int selectedComponent { get; set; } = 0; + int m_SelectedCamera = 0; - internal int selectedCameraIndex + /// Selected camera index + public int selectedCameraIndex { get { #if UNITY_EDITOR - if (m_SelectedCamera < 0 || m_SelectedCamera > cameras.Count + 1) + if (m_SelectedCamera < 0 || m_SelectedCamera > additionalCameraDatas.Count + 1) return 0; #else - if (m_SelectedCamera < 0 || m_SelectedCamera > cameras.Count) + if (m_SelectedCamera < 0 || m_SelectedCamera > additionalCameraDatas.Count) return 0; #endif return m_SelectedCamera; @@ -37,77 +40,40 @@ public Camera selectedCamera get { #if UNITY_EDITOR - if (m_SelectedCamera <= 0 || m_SelectedCamera > cameras.Count + 1) + if (m_SelectedCamera <= 0 || m_SelectedCamera > additionalCameraDatas.Count + 1) return null; if (m_SelectedCamera == 1) return SceneView.lastActiveSceneView.camera; else - return cameras[m_SelectedCamera - 2].GetComponent(); + return additionalCameraDatas[m_SelectedCamera - 2].GetComponent(); #else - if (m_SelectedCamera <= 0 || m_SelectedCamera > cameras.Count) + if (m_SelectedCamera <= 0 || m_SelectedCamera > additionalCameraDatas.Count) return null; - return cameras[m_SelectedCamera - 1].GetComponent(); + return additionalCameraDatas[m_SelectedCamera - 1].GetComponent(); #endif } } - /// Selected camera volume stack. - public VolumeStack selectedCameraVolumeStack + /// Returns the collection of registered cameras + public IEnumerable cameras { get { - Camera cam = selectedCamera; - if (cam == null) - return null; - var stack = HDCamera.GetOrCreate(cam).volumeStack; - if (stack != null) - return stack; - return VolumeManager.instance.stack; + foreach (T additionalCameraData in additionalCameraDatas) + { + yield return additionalCameraData.GetComponent(); + } } } + /// Selected camera volume stack. + public abstract VolumeStack selectedCameraVolumeStack { get; } + /// Selected camera volume layer mask. - public LayerMask selectedCameraLayerMask - { - get - { -#if UNITY_EDITOR - if (m_SelectedCamera <= 0 || m_SelectedCamera > cameras.Count + 1) - return (LayerMask)0; - if (m_SelectedCamera == 1) - return -1; - return cameras[m_SelectedCamera - 2].volumeLayerMask; -#else - if (m_SelectedCamera <= 0 || m_SelectedCamera > cameras.Count) - return (LayerMask)0; - return cameras[m_SelectedCamera - 1].volumeLayerMask; -#endif - } - } + public abstract LayerMask selectedCameraLayerMask { get; } /// Selected camera volume position. - public Vector3 selectedCameraPosition - { - get - { - Camera cam = selectedCamera; - if (cam == null) - return Vector3.zero; - - var anchor = HDCamera.GetOrCreate(cam).volumeAnchor; - if (anchor == null) // means the hdcamera has not been initialized - { - // So we have to update the stack manually - if (cam.TryGetComponent(out var data)) - anchor = data.volumeAnchorOverride; - if (anchor == null) anchor = cam.transform; - var stack = selectedCameraVolumeStack; - if (stack != null) - VolumeManager.instance.Update(stack, anchor, selectedCameraLayerMask); - } - return anchor.position; - } - } + public abstract Vector3 selectedCameraPosition { get; } /// Type of the current component to debug. public Type selectedComponentType @@ -154,18 +120,26 @@ public static string ComponentDisplayName(Type component) return component.Name; } - internal static List cameras { get; private set; } = new List(); + protected static List additionalCameraDatas { get; private set; } = new List(); - internal static void RegisterCamera(HDAdditionalCameraData camera) + /// + /// Register the camera for the Volume Debug + /// + /// The camera with it's additional camera data + public static void RegisterCamera(T additionalCamera) { - if (!cameras.Contains(camera)) - cameras.Add(camera); + if (!additionalCameraDatas.Contains(additionalCamera)) + additionalCameraDatas.Add(additionalCamera); } - internal static void UnRegisterCamera(HDAdditionalCameraData camera) + /// + /// Unregister the camera for the Volume Debug + /// + /// The camera with it's additional camera data + public static void UnRegisterCamera(T additionalCamera) { - if (cameras.Contains(camera)) - cameras.Remove(camera); + if (additionalCameraDatas.Contains(additionalCamera)) + additionalCameraDatas.Remove(additionalCamera); } internal VolumeParameter GetParameter(VolumeComponent component, FieldInfo field) @@ -277,7 +251,7 @@ bool ChangedStates(VolumeParameter[,] newStates) return false; } - internal bool RefreshVolumes(Volume[] newVolumes) + public bool RefreshVolumes(Volume[] newVolumes) { bool ret = false; if (volumes == null || !newVolumes.SequenceEqual(volumes)) @@ -304,7 +278,7 @@ internal bool RefreshVolumes(Volume[] newVolumes) return ret; } - internal float GetVolumeWeight(Volume volume) + public float GetVolumeWeight(Volume volume) { if (weights == null) return 0; @@ -323,7 +297,12 @@ internal float GetVolumeWeight(Volume volume) return 0f; } - internal bool VolumeHasInfluence(Volume volume) + /// + /// Return if the has influence + /// + /// to check the influence + /// If the volume has influence + public bool VolumeHasInfluence(Volume volume) { if (weights == null) return false; diff --git a/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs.meta b/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs.meta new file mode 100644 index 00000000000..3796625550d --- /dev/null +++ b/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4fefac0c47bcdce4299384727a250dc9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs index 8890c1978d6..2c070037f23 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs @@ -249,7 +249,7 @@ public class DebugData /// Current transparency debug settings. public TransparencyDebugSettings transparencyDebugSettings = new TransparencyDebugSettings(); /// Current volume debug settings. - public VolumeDebugSettings volumeDebugSettings = new VolumeDebugSettings(); + public IVolumeDebugSettings volumeDebugSettings = new HDVolumeDebugSettings(); /// Index of screen space shadow to display. public uint screenSpaceShadowIndex = 0; /// Max quad cost for quad overdraw display. @@ -1646,9 +1646,10 @@ void RegisterVolumeDebug() var componentNames = new List() { new GUIContent("None") }; var componentValues = new List() { componentIndex++ }; - foreach (var type in VolumeDebugSettings.componentTypes) + // TODO @alex.vazquez: Use the same method as VolumeComponentProvider + foreach (var type in HDVolumeDebugSettings.componentTypes) { - componentNames.Add(new GUIContent() { text = VolumeDebugSettings.ComponentDisplayName(type) }); + componentNames.Add(new GUIContent() { text = HDVolumeDebugSettings.ComponentDisplayName(type) }); componentValues.Add(componentIndex++); } @@ -1675,7 +1676,7 @@ void RegisterVolumeDebug() componentValues.Add(componentIndex++); #endif - foreach (var camera in VolumeDebugSettings.cameras) + foreach (var camera in data.volumeDebugSettings.cameras) { componentNames.Add(new GUIContent() { text = camera.name }); componentValues.Add(componentIndex++); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/HDVolumeDebugSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/Debug/HDVolumeDebugSettings.cs new file mode 100644 index 00000000000..b8ca95c164c --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/HDVolumeDebugSettings.cs @@ -0,0 +1,66 @@ +namespace UnityEngine.Rendering.HighDefinition +{ + /// + /// Volume debug settings. + /// + public class HDVolumeDebugSettings : VolumeDebugSettings + { + /// Selected camera volume stack. + public override VolumeStack selectedCameraVolumeStack + { + get + { + Camera cam = selectedCamera; + if (cam == null) + return null; + var stack = HDCamera.GetOrCreate(cam).volumeStack; + if (stack != null) + return stack; + return VolumeManager.instance.stack; + } + } + + /// Selected camera volume layer mask. + public override LayerMask selectedCameraLayerMask + { + get + { +#if UNITY_EDITOR + if (selectedCameraIndex <= 0 || selectedCameraIndex > additionalCameraDatas.Count + 1) + return (LayerMask)0; + if (selectedCameraIndex == 1) + return -1; + return additionalCameraDatas[selectedCameraIndex - 2].volumeLayerMask; +#else + if (m_SelectedCamera <= 0 || m_SelectedCamera > cameras.Count) + return (LayerMask)0; + return cameras[m_SelectedCamera - 1].volumeLayerMask; +#endif + } + } + + /// Selected camera volume position. + public override Vector3 selectedCameraPosition + { + get + { + Camera cam = selectedCamera; + if (cam == null) + return Vector3.zero; + + var anchor = HDCamera.GetOrCreate(cam).volumeAnchor; + if (anchor == null) // means the hdcamera has not been initialized + { + // So we have to update the stack manually + if (cam.TryGetComponent(out var data)) + anchor = data.volumeAnchorOverride; + if (anchor == null) anchor = cam.transform; + var stack = selectedCameraVolumeStack; + if (stack != null) + VolumeManager.instance.Update(stack, anchor, selectedCameraLayerMask); + } + return anchor.position; + } + } + } +} diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/HDVolumeDebugSettings.cs.meta b/com.unity.render-pipelines.high-definition/Runtime/Debug/HDVolumeDebugSettings.cs.meta new file mode 100644 index 00000000000..83624163b8a --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/HDVolumeDebugSettings.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 54a33a55f95b4a5448c709191d3aaff2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/Deprecated.cs b/com.unity.render-pipelines.high-definition/Runtime/Deprecated.cs index 22e6e61de66..647e37df4bd 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Deprecated.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Deprecated.cs @@ -3,13 +3,13 @@ namespace UnityEngine.Rendering.HighDefinition { /// Deprecated DensityVolume - [Obsolete("DensityVolume has been deprecated (UnityUpgradable) -> LocalVolumetricFog", false)] + [Obsolete("DensityVolume has been deprecated (UnityUpgradable) -> LocalVolumetricFog", true)] public class DensityVolume : LocalVolumetricFog { } /// Deprecated DensityVolumeArtistParameters - [Obsolete("DensityVolumeArtistParameters has been deprecated (UnityUpgradable) -> LocalVolumetricFogArtistParameters", false)] + [Obsolete("DensityVolumeArtistParameters has been deprecated (UnityUpgradable) -> LocalVolumetricFogArtistParameters", true)] public struct DensityVolumeArtistParameters { } @@ -17,7 +17,15 @@ public struct DensityVolumeArtistParameters public partial struct LocalVolumetricFogArtistParameters { /// Obsolete, do not use. - [Obsolete("Never worked correctly due to having engine working in percent. Will be removed soon.")] + [Obsolete("Never worked correctly due to having engine working in percent. Will be removed soon.", true)] public bool advancedFade => true; } + + /// + /// Volume debug settings. + /// + [Obsolete("VolumeDebugSettings has been deprecated. Use HDVolumeDebugSettings instead (UnityUpgradable) -> HDVolumeDebugSettings", true)] + public class VolumeDebugSettings : HDVolumeDebugSettings + { + } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDAdditionalCameraData.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDAdditionalCameraData.cs index 992d363d210..f3d8303b76a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDAdditionalCameraData.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDAdditionalCameraData.cs @@ -656,7 +656,7 @@ void RegisterDebug() if (m_Camera.cameraType != CameraType.Preview && m_Camera.cameraType != CameraType.Reflection) { DebugDisplaySettings.RegisterCamera(this); - VolumeDebugSettings.RegisterCamera(this); + HDVolumeDebugSettings.RegisterCamera(this); } m_IsDebugRegistered = true; } @@ -670,7 +670,7 @@ void UnRegisterDebug() // Do not attempt to not register them till this issue persist. if (m_Camera.cameraType != CameraType.Preview && m_Camera?.cameraType != CameraType.Reflection) { - VolumeDebugSettings.UnRegisterCamera(this); + HDVolumeDebugSettings.UnRegisterCamera(this); DebugDisplaySettings.UnRegisterCamera(this); } m_IsDebugRegistered = false; From b64a0b5ef80dafbae999e83f4228b242bc9c4f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20V=C3=A1zquez?= Date: Wed, 8 Sep 2021 16:40:48 +0200 Subject: [PATCH 2/5] Fix compilation --- com.unity.render-pipelines.core/CHANGELOG.md | 3 +++ .../Runtime/Debug/HDVolumeDebugSettings.cs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.core/CHANGELOG.md b/com.unity.render-pipelines.core/CHANGELOG.md index d128a3bb6f6..76a25bd0c3f 100644 --- a/com.unity.render-pipelines.core/CHANGELOG.md +++ b/com.unity.render-pipelines.core/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. Version Updated The version number for this package has increased due to a version update of a related graphics package. +### Added +- New `IVolumeDebugSettings` interfac and `VolumeDebugSettings` class that stores the information for the Volumes Debug Panel. + ## [12.0.0] - 2021-01-11 ### Added diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/HDVolumeDebugSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/Debug/HDVolumeDebugSettings.cs index b8ca95c164c..cf8dc31e48f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Debug/HDVolumeDebugSettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/HDVolumeDebugSettings.cs @@ -34,7 +34,7 @@ public override LayerMask selectedCameraLayerMask #else if (m_SelectedCamera <= 0 || m_SelectedCamera > cameras.Count) return (LayerMask)0; - return cameras[m_SelectedCamera - 1].volumeLayerMask; + return additionalCameraDatas[m_SelectedCamera - 1].volumeLayerMask; #endif } } From fd31e96dd04ba0a2709b99d2c849680d10ad40d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20V=C3=A1zquez?= Date: Wed, 8 Sep 2021 16:44:18 +0200 Subject: [PATCH 3/5] keep the obsolete for another pr --- .../Runtime/Deprecated.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Deprecated.cs b/com.unity.render-pipelines.high-definition/Runtime/Deprecated.cs index 647e37df4bd..9762fcd8bf7 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Deprecated.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Deprecated.cs @@ -3,13 +3,13 @@ namespace UnityEngine.Rendering.HighDefinition { /// Deprecated DensityVolume - [Obsolete("DensityVolume has been deprecated (UnityUpgradable) -> LocalVolumetricFog", true)] + [Obsolete("DensityVolume has been deprecated (UnityUpgradable) -> LocalVolumetricFog", false)] public class DensityVolume : LocalVolumetricFog { } /// Deprecated DensityVolumeArtistParameters - [Obsolete("DensityVolumeArtistParameters has been deprecated (UnityUpgradable) -> LocalVolumetricFogArtistParameters", true)] + [Obsolete("DensityVolumeArtistParameters has been deprecated (UnityUpgradable) -> LocalVolumetricFogArtistParameters", false)] public struct DensityVolumeArtistParameters { } @@ -17,7 +17,7 @@ public struct DensityVolumeArtistParameters public partial struct LocalVolumetricFogArtistParameters { /// Obsolete, do not use. - [Obsolete("Never worked correctly due to having engine working in percent. Will be removed soon.", true)] + [Obsolete("Never worked correctly due to having engine working in percent. Will be removed soon.", false)] public bool advancedFade => true; } From 9e7ee22176d2d9b0cb07e7e6778645931bd3b50f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20V=C3=A1zquez?= Date: Thu, 9 Sep 2021 10:54:36 +0200 Subject: [PATCH 4/5] Docs --- .../Runtime/Debugging/VolumeDebugSettings.cs | 10 ++++++++++ .../Runtime/Deprecated.cs | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs b/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs index b2106097994..c41eeee3886 100644 --- a/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs +++ b/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs @@ -251,6 +251,11 @@ bool ChangedStates(VolumeParameter[,] newStates) return false; } + /// + /// Refreshes the volumes, fetches the stored volumes on the panel + /// + /// The list of to refresh + /// If the volumes have been refreshed public bool RefreshVolumes(Volume[] newVolumes) { bool ret = false; @@ -278,6 +283,11 @@ public bool RefreshVolumes(Volume[] newVolumes) return ret; } + /// + /// Obtains the volume weight + /// + /// + /// The weight of the volume public float GetVolumeWeight(Volume volume) { if (weights == null) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Deprecated.cs b/com.unity.render-pipelines.high-definition/Runtime/Deprecated.cs index 9762fcd8bf7..ed2883e688f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Deprecated.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Deprecated.cs @@ -17,14 +17,14 @@ public struct DensityVolumeArtistParameters public partial struct LocalVolumetricFogArtistParameters { /// Obsolete, do not use. - [Obsolete("Never worked correctly due to having engine working in percent. Will be removed soon.", false)] + [Obsolete("Never worked correctly due to having engine working in percent. Will be removed soon.")] public bool advancedFade => true; } /// /// Volume debug settings. /// - [Obsolete("VolumeDebugSettings has been deprecated. Use HDVolumeDebugSettings instead (UnityUpgradable) -> HDVolumeDebugSettings", true)] + [Obsolete("VolumeDebugSettings has been deprecated. Use HDVolumeDebugSettings instead (UnityUpgradable) -> HDVolumeDebugSettings")] public class VolumeDebugSettings : HDVolumeDebugSettings { } From f64e1c3c0f148f8a19e59a77bea62caaa9bb9feb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20V=C3=A1zquez?= Date: Fri, 10 Sep 2021 15:18:29 +0200 Subject: [PATCH 5/5] Feedback from code review --- com.unity.render-pipelines.core/CHANGELOG.md | 2 +- .../Runtime/Debugging/IVolumeDebugSettings.cs | 8 ++--- .../Runtime/Debugging/VolumeDebugSettings.cs | 32 +++++++++---------- .../Runtime/Debug/HDVolumeDebugSettings.cs | 10 +++--- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/com.unity.render-pipelines.core/CHANGELOG.md b/com.unity.render-pipelines.core/CHANGELOG.md index 76a25bd0c3f..70f279ff1b8 100644 --- a/com.unity.render-pipelines.core/CHANGELOG.md +++ b/com.unity.render-pipelines.core/CHANGELOG.md @@ -10,7 +10,7 @@ Version Updated The version number for this package has increased due to a version update of a related graphics package. ### Added -- New `IVolumeDebugSettings` interfac and `VolumeDebugSettings` class that stores the information for the Volumes Debug Panel. +- New `IVolumeDebugSettings` interface and `VolumeDebugSettings` class that stores the information for the Volumes Debug Panel. ## [12.0.0] - 2021-01-11 diff --git a/com.unity.render-pipelines.core/Runtime/Debugging/IVolumeDebugSettings.cs b/com.unity.render-pipelines.core/Runtime/Debugging/IVolumeDebugSettings.cs index b92a09e5da8..58f9f1e5c1f 100644 --- a/com.unity.render-pipelines.core/Runtime/Debugging/IVolumeDebugSettings.cs +++ b/com.unity.render-pipelines.core/Runtime/Debugging/IVolumeDebugSettings.cs @@ -11,16 +11,16 @@ namespace UnityEngine.Rendering /// public interface IVolumeDebugSettings { - /// Selected component + /// Selected component. int selectedComponent { get; set; } /// Current camera to debug. Camera selectedCamera { get; } - /// Returns the collection of registered cameras + /// Returns the collection of registered cameras. IEnumerable cameras { get; } - /// Selected camera index + /// Selected camera index. int selectedCameraIndex { get; set; } /// Selected camera volume stack. @@ -38,7 +38,7 @@ public interface IVolumeDebugSettings /// /// Obtains the Volumes /// - /// + /// The list of Volume[] GetVolumes(); /// diff --git a/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs b/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs index c41eeee3886..855779e0c60 100644 --- a/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs +++ b/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs @@ -15,23 +15,23 @@ public abstract class VolumeDebugSettings : IVolumeDebugSettings /// Current volume component to debug. public int selectedComponent { get; set; } = 0; - int m_SelectedCamera = 0; + protected int m_SelectedCameraIndex = 0; - /// Selected camera index + /// Selected camera index. public int selectedCameraIndex { get { #if UNITY_EDITOR - if (m_SelectedCamera < 0 || m_SelectedCamera > additionalCameraDatas.Count + 1) + if (m_SelectedCameraIndex < 0 || m_SelectedCameraIndex > additionalCameraDatas.Count + 1) return 0; #else - if (m_SelectedCamera < 0 || m_SelectedCamera > additionalCameraDatas.Count) + if (m_SelectedCameraIndex < 0 || m_SelectedCameraIndex > additionalCameraDatas.Count) return 0; #endif - return m_SelectedCamera; + return m_SelectedCameraIndex; } - set { m_SelectedCamera = value; } + set { m_SelectedCameraIndex = value; } } /// Current camera to debug. @@ -40,21 +40,21 @@ public Camera selectedCamera get { #if UNITY_EDITOR - if (m_SelectedCamera <= 0 || m_SelectedCamera > additionalCameraDatas.Count + 1) + if (m_SelectedCameraIndex <= 0 || m_SelectedCameraIndex > additionalCameraDatas.Count + 1) return null; - if (m_SelectedCamera == 1) + if (m_SelectedCameraIndex == 1) return SceneView.lastActiveSceneView.camera; else - return additionalCameraDatas[m_SelectedCamera - 2].GetComponent(); + return additionalCameraDatas[m_SelectedCameraIndex - 2].GetComponent(); #else - if (m_SelectedCamera <= 0 || m_SelectedCamera > additionalCameraDatas.Count) + if (m_SelectedCameraIndex <= 0 || m_SelectedCameraIndex > additionalCameraDatas.Count) return null; - return additionalCameraDatas[m_SelectedCamera - 1].GetComponent(); + return additionalCameraDatas[m_SelectedCameraIndex - 1].GetComponent(); #endif } } - /// Returns the collection of registered cameras + /// Returns the collection of registered cameras. public IEnumerable cameras { get @@ -123,9 +123,9 @@ public static string ComponentDisplayName(Type component) protected static List additionalCameraDatas { get; private set; } = new List(); /// - /// Register the camera for the Volume Debug + /// Register the camera for the Volume Debug. /// - /// The camera with it's additional camera data + /// The AdditionalCameraData of the camera to be registered. public static void RegisterCamera(T additionalCamera) { if (!additionalCameraDatas.Contains(additionalCamera)) @@ -133,9 +133,9 @@ public static void RegisterCamera(T additionalCamera) } /// - /// Unregister the camera for the Volume Debug + /// Unregister the camera for the Volume Debug. /// - /// The camera with it's additional camera data + /// The AdditionalCameraData of the camera to be registered. public static void UnRegisterCamera(T additionalCamera) { if (additionalCameraDatas.Contains(additionalCamera)) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/HDVolumeDebugSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/Debug/HDVolumeDebugSettings.cs index cf8dc31e48f..0d67d587e9e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Debug/HDVolumeDebugSettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/HDVolumeDebugSettings.cs @@ -26,15 +26,15 @@ public override LayerMask selectedCameraLayerMask get { #if UNITY_EDITOR - if (selectedCameraIndex <= 0 || selectedCameraIndex > additionalCameraDatas.Count + 1) + if (m_SelectedCameraIndex <= 0 || m_SelectedCameraIndex > additionalCameraDatas.Count + 1) return (LayerMask)0; - if (selectedCameraIndex == 1) + if (m_SelectedCameraIndex == 1) return -1; - return additionalCameraDatas[selectedCameraIndex - 2].volumeLayerMask; + return additionalCameraDatas[m_SelectedCameraIndex - 2].volumeLayerMask; #else - if (m_SelectedCamera <= 0 || m_SelectedCamera > cameras.Count) + if (m_SelectedCameraIndex <= 0 || m_SelectedCameraIndex > additionalCameraDatas.Count) return (LayerMask)0; - return additionalCameraDatas[m_SelectedCamera - 1].volumeLayerMask; + return additionalCameraDatas[m_SelectedCameraIndex - 1].volumeLayerMask; #endif } }