stride3d/stride · error · ArgumentException
should be 1 in type.
Error message
{ nameof(heightScale) } should be 1 in { heightType } type. What it means
For HeightfieldTypes.Float heightfields, Stride requires HeightScale to be exactly 1, because float height data already stores absolute values and Bullet's float heightfield has no scaling step. CheckHeightParameters throws ArgumentException when type is Float and scale != 1.
Solutions
- Set HeightScale = 1 for Float heightmaps.
- Bake the desired scaling into the float height values themselves.
- Switch HeightType to Short/Byte if you need a non-1 scale.
- Run IsValid() first and surface a clear message to users.
Example fix
// before heightmap.HeightType = HeightfieldTypes.Float; heightmap.HeightScale = 2.0f; // after heightmap.HeightType = HeightfieldTypes.Float; heightmap.HeightScale = 1.0f; // scale must be 1 for Float
Defensive patterns
Strategy: validation
Validate before calling
if (heightType == HeightfieldTypes.Float) heightScale = 1f;
Type guard
bool ValidFloatScale(HeightfieldTypes t, float s) => t != HeightfieldTypes.Float || MathUtil.IsOne(s);
Try / catch
try { CheckHeightParameters(size, type, range, scale, true); } catch (ArgumentException) { /* force scale=1 or change type */ } Prevention
- Reset HeightScale to 1 whenever HeightType changes to Float
- Bake scaling into float data instead
- Test heightmap config changes in CI
When it happens
Trigger: Calling CheckHeightParameters (or creating a collider) on a Float-type heightmap whose HeightScale is 0.5, 2, or any value other than 1.
Common situations: Changing a heightmap's HeightType from Short/Byte (which use scale) to Float while keeping the old scale; authoring float terrains exported from tools with a baked scale factor.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Can't handle included both of positive and negative in type.
- parameters should be greater than or equal to 2.
- is 0.
- . should be greater than .
- is too short.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/acbbfadd8ec5a269.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Physics/Engine/HeightmapUtils.cs:31
try
{
// Size
if (size.X < HeightfieldColliderShape.MinimumHeightStickWidth || size.Y < HeightfieldColliderShape.MinimumHeightStickLength)
{
throw new ArgumentException($"{ nameof(size) } parameters should be greater than or equal to 2.");
}
// HeightScale
if (MathUtil.IsZero(heightScale))
{
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.");View on GitHub (pinned to 96fad776d2)