{"record":{"id":"e0a557ac4029cd9e","repo":"FyroxEngine/Fyrox","slug":"invalid-terrain-quad-tree-node-size","errorCode":null,"errorMessage":"Invalid Terrain quad tree node size","messagePattern":"Invalid Terrain quad tree node size","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"fyrox-impl/src/scene/terrain/quadtree.rs","lineNumber":235,"sourceCode":"            min_height,\n            max_height,\n        }\n    }\n\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);","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/FyroxEngine/Fyrox/blob/76c91aad8eca488ce527b1af707be8b3b24ad72d/fyrox-impl/src/scene/terrain/quadtree.rs#L217-L253","documentation":"Terrain quad-tree node aabb computation validates that the node's size is at least 1 on each axis; if not, it logs this error and returns a default (empty) AABB. A zero/negative node size means the quad tree was built with invalid parameters and spatial queries would be meaningless.","triggerScenarios":"Calling aabb (directly or via debug_draw/select) on a TerrainQuadTreeNode whose size.x or size.y < 1 — resulting from building the quad tree with invalid heightmap/physical size parameters.","commonSituations":"Terrain created with a heightmap smaller than valid bounds or zero physical size; corrupted saved terrain data; calling selection/debug drawing on a not-yet-built or degenerate quad tree.","solutions":["Fix terrain construction parameters so height_map_size >= 3x3 and physical_size components are positive before building the quad tree.","Reload or re-save the terrain resource if its stored quad-tree data is corrupted.","Guard debug_draw/select calls so they only run on terrains with valid, fully initialized quad trees."],"exampleFix":"// before\nlet terrain = TerrainBuilder::new()\n    .with_height_map_size(Vector2::new(1, 1)) // invalid\n    .build(...);\n\n// after\nlet terrain = TerrainBuilder::new()\n    .with_height_map_size(Vector2::new(64, 64))\n    .build(...);","handlingStrategy":"validation","validationCode":"// Validate terrain parameters before building the quad tree:\nassert!(height_map_size.x >= 3 && height_map_size.y >= 3, \"height map too small\");\nassert!(physical_size.x > 0.0 && physical_size.y > 0.0, \"physical size must be positive\");","typeGuard":"fn valid_terrain_params(hm: Vector2<u32>, phys: Vector2<f32>) -> bool {\n    hm.x >= 3 && hm.y >= 3 && phys.x > 0.0 && phys.y > 0.0\n}","tryCatchPattern":null,"preventionTips":["Always create terrains with height maps of at least 3x3 pixels and positive physical size.","Validate terrain resources loaded from disk before selection/debug drawing.","Add builder-time assertions for terrain size parameters."],"tags":["terrain","quadtree","spatial-index","invalid-parameters"],"backgroundTag":"invalid-config-value","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"}