Ejemplo n.º 1
0
// Takes a child node position and returns it's bounds.
func (n *Node) childBounds(pos, divisor math.Vec3) math.Rect3 {
	size := n.childSize(divisor)
	cb := math.Rect3{
		Min: pos,
		Max: pos.Add(size),
	}
	if !n.bounds.Contains(cb.Min) || !n.bounds.Contains(cb.Max) {
		fmt.Println(pos)
		fmt.Println(n.bounds)

		fmt.Println(n.bounds.Contains(cb.Min))
		fmt.Println(n.bounds.Contains(cb.Max))
		panic("not contained")
	}

	if !cb.In(n.bounds) {
		//fmt.Println("pos   ", pos)
		//fmt.Println("size  ", size)
		//fmt.Println("child ", cb)
		//fmt.Println("parent", n.bounds)
		//panic("")
	}

	return math.Rect3{
		Min: pos,
		Max: pos.Add(size),
	}
}
Ejemplo n.º 2
0
// Takes a child node position and returns it's bounds.
func (n *Node) childBounds(pos, divisor math.Vec3) math.Rect3 {
	size := n.childSize(divisor)
	return math.Rect3{
		Min: pos,
		Max: pos.Add(size),
	}
}
Ejemplo n.º 3
0
func random() gfx.Spatial {
	o := math.Vec3{
		rand.Float64() * float64(rand.Int()),
		rand.Float64() * float64(rand.Int()),
		rand.Float64() * float64(rand.Int()),
	}
	min := math.Vec3{rand.Float64(), rand.Float64(), rand.Float64()}
	max := min.Add(math.Vec3{rand.Float64(), rand.Float64(), rand.Float64()})
	min = min.Add(o)
	max = max.Add(o)
	return gfx.Bounds{min, max}
}
Ejemplo n.º 4
0
func LineVerts(start, end math.Vec3, width float64, result []gfx.Vec3) []gfx.Vec3 {
	hw := math.Vec3Zero.AddScalar(width).DivScalar(2.0)
	start = start.Sub(hw)
	end = end.Add(hw)
	return CubeVerts(start, end, result)
}