Skip to content

Commit 9572d4c

Browse files
authored
Merge pull request #240 from Unity-Technologies/remove-entities-dependency
Remove entities dependency
2 parents 6890807 + 615d4f5 commit 9572d4c

File tree

62 files changed

+794
-901
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+794
-901
lines changed

com.unity.perception/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ The color of keypoints and connections are now reported in the annotation defini
2929

3030
The PerceptionScenario abstract class has been added to abstract perception data capture specific functionality from the vanilla scenario lifecycle.
3131

32+
The newly added LabelManager class now enables custom Labelers to access the list of registered Labeling Components present in the scene.
33+
3234
Improved UI for KeypointTemplate and added useful default colors for keypoint and skeleton definitions.
3335

3436
### Changed
@@ -53,6 +55,8 @@ The randomizer methods OnCreate(), OnStartRunning(), and OnStopRunning() are now
5355

5456
### Removed
5557

58+
Removed the entities package dependency
59+
5660
### Fixed
5761

5862
Fixed a null reference error that appeared when adding options to categorical parameters.

com.unity.perception/Editor/GroundTruth/InstanceSegmentationPassEditor.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#if HDRP_PRESENT
2-
32
using UnityEditor.Rendering.HighDefinition;
43
using UnityEngine.Perception.GroundTruth;
54

@@ -10,7 +9,7 @@ public class InstanceSegmentationPassEditor : BaseCustomPassDrawer
109
{
1110
protected override void Initialize(SerializedProperty customPass)
1211
{
13-
var targetCameraProperty = customPass.FindPropertyRelative(nameof(GroundTruthPass.targetCamera));
12+
var targetCameraProperty = customPass.FindPropertyRelative(nameof(InstanceSegmentationPass.targetCamera));
1413
AddProperty(targetCameraProperty);
1514
AddProperty(customPass.FindPropertyRelative(nameof(InstanceSegmentationPass.targetTexture)));
1615
base.Initialize(customPass);

com.unity.perception/Runtime/GroundTruth/GroundTruthInfo.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

com.unity.perception/Runtime/GroundTruth/GroundTruthInfo.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

com.unity.perception/Runtime/GroundTruth/GroundTruthLabelSetupSystem.cs

Lines changed: 0 additions & 141 deletions
This file was deleted.

com.unity.perception/Runtime/GroundTruth/GroundTruthLabelSetupSystem.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

com.unity.perception/Runtime/GroundTruth/GroundTruthPass.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

com.unity.perception/Runtime/GroundTruth/GroundTruthRendererFeature.cs

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,83 +2,10 @@
22
using System;
33
using UnityEditor;
44
using UnityEngine;
5-
using UnityEngine.Rendering;
65
using UnityEngine.Rendering.Universal;
76

87
namespace UnityEngine.Perception.GroundTruth
98
{
10-
class InstanceSegmentationUrpPass : ScriptableRenderPass
11-
{
12-
InstanceSegmentationCrossPipelinePass m_InstanceSegmentationPass;
13-
14-
public InstanceSegmentationUrpPass(Camera camera, RenderTexture targetTexture)
15-
{
16-
m_InstanceSegmentationPass = new InstanceSegmentationCrossPipelinePass(camera);
17-
ConfigureTarget(targetTexture, targetTexture.depthBuffer);
18-
m_InstanceSegmentationPass.Setup();
19-
}
20-
21-
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
22-
{
23-
var commandBuffer = CommandBufferPool.Get(nameof(InstanceSegmentationUrpPass));
24-
m_InstanceSegmentationPass.Execute(context, commandBuffer, renderingData.cameraData.camera, renderingData.cullResults);
25-
CommandBufferPool.Release(commandBuffer);
26-
}
27-
28-
public void Cleanup()
29-
{
30-
m_InstanceSegmentationPass.Cleanup();
31-
}
32-
}
33-
34-
class SemanticSegmentationUrpPass : ScriptableRenderPass
35-
{
36-
public SemanticSegmentationCrossPipelinePass m_SemanticSegmentationCrossPipelinePass;
37-
38-
public SemanticSegmentationUrpPass(Camera camera, RenderTexture targetTexture, SemanticSegmentationLabelConfig labelConfig)
39-
{
40-
m_SemanticSegmentationCrossPipelinePass = new SemanticSegmentationCrossPipelinePass(camera, labelConfig);
41-
ConfigureTarget(targetTexture, targetTexture.depthBuffer);
42-
m_SemanticSegmentationCrossPipelinePass.Setup();
43-
}
44-
45-
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
46-
{
47-
var commandBuffer = CommandBufferPool.Get(nameof(SemanticSegmentationUrpPass));
48-
m_SemanticSegmentationCrossPipelinePass.Execute(context, commandBuffer, renderingData.cameraData.camera, renderingData.cullResults);
49-
CommandBufferPool.Release(commandBuffer);
50-
}
51-
52-
public void Cleanup()
53-
{
54-
m_SemanticSegmentationCrossPipelinePass.Cleanup();
55-
}
56-
}
57-
58-
class LensDistortionUrpPass : ScriptableRenderPass
59-
{
60-
public LensDistortionCrossPipelinePass m_LensDistortionCrossPipelinePass;
61-
62-
public LensDistortionUrpPass(Camera camera, RenderTexture targetTexture)
63-
{
64-
m_LensDistortionCrossPipelinePass = new LensDistortionCrossPipelinePass(camera, targetTexture);
65-
ConfigureTarget(targetTexture, targetTexture.depthBuffer);
66-
m_LensDistortionCrossPipelinePass.Setup();
67-
}
68-
69-
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
70-
{
71-
var commandBuffer = CommandBufferPool.Get(nameof(SemanticSegmentationUrpPass));
72-
m_LensDistortionCrossPipelinePass.Execute(context, commandBuffer, renderingData.cameraData.camera, renderingData.cullResults);
73-
CommandBufferPool.Release(commandBuffer);
74-
}
75-
76-
public void Cleanup()
77-
{
78-
m_LensDistortionCrossPipelinePass.Cleanup();
79-
}
80-
}
81-
829
public class GroundTruthRendererFeature : ScriptableRendererFeature
8310
{
8411
public override void Create() {}
@@ -95,7 +22,7 @@ public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingD
9522
if (!EditorApplication.isPlaying)
9623
return;
9724
#endif
98-
perceptionCamera.OnGroundTruthRendererFeatureRun();
25+
perceptionCamera.MarkGroundTruthRendererFeatureAsPresent();
9926
foreach (var pass in perceptionCamera.passes)
10027
renderer.EnqueuePass(pass);
10128
}

com.unity.perception/Runtime/GroundTruth/IGroundTruthGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
namespace UnityEngine.Perception.GroundTruth
44
{
55
/// <summary>
6-
/// Interface for setting up MeshRenderers for ground truth generation via <see cref="GroundTruthLabelSetupSystem"/>.
6+
/// Interface for setting up Renderers for ground truth generation via <see cref="LabelManager"/>.
77
/// </summary>
88
public interface IGroundTruthGenerator
99
{
1010
/// <summary>
11-
/// Called by <see cref="GroundTruthLabelSetupSystem"/> when first registered or when a Labeling is created at runtime.
11+
/// Called by <see cref="LabelManager"/> when first registered or when a Labeling is created at runtime.
1212
/// </summary>
1313
/// <param name="mpb">The MaterialPropertyBlock for the given meshRenderer. Can be used to set properties for custom rendering.</param>
1414
/// <param name="renderer">The Renderer under the given Labeling.</param>

com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBox3DLabeler.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Generic;
33
using System.Diagnostics.CodeAnalysis;
44
using Unity.Collections;
5-
using Unity.Entities;
65
using Unity.Profiling;
76

87
namespace UnityEngine.Perception.GroundTruth
@@ -14,8 +13,6 @@ namespace UnityEngine.Perception.GroundTruth
1413
/// </summary>
1514
public class BoundingBox3DLabeler : CameraLabeler
1615
{
17-
EntityQuery m_EntityQuery;
18-
1916
///<inheritdoc/>
2017
public override string description
2118
{
@@ -114,7 +111,7 @@ public BoundingBox3DLabeler() {}
114111
/// <param name="labelConfig">The label config for resolving the label for each object.</param>
115112
public BoundingBox3DLabeler(IdLabelConfig labelConfig)
116113
{
117-
this.idLabelConfig = labelConfig;
114+
idLabelConfig = labelConfig;
118115
}
119116

120117
/// <inheritdoc/>
@@ -128,8 +125,6 @@ protected override void Setup()
128125

129126
perceptionCamera.RenderedObjectInfosCalculated += OnRenderObjectInfosCalculated;
130127

131-
m_EntityQuery = World.DefaultGameObjectInjectionWorld.EntityManager.CreateEntityQuery(typeof(Labeling), typeof(GroundTruthInfo));
132-
133128
m_AsyncAnnotations = new Dictionary<int, AsyncAnnotation>();
134129
m_BoundingBoxValues = new Dictionary<int, Dictionary<uint, BoxData>>();
135130
m_ToReport = new List<BoxData>();
@@ -187,15 +182,8 @@ protected override void OnBeginRendering()
187182

188183
m_AsyncAnnotations[m_CurrentFrame] = perceptionCamera.SensorHandle.ReportAnnotationAsync(m_AnnotationDefinition);
189184

190-
var entities = m_EntityQuery.ToEntityArray(Allocator.TempJob);
191-
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
192-
193-
foreach (var entity in entities)
194-
{
195-
ProcessEntity(entityManager.GetComponentObject<Labeling>(entity));
196-
}
197-
198-
entities.Dispose();
185+
foreach (var label in LabelManager.singleton.registeredLabels)
186+
ProcessLabel(label);
199187
}
200188

201189
void OnRenderObjectInfosCalculated(int frameCount, NativeArray<RenderedObjectInfo> renderedObjectInfos)
@@ -228,7 +216,7 @@ void OnRenderObjectInfosCalculated(int frameCount, NativeArray<RenderedObjectInf
228216
}
229217
}
230218

231-
void ProcessEntity(Labeling labeledEntity)
219+
void ProcessLabel(Labeling labeledEntity)
232220
{
233221
using (s_BoundingBoxCallback.Auto())
234222
{

0 commit comments

Comments
 (0)