From fb71d50b84d7d478fa445d50da5fea83ac96b54a Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Fri, 26 Oct 2018 07:19:59 -0700 Subject: [PATCH] WIP: Fix up geometry for marching squares cells --- MetaballsKit/MarchingSquares.swift | 128 ++++++++++++++--------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/MetaballsKit/MarchingSquares.swift b/MetaballsKit/MarchingSquares.swift index 9444831..5c9830f 100644 --- a/MetaballsKit/MarchingSquares.swift +++ b/MetaballsKit/MarchingSquares.swift @@ -210,84 +210,84 @@ struct Variants { static let geometry: [Float] = [ // 0: no triangles // 1: lower left corner, 1 triangle - -1.0, -1.0, 0.0, - 0.0, -1.0, 0.0, - -1.0, 0.0, 0.0, + 0.0, 1.0, + 0.5, 1.0, + 0.0, 0.5, // 2: lower right corner, 1 triangle - 1.0, -1.0, 0.0, - 1.0, 0.0, 0.0, - 0.0, -1.0, 0.0, + 1.0, 1.0, + 0.5, 1.0, + 1.0, 0.5, // 3: bottom half, 2 triangles - -1.0, 0.0, 0.0, - -1.0, -1.0, 0.0, - 1.0, 0.0, 0.0, - 1.0, -1.0, 0.0, + 0.0, 0.5, + 0.0, 0.0, + 1.0, 0.5, + 1.0, 0.0, // 4: top right corner, 1 triangle - 1.0, 1.0, 0.0, - 0.0, 1.0, 0.0, - 1.0, 0.0, 0.0, + 1.0, 1.0, + 0.5, 1.0, + 1.0, 0.5, // 5: top right and bottom left, 4 triangles - -1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - -1.0, -1.0, 0.0, - 1.0, 1.0, 0.0, - 0.0, -1.0, 0.0, - 1.0, 0.0, 0.0, + 0.0, 0.5, + 0.5, 1.0, + 0.0, 0.0, + 1.0, 1.0, + 0.5, 0.0, + 1.0, 0.5, // 6: right half, 2 triangles - 1.0, -1.0, 0.0, - 1.0, 1.0, 0.0, - 0.0, -1.0, 0.0, - 0.0, 1.0, 0.0, + 1.0, 0.0, + 1.0, 1.0, + 0.5, 0.0, + 0.5, 1.0, // 7: bottom right corner 7/8ths, 3 triangles - -1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - -1.0, -1.0, 0.0, - 1.0, 1.0, 0.0, - 1.0, -1.0, 0.0, + 0.0, 0.5, + 0.5, 1.0, + 0.0, 0.0, + 1.0, 1.0, + 1.0, 0.0, // 8: top left corner, 1 triangle - -1.0, 1.0, 0.0, - 0.0, 1.0, 0.0, - -1.0, 0.0, 0.0, + 0.0, 1.0, + 0.5, 1.0, + 0.0, 0.5, // 9: left half, 2 triangles - -1.0, 1.0, 0.0, - 0.0, 1.0, 0.0, - -1.0, -1.0, 0.0, - 0.0, -1.0, 0.0, + 0.0, 1.0, + 0.5, 1.0, + 0.0, 0.0, + 0.5, 0.0, // 10: top left and bottom right, 4 triangles - -1.0, 0.0, 0.0, - 0.0, -1.0, 0.0, - -1.0, 1.0, 0.0, - 1.0, -1.0, 0.0, - 0.0, 1.0, 0.0, - 1.0, 0.0, 0.0, + 0.0, 0.5, + 0.5, 0.0, + 0.0, 1.0, + 1.0, 0.0, + 0.5, 1.0, + 1.0, 0.5, // 11: bottom left corner 7/8th, 3 triangles - 1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 1.0, -1.0, 0.0, - -1.0, 1.0, 0.0, - -1.0, -1.0, 0.0, + 1.0, 0.5, + 0.5, 1.0, + 1.0, 0.0, + 0.0, 1.0, + 0.0, 0.0, // 12: top half, 2 triangles - -1.0, 1.0, 0.0, - 1.0, 1.0, 0.0, - -1.0, 0.0, 0.0, - 1.0, 0.0, 0.0, + 0.0, 1.0, + 1.0, 1.0, + 0.0, 0.5, + 1.0, 0.5, // 13: top left corner 7/8ths, 3 triangles - 0.0, -1.0, 0.0, - 1.0, 0.0, 0.0, - -1.0, -1.0, 0.0, - 1.0, 1.0, 0.0, - -1.0, 1.0, 0.0, + 0.5, 0.0, + 1.0, 0.5, + 0.0, 0.0, + 1.0, 1.0, + 0.0, 1.0, // 14: top right corner 7/8th, 3 triangles - -1.0, 0.0, 0.0, - 0.0, -1.0, 0.0, - -1.0, 1.0, 0.0, - 1.0, -1.0, 0.0, - 1.0, 1.0, 0.0, + 0.0, 0.5, + 0.5, 0.0, + 0.0, 1.0, + 1.0, 0.0, + 1.0, 1.0, // 15: full, 2 triangles - -1.0, -1.0, 0.0, - 1.0, -1.0, 0.0, - -1.0, 1.0, 0.0, - 1.0, 1.0, 0.0, + 0.0, 0.0, + 1.0, 0.0, + 0.0, 1.0, + 1.0, 1.0, ] static func numberOfTriangles(for variation: UInt) -> UInt {