{"record":{"id":"65638f183882a5dc","repo":"FyroxEngine/Fyrox","slug":"terrain-brush-operation-dropped-due-to-sanity-limi","errorCode":null,"errorMessage":"Terrain brush operation dropped due to sanity limit: {area}","messagePattern":"Terrain brush operation dropped due to sanity limit: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"fyrox-impl/src/scene/terrain/brushstroke/mod.rs","lineNumber":824,"sourceCode":"            transform: Matrix2::identity(),\n            hardness: 0.0,\n            alpha: 1.0,\n            shape: Default::default(),\n            mode: Default::default(),\n            target: Default::default(),\n        }\n    }\n}\n\n/// Verify that the brush operation is not so big that it could cause the editor to freeze.\n/// The user can type in any size of brush they please, even disastrous sizes, and\n/// this check prevents the editor from breaking.\nfn within_size_limit(bounds: &Rect<i32>) -> bool {\n    let size = bounds.size;\n    let area = size.x * size.y;\n    let accepted = area <= BRUSH_PIXEL_SANITY_LIMIT;\n    if !accepted {\n        Log::warn(format!(\n            \"Terrain brush operation dropped due to sanity limit: {area}\"\n        ))\n    }\n    accepted\n}\n\nimpl Brush {\n    /// Send the pixels for this brush to the brush thread.\n    /// - `position`: The position of the brush in texture pixels.\n    /// - `scale`: The size of each pixel in local 2D space. This is used\n    /// to convert the brush's radius from local 2D to pixels.\n    /// - `value`: The brush's value. The meaning of this number depends on the brush.\n    /// - `draw_pixel`: The function that will draw the pixels to the terrain.\n    pub fn stamp<F>(&self, position: Vector2<f32>, scale: Vector2<f32>, mut draw_pixel: F)\n    where\n        F: FnMut(Vector2<i32>, f32),\n    {\n        let mut transform = self.transform;","sourceCodeStart":806,"sourceCodeEnd":842,"githubUrl":"https://github.com/FyroxEngine/Fyrox/blob/76c91aad8eca488ce527b1af707be8b3b24ad72d/fyrox-impl/src/scene/terrain/brushstroke/mod.rs#L806-L842","documentation":"Terrain brush operations compute the affected pixel rectangle; within_size_limit rejects strokes whose affected area exceeds BRUSH_PIXEL_SANITY_LIMIT, logging this warning and dropping the operation to keep the editor responsive. It prevents pathological strokes (e.g. gigantic brush radius or extreme zoom) from stalling the brush thread.","triggerScenarios":"Performing a terrain brush stroke where the brush's affected Rect<i32> has size.x * size.y > BRUSH_PIXEL_SANITY_LIMIT — typically from a huge brush size or a camera/terrain transform that magnifies the stroke footprint.","commonSituations":"Editor users setting an enormous brush radius; degenerate camera setups painting the whole terrain at once; strokes spanning multiple chunk boundaries over a large terrain.","solutions":["Reduce the brush size/radius in the terrain editor before painting.","Zoom in or paint in smaller sections so the per-stroke affected area stays under the sanity limit.","If legitimate large-area edits are needed, apply them in multiple smaller strokes or via script rather than one giant brush stamp."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Clamp brush size before issuing strokes:\nlet max_brush = (BRUSH_PIXEL_SANITY_LIMIT as f32).sqrt() as i32;\nlet brush_size = brush_size.min(max_brush);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cap brush radius in editor UI to a sane maximum.","Split large-area terrain edits into multiple moderate strokes.","Prefer scripted bulk edits over giant brush stamps for whole-terrain changes."],"tags":["terrain","brush","editor","sanity-limit"],"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"}