vsg 1.1.3
VulkanSceneGraph library
Loading...
Searching...
No Matches
BuildAccelerationStructureTraversal.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2019 Thomas Hogarth
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
9The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
11THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
13</editor-fold> */
14
15#include <vsg/vk/State.h>
16
17#include <vsg/core/Object.h>
18#include <vsg/core/Visitor.h>
19
20#include <vsg/nodes/Geometry.h>
21#include <vsg/nodes/MatrixTransform.h>
22#include <vsg/nodes/VertexIndexDraw.h>
23
24#include <vsg/raytracing/AccelerationStructure.h>
25#include <vsg/raytracing/BottomLevelAccelerationStructure.h>
26#include <vsg/raytracing/TopLevelAccelerationStructure.h>
27
28namespace vsg
29{
30
32 class VSG_DECLSPEC BuildAccelerationStructureTraversal : public Visitor
33 {
34 public:
36
37 void apply(Object& object) override;
38 void apply(Transform& transform) override;
39 void apply(Geometry& geometry) override;
40 void apply(VertexIndexDraw& vid) override;
41
42 // the top level acceleration structure we are creating and adding geometry instances to as we find and create them
44
45 protected:
46 void createGeometryInstance(BottomLevelAccelerationStructure* blas);
47
48 ref_ptr<Device> _device;
49
50 MatrixStack _transformStack;
51
52 // cache blas's created for various types of draw node
53 std::map<VertexIndexDraw*, ref_ptr<BottomLevelAccelerationStructure>> _vertexIndexDrawBlasMap;
54 std::map<Geometry*, ref_ptr<BottomLevelAccelerationStructure>> _geometryBlasMap;
55 };
57
58} // namespace vsg
BottomLevelAccelerationStructure encapsulates bottom level acceleration structure.
Definition BottomLevelAccelerationStructure.h:23
BuildAccelerationStructureTraversal is a helper class for traversal of a scene graph to build require...
Definition BuildAccelerationStructureTraversal.h:33
Device encapsulates VkDevice, a logical handle to the PhysicalDevice with capabilities specified duri...
Definition Device.h:37
Definition Geometry.h:30
MatrixStack used internally by vsg::State to manage stack of projection or modelview matrices.
Definition State.h:76
Definition Object.h:60
Transform node is a pure virtual base class for positioning/scaling/rotating subgraphs.
Definition Transform.h:22
Definition VertexIndexDraw.h:25
Definition Visitor.h:172
Definition ref_ptr.h:22