76
float cost(int num_nodes, int num_tris) const
78
__forceinline float cost(int num_nodes, int num_tris) const
77
79
{ return node_cost(num_nodes) + triangle_cost(num_tris); }
79
float triangle_cost(int n) const
81
__forceinline float triangle_cost(int n) const
80
82
{ return n*sah_triangle_cost; }
82
float node_cost(int n) const
84
__forceinline float node_cost(int n) const
83
85
{ return n*sah_node_cost; }
87
__forceinline bool small_enough_for_leaf(int size, int level)
88
{ return (size <= min_leaf_size || level >= MAX_DEPTH); }
93
* Reference to a primitive. Primitive index and object are sneakily packed
94
* into BoundBox to reduce memory usage and align nicely */
99
__forceinline BVHReference() {}
101
__forceinline BVHReference(const BoundBox& bounds_, int prim_index_, int prim_object_, int prim_segment)
104
rbounds.min.w = __int_as_float(prim_index_);
105
rbounds.max.w = __int_as_float(prim_object_);
106
segment = prim_segment;
109
__forceinline const BoundBox& bounds() const { return rbounds; }
110
__forceinline int prim_index() const { return __float_as_int(rbounds.min.w); }
111
__forceinline int prim_object() const { return __float_as_int(rbounds.max.w); }
112
__forceinline int prim_segment() const { return segment; }
121
* Build range used during construction, to indicate the bounds and place in
122
* the reference array of a subset of pirmitives Again uses trickery to pack
123
* integers into BoundBox for alignment purposes. */
128
__forceinline BVHRange()
130
rbounds.min.w = __int_as_float(0);
131
rbounds.max.w = __int_as_float(0);
134
__forceinline BVHRange(const BoundBox& bounds_, int start_, int size_)
137
rbounds.min.w = __int_as_float(start_);
138
rbounds.max.w = __int_as_float(size_);
141
__forceinline BVHRange(const BoundBox& bounds_, const BoundBox& cbounds_, int start_, int size_)
142
: rbounds(bounds_), cbounds(cbounds_)
144
rbounds.min.w = __int_as_float(start_);
145
rbounds.max.w = __int_as_float(size_);
148
__forceinline void set_start(int start_) { rbounds.min.w = __int_as_float(start_); }
150
__forceinline const BoundBox& bounds() const { return rbounds; }
151
__forceinline const BoundBox& cent_bounds() const { return cbounds; }
152
__forceinline int start() const { return __float_as_int(rbounds.min.w); }
153
__forceinline int size() const { return __float_as_int(rbounds.max.w); }
154
__forceinline int end() const { return start() + size(); }
161
/* BVH Spatial Bin */
169
__forceinline BVHSpatialBin()