예제 #1
0
파일: frustum.go 프로젝트: pombredanne/rand
func (ff frustum) Contains(bb gfx.Boundable) bool {
	f := math.Mat4(ff)
	b := bb.Bounds()

	// Every corner of the 3D rectangle must be in the frustum -- thus we can
	// say that if no corner is in the frustum, the rectangle is not contained.
	var inside bool
	for _, corner := range b.Corners() {
		if _, inside = f.Project(corner); !inside {
			return false
		}
	}
	return true
}
예제 #2
0
파일: frustum.go 프로젝트: pombredanne/rand
func (ff frustum) Intersects(bb gfx.Boundable) bool {
	f := math.Mat4(ff)
	b := bb.Bounds()

	// If any single corner of the 3D rectangle is in the frustum, then it is
	// intersecting.
	var inside bool
	for _, corner := range b.Corners() {
		if _, inside = f.Project(corner); inside {
			return true
		}
	}
	return false
}