2x Perf, because wtf *Material is useless, Material is an interface so it's already a ref
This commit is contained in:
parent
a6a3785a9f
commit
0ded879dce
4 changed files with 26 additions and 25 deletions
|
|
@ -6,8 +6,8 @@ type Sphere struct {
|
|||
material Material
|
||||
}
|
||||
|
||||
func (s Sphere) Distance(p Vector3) (float64, *Material) {
|
||||
return p.Length() - s.radius, &s.material
|
||||
func (s Sphere) Distance(p Vector3) (float64, Material) {
|
||||
return p.Length() - s.radius, s.material
|
||||
}
|
||||
|
||||
// Box
|
||||
|
|
@ -16,9 +16,9 @@ type Box struct {
|
|||
material Material
|
||||
}
|
||||
|
||||
func (s Box) Distance(p Vector3) (float64, *Material) {
|
||||
func (s Box) Distance(p Vector3) (float64, Material) {
|
||||
q := p.Abs().Sub(s.dimensions)
|
||||
return q.Max(0.0).Length() + min(max(q.X, max(q.Y, q.Z)), 0.0), &s.material
|
||||
return q.Max(0.0).Length() + min(max(q.X, max(q.Y, q.Z)), 0.0), s.material
|
||||
}
|
||||
|
||||
// Plane
|
||||
|
|
@ -27,6 +27,6 @@ type Plane struct {
|
|||
material Material
|
||||
}
|
||||
|
||||
func (s Plane) Distance(p Vector3) (float64, *Material) {
|
||||
return p.Dot(s.normal), &s.material
|
||||
func (s Plane) Distance(p Vector3) (float64, Material) {
|
||||
return p.Dot(s.normal), s.material
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue