比较提交

...
此合并请求有变更与目标分支冲突。
/com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs

2 次代码提交

作者 SHA1 备注 提交日期
Mohsen Kamalzadeh 7dddeacb Merge branch 'h-i' into for_vulkan_mem_test 3 年前
Mohsen Kamalzadeh 72b7eb89 commenting things to remove the compile errors in trunk 3 年前
共有 11 个文件被更改,包括 97 次插入58 次删除
  1. 4
      com.unity.perception/Editor/GroundTruth/AddToConfigWindow.cs
  2. 4
      com.unity.perception/Editor/GroundTruth/IdLabelConfigEditor.cs
  3. 4
      com.unity.perception/Editor/GroundTruth/LabelConfigEditor.cs
  4. 8
      com.unity.perception/Editor/Randomization/VisualElements/AssetSource/AssetListElement.cs
  5. 10
      com.unity.perception/Editor/Randomization/VisualElements/Parameter/ParameterElement.cs
  6. 9
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Materials/OutlineMaterial.mat
  7. 25
      com.unity.perception/Runtime/GroundTruth/RenderPasses/CrossPipelinePasses/GroundTruthCrossPipelinePass.cs
  8. 3
      com.unity.perception/Runtime/GroundTruth/RenderPasses/CrossPipelinePasses/InstanceSegmentationCrossPipelinePass.cs
  9. 2
      com.unity.perception/Runtime/GroundTruth/RenderPasses/CrossPipelinePasses/SemanticSegmentationCrossPipelinePass.cs
  10. 66
      com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Utilities/GameObjectOneWayCache.cs
  11. 20
      com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs

4
com.unity.perception/Editor/GroundTruth/AddToConfigWindow.cs


public void RefreshLists()
{
CheckInclusionInConfigs(m_AllLabelConfigGuids, s_LabelValues.Count == 1? s_LabelValues.First() : null);
s_PresentConfigsListview.Refresh();
s_NonPresentConfigsListview.Refresh();
s_PresentConfigsListview.Rebuild();
s_NonPresentConfigsListview.Rebuild();
}
void OnEnable()
{

4
com.unity.perception/Editor/GroundTruth/IdLabelConfigEditor.cs


serializedObject.ApplyModifiedProperties();
RefreshAddedLabels();
m_LabelListView.Refresh();
m_LabelListView.Rebuild();
RefreshListViewHeight();
}
}

serializedObject.ApplyModifiedProperties();
RefreshAddedLabels();
m_LabelListView.Refresh();
m_LabelListView.Rebuild();
RefreshListViewHeight();
}
}

4
com.unity.perception/Editor/GroundTruth/LabelConfigEditor.cs


if (m_EditorHasUi && m_UiInitialized)
{
RefreshNonPresentLabels();
m_NonPresentLabelsListView.Refresh();
m_NonPresentLabelsListView.Rebuild();
m_LabelListView.Refresh();
m_LabelListView.Rebuild();
}
}

8
com.unity.perception/Editor/Randomization/VisualElements/AssetSource/AssetListElement.cs


m_Property.serializedObject.ApplyModifiedProperties();
listView.itemsSource = list;
listView.Refresh();
listView.Rebuild();
};
};

m_Property.arraySize++;
m_Property.serializedObject.ApplyModifiedProperties();
listView.itemsSource = list;
listView.Refresh();
listView.Rebuild();
listView.ScrollToItem(m_Property.arraySize);
};

m_Property.serializedObject.ApplyModifiedProperties();
listView.itemsSource = list;
listView.Refresh();
listView.Rebuild();
};
var clearOptionsButton = this.Q<Button>("clear-assets");

m_Property.serializedObject.ApplyModifiedProperties();
listView.itemsSource = list;
listView.Refresh();
listView.Rebuild();
};
}
}

10
com.unity.perception/Editor/Randomization/VisualElements/Parameter/ParameterElement.cs


m_SerializedProperty.serializedObject.ApplyModifiedProperties();
listView.itemsSource = categoricalParameter.probabilities;
listView.Refresh();
listView.Rebuild();
};
}

m_SerializedProperty.serializedObject.ApplyModifiedProperties();
listView.itemsSource = categoricalParameter.probabilities;
listView.Refresh();
listView.Rebuild();
listView.ScrollToItem(probabilitiesProperty.arraySize);
};

m_SerializedProperty.serializedObject.ApplyModifiedProperties();
listView.itemsSource = categoricalParameter.probabilities;
listView.Refresh();
listView.Rebuild();
};
else
addFolderButton.style.display = new StyleEnum<DisplayStyle>(DisplayStyle.None);

optionsProperty.arraySize = 0;
m_SerializedProperty.serializedObject.ApplyModifiedProperties();
listView.itemsSource = categoricalParameter.probabilities;
listView.Refresh();
listView.Rebuild();
};
var scrollView = listView.Q<ScrollView>();

m_SerializedProperty.serializedObject.ApplyModifiedProperties();
listView.itemsSource = categoricalParameter.probabilities;
listView.Refresh();
listView.Rebuild();
});
m_PropertiesContainer.Add(template);

9
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Materials/OutlineMaterial.mat


m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 4
version: 5
--- !u!21 &2100000
Material:
serializedVersion: 6

m_PrefabAsset: {fileID: 0}
m_Name: OutlineMaterial
m_Shader: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3}
m_ShaderKeywords:
m_ShaderKeywords: _SURFACE_TYPE_TRANSPARENT
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

disabledShaderPasses:
- SHADOWCASTER
- DepthOnly
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
- _BlendOp: 0
- _BumpScale: 1
- _Cull: 2
- _Cutoff: 0.5

- _ZWrite: 0
m_Colors:
- _BaseColor: {r: 0, g: 0.6256573, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 0, g: 0.6256573, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []

25
com.unity.perception/Runtime/GroundTruth/RenderPasses/CrossPipelinePasses/GroundTruthCrossPipelinePass.cs


using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
using UnityEngine.Rendering.RendererUtils;
namespace UnityEngine.Perception.GroundTruth
{

renderContext.ExecuteCommandBuffer(cmd);
cmd.Clear();
if (rendererList.stateBlock == null)
renderContext.DrawRenderers(
rendererList.cullingResult, ref rendererList.drawSettings, ref rendererList.filteringSettings);
else
{
var renderStateBlock = rendererList.stateBlock.Value;
renderContext.DrawRenderers(
rendererList.cullingResult,
ref rendererList.drawSettings,
ref rendererList.filteringSettings,
ref renderStateBlock);
}
// if (rendererList.stateBlock == null)
// renderContext.DrawRenderers(
// rendererList.cullingResult, ref rendererList.drawSettings, ref rendererList.filteringSettings);
// else
// {
// var renderStateBlock = rendererList.stateBlock.Value;
// renderContext.DrawRenderers(
// rendererList.cullingResult,
// ref rendererList.drawSettings,
// ref rendererList.filteringSettings,
// ref renderStateBlock);
// }
}
public abstract void SetupMaterialProperties(

3
com.unity.perception/Runtime/GroundTruth/RenderPasses/CrossPipelinePasses/InstanceSegmentationCrossPipelinePass.cs


using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
using UnityEngine.Rendering.RendererUtils;
namespace UnityEngine.Perception.GroundTruth
{

var result = CreateRendererListDesc(
camera, cullingResult, "FirstPass", 0, m_OverrideMaterial, m_LayerMask);
DrawRendererList(renderContext, cmd, RendererList.Create(result));
//DrawRendererList(renderContext, cmd, RendererList.Create(result));
}
}

2
com.unity.perception/Runtime/GroundTruth/RenderPasses/CrossPipelinePasses/SemanticSegmentationCrossPipelinePass.cs


s_LastFrameExecuted = Time.frameCount;
var renderList = CreateRendererListDesc(camera, cullingResult, "FirstPass", 0, m_OverrideMaterial, -1);
cmd.ClearRenderTarget(true, true, m_LabelConfig.skyColor);
DrawRendererList(renderContext, cmd, RendererList.Create(renderList));
//DrawRendererList(renderContext, cmd, RendererList.Create(renderList));
}
public override void SetupMaterialProperties(

66
com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Utilities/GameObjectOneWayCache.cs


{
static ProfilerMarker s_ResetAllObjectsMarker = new ProfilerMarker("ResetAllObjects");
GameObject[] m_GameObjects;
List<GameObject> m_GameObjects;
List<CachedObjectData>[] m_InstantiatedObjects;
int[] m_NumObjectsActive;
List<List<CachedObjectData>> m_InstantiatedObjects;
List<int> m_NumObjectsActive;
int NumObjectsInCache { get; set; }
/// <summary>

/// </summary>
/// <param name="parent">The parent object all cached instances will be parented under</param>
/// <param name="gameObjects">The gameObjects to cache</param>
public GameObjectOneWayCache(Transform parent, GameObject[] gameObjects)
public GameObjectOneWayCache(Transform parent, GameObject[] gameObjects = null)
if (gameObjects.Length == 0)
throw new ArgumentException(
"A non-empty array of GameObjects is required to initialize this GameObject cache");
m_GameObjects = gameObjects;
m_GameObjects = new List<GameObject>();
m_InstantiatedObjects = new List<CachedObjectData>[gameObjects.Length];
m_NumObjectsActive = new int[gameObjects.Length];
m_InstantiatedObjects = new List<List<CachedObjectData>>();
m_NumObjectsActive = new List<int>();
var index = 0;
foreach (var obj in gameObjects)
if (gameObjects != null && gameObjects.Length != 0)
if (!IsPrefab(obj))
foreach (var obj in gameObjects)
obj.transform.parent = parent;
obj.SetActive(false);
AddGameObject(obj);
var instanceId = obj.GetInstanceID();
m_InstanceIdToIndex.Add(instanceId, index);
m_InstantiatedObjects[index] = new List<CachedObjectData>();
m_NumObjectsActive[index] = 0;
++index;
/// Adds the given GameObject to the list of cached objects. An instance of the object can be immediately requested afterwards.
/// </summary>
/// <param name="gameObject"></param>
public void AddGameObject(GameObject gameObject)
{
m_GameObjects.Add(gameObject);
var index = m_InstantiatedObjects.Count;
if (!IsPrefab(gameObject))
{
gameObject.transform.parent = m_CacheParent;
gameObject.SetActive(false);
}
var instanceId = gameObject.GetInstanceID();
m_InstanceIdToIndex.Add(instanceId, index);
m_InstantiatedObjects.Add(new List<CachedObjectData>());
m_NumObjectsActive.Add(index);
}
/// <summary>
/// Retrieves an existing instance of the given gameObject from the cache if available.
/// Otherwise, instantiate a new instance of the given gameObject.
/// </summary>

public GameObject GetOrInstantiate(GameObject gameObject)
{
if (!m_InstanceIdToIndex.TryGetValue(gameObject.GetInstanceID(), out var index))
throw new ArgumentException($"GameObject {gameObject.name} (ID: {gameObject.GetInstanceID()}) is not in cache.");
{
AddGameObject(gameObject);
if (!m_InstanceIdToIndex.TryGetValue(gameObject.GetInstanceID(), out index))
Debug.LogError("Object cache is not working properly.");
}
++NumObjectsActive;
if (m_NumObjectsActive[index] < m_InstantiatedObjects[index].Count)

foreach (var tag in nextInCache.randomizerTags)
tag.Register();
var obj = nextInCache.instance;
obj.transform.localPosition = Vector3.zero;
return nextInCache.instance;
}

++m_NumObjectsActive[index];
m_InstantiatedObjects[index].Add(new CachedObjectData(newObject));
newObject.transform.localPosition = Vector3.zero;
return newObject;
}

/// <returns>A random cached GameObject</returns>
public GameObject GetOrInstantiateRandomCachedObject()
{
return GetOrInstantiate(m_GameObjects[(int)(m_Sampler.Sample() * m_GameObjects.Length)]);
return GetOrInstantiate(m_GameObjects[(int)(m_Sampler.Sample() * m_GameObjects.Count)]);
}
/// <summary>

using (s_ResetAllObjectsMarker.Auto())
{
NumObjectsActive = 0;
for (var i = 0; i < m_InstantiatedObjects.Length; ++i)
for (var i = 0; i < m_InstantiatedObjects.Count; ++i)
{
m_NumObjectsActive[i] = 0;
foreach (var cachedObjectData in m_InstantiatedObjects[i])

/// <exception cref="ArgumentException">Thrown when gameObject is not an active cached object.</exception>
public void ResetObject(GameObject gameObject)
{
for (var i = 0; i < m_InstantiatedObjects.Length; ++i)
for (var i = 0; i < m_InstantiatedObjects.Count; ++i)
{
var instantiatedObjectList = m_InstantiatedObjects[i];
int indexFound = -1;

{
// Position outside the frame
cachedObjectData.instance.transform.localPosition = new Vector3(10000, 0, 0);
cachedObjectData.instance.transform.localRotation = Quaternion.identity;
foreach (var tag in cachedObjectData.randomizerTags)
tag.Unregister();
}

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


public TextAsset configuration;
private bool m_ShouldRestartIteration;
private bool m_ShouldDelayIteration;
private const int k_MaxIterationStartCount = 100;
/// <summary>

do
{
m_ShouldRestartIteration = false;
m_ShouldDelayIteration = false;
iterationStartCount++;
foreach (var randomizer in activeRandomizers)
{

if (m_ShouldDelayIteration)
{
Debug.Log($"Iteration was delayed by {randomizer.GetType().Name}");
break;
}
if (m_ShouldDelayIteration)
break;
} while (m_ShouldRestartIteration && iterationStartCount < k_MaxIterationStartCount);
if (m_ShouldRestartIteration)

randomizer.Update();
// Iterate scenario frame count
currentIterationFrame++;
if (!m_ShouldDelayIteration)
currentIterationFrame++;
framesSinceInitialization++;
}

public void RestartIteration()
{
m_ShouldRestartIteration = true;
}
public void DelayIteration()
{
m_ShouldDelayIteration = true;
}
}
}
正在加载...
取消
保存