Skip to content

Commit

Permalink
bump ms2 package version to use corrected polygon smooth calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
soypat committed Sep 19, 2024
1 parent af073a0 commit 1777b40
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/test/glsdf3test.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ func test_stl_generation() error {
return err
}
renderStart := time.Now()
triangles, err := glrender.RenderAll(renderer)
triangles, err := glrender.RenderAll(renderer, nil)
elapsed := time.Since(renderStart)
if err != nil {
return err
Expand Down
41 changes: 41 additions & 0 deletions forge/threads/threads_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package threads

import (
"math"
"testing"

"github.com/soypat/glgl/math/ms2"
"github.com/soypat/gsdf/gleval"
)

func TestScrew(t *testing.T) {
iso := ISO{ // Negative normal.
D: 1,
P: 0.1,
Ext: true,
}
shape, err := iso.Thread()
if err != nil {
t.Fatal(err)
}
sdf, err := gleval.AssertSDF2(shape)
if err != nil {
t.Fatal(err)
}
eval := func(x, y float32) float32 {
var dist [1]float32
err = sdf.Evaluate([]ms2.Vec{{X: x, Y: y}}, dist[:], &gleval.VecPool{})
if err != nil {
t.Fatal(err)
}
return dist[0]
}
outside := eval(iso.P/2, iso.D/2)
if outside < 0 || math.IsNaN(float64(outside)) {
t.Error("expected out of SDF", outside)
}
inside := eval(iso.P/2, iso.D/3)
if inside > 0 || math.IsNaN(float64(inside)) {
t.Error("expected inside of SDF", inside)
}
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module github.com/soypat/gsdf
go 1.22.1

require (
github.com/chewxy/math32 v1.11.0
github.com/chewxy/math32 v1.11.1
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71
github.com/soypat/glgl v0.0.0-20240831170050-86f4279df7c9
github.com/soypat/glgl v0.0.0-20240919181848-3ab2abb89c6d
)

require (
Expand Down
12 changes: 4 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
github.com/chewxy/math32 v1.11.0 h1:8sek2JWqeaKkVnHa7bPVqCEOUPbARo4SGxs6toKyAOo=
github.com/chewxy/math32 v1.11.0/go.mod h1:dOB2rcuFrCn6UHrze36WSLVPKtzPMRAQvBvUwkSsLqs=
github.com/chewxy/math32 v1.11.1 h1:b7PGHlp8KjylDoU8RrcEsRuGZhJuz8haxnKfuMMRqy8=
github.com/chewxy/math32 v1.11.1/go.mod h1:dOB2rcuFrCn6UHrze36WSLVPKtzPMRAQvBvUwkSsLqs=
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71 h1:5BVwOaUSBTlVZowGO6VZGw2H/zl9nrd3eCZfYV+NfQA=
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw=
github.com/go-gl/glfw v0.0.0-20221017161538-93cebf72946b h1:2hdUMUOJuLQkhaPAwoyOeSzoaBydYEkXkBEuqDuDBfg=
github.com/go-gl/glfw v0.0.0-20221017161538-93cebf72946b/go.mod h1:wyvWpaEu9B/VQiV1jsPs7Mha9I7yto/HqIBw197ZAzk=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b h1:GgabKamyOYguHqHjSkDACcgoPIz3w0Dis/zJ1wyHHHU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/soypat/glgl v0.0.0-20240825114214-5f981c176edb h1:pcHDn+P2dG5wf0f65OVwbUl0b0auu+RsKNjWsGO2KhI=
github.com/soypat/glgl v0.0.0-20240825114214-5f981c176edb/go.mod h1:ltzeLFgrGFBm2SBy10lH5IonqEdg9IkL30yam6QHMRs=
github.com/soypat/glgl v0.0.0-20240825222736-8a9aeb4f4a8f h1:TzJXvi/Y8E96YM8ZzTk8gtD5J6EJOOras1q617qoAAQ=
github.com/soypat/glgl v0.0.0-20240825222736-8a9aeb4f4a8f/go.mod h1:ltzeLFgrGFBm2SBy10lH5IonqEdg9IkL30yam6QHMRs=
github.com/soypat/glgl v0.0.0-20240831170050-86f4279df7c9 h1:uEm1bHTWa8mY77k/VVaUcCyKn/ZtpLXMN5Xg4eCrsMw=
github.com/soypat/glgl v0.0.0-20240831170050-86f4279df7c9/go.mod h1:ltzeLFgrGFBm2SBy10lH5IonqEdg9IkL30yam6QHMRs=
github.com/soypat/glgl v0.0.0-20240919181848-3ab2abb89c6d h1:ZGFeC6bqQoyQXdYCFitm+4y1FuS1JY6zh5zzBG0OoDQ=
github.com/soypat/glgl v0.0.0-20240919181848-3ab2abb89c6d/go.mod h1:1LcEp6XHSMCI91WlJHzl/aW4Bp5v6yQOiYFyjrlk350=
golang.org/x/exp v0.0.0-20221230185412-738e83a70c30 h1:m9O6OTJ627iFnN2JIWfdqlZCzneRO6EEBsHXI25P8ws=
golang.org/x/exp v0.0.0-20221230185412-738e83a70c30/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
5 changes: 5 additions & 0 deletions gsdf2d.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ func NewPolygon(vertices []ms2.Vec) (glbuild.Shader2D, error) {
if len(vertices) < 3 {
return nil, errors.New("polygon needs at least 3 vertices")
}
for i := range vertices {
if math32.IsNaN(vertices[i].X) || math32.IsNaN(vertices[i].Y) {
return nil, errors.New("NaN value in vertices")
}
}
return &poly2D{vert: vertices}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,8 @@ func circularArray(s glbuild.Shader3D, angle float32, n int) (glbuild.Shader3D,
} else if s == nil {
return nil, errors.New("nil argument to circarray")
}
// return &circarray{s: s, n: n, angle: angle}, nil
return nil, errors.New("TODO")
return &circarray{s: s, n: n, angle: angle}, nil
}

type circarray struct {
Expand Down

0 comments on commit 1777b40

Please sign in to comment.