Blender  V2.93
bvh/bvh.h
Go to the documentation of this file.
1 /*
2  * Adapted from code copyright 2009-2010 NVIDIA Corporation
3  * Modifications Copyright 2011, Blender Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef __BVH_H__
19 #define __BVH_H__
20 
21 #include "bvh/bvh_params.h"
22 #include "util/util_array.h"
23 #include "util/util_types.h"
24 #include "util/util_vector.h"
25 
27 
28 class BoundBox;
29 class BVHNode;
30 class BVHParams;
31 class Device;
32 class DeviceScene;
33 class Geometry;
34 class LeafNode;
35 class Object;
36 class Progress;
37 class Stats;
38 
39 #define BVH_ALIGN 4096
40 #define TRI_NODE_SIZE 3
41 /* Packed BVH
42  *
43  * BVH stored as it will be used for traversal on the rendering device. */
44 
45 struct PackedBVH {
46  /* BVH nodes storage, one node is 4x int4, and contains two bounding boxes,
47  * and child, triangle or object indexes depending on the node type */
49  /* BVH leaf nodes storage. */
51  /* object index to BVH node index mapping for instances */
53  /* Mapping from primitive index to index in triangle array. */
55  /* Continuous storage of triangle vertices. */
57  /* primitive type - triangle or strand */
59  /* visibility visibilitys for primitives */
61  /* mapping from BVH primitive index to true primitive index, as primitives
62  * may be duplicated due to spatial splits. -1 for instances. */
64  /* mapping from BVH primitive index, to the object id of that primitive. */
66  /* Time range of BVH primitive. */
68 
69  /* index of the root node. */
71 
73  {
74  root_index = 0;
75  }
76 };
77 
78 /* BVH */
79 
80 class BVH {
81  public:
85 
86  static BVH *create(const BVHParams &params,
89  Device *device);
90  virtual ~BVH()
91  {
92  }
93 
94  protected:
95  BVH(const BVHParams &params,
97  const vector<Object *> &objects);
98 };
99 
101 
102 #endif /* __BVH_H__ */
Definition: bvh/bvh.h:80
virtual ~BVH()
Definition: bvh/bvh.h:90
vector< Geometry * > geometry
Definition: bvh/bvh.h:83
static BVH * create(const BVHParams &params, const vector< Geometry * > &geometry, const vector< Object * > &objects, Device *device)
Definition: bvh.cpp:85
BVH(const BVHParams &params, const vector< Geometry * > &geometry, const vector< Object * > &objects)
Definition: bvh.cpp:78
BVHParams params
Definition: bvh/bvh.h:82
vector< Object * > objects
Definition: bvh/bvh.h:84
Definition: device.h:293
#define CCL_NAMESPACE_END
array< int > prim_index
Definition: bvh/bvh.h:63
array< int > prim_type
Definition: bvh/bvh.h:58
array< int4 > nodes
Definition: bvh/bvh.h:48
array< uint > prim_visibility
Definition: bvh/bvh.h:60
array< float4 > prim_tri_verts
Definition: bvh/bvh.h:56
array< float2 > prim_time
Definition: bvh/bvh.h:67
array< int4 > leaf_nodes
Definition: bvh/bvh.h:50
PackedBVH()
Definition: bvh/bvh.h:72
array< uint > prim_tri_index
Definition: bvh/bvh.h:54
array< int > prim_object
Definition: bvh/bvh.h:65
int root_index
Definition: bvh/bvh.h:70
array< int > object_node
Definition: bvh/bvh.h:52