bvh

package
v0.0.0-...-e791307 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2023 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// A split scoring strategy that uses the surface area heuristic (SAH).
	SurfaceAreaHeuristic = surfaceAreaHeuristic{}
)

Functions

func Build

func Build(workList []BoundedVolume, minLeafItems int, leafCb LeafCallback, scoreStrategy ScoreStrategy) []scene.BvhNode

Construct a BVH from a set of bounded volumes.

The builder uses SAH for scoring splits: score = num_polygons * node bbox face area.

The minLeafItems param should be used to specified the minimum number of items that can form a leaf. The BVH builder will automatically generate leafs if the incoming work length is <= minLeafItems.

Types

type Axis

type Axis uint8
const (
	XAxis Axis = iota
	YAxis
	ZAxis
)

type BoundedVolume

type BoundedVolume interface {
	BBox() [2]types.Vec3
	Center() types.Vec3
}

The BoundedVolume interface is implemented by all meshes/primitives that can be partitioned by the bvh builder.

type LeafCallback

type LeafCallback func(leaf *scene.BvhNode, itemList []BoundedVolume)

A callback that is called whenever the BVH builder creates a new leaf.

type ScoreStrategy

type ScoreStrategy interface {
	// Calculate a score for splitting workList at splitPoint along a particular Axis.
	ScoreSplit(workList []BoundedVolume, splitAxis Axis, splitPoint float32) (leftCount, rightCount int, score float32)

	// Calculate a score for all items in workList.
	ScorePartition(workList []BoundedVolume) (score float32)
}

A split scoring strategy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL