Problem
Mesh primitives created using geometry nodes uses loops to create vertices and accumulates positions/angles in FP variables. This allows FP rounding errors to accumulate and can introduce significant errors.
Solution
To minimize changes from original implementation, variables allowing errors to accumulate are replaced by: delta * index.
Affected 'Mesh Primitives' nodes: Line, Grid, Cylinder, Circle, Cone, UV-Sphere.
Limitations
It is possible to further improve precision in the generated vertex coordinates. However this patch is only concerned with resolving the bug in the current algorithms. Example of further improvements is available in T87779 and the attempted fix rB5946352ae2c.
The issue only significant for large number of vertices, this also implies that performance is not affected (vertex count is small) or performance is affected but accuracy is improved (vertex count is large).
Related issues
Test
A test file to reproduce the issues are available in the file below. Objects are placed at an offset of 10k and uses ~20k verts at which errors are visible (see below). Results may vary depending on the compiler/system.
Basic sys to produce test results:
Operating system: Windows 10
Blender version: 3.0.0 hash: c18d91918fbb, master, 2021-08-04
Node setup:
master
Errors are clearly visible in encircled areas, circular primitives create overlapping geometry (this will occur for large vertex counts even if radius is small), and the grid/line primitive does not reach their intended size.
solution
Overlapping geometry is no longer visible and grid/line primitive reach their intended size. However, the grid/line only does not match the intended size exactly and circle primitives are not perfectly symmetric due to FP rounding errors (i.e. algorithms can be improved further).


