{"record":{"id":"81b19c95d1f30ecc","repo":"bevyengine/bevy","slug":"mesh-winding-inversion-does-not-work-for-primitive","errorCode":null,"errorMessage":"Mesh winding inversion does not work for primitive topology `PointList`","messagePattern":"Mesh winding inversion does not work for primitive topology `PointList`","errorType":"exception","errorClass":"MeshWindingInvertError","httpStatus":null,"severity":"error","filePath":"crates/bevy_mesh/src/index.rs","lineNumber":53,"sourceCode":"            FourIterators::Fourth(iter) => iter.next(),\n        }\n    }\n\n    fn size_hint(&self) -> (usize, Option<usize>) {\n        match self {\n            FourIterators::First(iter) => iter.size_hint(),\n            FourIterators::Second(iter) => iter.size_hint(),\n            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\")]","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_mesh/src/index.rs#L35-L71","documentation":"Mesh::invert_winding() (crates/bevy_mesh/src/mesh.rs:1560) swaps vertices inside each face to flip triangle or line orientation. PointList meshes have no faces or edges to reorder, so the operation is rejected up front with MeshWindingInvertError::WrongTopology.","triggerScenarios":"mesh.invert_winding() on a mesh whose primitive_topology() is PrimitiveTopology::PointList (particles, point clouds, meshes built for gl_Point rendering).","commonSituations":"Generic flip-normals utilities applied to every mesh in an Assets<Mesh> collection; point-cloud assets routed through the same pipeline as triangle meshes; mesh-import code that defaults to PointList for unknown formats.","solutions":["Skip inversion for PointList meshes: they have no winding to flip","Gate on topology and only call invert_winding for TriangleList, TriangleStrip, LineList and LineStrip","If triangles were expected, fix the mesh construction that set PointList topology"],"exampleFix":"// before\nmesh.invert_winding()?; // Err(WrongTopology) on point lists\n\n// after\nif !matches!(mesh.primitive_topology(), PrimitiveTopology::PointList) {\n    mesh.invert_winding()?;\n}","handlingStrategy":"validation","validationCode":"fn can_invert_winding(mesh: &Mesh) -> bool {\n    !matches!(mesh.primitive_topology(), PrimitiveTopology::PointList)\n}\n\nif can_invert_winding(&mesh) {\n    mesh.invert_winding()?;\n}","typeGuard":null,"tryCatchPattern":"if let Err(MeshWindingInvertError::WrongTopology) = mesh.invert_winding() {\n    // point list: nothing to invert, continue\n}","preventionTips":["Gate mesh-mutation utilities on primitive_topology()","Keep point/line meshes out of triangle-oriented pipelines","Assert expected topology at asset load time, not deep inside render code"],"tags":["bevy","bevy-mesh","rust","mesh","topology","winding"],"backgroundTag":"mesh-topology-mismatch","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"}