Packageflare.physics.geom
Classpublic class BVH
InheritanceBVH Inheritance Object

Defines a (bounding volume hierarchy) spatial structure to speed up calculations for triangle meshes.



Public Properties
 PropertyDefined By
  maxDepth : int = 8
[static] The maximun number of depth nodes allowed.
BVH
  maxX : Number
The maximum position along the Z-Axis in local space.
BVH
  maxY : Number
The maximum position along the Z-Axis in local space.
BVH
  maxZ : Number
The maximum position along the Z-Axis in local space.
BVH
  minX : Number
The minimum position along the X-Axis in local space.
BVH
  minY : Number
The minimum position along the Y-Axis in local space.
BVH
  minZ : Number
The minimum position along the Z-Axis in local space.
BVH
  node0 : BVH
The first leaf of this BVH node.
BVH
  node1 : BVH
The second leaf of this BVH node.
BVH
  parent : BVH
The parent BVH tree node.
BVH
  tris : Vector.<Triangle>
The triangle list contained in this node.
BVH
Public Methods
 MethodDefined By
  
BVH(parent:BVH = null)
Creates a new BVH node.
BVH
  
build(depth:int = 0):void
Builds this node and slits into new nodes recursively if necessary.
BVH
  
intersectRay(from:Vector3D, direction:Vector3D, out:Vector.<BVH>, count:int = 0, sort:Boolean = true):int
Test a ray againts the BVH.
BVH
  
intersectSphere(from:Vector3D, radius:Number, out:Vector.<BVH>, count:int = 0):int
Thest a sphere volume against the BVH tree.
BVH
  
trim():void
Recalculates the local space bounds for all the tree nodes.
BVH
Property Detail
maxDepthproperty
public static var maxDepth:int = 8

The maximun number of depth nodes allowed.

maxXproperty 
public var maxX:Number

The maximum position along the Z-Axis in local space.

maxYproperty 
public var maxY:Number

The maximum position along the Z-Axis in local space.

maxZproperty 
public var maxZ:Number

The maximum position along the Z-Axis in local space.

minXproperty 
public var minX:Number

The minimum position along the X-Axis in local space.

minYproperty 
public var minY:Number

The minimum position along the Y-Axis in local space.

minZproperty 
public var minZ:Number

The minimum position along the Z-Axis in local space.

node0property 
public var node0:BVH

The first leaf of this BVH node.

node1property 
public var node1:BVH

The second leaf of this BVH node.

parentproperty 
public var parent:BVH

The parent BVH tree node.

trisproperty 
public var tris:Vector.<Triangle>

The triangle list contained in this node.

Constructor Detail
BVH()Constructor
public function BVH(parent:BVH = null)

Creates a new BVH node.

Parameters
parent:BVH (default = null) — The parent node or null if it is the root node.
Method Detail
build()method
public function build(depth:int = 0):void

Builds this node and slits into new nodes recursively if necessary.

Parameters

depth:int (default = 0) — The current node depth.

intersectRay()method 
public function intersectRay(from:Vector3D, direction:Vector3D, out:Vector.<BVH>, count:int = 0, sort:Boolean = true):int

Test a ray againts the BVH.

Parameters

from:Vector3D — The source position of the ray.
 
direction:Vector3D — The normalized direction of the ray.
 
out:Vector.<BVH> — The output list of BVH nodes.
 
count:int (default = 0) — The first index on the output list from where to start adding the resulted nodes.
 
sort:Boolean (default = true) — Sort the result along the ray direction.

Returns
int — The current index of the output BVH vector.
intersectSphere()method 
public function intersectSphere(from:Vector3D, radius:Number, out:Vector.<BVH>, count:int = 0):int

Thest a sphere volume against the BVH tree.

Parameters

from:Vector3D — The source position of the sphere.
 
radius:Number — The radius of the sphere to test.
 
out:Vector.<BVH> — The output list of BVH nodes.
 
count:int (default = 0) — The first index on the output list from where to start adding the resulted nodes.

Returns
int — The current index of the output BVH vector.
trim()method 
public function trim():void

Recalculates the local space bounds for all the tree nodes.