Skip to content

Commit 40fbbf9

Browse files
mkamalzaaryan-mann
authored andcommitted
Merge pull request #321 from Unity-Technologies/fix_sampler_rounding_issue
Categorical parameter fix
1 parent f254414 commit 40fbbf9

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

com.unity.perception/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ Upgraded capture package dependency to 0.0.10-preview.22 to fix an issue with UR
3131
### Fixed
3232
Fixed keypoint labeling bug when visualizations are disabled.
3333

34+
Fixed an issue where Simulation Delta Time values larger than 100 seconds (in Perception Camera) would cause incorrect capture scheduling behavior.
35+
36+
Fixed an issue where Categorical Parameters sometimes tried to fetch items at `i = categories.Count`, which caused an exception.
37+
3438
## [0.8.0-preview.3] - 2021-03-24
3539
### Changed
3640

com.unity.perception/Runtime/Randomization/Parameters/CategoricalParameter.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,13 @@ int BinarySearch(float key) {
175175
public T Sample()
176176
{
177177
var randomValue = m_Sampler.Sample();
178-
return uniform
179-
? m_Categories[(int)(randomValue * m_Categories.Count)]
180-
: m_Categories[BinarySearch(randomValue)];
178+
if (uniform)
179+
{
180+
var index = (int)(randomValue * m_Categories.Count);
181+
index = index == m_Categories.Count ? index - 1 : index;
182+
return m_Categories[index];
183+
}
184+
return m_Categories[BinarySearch(randomValue)];
181185
}
182186

183187
/// <summary>

0 commit comments

Comments
 (0)