stride3d/stride · error · ArgumentException
is too short.
Error message
{ nameof(heightRange) } is too short. What it means
After ordering, CheckHeightParameters requires the height range span (|Y - X| after dividing by scale) to be at least 1 unit; a span smaller than 1 gives Bullet a degenerate heightfield and throws ArgumentException 'heightRange is too short'.
Solutions
- Widen HeightRange so (Y - X) / HeightScale >= 1.
- Reduce HeightScale so the effective span reaches at least 1.
- Quantize/expand the data range when deriving min/max from heights.
- Pre-check with IsValid() and clamp/expand the range automatically.
Example fix
// before heightmap.HeightRange = new FloatRange(0f, 0.5f); // span < 1 // after heightmap.HeightRange = new FloatRange(0f, 1f); // span >= 1
Defensive patterns
Strategy: validation
Validate before calling
if (Math.Abs((range.Y - range.X) / scale) < 1) range = ExpandToMinimumSpan(range, scale);
Type guard
bool SpanSufficient(FloatRange r, float scale) => Math.Abs((r.Y - r.X) / scale) >= 1;
Try / catch
try { CheckHeightParameters(size, type, range, scale, true); } catch (ArgumentException) { /* widen range or reduce scale */ } Prevention
- Keep terrain height spans at least 1 unit relative to scale
- Avoid very large HeightScale values
- Auto-expand degenerate data ranges
When it happens
Trigger: Calling CheckHeightParameters with a range like (0, 0.5) and scale 1, or a large HeightScale shrinking the effective span below 1 (e.g. range span 10 with scale 100).
Common situations: Terrain with nearly flat heights and tight min/max; setting an overly large HeightScale that divides the span down below 1; auto-computed ranges from almost-uniform data.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- . should be greater than .
- parameters should be greater than or equal to 2.
- is 0.
- should be 1 in type.
- Can't handle included both of positive and negative in type.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/7b7102172588c467.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Physics/Engine/HeightmapUtils.cs:43
{
throw new ArgumentException($"{ nameof(heightScale) } is 0.");
}
if ((heightType == HeightfieldTypes.Float) && !MathUtil.IsOne(heightScale))
{
throw new ArgumentException($"{ nameof(heightScale) } should be 1 in { heightType } type.");
}
// HeightRange
if (heightRange.Y < heightRange.X)
{
throw new ArgumentException($"{ nameof(heightRange) }.{ nameof(heightRange.Y) } should be greater than { nameof(heightRange.X) }.");
}
if (Math.Abs((heightRange.Y / heightScale) - (heightRange.X / heightScale)) < 1)
{
throw new ArgumentException($"{ nameof(heightRange) } is too short.");
}
if ((heightType == HeightfieldTypes.Byte) &&
(Math.Sign(heightRange.X) + Math.Sign(heightRange.Y)) == 0)
{
throw new ArgumentException($"Can't handle { nameof(heightRange) } included both of positive and negative in { heightType } type.");
}
}
catch (ArgumentException)
{
if (throwExceptionWhenInvalid) throw;
return false;
}
return true;
}
View on GitHub (pinned to 96fad776d2)