Blender  V3.3
bvh/bvh.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Adapted from code copyright 2009-2010 NVIDIA Corporation
3  * Modifications Copyright 2011-2022 Blender Foundation. */
4 
5 #ifndef __BVH_H__
6 #define __BVH_H__
7 
8 #include "bvh/params.h"
9 #include "util/array.h"
10 #include "util/types.h"
11 #include "util/vector.h"
12 
14 
15 class BoundBox;
16 class BVHNode;
17 class BVHParams;
18 class Device;
19 class DeviceScene;
20 class Geometry;
21 class LeafNode;
22 class Object;
23 class Progress;
24 class Stats;
25 
26 #define BVH_ALIGN 4096
27 #define TRI_NODE_SIZE 3
28 /* Packed BVH
29  *
30  * BVH stored as it will be used for traversal on the rendering device. */
31 
32 struct PackedBVH {
33  /* BVH nodes storage, one node is 4x int4, and contains two bounding boxes,
34  * and child, triangle or object indexes depending on the node type */
36  /* BVH leaf nodes storage. */
38  /* object index to BVH node index mapping for instances */
40  /* primitive type - triangle or strand */
42  /* Visibility visibilities for primitives. */
44  /* mapping from BVH primitive index to true primitive index, as primitives
45  * may be duplicated due to spatial splits. -1 for instances. */
47  /* mapping from BVH primitive index, to the object id of that primitive. */
49  /* Time range of BVH primitive. */
51 
52  /* index of the root node. */
54 
56  {
57  root_index = 0;
58  }
59 };
60 
61 /* BVH */
62 
63 class BVH {
64  public:
68 
69  static BVH *create(const BVHParams &params,
72  Device *device);
73  virtual ~BVH()
74  {
75  }
76 
79  {
80  this->geometry = geometry;
81  this->objects = objects;
82  }
83 
84  protected:
85  BVH(const BVHParams &params,
87  const vector<Object *> &objects);
88 };
89 
91 
92 #endif /* __BVH_H__ */
Definition: bvh/bvh.h:63
virtual ~BVH()
Definition: bvh/bvh.h:73
vector< Geometry * > geometry
Definition: bvh/bvh.h:66
virtual void replace_geometry(const vector< Geometry * > &geometry, const vector< Object * > &objects)
Definition: bvh/bvh.h:77
static BVH * create(const BVHParams &params, const vector< Geometry * > &geometry, const vector< Object * > &objects, Device *device)
Definition: bvh.cpp:77
BVH(const BVHParams &params, const vector< Geometry * > &geometry, const vector< Object * > &objects)
Definition: bvh.cpp:70
BVHParams params
Definition: bvh/bvh.h:65
vector< Object * > objects
Definition: bvh/bvh.h:67
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
array< int > prim_index
Definition: bvh/bvh.h:46
array< int > prim_type
Definition: bvh/bvh.h:41
array< int4 > nodes
Definition: bvh/bvh.h:35
array< uint > prim_visibility
Definition: bvh/bvh.h:43
array< float2 > prim_time
Definition: bvh/bvh.h:50
array< int4 > leaf_nodes
Definition: bvh/bvh.h:37
PackedBVH()
Definition: bvh/bvh.h:55
array< int > prim_object
Definition: bvh/bvh.h:48
int root_index
Definition: bvh/bvh.h:53
array< int > object_node
Definition: bvh/bvh.h:39