Skip to content

Commit

Permalink
Merge pull request Unity-Technologies#321 from Unity-Technologies/fix…
Browse files Browse the repository at this point in the history
…_sampler_rounding_issue

Categorical parameter fix
  • Loading branch information
mkamalza authored Jun 16, 2021
2 parents 08a58bd + f76b5d7 commit e809f13
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions com.unity.perception/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Fixed keypoint labeling bug when visualizations are disabled.

Fixed an issue where Simulation Delta Time values larger than 100 seconds (in Perception Camera) would cause incorrect capture scheduling behavior.

Fixed an issue where Categorical Parameters sometimes tried to fetch items at `i = categories.Count`, which caused an exception.

## [0.8.0-preview.3] - 2021-03-24
### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,13 @@ int BinarySearch(float key) {
public T Sample()
{
var randomValue = m_Sampler.Sample();
return uniform
? m_Categories[(int)(randomValue * m_Categories.Count)]
: m_Categories[BinarySearch(randomValue)];
if (uniform)
{
var index = (int)(randomValue * m_Categories.Count);
index = index == m_Categories.Count ? index - 1 : index;
return m_Categories[index];
}
return m_Categories[BinarySearch(randomValue)];
}

/// <summary>
Expand Down

0 comments on commit e809f13

Please sign in to comment.