Blender V2.61 - r43446

bvh_params.h

Go to the documentation of this file.
00001 /*
00002  * Adapted from code copyright 2009-2010 NVIDIA Corporation
00003  * Modifications Copyright 2011, Blender Foundation.
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  * http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef __BVH_PARAMS_H__
00019 #define __BVH_PARAMS_H__
00020 
00021 CCL_NAMESPACE_BEGIN
00022 
00023 /* BVH Parameters */
00024 
00025 class BVHParams
00026 {
00027 public:
00028     /* spatial split area threshold */
00029     int use_spatial_split;
00030     float spatial_split_alpha;
00031 
00032     /* SAH costs */
00033     float sah_node_cost;
00034     float sah_triangle_cost;
00035 
00036     /* number of triangles in leaf */
00037     int min_leaf_size;
00038     int max_leaf_size;
00039 
00040     /* object or mesh level bvh */
00041     int top_level;
00042 
00043     /* disk cache */
00044     int use_cache;
00045 
00046     /* QBVH */
00047     int use_qbvh;
00048 
00049     int pad;
00050 
00051     /* fixed parameters */
00052     enum {
00053         MAX_DEPTH = 64,
00054         MAX_SPATIAL_DEPTH = 48,
00055         NUM_SPATIAL_BINS = 32
00056     };
00057 
00058     BVHParams()
00059     {
00060         use_spatial_split = true;
00061         spatial_split_alpha = 1e-5f;
00062 
00063         sah_node_cost = 1.0f;
00064         sah_triangle_cost = 1.0f;
00065 
00066         min_leaf_size = 1;
00067         max_leaf_size = 0x7FFFFFF;
00068 
00069         top_level = false;
00070         use_cache = false;
00071         use_qbvh = false;
00072         pad = false;
00073     }
00074 
00075     /* SAH costs */
00076     float cost(int num_nodes, int num_tris) const
00077     { return node_cost(num_nodes) + triangle_cost(num_tris); }
00078 
00079     float triangle_cost(int n) const
00080     { return n*sah_triangle_cost; }
00081 
00082     float node_cost(int n) const
00083     { return n*sah_node_cost; }
00084 };
00085 
00086 CCL_NAMESPACE_END
00087 
00088 #endif /* __BVH_PARAMS_H__ */
00089