#include <unsafekdtreeaccel.h>
Public Member Functions | |
UnsafeKdTreeAccel (const vector< boost::shared_ptr< Primitive > > &p, int icost, int scost, float ebonus, int maxp, int maxDepth) | |
virtual BBox | WorldBound () const |
virtual bool | CanIntersect () const |
virtual | ~UnsafeKdTreeAccel () |
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 | |
void | buildTree (int nodeNum, const BBox &bounds, const vector< BBox > &primBounds, int *primNums, int nprims, int depth, UnsafeBoundEdge *edges[3], int *prims0, int *prims1, int badRefines=0) |
Private Attributes | |
BBox | bounds |
int | isectCost |
int | traversalCost |
int | maxPrims |
float | emptyBonus |
u_int | nMailboxes |
MailboxPrim * | mailboxPrims |
int | curMailboxId |
UnsafeKdAccelNode * | nodes |
int | nAllocedNodes |
int | nextFreeNode |
MemoryArena | arena |
Definition at line 118 of file unsafekdtreeaccel.h.
UnsafeKdTreeAccel::UnsafeKdTreeAccel | ( | const vector< boost::shared_ptr< Primitive > > & | p, | |
int | icost, | |||
int | scost, | |||
float | ebonus, | |||
int | maxp, | |||
int | maxDepth | |||
) |
Definition at line 32 of file unsafekdtree.cpp.
References b, bounds, buildTree(), CanIntersect(), curMailboxId, Log2Int(), mailboxPrims, nAllocedNodes, nextFreeNode, nMailboxes, p, Round2Int(), and lux::Union().
Referenced by CreateAccelerator().
UnsafeKdTreeAccel::~UnsafeKdTreeAccel | ( | ) | [virtual] |
Definition at line 86 of file unsafekdtree.cpp.
References lux::FreeAligned(), mailboxPrims, nMailboxes, and nodes.
void UnsafeKdTreeAccel::buildTree | ( | int | nodeNum, | |
const BBox & | bounds, | |||
const vector< BBox > & | primBounds, | |||
int * | primNums, | |||
int | nprims, | |||
int | depth, | |||
UnsafeBoundEdge * | edges[3], | |||
int * | prims0, | |||
int * | prims1, | |||
int | badRefines = 0 | |||
) | [private] |
Definition at line 93 of file unsafekdtree.cpp.
References lux::UnsafeKdAccelNode::aboveChild, arena, emptyBonus, lux::UnsafeBoundEdge::END, lux::FreeAligned(), lux::UnsafeKdAccelNode::initInterior(), lux::UnsafeKdAccelNode::initLeaf(), isectCost, mailboxPrims, cimg_library::cimg::max(), maxPrims, memcpy(), nAllocedNodes, nextFreeNode, nodes, lux::BBox::pMax, lux::BBox::pMin, lux::UnsafeBoundEdge::primNum, cimg_library::sort(), lux::UnsafeBoundEdge::START, lux::UnsafeBoundEdge::t, traversalCost, lux::Vector::x, lux::Vector::y, and lux::Vector::z.
Referenced by UnsafeKdTreeAccel().
virtual bool lux::UnsafeKdTreeAccel::CanIntersect | ( | ) | const [inline, virtual] |
Returns whether this primitive can be intersected.
Reimplemented from lux::Aggregate.
Definition at line 125 of file unsafekdtreeaccel.h.
Referenced by UnsafeKdTreeAccel().
Aggregate * UnsafeKdTreeAccel::CreateAccelerator | ( | const vector< boost::shared_ptr< Primitive > > & | prims, | |
const ParamSet & | ps | |||
) | [static] |
Definition at line 400 of file unsafekdtree.cpp.
References emptyBonus, lux::ParamSet::FindOneFloat(), lux::ParamSet::FindOneInt(), isectCost, maxPrims, and UnsafeKdTreeAccel().
void UnsafeKdTreeAccel::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 393 of file unsafekdtree.cpp.
References mailboxPrims, and nMailboxes.
bool UnsafeKdTreeAccel::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 209 of file unsafekdtree.cpp.
References lux::UnsafeKdAccelNode::aboveChild, bounds, curMailboxId, lux::Ray::d, lux::BBox::IntersectP(), lux::UnsafeKdAccelNode::IsLeaf(), lux::MailboxPrim::lastMailboxId, MAX_TODO, lux::Ray::maxt, lux::KdToDo::node, nodes, lux::UnsafeKdAccelNode::nPrimitives(), lux::Ray::o, lux::UnsafeKdAccelNode::onePrimitive, lux::MailboxPrim::primitive, lux::UnsafeKdAccelNode::primitives, lux::UnsafeKdAccelNode::SplitAxis(), lux::UnsafeKdAccelNode::SplitPos(), lux::KdToDo::tmax, lux::KdToDo::tmin, lux::Vector::x, lux::Vector::y, and lux::Vector::z.
bool UnsafeKdTreeAccel::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 304 of file unsafekdtree.cpp.
References lux::UnsafeKdAccelNode::aboveChild, bounds, curMailboxId, lux::Ray::d, lux::BBox::IntersectP(), lux::UnsafeKdAccelNode::IsLeaf(), lux::MailboxPrim::lastMailboxId, MAX_TODO, lux::KdToDo::node, nodes, lux::UnsafeKdAccelNode::nPrimitives(), lux::Ray::o, lux::UnsafeKdAccelNode::onePrimitive, lux::MailboxPrim::primitive, lux::UnsafeKdAccelNode::primitives, lux::UnsafeKdAccelNode::SplitAxis(), lux::UnsafeKdAccelNode::SplitPos(), lux::KdToDo::tmax, lux::KdToDo::tmin, lux::Vector::x, lux::Vector::y, and lux::Vector::z.
virtual BBox lux::UnsafeKdTreeAccel::WorldBound | ( | ) | const [inline, virtual] |
Returns the world bounds of this primitive.
Implements lux::Primitive.
Definition at line 124 of file unsafekdtreeaccel.h.
References bounds.
MemoryArena lux::UnsafeKdTreeAccel::arena [private] |
Definition at line 150 of file unsafekdtreeaccel.h.
Referenced by buildTree().
BBox lux::UnsafeKdTreeAccel::bounds [private] |
Definition at line 141 of file unsafekdtreeaccel.h.
Referenced by Intersect(), IntersectP(), UnsafeKdTreeAccel(), and WorldBound().
int lux::UnsafeKdTreeAccel::curMailboxId [mutable, private] |
Definition at line 146 of file unsafekdtreeaccel.h.
Referenced by Intersect(), IntersectP(), and UnsafeKdTreeAccel().
float lux::UnsafeKdTreeAccel::emptyBonus [private] |
Definition at line 143 of file unsafekdtreeaccel.h.
Referenced by buildTree(), and CreateAccelerator().
int lux::UnsafeKdTreeAccel::isectCost [private] |
Definition at line 142 of file unsafekdtreeaccel.h.
Referenced by buildTree(), and CreateAccelerator().
MailboxPrim* lux::UnsafeKdTreeAccel::mailboxPrims [private] |
Definition at line 145 of file unsafekdtreeaccel.h.
Referenced by buildTree(), GetPrimitives(), UnsafeKdTreeAccel(), and ~UnsafeKdTreeAccel().
int lux::UnsafeKdTreeAccel::maxPrims [private] |
Definition at line 142 of file unsafekdtreeaccel.h.
Referenced by buildTree(), and CreateAccelerator().
int lux::UnsafeKdTreeAccel::nAllocedNodes [private] |
Definition at line 148 of file unsafekdtreeaccel.h.
Referenced by buildTree(), and UnsafeKdTreeAccel().
int lux::UnsafeKdTreeAccel::nextFreeNode [private] |
Definition at line 148 of file unsafekdtreeaccel.h.
Referenced by buildTree(), and UnsafeKdTreeAccel().
u_int lux::UnsafeKdTreeAccel::nMailboxes [private] |
Definition at line 144 of file unsafekdtreeaccel.h.
Referenced by GetPrimitives(), UnsafeKdTreeAccel(), and ~UnsafeKdTreeAccel().
UnsafeKdAccelNode* lux::UnsafeKdTreeAccel::nodes [private] |
Definition at line 147 of file unsafekdtreeaccel.h.
Referenced by buildTree(), Intersect(), IntersectP(), and ~UnsafeKdTreeAccel().
int lux::UnsafeKdTreeAccel::traversalCost [private] |
Definition at line 142 of file unsafekdtreeaccel.h.
Referenced by buildTree().