Skip to content

Commit

Permalink
fix smoothing in latest ms2 update; fixes screw normals
Browse files Browse the repository at this point in the history
  • Loading branch information
soypat committed Aug 16, 2024
1 parent 9421e98 commit f5ebee4
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 14 deletions.
3 changes: 1 addition & 2 deletions examples/test/glsdf3test.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ func test_bounds(sdf gleval.SDF3, scratchDist []float32, userData any) (err erro
})

var skipNormCheck bool
skipNormCheck = skipNormCheck || strings.Contains(typename, "screw")
skipNormCheck = skipNormCheck
skipNormCheck = skipNormCheck || strings.Contains(typename, "torus")
skipNormCheck = skipNormCheck || strings.Contains(typename, "smoothDiff")
if skipNormCheck {
Expand Down Expand Up @@ -617,7 +617,6 @@ func randomShell(a glbuild.Shader3D, rng *rand.Rand) glbuild.Shader3D {

halfbox, _ := gsdf.NewBox(size.X*20, size.Y/3, size.Z*20, 0)
halfbox = gsdf.Translate(halfbox, 0, size.Y/3, 0)
fmt.Println("thick", thickness, maxSize)
return gsdf.Difference(shell, halfbox)
}

Expand Down
2 changes: 1 addition & 1 deletion forge/threads/acme.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (acme Acme) Thread() (glbuild.Shader2D, error) {
poly.AddXY(-xOfs1, h)
poly.AddXY(-radius, h)
poly.AddXY(-radius, 0)
verts, err := poly.AppendVertices(nil)
verts, err := poly.AppendVecs(nil)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion forge/threads/ansibuttress.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (ansi ANSIButtress) Thread() (glbuild.Shader2D, error) {
tp.AddXY(-ansi.P, radius)
tp.AddXY(-ansi.P, 0)

verts, err := tp.AppendVertices(nil)
verts, err := tp.AppendVecs(nil)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion forge/threads/bolt.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func chamferedCylinder(s glbuild.Shader3D, kb, kt float32) (glbuild.Shader3D, er
poly.AddXY(r, -l).Chamfer(r * kb)
poly.AddXY(r, l).Chamfer(r * kt)
poly.AddXY(0, l)
verts, err := poly.AppendVertices(nil)
verts, err := poly.AppendVecs(nil)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion forge/threads/hexhead.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func HexHead(radius float32, height float32, round string) (s glbuild.Shader3D,
cornerRound := radius * 0.08
var poly ms2.PolygonBuilder
poly.Nagon(6, radius-cornerRound)
vertices, err := poly.AppendVertices(nil)
vertices, err := poly.AppendVecs(nil)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion forge/threads/iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (iso ISO) Thread() (glbuild.Shader2D, error) {
poly.AddXY(-iso.P, rMinor)
poly.AddXY(-iso.P, 0)
}
vertices, err := poly.AppendVertices(nil)
vertices, err := poly.AppendVecs(nil)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion forge/threads/knurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (k KnurlParams) Thread() (glbuild.Shader2D, error) {
knurl.AddXY(-k.Pitch/2, k.Radius)
knurl.AddXY(-k.Pitch/2, 0)
//knurl.Render("knurl.dxf")
verts, err := knurl.AppendVertices(nil)
verts, err := knurl.AppendVecs(nil)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion forge/threads/plasticbuttress.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (butt PlasticButtress) Thread() (glbuild.Shader2D, error) {
tp.AddXY((h0-h1)*t0-hp, radius).Smooth(0.15*butt.P, 5)
tp.AddXY(-butt.P, radius)
tp.AddXY(-butt.P, 0)
verts, err := tp.AppendVertices(nil)
verts, err := tp.AppendVecs(nil)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22.1
require (
github.com/chewxy/math32 v1.10.1
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71
github.com/soypat/glgl v0.0.0-20240811035753-f615f56436f0
github.com/soypat/glgl v0.0.0-20240816031826-41aea5d4ce11
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b h1:GgabKamyOY
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/soypat/glgl v0.0.0-20240811035753-f615f56436f0 h1:9CU+IDi7gSeBRWxekqmbFHLzooDZBqu7tgiuuKehJWE=
github.com/soypat/glgl v0.0.0-20240811035753-f615f56436f0/go.mod h1:jcTX7fb8Y1WYrBfHyqZtzZyXzEQaOVp/z+ngMn9IQuk=
github.com/soypat/glgl v0.0.0-20240816031826-41aea5d4ce11 h1:fM68EXUFrx6EmIQOUz6PV4X5Jnrx0FhSzrzY9h2Ut24=
github.com/soypat/glgl v0.0.0-20240816031826-41aea5d4ce11/go.mod h1:jcTX7fb8Y1WYrBfHyqZtzZyXzEQaOVp/z+ngMn9IQuk=
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=
4 changes: 0 additions & 4 deletions operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,6 @@ type shell struct {
func (u *shell) Bounds() ms3.Box {
bb := u.s.Bounds()
return bb
return ms3.Box{
Min: ms3.Sub(bb.Min, ms3.Vec{u.thick, u.thick, u.thick}),
Max: ms3.Add(bb.Max, ms3.Vec{u.thick, u.thick, u.thick}),
}
}

func (s *shell) ForEachChild(userData any, fn func(userData any, s *glbuild.Shader3D) error) error {
Expand Down

0 comments on commit f5ebee4

Please sign in to comment.