{"record":{"id":"d84e4fbb384b971a","repo":"FyroxEngine/Fyrox","slug":"invalid-terrain-quad-tree-node-position","errorCode":null,"errorMessage":"Invalid Terrain quad tree node position","messagePattern":"Invalid Terrain quad tree node position","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"fyrox-impl/src/scene/terrain/quadtree.rs","lineNumber":243,"sourceCode":"    /// * 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;\n        let max_y = ((pos.y + real_node_size.y) as f32 / real_map_size.y as f32) * physical_size.y;\n\n        let min = Vector3::new(min_x, self.min_height, min_y);\n        let max = Vector3::new(max_x, self.max_height, max_y);","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/FyroxEngine/Fyrox/blob/76c91aad8eca488ce527b1af707be8b3b24ad72d/fyrox-impl/src/scene/terrain/quadtree.rs#L225-L261","documentation":"Fyrox terrain quadtree nodes must have an integer position >= 1 on each axis; a node positioned below that is invalid and its AABB cannot be computed. The library logs this error and returns a default empty AABB instead of computing geometry.","triggerScenarios":"Calling Terrain::aabb (via debug_draw or select) when a quadtree node's position.x or position.y is less than 1 — typically from corrupted terrain data or a bad split during quadtree build.","commonSituations":"Loading a scene file whose terrain quadtree was serialized with bad node positions; custom code mutating terrain chunk layout; version changes in terrain serialization format.","solutions":["Check the terrain data in the scene file for nodes with position < 1 and fix or rebuild the terrain.","Rebuild the terrain from its height map so the quadtree is regenerated with valid positions.","Avoid directly editing quadtree node positions; use the terrain API.","Report or investigate if the corruption appears after upgrading Fyrox versions (serialization format change)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before relying on terrain.aabb(), re-generate terrain from its height map\nterrain.refresh(); // ensure quadtree is rebuilt from valid data","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not mutate quadtree node positions directly.","Rebuild terrain after editing scene data instead of patching serialized quadtree fields.","Verify scene files after Fyrox version migrations."],"tags":["fyrox","terrain","quadtree","invariant"],"backgroundTag":"internal-invariant-violation","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"}