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