create planes.go

This commit is contained in:
Octopus Octopus 2022-06-12 11:10:29 -05:00
parent 5598da5ba9
commit d60aa042e5
1 changed files with 28 additions and 0 deletions

28
fightstick/planes.go Normal file
View File

@ -0,0 +1,28 @@
package main
import (
"github.com/deadsy/sdfx/sdf"
v2 "github.com/deadsy/sdfx/vec/v2"
)
type planes map[string]sdf.SDF2
func (p planes) add(p2 planes) {
for k, v := range p2 {
p[k] = v
}
}
func splitPlane(name string, plane sdf.SDF2) map[string]sdf.SDF2 {
planes := make(map[string]sdf.SDF2)
/* original := topPlane()
x, y := original.BoundingBox().Max.X*2, original.BoundingBox().Max.Y*2
cutout := sdf.Box2D(sdf.V2{X: x, Y: y}, 0)
cOLeft := sdf.Transform2D(cutout, sdf.Translate2d(sdf.V2{X: x / 2, Y: 0}))
cORight := sdf.Transform2D(cutout, sdf.Translate2d(sdf.V2{X: -x / 2, Y: 0}))
planes["left"] = sdf.Difference2D(original, cOLeft)
planes["right"] = sdf.Difference2D(original, cORight)*/
planes[name+" "+"right"] = sdf.Cut2D(plane, v2.Vec{X: 0, Y: 0}, v2.Vec{X: 0, Y: 1})
planes[name+" "+"left"] = sdf.Transform2D(sdf.Cut2D(sdf.Transform2D(plane, sdf.MirrorY()), v2.Vec{X: 0, Y: 0}, v2.Vec{X: 0, Y: 1}), sdf.MirrorY())
return planes
}