~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to intern/cycles/bvh/bvh_params.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#ifndef __BVH_PARAMS_H__
19
19
#define __BVH_PARAMS_H__
20
20
 
 
21
#include "util_boundbox.h"
 
22
 
21
23
CCL_NAMESPACE_BEGIN
22
24
 
23
25
/* BVH Parameters */
73
75
        }
74
76
 
75
77
        /* SAH costs */
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); }
78
80
 
79
 
        float triangle_cost(int n) const
 
81
        __forceinline float triangle_cost(int n) const
80
82
        { return n*sah_triangle_cost; }
81
83
 
82
 
        float node_cost(int n) const
 
84
        __forceinline float node_cost(int n) const
83
85
        { return n*sah_node_cost; }
 
86
 
 
87
        __forceinline bool small_enough_for_leaf(int size, int level)
 
88
        { return (size <= min_leaf_size || level >= MAX_DEPTH); }
 
89
};
 
90
 
 
91
/* BVH Reference
 
92
 *
 
93
 * Reference to a primitive. Primitive index and object are sneakily packed
 
94
 * into BoundBox to reduce memory usage and align nicely */
 
95
 
 
96
class BVHReference
 
97
{
 
98
public:
 
99
        __forceinline BVHReference() {}
 
100
 
 
101
        __forceinline BVHReference(const BoundBox& bounds_, int prim_index_, int prim_object_, int prim_segment)
 
102
        : rbounds(bounds_)
 
103
        {
 
104
                rbounds.min.w = __int_as_float(prim_index_);
 
105
                rbounds.max.w = __int_as_float(prim_object_);
 
106
                segment = prim_segment;
 
107
        }
 
108
 
 
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; }
 
113
 
 
114
protected:
 
115
        BoundBox rbounds;
 
116
        uint segment;
 
117
};
 
118
 
 
119
/* BVH Range
 
120
 *
 
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. */
 
124
 
 
125
class BVHRange
 
126
{
 
127
public:
 
128
        __forceinline BVHRange()
 
129
        {
 
130
                rbounds.min.w = __int_as_float(0);
 
131
                rbounds.max.w = __int_as_float(0);
 
132
        }
 
133
 
 
134
        __forceinline BVHRange(const BoundBox& bounds_, int start_, int size_)
 
135
        : rbounds(bounds_)
 
136
        {
 
137
                rbounds.min.w = __int_as_float(start_);
 
138
                rbounds.max.w = __int_as_float(size_);
 
139
        }
 
140
 
 
141
        __forceinline BVHRange(const BoundBox& bounds_, const BoundBox& cbounds_, int start_, int size_)
 
142
        : rbounds(bounds_), cbounds(cbounds_)
 
143
        {
 
144
                rbounds.min.w = __int_as_float(start_);
 
145
                rbounds.max.w = __int_as_float(size_);
 
146
        }
 
147
 
 
148
        __forceinline void set_start(int start_) { rbounds.min.w = __int_as_float(start_); }
 
149
 
 
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(); }
 
155
 
 
156
protected:
 
157
        BoundBox rbounds;
 
158
        BoundBox cbounds;
 
159
};
 
160
 
 
161
/* BVH Spatial Bin */
 
162
 
 
163
struct BVHSpatialBin
 
164
{
 
165
        BoundBox bounds;
 
166
        int enter;
 
167
        int exit;
 
168
 
 
169
        __forceinline BVHSpatialBin()
 
170
        {
 
171
        }
84
172
};
85
173
 
86
174
CCL_NAMESPACE_END