From 9d6086120642250dc00d6578000e0cfaa8d9591f Mon Sep 17 00:00:00 2001 From: Jon Hogins Date: Thu, 23 Apr 2020 07:31:37 -0700 Subject: [PATCH] Code formatting --- .editorconfig | 74 +++++++++++++++++++ .../GroundTruth/BaseCustomPassDrawer.cs | 2 +- .../InstanceSegmentationPassEditor.cs | 2 +- .../LabelingConfigurationEditor.cs | 2 +- .../Editor/GroundTruth/LabelingEditor.cs | 2 +- .../GroundTruth/ObjectCountPassEditor.cs | 2 +- .../SemanticSegmentationPassEditor.cs | 2 +- .../Runtime/GroundTruth/BoundingBoxOrigin.cs | 2 +- .../Runtime/GroundTruth/DatasetJsonUtility.cs | 4 + .../Runtime/GroundTruth/Ego.cs | 2 +- .../GroundTruthCrossPipelinePass.cs | 6 +- .../Runtime/GroundTruth/GroundTruthInfo.cs | 2 +- .../GroundTruthLabelSetupSystem.cs | 7 +- .../GroundTruth/GroundTruthRendererFeature.cs | 4 +- .../GroundTruth/IGroundTruthGenerator.cs | 2 +- .../InstanceSegmentationCrossPipelinePass.cs | 4 +- .../GroundTruth/InstanceSegmentationPass.cs | 2 +- .../Labeling/LabelingConfiguration.cs | 2 +- .../Runtime/GroundTruth/ObjectCountPass.cs | 4 +- .../Runtime/GroundTruth/PerceptionCamera.cs | 7 +- .../GroundTruth/RenderTextureReader.cs | 2 +- .../Runtime/GroundTruth/RenderedObjectInfo.cs | 2 +- .../RenderedObjectInfoGenerator.cs | 2 +- .../SemanticSegmentationCrossPipelinePass.cs | 2 +- .../GroundTruth/SemanticSegmentationPass.cs | 2 +- .../SimulationManagementComponentSystem.cs | 2 +- .../Runtime/GroundTruth/SimulationManager.cs | 15 ++-- .../Runtime/GroundTruth/SimulationState.cs | 7 +- .../GroundTruth/SimulationState_Json.cs | 4 +- .../Tests/Editor/BuildPerceptionPlayer.cs | 9 +-- .../Editor/PerceptionCameraEditorTests.cs | 2 +- .../GroundTruthTests/BoundingBox2DTests.cs | 6 +- .../DatasetJsonUtilityTests.cs | 2 + .../GroundTruthTests/GroundTruthTestBase.cs | 2 +- .../GroundTruthTests/ObjectCountTests.cs | 4 +- .../PerceptionCameraIntegrationTests.cs | 2 +- .../SegmentationGroundTruthTests.cs | 5 +- .../SimulationManagerSensorSchedulingTests.cs | 21 ++++-- .../SimulationManagerTests.cs | 29 ++++---- .../Runtime/GroundTruthTests/TestHelper.cs | 4 +- 40 files changed, 171 insertions(+), 87 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..bf5ea2d27 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,74 @@ +; see http://editorconfig.org/ for docs on this file + +root = true + +[*] +ignore_if_in_header = This code was generated by a tool| +indent_style = space +indent_size = 4 +; uncomment to help with sharing files across os's (i.e. network share or through local vm) +#end_of_line = lf +; avoid a bom, which causes endless problems with naive text tooling +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +; keeping auto-format enabled helps avoid merge hell for projects without CI-based format validation +#disable_auto_format = true + +[*.cs] +; uncomment to enable full formatting of c# files +formatters = generic, uncrustify + +[*.asmdef] +scrape_api = true + +[**/Tests/**.asmdef] +scrape_api = false + +[*.Tests.asmdef] +scrape_api = false + +[*.md] +indent_size = 2 +; trailing whitespace is unfortunately significant in markdown +trim_trailing_whitespace = false +; uncomment to enable basic formatting of markdown files +#formatters = generic + +[{Makefile,makefile}] +; tab characters are part of the Makefile format +indent_style = tab + +[*.asmdef] +indent_size = 4 + +[*.json] +indent_size = 2 + +[*.{vcproj,bat,cmd,xaml,tt,t4,ttinclude}] +end_of_line = crlf + +; this VS-specific stuff is based on experiments to see how VS will modify a file after it has been manually edited. +; the settings are meant to closely match what VS does to minimize unnecessary diffs. +[*.{vcxproj,vcxproj.filters}] +indent_style = space +indent_size = 2 +end_of_line = crlf +charset = utf-8-bom +trim_trailing_whitespace = true +insert_final_newline = false +; must be broken out because of 51-char bug (https://github.com/editorconfig/editorconfig-visualstudio/issues/21) +[*.{csproj,pyproj,props,targets}] +indent_style = space +indent_size = 2 +end_of_line = crlf +charset = utf-8-bom +trim_trailing_whitespace = true +insert_final_newline = false +[*.{sln,sln.template}] +indent_style = tab +indent_size = 4 +end_of_line = crlf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = false diff --git a/com.unity.perception/Editor/GroundTruth/BaseCustomPassDrawer.cs b/com.unity.perception/Editor/GroundTruth/BaseCustomPassDrawer.cs index b5cff433b..c49fd7674 100644 --- a/com.unity.perception/Editor/GroundTruth/BaseCustomPassDrawer.cs +++ b/com.unity.perception/Editor/GroundTruth/BaseCustomPassDrawer.cs @@ -1,4 +1,4 @@ -#if HDRP_PRESENT +#if HDRP_PRESENT using System; using System.Collections.Generic; diff --git a/com.unity.perception/Editor/GroundTruth/InstanceSegmentationPassEditor.cs b/com.unity.perception/Editor/GroundTruth/InstanceSegmentationPassEditor.cs index ba43e7b9b..fa9cf5140 100644 --- a/com.unity.perception/Editor/GroundTruth/InstanceSegmentationPassEditor.cs +++ b/com.unity.perception/Editor/GroundTruth/InstanceSegmentationPassEditor.cs @@ -1,4 +1,4 @@ -#if HDRP_PRESENT +#if HDRP_PRESENT using UnityEditor.Rendering.HighDefinition; using UnityEngine.Perception.GroundTruth; diff --git a/com.unity.perception/Editor/GroundTruth/LabelingConfigurationEditor.cs b/com.unity.perception/Editor/GroundTruth/LabelingConfigurationEditor.cs index e6fb90963..5681ee26b 100644 --- a/com.unity.perception/Editor/GroundTruth/LabelingConfigurationEditor.cs +++ b/com.unity.perception/Editor/GroundTruth/LabelingConfigurationEditor.cs @@ -1,4 +1,4 @@ -using UnityEditorInternal; +using UnityEditorInternal; using UnityEngine; using UnityEngine.Perception.GroundTruth; diff --git a/com.unity.perception/Editor/GroundTruth/LabelingEditor.cs b/com.unity.perception/Editor/GroundTruth/LabelingEditor.cs index 56de7f940..b2e7647ae 100644 --- a/com.unity.perception/Editor/GroundTruth/LabelingEditor.cs +++ b/com.unity.perception/Editor/GroundTruth/LabelingEditor.cs @@ -1,4 +1,4 @@ -using UnityEditorInternal; +using UnityEditorInternal; using UnityEngine; namespace UnityEditor.Perception.GroundTruth diff --git a/com.unity.perception/Editor/GroundTruth/ObjectCountPassEditor.cs b/com.unity.perception/Editor/GroundTruth/ObjectCountPassEditor.cs index 36e68d3af..1cbe9949e 100644 --- a/com.unity.perception/Editor/GroundTruth/ObjectCountPassEditor.cs +++ b/com.unity.perception/Editor/GroundTruth/ObjectCountPassEditor.cs @@ -1,4 +1,4 @@ -#if HDRP_PRESENT +#if HDRP_PRESENT using System; using UnityEditor.Rendering.HighDefinition; diff --git a/com.unity.perception/Editor/GroundTruth/SemanticSegmentationPassEditor.cs b/com.unity.perception/Editor/GroundTruth/SemanticSegmentationPassEditor.cs index d0f20b6a5..5c4ea67c3 100644 --- a/com.unity.perception/Editor/GroundTruth/SemanticSegmentationPassEditor.cs +++ b/com.unity.perception/Editor/GroundTruth/SemanticSegmentationPassEditor.cs @@ -1,4 +1,4 @@ -#if HDRP_PRESENT +#if HDRP_PRESENT using System; using UnityEditor.Rendering.HighDefinition; diff --git a/com.unity.perception/Runtime/GroundTruth/BoundingBoxOrigin.cs b/com.unity.perception/Runtime/GroundTruth/BoundingBoxOrigin.cs index 68927e034..3ea838119 100644 --- a/com.unity.perception/Runtime/GroundTruth/BoundingBoxOrigin.cs +++ b/com.unity.perception/Runtime/GroundTruth/BoundingBoxOrigin.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace UnityEngine.Perception.GroundTruth { diff --git a/com.unity.perception/Runtime/GroundTruth/DatasetJsonUtility.cs b/com.unity.perception/Runtime/GroundTruth/DatasetJsonUtility.cs index 107cba2da..804ec9bd1 100644 --- a/com.unity.perception/Runtime/GroundTruth/DatasetJsonUtility.cs +++ b/com.unity.perception/Runtime/GroundTruth/DatasetJsonUtility.cs @@ -19,6 +19,7 @@ public static JToken ToJToken(Vector3 value) obj.Add(value.z); return obj; } + public static JToken ToJToken(Quaternion value) { var obj = new JArray(); @@ -28,6 +29,7 @@ public static JToken ToJToken(Quaternion value) obj.Add(value.w); return obj; } + public static JToken ToJToken(float3x3 value) { var obj = new JArray(); @@ -36,6 +38,7 @@ public static JToken ToJToken(float3x3 value) obj.Add(ToJToken(value.c2)); return obj; } + public static JToken ToJToken(float3 value) { var obj = new JArray(); @@ -44,6 +47,7 @@ public static JToken ToJToken(float3 value) obj.Add(value.z); return obj; } + public static JToken ToJToken(T value) { switch (value) diff --git a/com.unity.perception/Runtime/GroundTruth/Ego.cs b/com.unity.perception/Runtime/GroundTruth/Ego.cs index d5230966e..eb512af93 100644 --- a/com.unity.perception/Runtime/GroundTruth/Ego.cs +++ b/com.unity.perception/Runtime/GroundTruth/Ego.cs @@ -1,4 +1,4 @@ -using System; +using System; using UnityEngine; namespace UnityEngine.Perception.GroundTruth diff --git a/com.unity.perception/Runtime/GroundTruth/GroundTruthCrossPipelinePass.cs b/com.unity.perception/Runtime/GroundTruth/GroundTruthCrossPipelinePass.cs index a38ffa4f1..2b2b40bf7 100644 --- a/com.unity.perception/Runtime/GroundTruth/GroundTruthCrossPipelinePass.cs +++ b/com.unity.perception/Runtime/GroundTruth/GroundTruthCrossPipelinePass.cs @@ -1,4 +1,4 @@ -using System; +using System; using Unity.Entities; using UnityEngine; using UnityEngine.Experimental.Rendering; @@ -53,8 +53,7 @@ public void Cleanup() labelSetupSystem?.Deactivate(this); } - - protected RendererListDesc CreateRendererListDesc(Camera camera, CullingResults cullingResult, string overrideMaterialPassName, int overrideMaterialPassIndex, Material overrideMaterial, LayerMask layerMask/*, PerObjectData perObjectData*/) + protected RendererListDesc CreateRendererListDesc(Camera camera, CullingResults cullingResult, string overrideMaterialPassName, int overrideMaterialPassIndex, Material overrideMaterial, LayerMask layerMask /*, PerObjectData perObjectData*/) { var shaderPasses = new[] { @@ -85,7 +84,6 @@ protected RendererListDesc CreateRendererListDesc(Camera camera, CullingResults return result; } - public static void DrawRendererList(ScriptableRenderContext renderContext, CommandBuffer cmd, RendererList rendererList) { if (!rendererList.isValid) diff --git a/com.unity.perception/Runtime/GroundTruth/GroundTruthInfo.cs b/com.unity.perception/Runtime/GroundTruth/GroundTruthInfo.cs index 3dcf839f4..2a8a2919b 100644 --- a/com.unity.perception/Runtime/GroundTruth/GroundTruthInfo.cs +++ b/com.unity.perception/Runtime/GroundTruth/GroundTruthInfo.cs @@ -1,4 +1,4 @@ -using Unity.Entities; +using Unity.Entities; namespace UnityEngine.Perception.GroundTruth { diff --git a/com.unity.perception/Runtime/GroundTruth/GroundTruthLabelSetupSystem.cs b/com.unity.perception/Runtime/GroundTruth/GroundTruthLabelSetupSystem.cs index a90711e72..425b0228b 100644 --- a/com.unity.perception/Runtime/GroundTruth/GroundTruthLabelSetupSystem.cs +++ b/com.unity.perception/Runtime/GroundTruth/GroundTruthLabelSetupSystem.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading; using Unity.Entities; @@ -22,8 +22,8 @@ public class GroundTruthLabelSetupSystem : ComponentSystem protected override void OnCreate() { //These are here to inform the system runner the queries we are interested in. Without these calls, OnUpdate() might not be called - GetEntityQuery( ComponentType.Exclude(), ComponentType.ReadOnly()); - GetEntityQuery( ComponentType.ReadOnly(), ComponentType.ReadOnly()); + GetEntityQuery(ComponentType.Exclude(), ComponentType.ReadOnly()); + GetEntityQuery(ComponentType.ReadOnly(), ComponentType.ReadOnly()); } /// @@ -91,7 +91,6 @@ public void Activate(IGroundTruthGenerator generator) var gameObject = labeling.gameObject; InitGameObjectRecursive(gameObject, m_MaterialPropertyBlocks.Value, labeling, info.instanceId); }); - } /// diff --git a/com.unity.perception/Runtime/GroundTruth/GroundTruthRendererFeature.cs b/com.unity.perception/Runtime/GroundTruth/GroundTruthRendererFeature.cs index 29ff87bd5..1ce36b90c 100644 --- a/com.unity.perception/Runtime/GroundTruth/GroundTruthRendererFeature.cs +++ b/com.unity.perception/Runtime/GroundTruth/GroundTruthRendererFeature.cs @@ -1,4 +1,4 @@ -#if URP_PRESENT +#if URP_PRESENT using System; using UnityEditor; using UnityEngine; @@ -47,7 +47,7 @@ public override void Execute(ScriptableRenderContext context, ref RenderingData public class GroundTruthRendererFeature : ScriptableRendererFeature { - public override void Create() { } + public override void Create() {} public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) { diff --git a/com.unity.perception/Runtime/GroundTruth/IGroundTruthGenerator.cs b/com.unity.perception/Runtime/GroundTruth/IGroundTruthGenerator.cs index dcbb062cd..7bec0a411 100644 --- a/com.unity.perception/Runtime/GroundTruth/IGroundTruthGenerator.cs +++ b/com.unity.perception/Runtime/GroundTruth/IGroundTruthGenerator.cs @@ -1,4 +1,4 @@ -using UnityEngine; +using UnityEngine; namespace UnityEngine.Perception.GroundTruth { diff --git a/com.unity.perception/Runtime/GroundTruth/InstanceSegmentationCrossPipelinePass.cs b/com.unity.perception/Runtime/GroundTruth/InstanceSegmentationCrossPipelinePass.cs index dc18109f2..64606643c 100644 --- a/com.unity.perception/Runtime/GroundTruth/InstanceSegmentationCrossPipelinePass.cs +++ b/com.unity.perception/Runtime/GroundTruth/InstanceSegmentationCrossPipelinePass.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Unity.Profiling; using UnityEngine; @@ -31,7 +31,7 @@ class InstanceSegmentationCrossPipelinePass : GroundTruthCrossPipelinePass /// /// public InstanceSegmentationCrossPipelinePass(Camera targetCamera) - :base(targetCamera) + : base(targetCamera) { if (targetCamera == null) throw new ArgumentNullException(nameof(targetCamera)); diff --git a/com.unity.perception/Runtime/GroundTruth/InstanceSegmentationPass.cs b/com.unity.perception/Runtime/GroundTruth/InstanceSegmentationPass.cs index 07cde2ac7..b8ca085de 100644 --- a/com.unity.perception/Runtime/GroundTruth/InstanceSegmentationPass.cs +++ b/com.unity.perception/Runtime/GroundTruth/InstanceSegmentationPass.cs @@ -1,4 +1,4 @@ -#if HDRP_PRESENT +#if HDRP_PRESENT using System; using JetBrains.Annotations; diff --git a/com.unity.perception/Runtime/GroundTruth/Labeling/LabelingConfiguration.cs b/com.unity.perception/Runtime/GroundTruth/Labeling/LabelingConfiguration.cs index 3b1da88d1..ea3b46735 100644 --- a/com.unity.perception/Runtime/GroundTruth/Labeling/LabelingConfiguration.cs +++ b/com.unity.perception/Runtime/GroundTruth/Labeling/LabelingConfiguration.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; namespace UnityEngine.Perception.GroundTruth diff --git a/com.unity.perception/Runtime/GroundTruth/ObjectCountPass.cs b/com.unity.perception/Runtime/GroundTruth/ObjectCountPass.cs index 8e5939f7b..254ea8af2 100644 --- a/com.unity.perception/Runtime/GroundTruth/ObjectCountPass.cs +++ b/com.unity.perception/Runtime/GroundTruth/ObjectCountPass.cs @@ -1,4 +1,4 @@ -#if HDRP_PRESENT +#if HDRP_PRESENT using Unity.Collections.LowLevel.Unsafe; using System; @@ -50,7 +50,7 @@ public override void SetupMaterialProperties(MaterialPropertyBlock mpb, MeshRend m_InstanceIdToClassIdLookup.Resize((int)instanceId + 1, NativeArrayOptions.ClearMemory); } m_IdBuffersNeedUpdating = true; - m_InstanceIdToClassIdLookup[(int) instanceId] = index + 1; + m_InstanceIdToClassIdLookup[(int)instanceId] = index + 1; } } diff --git a/com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs b/com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs index f7300bbd7..82da58c48 100644 --- a/com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs +++ b/com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; @@ -93,7 +93,7 @@ public class PerceptionCamera : MonoBehaviour /// public event Action> renderedObjectInfosCalculated; - internal event Action> segmentationImageReceived; + internal event Action> segmentationImageReceived; internal event Action, IReadOnlyList, int> classCountsReceived; @@ -394,6 +394,7 @@ void SetupPasses(CustomPassVolume customPassVolume) if (produceSegmentationImages) customPassVolume.customPasses.Add(m_SemanticSegmentationPass); } + #endif void ProduceBoundingBoxesAnnotation(NativeArray renderedObjectInfos, List labelingConfigurations, int frameCount) @@ -592,7 +593,7 @@ static unsafe void FlipImageY(byte[] dataColorBuffer, int height) { var stride = dataColorBuffer.Length / height; var buffer = new NativeArray(stride, Allocator.TempJob, NativeArrayOptions.UninitializedMemory); - fixed (byte* colorBufferPtr = &dataColorBuffer[0]) + fixed(byte* colorBufferPtr = &dataColorBuffer[0]) { var unsafePtr = (byte*)buffer.GetUnsafePtr(); for (var row = 0; row < height / 2; row++) diff --git a/com.unity.perception/Runtime/GroundTruth/RenderTextureReader.cs b/com.unity.perception/Runtime/GroundTruth/RenderTextureReader.cs index d42ff1600..e4689a379 100644 --- a/com.unity.perception/Runtime/GroundTruth/RenderTextureReader.cs +++ b/com.unity.perception/Runtime/GroundTruth/RenderTextureReader.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using Unity.Collections; using Unity.Simulation; diff --git a/com.unity.perception/Runtime/GroundTruth/RenderedObjectInfo.cs b/com.unity.perception/Runtime/GroundTruth/RenderedObjectInfo.cs index 031685bb4..50f62c15b 100644 --- a/com.unity.perception/Runtime/GroundTruth/RenderedObjectInfo.cs +++ b/com.unity.perception/Runtime/GroundTruth/RenderedObjectInfo.cs @@ -1,4 +1,4 @@ -using System; +using System; // ReSharper disable NonReadonlyMemberInGetHashCode namespace UnityEngine.Perception.GroundTruth diff --git a/com.unity.perception/Runtime/GroundTruth/RenderedObjectInfoGenerator.cs b/com.unity.perception/Runtime/GroundTruth/RenderedObjectInfoGenerator.cs index 68c86bd93..1334a87b6 100644 --- a/com.unity.perception/Runtime/GroundTruth/RenderedObjectInfoGenerator.cs +++ b/com.unity.perception/Runtime/GroundTruth/RenderedObjectInfoGenerator.cs @@ -1,4 +1,4 @@ -using System; +using System; using Unity.Burst; using Unity.Collections; using Unity.Collections.LowLevel.Unsafe; diff --git a/com.unity.perception/Runtime/GroundTruth/SemanticSegmentationCrossPipelinePass.cs b/com.unity.perception/Runtime/GroundTruth/SemanticSegmentationCrossPipelinePass.cs index d1d060f3e..3b0e44472 100644 --- a/com.unity.perception/Runtime/GroundTruth/SemanticSegmentationCrossPipelinePass.cs +++ b/com.unity.perception/Runtime/GroundTruth/SemanticSegmentationCrossPipelinePass.cs @@ -1,4 +1,4 @@ -using System; +using System; using UnityEngine.Experimental.Rendering; using UnityEngine.Rendering; diff --git a/com.unity.perception/Runtime/GroundTruth/SemanticSegmentationPass.cs b/com.unity.perception/Runtime/GroundTruth/SemanticSegmentationPass.cs index 955e204c9..88a8071bd 100644 --- a/com.unity.perception/Runtime/GroundTruth/SemanticSegmentationPass.cs +++ b/com.unity.perception/Runtime/GroundTruth/SemanticSegmentationPass.cs @@ -1,4 +1,4 @@ -#if HDRP_PRESENT +#if HDRP_PRESENT using System; using UnityEngine.Rendering; diff --git a/com.unity.perception/Runtime/GroundTruth/SimulationManagementComponentSystem.cs b/com.unity.perception/Runtime/GroundTruth/SimulationManagementComponentSystem.cs index 8110ac7c3..7b2f7ce60 100644 --- a/com.unity.perception/Runtime/GroundTruth/SimulationManagementComponentSystem.cs +++ b/com.unity.perception/Runtime/GroundTruth/SimulationManagementComponentSystem.cs @@ -1,4 +1,4 @@ -using System; +using System; using Unity.Entities; namespace UnityEngine.Perception.GroundTruth diff --git a/com.unity.perception/Runtime/GroundTruth/SimulationManager.cs b/com.unity.perception/Runtime/GroundTruth/SimulationManager.cs index 21a322b22..15c26e8e5 100644 --- a/com.unity.perception/Runtime/GroundTruth/SimulationManager.cs +++ b/com.unity.perception/Runtime/GroundTruth/SimulationManager.cs @@ -1,4 +1,4 @@ -using System; +using System; using JetBrains.Annotations; using Newtonsoft.Json.Linq; using Unity.Simulation; @@ -270,7 +270,7 @@ public AsyncAnnotation ReportAnnotationAsync(AnnotationDefinition annotationDefi /// Spatial data describing the sensor and the ego containing it. /// Additional values to be emitted as json name/value pairs on the sensor object under the capture. /// Thrown if ReportCapture is being called when ShouldCaptureThisFrame is false or it has already been called this frame. - public void ReportCapture(string filename, SensorSpatialData sensorSpatialData, params (string, object)[] additionalSensorValues) + public void ReportCapture(string filename, SensorSpatialData sensorSpatialData, params(string, object)[] additionalSensorValues) { if (!ShouldCaptureThisFrame) { @@ -381,7 +381,7 @@ public override int GetHashCode() /// The first SensorHandle. /// The second SensorHandle. /// Returns true if the two SensorHandles refer to the same sensor. - public static bool operator ==(SensorHandle left, SensorHandle right) + public static bool operator==(SensorHandle left, SensorHandle right) { return left.Equals(right); } @@ -392,7 +392,7 @@ public override int GetHashCode() /// The first SensorHandle. /// The second SensorHandle. /// Returns false if the two SensorHandles refer to the same sensor. - public static bool operator !=(SensorHandle left, SensorHandle right) + public static bool operator!=(SensorHandle left, SensorHandle right) { return !left.Equals(right); } @@ -660,19 +660,18 @@ public override int GetHashCode() /// The first EgoHandle. /// The second EgoHandle. /// Returns true if the two EgoHandles refer to the same ego. - public static bool operator ==(EgoHandle left, EgoHandle right) + public static bool operator==(EgoHandle left, EgoHandle right) { return left.Equals(right); } - /// /// Compares two instances for inequality. /// /// The first EgoHandle. /// The second EgoHandle. /// Returns true if the two EgoHandles refer to the same ego. - public static bool operator !=(EgoHandle left, EgoHandle right) + public static bool operator!=(EgoHandle left, EgoHandle right) { return !left.Equals(right); } @@ -692,6 +691,7 @@ internal MetricDefinition(Guid id) { Id = id; } + /// public bool Equals(MetricDefinition other) { @@ -802,5 +802,4 @@ public static SensorSpatialData FromGameObjects(GameObject ego, GameObject senso return sensorSpatialData; } } - } diff --git a/com.unity.perception/Runtime/GroundTruth/SimulationState.cs b/com.unity.perception/Runtime/GroundTruth/SimulationState.cs index f09d21ee4..6dcf7ab8f 100644 --- a/com.unity.perception/Runtime/GroundTruth/SimulationState.cs +++ b/com.unity.perception/Runtime/GroundTruth/SimulationState.cs @@ -77,7 +77,7 @@ class PendingCapture public float Timestamp; public Guid SequenceId; public (string, object)[] AdditionalSensorValues; - public List<(Annotation, AnnotationData )> Annotations = new List<(Annotation, AnnotationData)>(); + public List<(Annotation, AnnotationData)> Annotations = new List<(Annotation, AnnotationData)>(); public bool CaptureReported; public PendingCapture(Guid id, SensorHandle sensorHandle, SensorData sensorData, Guid sequenceId, int frameCount, int step, float timestamp) @@ -211,7 +211,7 @@ public override int GetHashCode() } } - internal void ReportCapture(SensorHandle sensorHandle, string filename, SensorSpatialData sensorSpatialData, params (string, object)[] additionalSensorValues) + internal void ReportCapture(SensorHandle sensorHandle, string filename, SensorSpatialData sensorSpatialData, params(string, object)[] additionalSensorValues) { var sensorData = m_Sensors[sensorHandle]; var pendingCapture = GetOrCreatePendingCaptureForThisFrame(sensorHandle, out _); @@ -411,7 +411,8 @@ public void Update() do { sensorData.sequenceTimeNextCapture += sensorData.period; - } while (sensorData.sequenceTimeNextCapture <= UnscaledSequenceTime); + } + while (sensorData.sequenceTimeNextCapture <= UnscaledSequenceTime); sensorData.lastCaptureFrameCount = Time.frameCount; m_Sensors[activeSensor] = sensorData; diff --git a/com.unity.perception/Runtime/GroundTruth/SimulationState_Json.cs b/com.unity.perception/Runtime/GroundTruth/SimulationState_Json.cs index 95b608608..9e33c8ade 100644 --- a/com.unity.perception/Runtime/GroundTruth/SimulationState_Json.cs +++ b/com.unity.perception/Runtime/GroundTruth/SimulationState_Json.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.IO; @@ -293,7 +293,7 @@ static JToken JObjectFromPendingCapture(PendingCapture pendingCapture) if (pendingCapture.AdditionalSensorValues != null) { - foreach (var (name, value) in pendingCapture.AdditionalSensorValues) + foreach (var(name, value) in pendingCapture.AdditionalSensorValues) sensorJObject.Add(name, DatasetJsonUtility.ToJToken(value)); } diff --git a/com.unity.perception/Tests/Editor/BuildPerceptionPlayer.cs b/com.unity.perception/Tests/Editor/BuildPerceptionPlayer.cs index 0120fa0ca..6a17618d9 100644 --- a/com.unity.perception/Tests/Editor/BuildPerceptionPlayer.cs +++ b/com.unity.perception/Tests/Editor/BuildPerceptionPlayer.cs @@ -64,11 +64,11 @@ public void TestsScenesPath() } else if (targetPath.EndsWith(".unity")) if (targetPath.EndsWith(".unity")) - { - Debug.Log("Scenes Path : " + targetPath); + { + Debug.Log("Scenes Path : " + targetPath); - m_EditorBuildSettingsScenes.Add(new EditorBuildSettingsScene(targetPath, true)); - } + m_EditorBuildSettingsScenes.Add(new EditorBuildSettingsScene(targetPath, true)); + } } EditorBuildSettings.scenes = m_EditorBuildSettingsScenes.ToArray(); } @@ -88,4 +88,3 @@ void BuildPlayer(BuildTargetGroup buildTargetGroup, BuildTarget buildTarget, str } } } - diff --git a/com.unity.perception/Tests/Editor/PerceptionCameraEditorTests.cs b/com.unity.perception/Tests/Editor/PerceptionCameraEditorTests.cs index 5f3610593..3a8cb871a 100644 --- a/com.unity.perception/Tests/Editor/PerceptionCameraEditorTests.cs +++ b/com.unity.perception/Tests/Editor/PerceptionCameraEditorTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.IO; using NUnit.Framework; diff --git a/com.unity.perception/Tests/Runtime/GroundTruthTests/BoundingBox2DTests.cs b/com.unity.perception/Tests/Runtime/GroundTruthTests/BoundingBox2DTests.cs index 9d3d5b82e..27dd880b0 100644 --- a/com.unity.perception/Tests/Runtime/GroundTruthTests/BoundingBox2DTests.cs +++ b/com.unity.perception/Tests/Runtime/GroundTruthTests/BoundingBox2DTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using NUnit.Framework; @@ -55,7 +55,7 @@ public static IEnumerable ProducesCorrectBoundingBoxesTestCases() }, new uint[] { 1, - 0 + 0 }, 2, BoundingBoxOrigin.BottomLeft, @@ -144,7 +144,7 @@ public static IEnumerable ProducesCorrectBoundingBoxesTestCases() } [UnityTest] - public IEnumerator ProducesCorrectBoundingBoxes([ValueSource(nameof(ProducesCorrectBoundingBoxesTestCases))]ProducesCorrectBoundingBoxesData producesCorrectBoundingBoxesData) + public IEnumerator ProducesCorrectBoundingBoxes([ValueSource(nameof(ProducesCorrectBoundingBoxesTestCases))] ProducesCorrectBoundingBoxesData producesCorrectBoundingBoxesData) { var label = "label"; var label2 = "label2"; diff --git a/com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetJsonUtilityTests.cs b/com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetJsonUtilityTests.cs index 0ace8b533..b57a41b52 100644 --- a/com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetJsonUtilityTests.cs +++ b/com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetJsonUtilityTests.cs @@ -28,6 +28,7 @@ public void Vector3ToJToken_ReturnsArrayFormat(float x, float y, float z, string var jsonActual = DatasetJsonUtility.ToJToken(new Vector3(x, y, z)); Assert.AreEqual(jsonExpected, jsonActual.ToString()); } + [Test] [TestCase(-2f, 0f, 3f, 4f, @"[ -2.0, @@ -52,6 +53,7 @@ public void QuaternionToJToken_ReturnsArrayFormat(float x, float y, float z, flo var jsonActual = DatasetJsonUtility.ToJToken(new Quaternion(x, y, z, w)).ToString(); Assert.AreEqual(jsonExpected, jsonActual); } + [Test] [TestCase(0.1f, 0.2f, 0.3f, 4f, 5f, 6f, 70f, 80f, 90f, @"[ [ diff --git a/com.unity.perception/Tests/Runtime/GroundTruthTests/GroundTruthTestBase.cs b/com.unity.perception/Tests/Runtime/GroundTruthTests/GroundTruthTestBase.cs index 411002224..4fd48faec 100644 --- a/com.unity.perception/Tests/Runtime/GroundTruthTests/GroundTruthTestBase.cs +++ b/com.unity.perception/Tests/Runtime/GroundTruthTests/GroundTruthTestBase.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using NUnit.Framework; diff --git a/com.unity.perception/Tests/Runtime/GroundTruthTests/ObjectCountTests.cs b/com.unity.perception/Tests/Runtime/GroundTruthTests/ObjectCountTests.cs index e5d510b02..960ac5ad5 100644 --- a/com.unity.perception/Tests/Runtime/GroundTruthTests/ObjectCountTests.cs +++ b/com.unity.perception/Tests/Runtime/GroundTruthTests/ObjectCountTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -47,7 +47,7 @@ public IEnumerator ProducesCorrectValuesWithChangingObjects() //TestHelper.LoadAndStartRenderDocCapture(out EditorWindow gameView); var startFrameCount = Time.frameCount; - var expectedFramesAndCounts= new Dictionary() + var expectedFramesAndCounts = new Dictionary() { {Time.frameCount , 0}, {startFrameCount + 1, 1}, diff --git a/com.unity.perception/Tests/Runtime/GroundTruthTests/PerceptionCameraIntegrationTests.cs b/com.unity.perception/Tests/Runtime/GroundTruthTests/PerceptionCameraIntegrationTests.cs index b395d2cc4..155ee5959 100644 --- a/com.unity.perception/Tests/Runtime/GroundTruthTests/PerceptionCameraIntegrationTests.cs +++ b/com.unity.perception/Tests/Runtime/GroundTruthTests/PerceptionCameraIntegrationTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.IO; diff --git a/com.unity.perception/Tests/Runtime/GroundTruthTests/SegmentationGroundTruthTests.cs b/com.unity.perception/Tests/Runtime/GroundTruthTests/SegmentationGroundTruthTests.cs index 4a4e22822..555fa2463 100644 --- a/com.unity.perception/Tests/Runtime/GroundTruthTests/SegmentationGroundTruthTests.cs +++ b/com.unity.perception/Tests/Runtime/GroundTruthTests/SegmentationGroundTruthTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -71,7 +71,7 @@ public IEnumerator SegmentationPassTestsWithEnumeratorPasses() //Put a plane in front of the camera var planeObject = GameObject.CreatePrimitive(PrimitiveType.Plane); - planeObject.transform.SetPositionAndRotation(new Vector3(0, 0, 10), Quaternion.Euler(90, 0, 0) ); + planeObject.transform.SetPositionAndRotation(new Vector3(0, 0, 10), Quaternion.Euler(90, 0, 0)); planeObject.transform.localScale = new Vector3(10, -1, 10); planeObject.AddComponent(); AddTestObjectForCleanup(planeObject); @@ -86,6 +86,7 @@ public IEnumerator SegmentationPassTestsWithEnumeratorPasses() Assert.AreEqual(4, timesSegmentationImageReceived); } + [UnityTest] public IEnumerator SegmentationPassProducesCorrectValuesEachFrame() { diff --git a/com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManagerSensorSchedulingTests.cs b/com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManagerSensorSchedulingTests.cs index 054dc962d..676ffe599 100644 --- a/com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManagerSensorSchedulingTests.cs +++ b/com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManagerSensorSchedulingTests.cs @@ -1,4 +1,4 @@ -using System.Collections; +using System.Collections; using System.Text.RegularExpressions; using NUnit.Framework; using UnityEngine; @@ -25,7 +25,8 @@ public IEnumerator FramesScheduledBySensorConfig() var period = .4f; SimulationManager.RegisterSensor(ego, "cam", "", period, firstCaptureTime); - float[] deltaTimeSamplesExpected = { + float[] deltaTimeSamplesExpected = + { firstCaptureTime, period, period, @@ -50,7 +51,8 @@ public IEnumerator FramesScheduled_WithTimeScale_ResultsInProperDeltaTime() Time.timeScale = timeScale; SimulationManager.RegisterSensor(ego, "cam", "", period, firstCaptureTime); - float[] deltaTimeSamplesExpected = { + float[] deltaTimeSamplesExpected = + { timeScale * firstCaptureTime, timeScale * period, timeScale * period, @@ -95,7 +97,8 @@ public IEnumerator FramesScheduled_WithChangingTimeScale_ResultsInProperDeltaTim var ego = SimulationManager.RegisterEgo("ego"); var firstCaptureTime = 2f; var period = 1f; - float[] newTimeScalesPerFrame = { + float[] newTimeScalesPerFrame = + { 2f, 10f, .01f, @@ -103,7 +106,8 @@ public IEnumerator FramesScheduled_WithChangingTimeScale_ResultsInProperDeltaTim }; SimulationManager.RegisterSensor(ego, "cam", "", period, firstCaptureTime); - float[] deltaTimeSamplesExpected = { + float[] deltaTimeSamplesExpected = + { newTimeScalesPerFrame[0] * firstCaptureTime, newTimeScalesPerFrame[1] * period, newTimeScalesPerFrame[2] * period, @@ -144,14 +148,15 @@ public IEnumerator ShouldCaptureThisFrame_ReturnsTrueOnProperFrames() var sensor3 = SimulationManager.RegisterSensor(ego, "cam", "3", 1, 1); sensor3.Enabled = false; - (float deltaTime, bool sensor1ShouldCapture, bool sensor2ShouldCapture)[] samplesExpected = { + (float deltaTime, bool sensor1ShouldCapture, bool sensor2ShouldCapture)[] samplesExpected = + { ((float)firstCaptureTime1, true, true), (4, true, false), (2, false, true), (2, true, false), (4, true, true) }; - var samplesActual = new (float deltaTime, bool sensor1ShouldCapture, bool sensor2ShouldCapture)[samplesExpected.Length]; + var samplesActual = new(float deltaTime, bool sensor1ShouldCapture, bool sensor2ShouldCapture)[samplesExpected.Length]; for (int i = 0; i < samplesActual.Length; i++) { yield return null; @@ -164,7 +169,7 @@ public IEnumerator ShouldCaptureThisFrame_ReturnsTrueOnProperFrames() [Test] public void Enabled_StartsTrue() { - var sensor1 = SimulationManager.RegisterSensor(SimulationManager.RegisterEgo(""), "cam", "1", 1,1); + var sensor1 = SimulationManager.RegisterSensor(SimulationManager.RegisterEgo(""), "cam", "1", 1, 1); Assert.IsTrue(sensor1.Enabled); } } diff --git a/com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManagerTests.cs b/com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManagerTests.cs index e59d618b0..3bc041b40 100644 --- a/com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManagerTests.cs +++ b/com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManagerTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Globalization; @@ -167,7 +167,7 @@ public void ReportCapture_ReportsProperJson() [UnityTest] public IEnumerator StartNewSequence_ProperlyIncrementsSequence() { - var timingsExpected = new (int step, int timestamp, bool expectNewSequence)[] + var timingsExpected = new(int step, int timestamp, bool expectNewSequence)[] { (0, 0, true), (1, 2, false), @@ -240,7 +240,7 @@ public void ReportAnnotation_AddsProperJsonToCapture() var filename = "my/file.png"; var annotationDefinitionGuid = Guid.NewGuid(); - var annotationDefinitionsJsonExpected= + var annotationDefinitionsJsonExpected = $@"{{ ""version"": ""{SimulationManager.SchemaVersion}"", ""annotation_definitions"": [ @@ -252,7 +252,7 @@ public void ReportAnnotation_AddsProperJsonToCapture() }} ] }}"; - var annotationsJsonExpected= + var annotationsJsonExpected = $@" ""annotations"": [ {{ ""id"": , @@ -333,7 +333,7 @@ public void ReportAnnotationFile_WhenCaptureNotExpected_Throws() var ego = SimulationManager.RegisterEgo(""); var annotationDefinition = SimulationManager.RegisterAnnotationDefinition(""); var sensorHandle = SimulationManager.RegisterSensor(ego, "", "", 1, 100); - Assert.Throws(()=>sensorHandle.ReportAnnotationFile(annotationDefinition, "")); + Assert.Throws(() => sensorHandle.ReportAnnotationFile(annotationDefinition, "")); } [Test] @@ -342,7 +342,7 @@ public void ReportAnnotationValues_WhenCaptureNotExpected_Throws() var ego = SimulationManager.RegisterEgo(""); var annotationDefinition = SimulationManager.RegisterAnnotationDefinition(""); var sensorHandle = SimulationManager.RegisterSensor(ego, "", "", 1, 100); - Assert.Throws(()=>sensorHandle.ReportAnnotationValues(annotationDefinition, new int[0])); + Assert.Throws(() => sensorHandle.ReportAnnotationValues(annotationDefinition, new int[0])); } [Test] @@ -351,7 +351,7 @@ public void ReportAnnotationAsync_WhenCaptureNotExpected_Throws() var ego = SimulationManager.RegisterEgo(""); var annotationDefinition = SimulationManager.RegisterAnnotationDefinition(""); var sensorHandle = SimulationManager.RegisterSensor(ego, "", "", 1, 100); - Assert.Throws(()=>sensorHandle.ReportAnnotationAsync(annotationDefinition)); + Assert.Throws(() => sensorHandle.ReportAnnotationAsync(annotationDefinition)); } [Test] @@ -417,7 +417,6 @@ public void AnnotationAsyncReportFile_ReportsProperJson() StringAssert.Contains(expectedAnnotation, EscapeGuids(File.ReadAllText(capturesPath))); } - public struct TestValues { public string a; @@ -479,7 +478,7 @@ public void CreateAnnotation_MultipleTimes_WritesProperTypeOnce() { var annotationDefinitionGuid = new Guid(10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - var annotationDefinitionsJsonExpected= + var annotationDefinitionsJsonExpected = $@"{{ ""version"": ""{SimulationManager.SchemaVersion}"", ""annotation_definitions"": [ @@ -508,7 +507,7 @@ public void CreateAnnotation_MultipleTimesWithDifferentParameters_WritesProperTy { var annotationDefinitionGuid = new Guid(10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - var annotationDefinitionsJsonExpected= + var annotationDefinitionsJsonExpected = $@"{{ ""version"": ""{SimulationManager.SchemaVersion}"", ""annotation_definitions"": [ @@ -544,7 +543,7 @@ public void ReportMetricValues_WhenCaptureNotExpected_Throws() var ego = SimulationManager.RegisterEgo(""); var metricDefinition = SimulationManager.RegisterMetricDefinition(""); var sensorHandle = SimulationManager.RegisterSensor(ego, "", "", 1, 100); - Assert.Throws(()=>sensorHandle.ReportMetric(metricDefinition, new int[0])); + Assert.Throws(() => sensorHandle.ReportMetric(metricDefinition, new int[0])); } [Test] @@ -553,7 +552,7 @@ public void ReportMetricAsync_WhenCaptureNotExpected_Throws() var ego = SimulationManager.RegisterEgo(""); var metricDefinition = SimulationManager.RegisterMetricDefinition(""); var sensorHandle = SimulationManager.RegisterSensor(ego, "", "", 1, 100); - Assert.Throws(()=>sensorHandle.ReportMetricAsync(metricDefinition)); + Assert.Throws(() => sensorHandle.ReportMetricAsync(metricDefinition)); } [Test] @@ -739,7 +738,7 @@ public void CreateMetric_MultipleTimesWithDifferentParameters_WritesProperTypes( { var metricDefinitionGuid = new Guid(10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - var metricDefinitionsJsonExpected= + var metricDefinitionsJsonExpected = $@"{{ ""version"": ""{SimulationManager.SchemaVersion}"", ""metric_definitions"": [ @@ -784,7 +783,7 @@ public enum AdditionalInfoKind public void CreateAnnotationOrMetric_WithSpecValues_WritesProperTypes( [Values(AdditionalInfoKind.Annotation, AdditionalInfoKind.Metric)] AdditionalInfoKind additionalInfoKind) { - var specValues = new [] + var specValues = new[] { new TestSpec { @@ -815,7 +814,7 @@ public void CreateAnnotationOrMetric_WithSpecValues_WritesProperTypes( jsonContainerName = "metric_definitions"; } - var annotationDefinitionsJsonExpected= + var annotationDefinitionsJsonExpected = $@"{{ ""version"": ""{SimulationManager.SchemaVersion}"", ""{jsonContainerName}"": [ diff --git a/com.unity.perception/Tests/Runtime/GroundTruthTests/TestHelper.cs b/com.unity.perception/Tests/Runtime/GroundTruthTests/TestHelper.cs index 2aaf476b6..eddf240f4 100644 --- a/com.unity.perception/Tests/Runtime/GroundTruthTests/TestHelper.cs +++ b/com.unity.perception/Tests/Runtime/GroundTruthTests/TestHelper.cs @@ -1,4 +1,4 @@ -using System; +using System; using UnityEngine; namespace GroundTruthTests @@ -15,6 +15,7 @@ public static GameObject CreateLabeledPlane(float scale = 10, string label = "la labeling.labels.Add(label); return planeObject; } + #if UNITY_EDITOR public static void LoadAndStartRenderDocCapture(out UnityEditor.EditorWindow gameView) { @@ -24,6 +25,7 @@ public static void LoadAndStartRenderDocCapture(out UnityEditor.EditorWindow gam gameView = UnityEditor.EditorWindow.GetWindow(type); UnityEditorInternal.RenderDoc.BeginCaptureRenderDoc(gameView); } + #endif } }