findCoplanarOverlaps method

List<CoplanarOverlap> findCoplanarOverlaps({
  1. Camera? camera,
})

Finds surfaces that overlap in one plane and so flicker against each other (z-fighting), from the scene's geometry, without rendering.

Compares the faces of every drawn mesh and instance (meshes that keep their CPU data, up to 20,000 triangles each) and reports pairs from different nodes or instances that face the same way and overlap by more than 0.01 m² in one plane. From a camera (the last on-screen view's, then the primary camera, when omitted), it also reports pairs whose planes sit closer than the depth buffer can separate at their distance from it, given the scene's depth settings. Pairs whose Material.depthLayer differs are left out, since the layer resolves them; pairs sharing a material are not, since vertex colors, texture coordinates, or normals can still tell their pixels apart.

Each overlap names its nodes and, for repeated pieces longer than their spacing, the fix. probeDepthConflicts finds the same fights by rendering, including ones in meshes this skips.

Implementation

List<coplanar.CoplanarOverlap> findCoplanarOverlaps({Camera? camera}) {
  final scan = _coplanarOverlapScan(camera: camera);
  scan.advance();
  return scan.result!;
}