{"record":{"id":"5be9c9c98c925180","repo":"bevyengine/bevy","slug":"mesh-access-error-0","errorCode":null,"errorMessage":"Mesh access error: {0}","messagePattern":"Mesh access error: (.+?)","errorType":"exception","errorClass":"MeshWindingInvertError","httpStatus":null,"severity":"error","filePath":"crates/bevy_mesh/src/index.rs","lineNumber":61,"sourceCode":"            FourIterators::Third(iter) => iter.size_hint(),\n            FourIterators::Fourth(iter) => iter.size_hint(),\n        }\n    }\n}\n\n/// An error that occurred while trying to invert the winding of a [`Mesh`](super::Mesh).\n#[derive(Debug, Error)]\npub enum MeshWindingInvertError {\n    /// This error occurs when you try to invert the winding for a mesh with [`PrimitiveTopology::PointList`](super::PrimitiveTopology::PointList).\n    #[error(\"Mesh winding inversion does not work for primitive topology `PointList`\")]\n    WrongTopology,\n\n    /// This error occurs when you try to invert the winding for a mesh with\n    /// * [`PrimitiveTopology::TriangleList`](super::PrimitiveTopology::TriangleList), but the indices are not in chunks of 3.\n    /// * [`PrimitiveTopology::LineList`](super::PrimitiveTopology::LineList), but the indices are not in chunks of 2.\n    #[error(\"Indices weren't in chunks according to topology\")]\n    AbruptIndicesEnd,\n    #[error(\"Mesh access error: {0}\")]\n    MeshAccessError(#[from] MeshAccessError),\n}\n\n/// An error that occurred while trying to extract a collection of triangles from a [`Mesh`](super::Mesh).\n#[derive(Debug, Error)]\npub enum MeshTrianglesError {\n    #[error(\"Source mesh does not have primitive topology TriangleList or TriangleStrip\")]\n    WrongTopology,\n\n    #[error(\"Source mesh position data is not Float32x3\")]\n    PositionsFormat,\n\n    #[error(\"Face index data references vertices that do not exist\")]\n    BadIndices,\n    #[error(\"mesh access error: {0}\")]\n    MeshAccessError(#[from] MeshAccessError),\n}\n","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_mesh/src/index.rs#L43-L79","documentation":"invert_winding() must mutate vertex and index data on the CPU. MeshWindingInvertError::MeshAccessError wraps a MeshAccessError raised by the mesh's extractable-data accessors: the vertex/index data was already moved to the RenderWorld because the mesh's asset_usage excludes MAIN_WORLD, so there is nothing on the CPU side to reorder.","triggerScenarios":"Calling mesh.invert_winding() after the mesh was rendered with asset_usage set to only RenderAssetUsages::RENDER_WORLD; the extraction step has already consumed the CPU-side data.","commonSituations":"Memory-saving asset_usage set to RENDER_WORLD, then a later system tries to flip winding for a mirror effect or double-sided hack; editing meshes in systems that run after the render schedule.","solutions":["Include MAIN_WORLD in asset_usage: mesh.asset_usage = RenderAssetUsages::MAIN_WORLD | RenderAssetUsages::RENDER_WORLD","Perform winding edits before the mesh is added as a render asset","Keep a CPU-side clone of the mesh data and invert the clone"],"exampleFix":"// before\nmesh.asset_usage = RenderAssetUsages::RENDER_WORLD;\n// ... after extraction:\nmesh.invert_winding()?; // Err(MeshAccessError::ExtractedToRenderWorld)\n\n// after\nmesh.asset_usage = RenderAssetUsages::MAIN_WORLD | RenderAssetUsages::RENDER_WORLD;\nmesh.invert_winding()?; // data still available on the CPU","handlingStrategy":"validation","validationCode":"fn mesh_editable_on_cpu(mesh: &Mesh) -> bool {\n    mesh.asset_usage.contains(RenderAssetUsages::MAIN_WORLD)\n}\n\nif mesh_editable_on_cpu(&mesh) {\n    mesh.invert_winding()?;\n}","typeGuard":null,"tryCatchPattern":"match mesh.invert_winding() {\n    Ok(()) => {}\n    Err(MeshWindingInvertError::MeshAccessError(\n        MeshAccessError::ExtractedToRenderWorld,\n    )) => { /* re-insert data or edit a CPU-side clone instead */ }\n    Err(other) => { /* topology / index errors */ }\n}","preventionTips":["Keep MAIN_WORLD in asset_usage for any mesh you mutate after upload","Do winding edits before adding the mesh to Assets<Mesh>","Retain a CPU copy of geometry for meshes that need runtime modification"],"tags":["bevy","bevy-mesh","rust","mesh","asset-usage","render-world","winding"],"backgroundTag":"mesh-data-extracted","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}