浏览代码

Merge branch 'master' into animation_curve_sampling

/main
Mohsen Kamalzadeh 4 年前
当前提交
e1b52e4f
共有 12 个文件被更改,包括 104 次插入17 次删除
  1. 2
      com.unity.perception/CHANGELOG.md
  2. 5
      com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs
  3. 2
      com.unity.perception/Runtime/Randomization/Randomizers/Randomizer.cs
  4. 1
      com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Randomizers/BackgroundObjectPlacementRandomizer.cs
  5. 1
      com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Randomizers/ForegroundObjectPlacementRandomizer.cs
  6. 9
      com.unity.perception/Runtime/Randomization/Randomizers/RandomizerTag.cs
  7. 5
      com.unity.perception/Runtime/Randomization/Randomizers/RandomizerTagManager.cs
  8. 22
      com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs
  9. 5
      com.unity.perception/Runtime/Unity.Perception.Runtime.asmdef
  10. 8
      com.unity.perception/Tests/Runtime/Randomization/RandomizerTests/RandomizerTagTests.cs
  11. 58
      com.unity.perception/Tests/Editor/RandomizerEditorTests.cs
  12. 3
      com.unity.perception/Tests/Editor/RandomizerEditorTests.cs.meta

2
com.unity.perception/CHANGELOG.md


Fixed memory leak or crash occurring at the end of long simulations when using BackgroundObjectPlacementRandomizer or ForegroundObjectPlacementRandomizer
Randomizer.OnCreate() is no longer called in edit-mode when adding a randomizer to a scenario
## [0.6.0-preview.1] - 2020-12-03
### Added

5
com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs


}
};
#if SIMULATION_CAPTURE_0_0_10_PREVIEW_16_OR_NEWER
CaptureCamera.Capture(cam, colorFunctor, forceFlip: ForceFlip.None);
#else
#endif
Profiler.EndSample();
}

2
com.unity.perception/Runtime/Randomization/Randomizers/Randomizer.cs


/// <summary>
/// Retrieves the RandomizerTagManager of the scenario containing this Randomizer
/// </summary>
public RandomizerTagManager tagManager => scenario.tagManager;
public RandomizerTagManager tagManager => RandomizerTagManager.singleton;
internal IEnumerable<Parameter> parameters
{

1
com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Randomizers/BackgroundObjectPlacementRandomizer.cs


GameObject m_Container;
GameObjectOneWayCache m_GameObjectOneWayCache;
/// <inheritdoc/>
protected override void OnCreate()
{
m_Container = new GameObject("BackgroundContainer");

1
com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Randomizers/ForegroundObjectPlacementRandomizer.cs


GameObject m_Container;
GameObjectOneWayCache m_GameObjectOneWayCache;
/// <inheritdoc/>
protected override void OnCreate()
{
m_Container = new GameObject("Foreground Objects");

9
com.unity.perception/Runtime/Randomization/Randomizers/RandomizerTag.cs


using System;
using UnityEngine.Experimental.Perception.Randomization.Scenarios;
namespace UnityEngine.Experimental.Perception.Randomization.Randomizers
{

[Serializable]
public abstract class RandomizerTag : MonoBehaviour
{
RandomizerTagManager tagManager => RandomizerTagManager.singleton;
ScenarioBase.activeScenario.tagManager.AddTag(GetType(), gameObject);
tagManager.AddTag(GetType(), gameObject);
var scenario = ScenarioBase.activeScenario;
if (scenario)
scenario.tagManager.RemoveTag(GetType(), gameObject);
tagManager.RemoveTag(GetType(), gameObject);
}
}
}

5
com.unity.perception/Runtime/Randomization/Randomizers/RandomizerTagManager.cs


/// </summary>
public class RandomizerTagManager
{
/// <summary>
/// Returns the singleton RandomizerTagManager instance
/// </summary>
public static RandomizerTagManager singleton { get; } = new RandomizerTagManager();
Dictionary<Type, HashSet<Type>> m_TypeTree = new Dictionary<Type, HashSet<Type>>();
Dictionary<Type, HashSet<GameObject>> m_TagMap = new Dictionary<Type, HashSet<GameObject>>();

22
com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs


using UnityEngine.Experimental.Perception.Randomization.Randomizers;
using UnityEngine.Experimental.Perception.Randomization.Samplers;
using UnityEngine.Perception.GroundTruth;
using UnityEngine.Rendering;
namespace UnityEngine.Experimental.Perception.Randomization.Scenarios
{

bool m_SkipFrame = true;
bool m_FirstScenarioFrame = true;
bool m_WaitingForFinalUploads;
RandomizerTagManager m_TagManager = new RandomizerTagManager();
IEnumerable<Randomizer> activeRandomizers
{

// ReSharper disable once InconsistentNaming
[SerializeReference] internal List<Randomizer> m_Randomizers = new List<Randomizer>();
/// <summary>
/// The RandomizerTagManager attached to this scenario
/// </summary>
public RandomizerTagManager tagManager => m_TagManager;
/// <summary>
/// Return the list of randomizers attached to this scenario

m_SkipFrame = false;
}
void OnEnable()
{
activeScenario = this;
}
void OnDisable()
{
activeScenario = null;
}
void Start()
{
var randomSeedMetricDefinition = DatasetCapture.RegisterMetricDefinition(

$"Two Randomizers of the same type ({randomizerType.Name}) cannot both be active simultaneously");
var newRandomizer = (Randomizer)Activator.CreateInstance(randomizerType);
m_Randomizers.Add(newRandomizer);
#if UNITY_EDITOR
if (Application.isPlaying)
newRandomizer.Create();
#else
#endif
return newRandomizer;
}

5
com.unity.perception/Runtime/Unity.Perception.Runtime.asmdef


"name": "com.unity.render-pipelines.universal",
"expression": "",
"define": "URP_PRESENT"
},
{
"name": "com.unity.simulation.capture",
"expression": "0.0.10-preview.16",
"define": "SIMULATION_CAPTURE_0_0_10_PREVIEW_16_OR_NEWER"
}
],
"noEngineReferences": false

8
com.unity.perception/Tests/Runtime/Randomization/RandomizerTests/RandomizerTagTests.cs


using System.Linq;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.Experimental.Perception.Randomization.Randomizers;
using UnityEngine.Experimental.Perception.Randomization.Scenarios;
using Assert = Unity.Assertions.Assert;

for (var i = 0; i < copyCount - 1; i++)
Object.Instantiate(gameObject2);
var queriedObjects = m_Scenario.tagManager.Query<ExampleTag>().ToArray();
var tagManager = RandomizerTagManager.singleton;
var queriedObjects = tagManager.Query<ExampleTag>().ToArray();
queriedObjects = m_Scenario.tagManager.Query<ExampleTag2>().ToArray();
queriedObjects = tagManager.Query<ExampleTag2>().ToArray();
queriedObjects = m_Scenario.tagManager.Query<ExampleTag>(true).ToArray();
queriedObjects = tagManager.Query<ExampleTag>(true).ToArray();
Assert.AreEqual(queriedObjects.Length, copyCount * 2);
}
}

58
com.unity.perception/Tests/Editor/RandomizerEditorTests.cs


using System;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.Experimental.Perception.Randomization.Randomizers;
using UnityEngine.Experimental.Perception.Randomization.Scenarios;
using Object = UnityEngine.Object;
namespace EditorTests
{
[TestFixture]
public class RandomizerEditorTests
{
GameObject m_TestObject;
FixedLengthScenario m_Scenario;
[SetUp]
public void Setup()
{
m_TestObject = new GameObject();
m_Scenario = m_TestObject.AddComponent<FixedLengthScenario>();
}
[TearDown]
public void TearDown()
{
Object.DestroyImmediate(m_TestObject);
}
[Test]
public void RandomizerOnCreateMethodNotCalledInEditMode()
{
// TestRandomizer.OnCreate() should NOT be called here while in edit-mode
// if ScenarioBase.CreateRandomizer<>() was coded correctly
Assert.DoesNotThrow(() =>
{
m_Scenario.CreateRandomizer<ErrorsOnCreateTestRandomizer>();
});
}
}
[Serializable]
[AddRandomizerMenu("Test Randomizers/Errors OnCreate Test Randomizer")]
class ErrorsOnCreateTestRandomizer : Randomizer
{
public GameObject testGameObject;
protected override void OnCreate()
{
// This line should throw a NullReferenceException
testGameObject.transform.position = Vector3.zero;
}
protected override void OnIterationStart()
{
testGameObject = new GameObject("Test");
}
}
}

3
com.unity.perception/Tests/Editor/RandomizerEditorTests.cs.meta


fileFormatVersion: 2
guid: 26d4a82fa0c640349e6d89fe1c536b72
timeCreated: 1610137610
正在加载...
取消
保存