浏览代码

Merge pull request #117 from Unity-Technologies/fixed-random-seed-from-index

Fixed GenerateRandomSeedFromIndex method
/main
GitHub 4 年前
当前提交
97f5df3f
共有 4 个文件被更改,包括 26 次插入5 次删除
  1. 4
      com.unity.perception/CHANGELOG.md
  2. 2
      com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Randomizers/BackgroundObjectPlacementRandomizer.cs
  3. 10
      com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs
  4. 15
      com.unity.perception/Tests/Runtime/Randomization/ScenarioTests.cs

4
com.unity.perception/CHANGELOG.md


Expanded all Unity Simulation references from USim to Unity Simulation
Uniform and Normal samplers now serialize their random seeds
The ScenarioBase's GenerateIterativeRandomSeed() method has been renamed to GenerateRandomSeedFromIndex()
### Deprecated
### Removed

Fixed Unity Simulation nodes generating one extra empty image before generating their share of the randomization scenario iterations
Fixed enumeration in the CategoricalParameter.categories property
The GenerateRandomSeedFromIndex method now correctly hashes the current scenario iteration into the random seed it generates
## [0.5.0-preview.1] - 2020-10-14

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


for (var i = 0; i < layerCount; i++)
{
var seed = scenario.GenerateIterativeRandomSeed(i);
var seed = scenario.GenerateRandomSeedFromIndex(i);
var placementSamples = PoissonDiskSampling.GenerateSamples(
placementArea.x, placementArea.y, separationDistance, seed);
var offset = new Vector3(placementArea.x, placementArea.y, 0f) * -0.5f;

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


}
/// <summary>
/// Generates a random seed by hashing three values together: an arbitrary iteration value,
/// the current scenario iteration, and a base random seed
/// Generates a random seed by hashing three values together: an arbitrary index value,
/// the current scenario iteration, and a base random seed. This method is useful for deterministically
/// generating random seeds from within a for-loop.
public uint GenerateIterativeRandomSeed(int iteration, uint baseSeed = SamplerUtility.largePrime)
public uint GenerateRandomSeedFromIndex(int iteration, uint baseSeed = SamplerUtility.largePrime)
return SamplerUtility.IterateSeed((uint)iteration, baseSeed);
var seed = SamplerUtility.IterateSeed((uint)iteration, baseSeed);
return SamplerUtility.IterateSeed((uint)currentIteration, seed);
}
void ValidateParameters()

15
com.unity.perception/Tests/Runtime/Randomization/ScenarioTests.cs


Assert.AreEqual(DatasetCapture.SimulationState.SequenceTime, 0);
}
[UnityTest]
public IEnumerator GeneratedRandomSeedsChangeWithScenarioIteration()
{
yield return CreateNewScenario(3, 1);
var seed = m_Scenario.GenerateRandomSeed();
var seeds = new uint[3];
for (var i = 0; i < 3; i++)
seeds[i] = m_Scenario.GenerateRandomSeedFromIndex(i);
yield return null;
Assert.AreNotEqual(seed, m_Scenario.GenerateRandomSeed());
for (var i = 0; i < 3; i++)
Assert.AreNotEqual(seeds[i], m_Scenario.GenerateRandomSeedFromIndex(i));
}
PerceptionCamera SetupPerceptionCamera()
{
m_TestObject.SetActive(false);

正在加载...
取消
保存