#include <bvhaccel.h>
Public Member Functions | |
BVHAccel (const vector< boost::shared_ptr< Primitive > > &p, int treetype, int csamples, int icost, int tcost, float ebonus) | |
virtual | ~BVHAccel () |
virtual BBox | WorldBound () const |
virtual bool | CanIntersect () const |
virtual bool | Intersect (const Ray &ray, Intersection *isect) const |
virtual bool | IntersectP (const Ray &ray) const |
virtual void | GetPrimitives (vector< boost::shared_ptr< Primitive > > &prims) |
Static Public Member Functions | |
static Aggregate * | CreateAccelerator (const vector< boost::shared_ptr< Primitive > > &prims, const ParamSet &ps) |
Private Member Functions | |
boost::shared_ptr < BVHAccelTreeNode > | BuildHierarchy (vector< boost::shared_ptr< BVHAccelTreeNode > > &list, u_int begin, u_int end, u_int axis) |
void | FindBestSplit (vector< boost::shared_ptr< BVHAccelTreeNode > > &list, u_int begin, u_int end, float *splitValue, u_int *bestAxis) |
u_int | BuildArray (boost::shared_ptr< BVHAccelTreeNode > node, u_int offset) |
Private Attributes | |
u_char | treeType |
int | costSamples |
int | isectCost |
int | traversalCost |
float | emptyBonus |
u_int | nPrims |
boost::shared_ptr< Primitive > * | prims |
u_int | nNodes |
BVHAccelArrayNode * | bvhTree |
Definition at line 45 of file bvhaccel.h.
BVHAccel::BVHAccel | ( | const vector< boost::shared_ptr< Primitive > > & | p, | |
int | treetype, | |||
int | csamples, | |||
int | icost, | |||
int | tcost, | |||
float | ebonus | |||
) |
Definition at line 43 of file bvhaccel.cpp.
References BuildArray(), BuildHierarchy(), bvhTree, CanIntersect(), lux::MachineEpsilon::E(), LUX_INFO, LUX_NOERROR, luxError, nNodes, nPrims, p, prims, and treeType.
Referenced by CreateAccelerator().
BVHAccel::~BVHAccel | ( | ) | [virtual] |
Definition at line 95 of file bvhaccel.cpp.
References bvhTree, lux::FreeAligned(), nPrims, and prims.
u_int BVHAccel::BuildArray | ( | boost::shared_ptr< BVHAccelTreeNode > | node, | |
u_int | offset | |||
) | [private] |
Definition at line 248 of file bvhaccel.cpp.
References lux::BVHAccelArrayNode::bbox, bvhTree, p, lux::BVHAccelArrayNode::primitive, and lux::BVHAccelArrayNode::skipIndex.
Referenced by BVHAccel().
boost::shared_ptr< BVHAccelTreeNode > BVHAccel::BuildHierarchy | ( | vector< boost::shared_ptr< BVHAccelTreeNode > > & | list, | |
u_int | begin, | |||
u_int | end, | |||
u_int | axis | |||
) | [private] |
Definition at line 108 of file bvhaccel.cpp.
References bvh_ltf, FindBestSplit(), cimg_library::cimg::max(), cimg_library::cimg::min(), nNodes, treeType, and lux::Union().
Referenced by BVHAccel().
virtual bool lux::BVHAccel::CanIntersect | ( | ) | const [inline, virtual] |
Returns whether this primitive can be intersected.
Reimplemented from lux::Aggregate.
Definition at line 51 of file bvhaccel.h.
Referenced by BVHAccel().
Aggregate * BVHAccel::CreateAccelerator | ( | const vector< boost::shared_ptr< Primitive > > & | prims, | |
const ParamSet & | ps | |||
) | [static] |
Definition at line 312 of file bvhaccel.cpp.
References BVHAccel(), costSamples, emptyBonus, lux::ParamSet::FindOneFloat(), lux::ParamSet::FindOneInt(), isectCost, prims, and treeType.
void BVHAccel::FindBestSplit | ( | vector< boost::shared_ptr< BVHAccelTreeNode > > & | list, | |
u_int | begin, | |||
u_int | end, | |||
float * | splitValue, | |||
u_int * | bestAxis | |||
) | [private] |
Definition at line 176 of file bvhaccel.cpp.
References costSamples, emptyBonus, isectCost, lux::BBox::pMax, lux::BBox::pMin, traversalCost, lux::Union(), lux::Point::x, lux::Vector::x, lux::Point::y, lux::Vector::y, lux::Point::z, and lux::Vector::z.
Referenced by BuildHierarchy().
void BVHAccel::GetPrimitives | ( | vector< boost::shared_ptr< Primitive > > & | prims | ) | [virtual] |
Gives all primitives in this aggregate.
prims | The destination list for the primitives. |
Implements lux::Aggregate.
Definition at line 305 of file bvhaccel.cpp.
bool BVHAccel::Intersect | ( | const Ray & | r, | |
Intersection * | in | |||
) | const [virtual] |
Intersects this primitive with the given ray. If an intersection is found, the ray will (i.e. r.tmax) and all fields in the intersection info will be updated.
r | The ray to intersect with this primitive. | |
in | The destination of the intersection information. |
Reimplemented from lux::Primitive.
Definition at line 267 of file bvhaccel.cpp.
References bvhTree, and lux::BVHAccelArrayNode::skipIndex.
bool BVHAccel::IntersectP | ( | const Ray & | r | ) | const [virtual] |
Tests for intersection of this primitive with the given ray.
r | The ray to intersect with this primitive. |
Reimplemented from lux::Primitive.
Definition at line 287 of file bvhaccel.cpp.
References bvhTree, and lux::BVHAccelArrayNode::skipIndex.
BBox BVHAccel::WorldBound | ( | ) | const [virtual] |
Returns the world bounds of this primitive.
Implements lux::Primitive.
Definition at line 263 of file bvhaccel.cpp.
References lux::BVHAccelArrayNode::bbox, and bvhTree.
BVHAccelArrayNode* lux::BVHAccel::bvhTree [private] |
Definition at line 72 of file bvhaccel.h.
Referenced by BuildArray(), BVHAccel(), Intersect(), IntersectP(), WorldBound(), and ~BVHAccel().
int lux::BVHAccel::costSamples [private] |
Definition at line 67 of file bvhaccel.h.
Referenced by CreateAccelerator(), and FindBestSplit().
float lux::BVHAccel::emptyBonus [private] |
Definition at line 68 of file bvhaccel.h.
Referenced by CreateAccelerator(), and FindBestSplit().
int lux::BVHAccel::isectCost [private] |
Definition at line 67 of file bvhaccel.h.
Referenced by CreateAccelerator(), and FindBestSplit().
u_int lux::BVHAccel::nNodes [private] |
Definition at line 71 of file bvhaccel.h.
Referenced by BuildHierarchy(), and BVHAccel().
u_int lux::BVHAccel::nPrims [private] |
Definition at line 69 of file bvhaccel.h.
Referenced by BVHAccel(), GetPrimitives(), and ~BVHAccel().
boost::shared_ptr<Primitive>* lux::BVHAccel::prims [private] |
Definition at line 70 of file bvhaccel.h.
Referenced by BVHAccel(), CreateAccelerator(), GetPrimitives(), and ~BVHAccel().
int lux::BVHAccel::traversalCost [private] |
Definition at line 67 of file bvhaccel.h.
Referenced by FindBestSplit().
u_char lux::BVHAccel::treeType [private] |
Definition at line 66 of file bvhaccel.h.
Referenced by BuildHierarchy(), BVHAccel(), and CreateAccelerator().