Blender V5.0
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#pragma once
9
10#include "bvh/params.h"
11#include "util/array.h"
12#include "util/types.h"
13#include "util/unique_ptr.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 // NOLINT
30#define TRI_NODE_SIZE 3 // NOLINT
31
32/* Packed BVH
33 *
34 * BVH stored as it will be used for traversal on the rendering device. */
35
36struct PackedBVH {
37 /* BVH nodes storage, one node is 4x int4, and contains two bounding boxes,
38 * and child, triangle or object indexes depending on the node type */
40 /* BVH leaf nodes storage. */
42 /* object index to BVH node index mapping for instances */
44 /* primitive type - triangle or strand */
46 /* Visibility visibilities for primitives. */
48 /* mapping from BVH primitive index to true primitive index, as primitives
49 * may be duplicated due to spatial splits. -1 for instances. */
51 /* mapping from BVH primitive index, to the object id of that primitive. */
53 /* Time range of BVH primitive. */
55
56 /* index of the root node. */
58
60 {
61 root_index = 0;
62 }
63};
64
65/* BVH */
66
67class BVH {
68 public:
72
76 Device *device);
77 virtual ~BVH() = default;
78
81 {
82 this->geometry = geometry;
83 this->objects = objects;
84 }
85
86 protected:
87 BVH(const BVHParams &params,
90};
91
virtual ~BVH()=default
static unique_ptr< BVH > create(const BVHParams &params, const vector< Geometry * > &geometry, const vector< Object * > &objects, Device *device)
Definition bvh.cpp:97
vector< Geometry * > geometry
Definition bvh/bvh.h:70
virtual void replace_geometry(const vector< Geometry * > &geometry, const vector< Object * > &objects)
Definition bvh/bvh.h:79
BVH(const BVHParams &params, const vector< Geometry * > &geometry, const vector< Object * > &objects)
Definition bvh.cpp:90
BVHParams params
Definition bvh/bvh.h:69
vector< Object * > objects
Definition bvh/bvh.h:71
#define CCL_NAMESPACE_END
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
array< int > prim_index
Definition bvh/bvh.h:50
array< int > prim_type
Definition bvh/bvh.h:45
array< int4 > nodes
Definition bvh/bvh.h:39
array< uint > prim_visibility
Definition bvh/bvh.h:47
array< float2 > prim_time
Definition bvh/bvh.h:54
array< int4 > leaf_nodes
Definition bvh/bvh.h:41
PackedBVH()
Definition bvh/bvh.h:59
array< int > prim_object
Definition bvh/bvh.h:52
int root_index
Definition bvh/bvh.h:57
array< int > object_node
Definition bvh/bvh.h:43