stride3d/stride · error · NotSupportedException
Unknown height type.
Error message
Unknown height type.
What it means
HeightScaleCalculator.Calculate computes the height scale factor for a heightfield based on its HeightStickArraySource's height type (float, short, or byte). The switch's default branch throws NotSupportedException when the height type is not one of the known values, meaning the stored height type enum carries an out-of-range or uninitialized value.
Solutions
- Set HeightType explicitly to a supported value (Byte, Short, or Float) on the heightstick source.
- Validate the enum value before calling Calculate.
- Check for serialization/config code that resets HeightType to an invalid default.
Example fix
// before source.HeightType = (HeightType)7; // invalid, throws in Calculate // after source.HeightType = HeightType.Short; // or Byte / Float
Defensive patterns
Strategy: validation
Validate before calling
if (source.HeightType is not (HeightType.Byte or HeightType.Short or HeightType.Float))
throw new InvalidOperationException("HeightType must be Byte, Short, or Float"); Try / catch
try { var scale = HeightScaleCalculator.Calculate(source); }
catch (NotSupportedException) { /* fix HeightType value */ } Prevention
- Always set HeightType to a valid enum value
- Beware of default(HeightType) == 0 when constructing sources
- Validate enums after deserialization
When it happens
Trigger: Calling Calculate with a heightstick source whose HeightType value is not byte, short, or float — e.g. a default-initialized or corrupted enum value (like 0 if 0 is not a valid height type in this enum).
Common situations: Constructing a heightstick source without setting HeightType; serialization round-trips that zero out the enum; casting arbitrary ints into the height type enum.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- ArgumentNullException: heightStickArray
- ArgumentNullException: heightStickArray
- heightStickArray
- heightStickArray
- IndexOutOfRangeException: index
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/fe58935f6ac8ecf8.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Physics/HeightScaleCalculator.cs:35
{
case HeightfieldTypes.Float:
return 1f;
case HeightfieldTypes.Short:
return Math.Max(Math.Abs(heightRange.X), Math.Abs(heightRange.Y)) / short.MaxValue;
case HeightfieldTypes.Byte:
if (Math.Abs(heightRange.X) <= Math.Abs(heightRange.Y))
{
return heightRange.Y / byte.MaxValue;
}
else
{
return heightRange.X / byte.MaxValue;
}
default:
throw new NotSupportedException($"Unknown height type.");
}
}
}
}
View on GitHub (pinned to 96fad776d2)