{"record":{"id":"e847a347bdfed9ce","repo":"FyroxEngine/Fyrox","slug":"invalid-terrain-height-texture-size","errorCode":null,"errorMessage":"Invalid Terrain height texture size","messagePattern":"Invalid Terrain height texture size","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"fyrox-impl/src/scene/terrain/quadtree.rs","lineNumber":239,"sourceCode":"\n    /// Construct an AABB for the node.\n    /// * transform: Transformation matrix to apply to the AABB just before it is returned.\n    /// * height_map_size: The overall size of the whole of the height map data that this node is a part of.\n    /// * physical_size: The size of the whole of the height map data in world units.\n    /// Note that the sizes of these arguments are only for the chunk of this [QuadTree].\n    /// Other chunks are not included since they have entirely separate height data.\n    pub fn aabb(\n        &self,\n        transform: &Matrix4<f32>,\n        height_map_size: Vector2<u32>,\n        physical_size: Vector2<f32>,\n    ) -> AxisAlignedBoundingBox {\n        if self.size.x < 1 || self.size.y < 1 {\n            Log::err(\"Invalid Terrain quad tree node size\");\n            return Default::default();\n        }\n        if height_map_size.x < 3 || height_map_size.y < 3 {\n            Log::err(\"Invalid Terrain height texture size\");\n            return Default::default();\n        }\n        if self.position.x < 1 || self.position.y < 1 {\n            Log::err(\"Invalid Terrain quad tree node position\");\n            return Default::default();\n        }\n        // Convert sizes from pixel sizes to mesh sizes.\n        // For calculating AABB, we do not care about the number of vertices;\n        // we care about the number of edges between vertices, which is one fewer.\n        let real_map_size = height_map_size.map(|x| x - 3);\n        // Nodes have no margins, but we still need to subtract one so we are measuring length, not counting vertices.\n        let real_node_size = self.size.map(|x| x - 1);\n        // Exclude the one-pixel margin when calculating the real position of this node.\n        let pos = self.position.map(|x| x - 1);\n        let min_x = (pos.x as f32 / real_map_size.x as f32) * physical_size.x;\n        let min_y = (pos.y as f32 / real_map_size.y as f32) * physical_size.y;\n\n        let max_x = ((pos.x + real_node_size.x) as f32 / real_map_size.x as f32) * physical_size.x;","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/FyroxEngine/Fyrox/blob/76c91aad8eca488ce527b1af707be8b3b24ad72d/fyrox-impl/src/scene/terrain/quadtree.rs#L221-L257","documentation":"Fyrox terrain quadtree construction logs this error when the height map (height texture) dimensions are smaller than 3x3 pixels. The quadtree AABB cannot be computed for such maps, so the default (empty) bounding box is returned instead. It is a guard against degenerate terrain height data.","triggerScenarios":"Calling Terrain::aabb (directly or indirectly via debug_draw or select) when the terrain's height map texture is smaller than 3 pixels in x or y.","commonSituations":"Loading a scene saved with a corrupted or placeholder height map; programmatically assigning a 1x1 or 2x2 texture as a terrain heightmap; a resource failing to load and falling back to a default minimal texture.","solutions":["Ensure the terrain's height map texture is at least 3x3 pixels before the scene is built or aabb/debug_draw/select is called.","Check that the height map resource path is correct and loads successfully (no fallback to a default small texture).","Regenerate or replace the height map if it was saved corrupted.","Inspect Log output upstream for resource-load failures that may have produced a degenerate height map."],"exampleFix":"// before\nlet heightmap = TextureResource::from_bytes(&ctx, TextureKind::Rectangle(2, 2), ...)?;\nterrain.height_map = heightmap;\n// after\nlet heightmap = TextureResource::from_bytes(&ctx, TextureKind::Rectangle(64, 64), ...)?;\nterrain.height_map = heightmap;","handlingStrategy":"validation","validationCode":"let size = terrain.height_map_ref().data_size(); // or known texture dimensions\nassert!(size.x >= 3 && size.y >= 3, \"height map must be at least 3x3 pixels\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always assign height map textures >= 3x3 pixels to terrain.","Log texture dimensions when building terrain programmatically.","Watch the Fyrox log during scene load for earlier resource errors."],"tags":["fyrox","terrain","heightmap","validation"],"backgroundTag":"value-out-of-range","analyzedSha":"76c91aad8eca488ce527b1af707be8b3b24ad72d","analyzedAt":"2026-09-10T16:04:01.633Z","contentChangedAt":"2026-09-10T16:04:01.633Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}