Inner margin for ClampLocationNavigableWorld #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR changes ClampLocationToNavigableWorld so that vector components with values greater than the max world edges are clamped to just below the max values. For instance, the vector (150, 0, 0) is clamped to (99.9999, 0, 0) instead of (100, 0, 0) in a 100 centimeter world.
This was made in response to an engine crash I experienced after using ClampLocationToNavigableWorld to clean a location value before sending it into DoN. The engine crashed because VolumeAtId uses a float-to-int comparison in order to obtain a voxel address from a floating-point location, and the clamped value rounded to invalid index "100" in a 100-voxel world, whereas the valid indices ran from 0-99.
With this in mind it seems that locations exactly along the maximum edges of a DoN world are not safe, and thus it makes sense to me that ClampLocationToNavigableWorld should clamp away from them.
Thank you for all your hard work on this plugin!