spatial

package
v0.0.0-...-da3de13 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2015 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_OCTREE_DEPTH = 2
View Source
const MAX_SPHERES_PER_CONTAINER = 64

Variables

This section is empty.

Functions

This section is empty.

Types

type ObjectContainer

type ObjectContainer struct {

	// Cache-friendly list of sphere intersection data
	SphereInfos [MAX_SPHERES_PER_CONTAINER]scene.SphereIntersectionInfo

	// Less frequently accessed sphere data. This is assumed to have the
	// same length and order as SphereInfos, so that the remaining sphere
	// data corresponding to a certain intersection info can be retrieved using
	// an index into SphereInfos
	SphereRemainders []*scene.TraceableBase

	// Non-spheres (not optimized)
	Objects []*scene.Traceable
}

Back end for spatial data structures: A flat list of traceables, that allows checking against rays. When used directly as tracing Engine, you get the classic "naive ray tracing" algorithm.

func (*ObjectContainer) FindClosestObject

func (self *ObjectContainer) FindClosestObject(ray *scene.Ray) (*scene.Traceable, float32)

func (*ObjectContainer) FindOccluder

func (self *ObjectContainer) FindOccluder(ray *scene.Ray, lightDistance float32) bool

func (*ObjectContainer) Insert

func (self *ObjectContainer) Insert(object *scene.Traceable)

type Octree

type Octree struct {
	Root OctreeNode
}

A very naive and unoptimized Octree. This actually uses an AABB per node - normally you wouldn't do that, since there are Octree-specific ray intersection testing/walking algorithms. The placement heuristics are also super simple and not tweaked at all.

I'm planning to replace this with a Kd-Tree anyway

func MakeOctree

func MakeOctree(bounds scene.AABB) Octree

func (*Octree) FindClosestObject

func (self *Octree) FindClosestObject(ray *scene.Ray) (
	foundObject *scene.Traceable, distance float32,
)

func (*Octree) FindOccluder

func (self *Octree) FindOccluder(ray *scene.Ray, lightDistance float32) bool

func (*Octree) InsertObject

func (self *Octree) InsertObject(object *scene.Traceable)

type OctreeNode

type OctreeNode struct {
	Bounds   scene.AABB
	Children [8]*OctreeNode

	Objects *ObjectContainer
	// contains filtered or unexported fields
}

func MakeNode

func MakeNode(bounds scene.AABB) *OctreeNode

func (*OctreeNode) AddObject

func (self *OctreeNode) AddObject(object *scene.Traceable)

func (*OctreeNode) IsLeaf

func (self *OctreeNode) IsLeaf() bool

func (*OctreeNode) Split

func (self *OctreeNode) Split()

Jump to

Keyboard shortcuts

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