@@ -31,7 +31,8 @@ func interpolateV1(v1, v2, t float64) float64 {
3131
3232func interpolateVerts (v1 , v2 vector3.Float64 , v1v , v2v , cutoff float64 ) vector3.Float64 {
3333 t := interpolationValueFromCutoff (v1v , v2v , cutoff )
34- return v2 .Sub (v1 ).Scale (t ).Add (v1 )
34+ // return v2.Sub(v1).Scale(t).Add(v1)
35+ return v1 .Scale (1 - t ).Add (v2 .Scale (t ))
3536}
3637
3738func lookupOrAdd (data * workingData , vert vector3.Float64 ) int {
@@ -628,17 +629,18 @@ func (d *MarchingCanvas) marchFloat1BlockPosition(
628629 lookupIndex |= 128
629630 }
630631
631- for i := 0 ; triangulation [lookupIndex ][i ] != - 1 ; i += 3 {
632+ tris := triangulation [lookupIndex ]
633+ for i := 0 ; tris [i ] != - 1 ; i += 3 {
632634 // Get indices of corner points A and B for each of the three edges
633635 // of the cube that need to be joined to form the triangle.
634- a0 := cornerIndexAFromEdge [triangulation [ lookupIndex ] [i ]]
635- b0 := cornerIndexBFromEdge [triangulation [ lookupIndex ] [i ]]
636+ a0 := cornerIndexAFromEdge [tris [i ]]
637+ b0 := cornerIndexBFromEdge [tris [i ]]
636638
637- a1 := cornerIndexAFromEdge [triangulation [ lookupIndex ] [i + 1 ]]
638- b1 := cornerIndexBFromEdge [triangulation [ lookupIndex ] [i + 1 ]]
639+ a1 := cornerIndexAFromEdge [tris [i + 1 ]]
640+ b1 := cornerIndexBFromEdge [tris [i + 1 ]]
639641
640- a2 := cornerIndexAFromEdge [triangulation [ lookupIndex ] [i + 2 ]]
641- b2 := cornerIndexBFromEdge [triangulation [ lookupIndex ] [i + 2 ]]
642+ a2 := cornerIndexAFromEdge [tris [i + 2 ]]
643+ b2 := cornerIndexBFromEdge [tris [i + 2 ]]
642644
643645 v1 := interpolateVerts (cubeCornerPositions [a0 ], cubeCornerPositions [b0 ], cubeCorners [a0 ], cubeCorners [b0 ], cutoff ).Add (offset )
644646 v2 := interpolateVerts (cubeCornerPositions [a1 ], cubeCornerPositions [b1 ], cubeCorners [a1 ], cubeCorners [b1 ], cutoff ).Add (offset )
0 commit comments