浏览代码

added test and fixed a couple of bugs

/main
Mohsen Kamalzadeh 4 年前
当前提交
4717b7e9
共有 4 个文件被更改,包括 15 次插入2 次删除
  1. 5
      com.unity.perception/Runtime/Randomization/Randomizers/Randomizer.cs
  2. 8
      com.unity.perception/Runtime/Randomization/Samplers/SamplerTypes/AnimationCurveSampler.cs
  3. 2
      com.unity.perception/Runtime/Randomization/Samplers/SamplerUtility.cs
  4. 2
      com.unity.perception/Tests/Runtime/Randomization/SamplerTests/SamplerTestsBase.cs

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


/// <summary>
/// OnCreate is called when the Randomizer is added or loaded to a scenario
/// </summary>
protected virtual void OnCreate() { }
protected virtual void OnCreate()
{
InitializeSamplers();
}
/// <summary>
/// OnIterationStart is called at the start of a new scenario iteration

8
com.unity.perception/Runtime/Randomization/Samplers/SamplerTypes/AnimationCurveSampler.cs


using System;
using System.Runtime.CompilerServices;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Jobs;
using UnityEngine.Experimental.Perception.Randomization.Scenarios;

[BurstCompile]
struct SampleJob : IJobParallelForBatch
{
[ReadOnly]
public NativeArray<float> integratedCurve;
public float interval;
public float startTime;

var endIndex = startIndex + count;
var batchIndex = startIndex / SamplerUtility.samplingBatchSize;
var rng = new Unity.Mathematics.Random(SamplerUtility.IterateSeed((uint)batchIndex, seed));
{
}
}
/// <summary>

2
com.unity.perception/Runtime/Randomization/Samplers/SamplerUtility.cs


var valueDifference = integratedCurve[i + 1] - integratedCurve[i];
var upperWeight = (scaledSample - integratedCurve[i]) / valueDifference;
var lowerWeight = 1 - upperWeight;
var matchingIndex = (i * lowerWeight) + (i + 1 * upperWeight);
var matchingIndex = ((i * lowerWeight) + (i + 1 * upperWeight)) / 2;
var matchingTimeStamp = startTime + matchingIndex * interval;
return matchingTimeStamp;
}

2
com.unity.perception/Tests/Runtime/Randomization/SamplerTests/SamplerTestsBase.cs


public void Setup()
{
m_Sampler = m_BaseSampler;
m_BaseSampler.Initialize();
m_ScenarioObj = new GameObject("Scenario");
m_ScenarioObj.AddComponent<FixedLengthScenario>();
}

{
m_BaseSampler.Cleanup();
Object.DestroyImmediate(m_ScenarioObj);
}

正在加载...
取消
保存