{"record":{"id":"fe58935f6ac8ecf8","repo":"stride3d/stride","slug":"unknown-height-type","errorCode":null,"errorMessage":"Unknown height type.","messagePattern":"Unknown height type\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Physics/HeightScaleCalculator.cs","lineNumber":35,"sourceCode":"            {\n                case HeightfieldTypes.Float:\n                    return 1f;\n\n                case HeightfieldTypes.Short:\n                    return Math.Max(Math.Abs(heightRange.X), Math.Abs(heightRange.Y)) / short.MaxValue;\n\n                case HeightfieldTypes.Byte:\n                    if (Math.Abs(heightRange.X) <= Math.Abs(heightRange.Y))\n                    {\n                        return heightRange.Y / byte.MaxValue;\n                    }\n                    else\n                    {\n                        return heightRange.X / byte.MaxValue;\n                    }\n\n                default:\n                    throw new NotSupportedException($\"Unknown height type.\");\n            }\n        }\n    }\n}\n","sourceCodeStart":17,"sourceCodeEnd":40,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Physics/HeightScaleCalculator.cs#L17-L40","documentation":"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.","triggerScenarios":"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).","commonSituations":"Constructing a heightstick source without setting HeightType; serialization round-trips that zero out the enum; casting arbitrary ints into the height type enum.","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."],"exampleFix":"// before\nsource.HeightType = (HeightType)7; // invalid, throws in Calculate\n// after\nsource.HeightType = HeightType.Short; // or Byte / Float","handlingStrategy":"validation","validationCode":"if (source.HeightType is not (HeightType.Byte or HeightType.Short or HeightType.Float))\n    throw new InvalidOperationException(\"HeightType must be Byte, Short, or Float\");","typeGuard":null,"tryCatchPattern":"try { var scale = HeightScaleCalculator.Calculate(source); }\ncatch (NotSupportedException) { /* fix HeightType value */ }","preventionTips":["Always set HeightType to a valid enum value","Beware of default(HeightType) == 0 when constructing sources","Validate enums after deserialization"],"tags":["physics","heightfield","invalid-enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}