vsg: include/vsg/utils/Intersector.h Source File

vsg 1.1.13 VulkanSceneGraph library

Loading...
Searching...
No Matches
Intersector.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2020 Robert Osfield
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/nodes/Node.h>
16#include <vsg/state/ArrayState.h>
17
18namespace vsg
19{
20
23 class VSG_DECLSPEC Intersector : public Inherit<ConstVisitor, Intersector>
24 {
25 public:
26 using NodePath = std::vector<const Node*>;
27 using ArrayStateStack = std::vector<ref_ptr<ArrayState>>;
28
29 Intersector(ref_ptr<ArrayState> initialArrayState = {});
30
31 //
32 // handle traverse of the scene graph
33 //
34 void apply(const Node& node) override;
35 void apply(const StateGroup& stategroup) override;
36 void apply(const Transform& transform) override;
37 void apply(const LOD& lod) override;
38 void apply(const PagedLOD& plod) override;
39 void apply(const CullNode& cn) override;
40 void apply(const CullGroup& cn) override;
41 void apply(const DepthSorted& cn) override;
42
43 void apply(const VertexDraw& vid) override;
44 void apply(const VertexIndexDraw& vid) override;
45 void apply(const Geometry& geometry) override;
46
47 void apply(const BindVertexBuffers& bvb) override;
48 void apply(const BindIndexBuffer& bib) override;
49 void apply(const Draw& draw) override;
50 void apply(const DrawIndexed& drawIndexed) override;
51
52 void apply(const BufferInfo& bufferInfo) override;
53 void apply(const ubyteArray& array) override;
54 void apply(const ushortArray& array) override;
55 void apply(const uintArray& array) override;
56
57 void apply(const TextTechnique& technique) override;
58
59 //
60 // provide virtual functions for concrete Intersector implementations to provide handling of intersection with mesh geometries
61 //
62
64 virtual void pushTransform(const Transform& transform) = 0;
65
66 virtual void popTransform() = 0;
67
69 virtual bool intersects(const dsphere& sphere) = 0;
70
72 virtual bool intersectDraw(uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount) = 0;
73
75 virtual bool intersectDrawIndexed(uint32_t firstIndex, uint32_t indexCount, uint32_t firstInstance, uint32_t instanceCount) = 0;
76
78 std::vector<dmat4>& localToWorldStack() { return arrayStateStack.back()->localToWorldStack; }
79
81 std::vector<dmat4>& worldToLocalStack() { return arrayStateStack.back()->worldToLocalStack; }
82
83 protected:
84 ArrayStateStack arrayStateStack;
85
86 ref_ptr<const ubyteArray> ubyte_indices;
87 ref_ptr<const ushortArray> ushort_indices;
88 ref_ptr<const uintArray> uint_indices;
89
90 NodePath _nodePath;
91 };
92 VSG_type_name(vsg::Intersector);
93
94} // namespace vsg
vsg::BindIndexBuffer
BindIndexBuffer command encapsulates vkCmdBindIndexBuffer call and associated settings.
Definition BindIndexBuffer.h:28
vsg::BindVertexBuffers
BindVertexBuffers command encapsulates vkCmdBindVertexBuffers call and associated settings.
Definition BindVertexBuffers.h:25
vsg::BufferInfo
BufferInfo encapsulates the settings that map to VkDescriptorBufferInfo.
Definition BufferInfo.h:27
vsg::CullGroup
CullNode that enables view frustum culling on a list of children.
Definition CullGroup.h:23
vsg::CullNode
Definition CullNode.h:25
vsg::DepthSorted
Definition DepthSorted.h:27
vsg::Draw
Draw command encapsulates vkCmdDraw call and associated settings.
Definition Draw.h:24
vsg::DrawIndexed
DrawIndexed command encapsulates vkCmdDrawIndexed call and associated settings.
Definition DrawIndexed.h:24
vsg::Geometry
Definition Geometry.h:30
vsg::Intersector
Definition Intersector.h:24
vsg::Intersector::intersectDraw
virtual bool intersectDraw(uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount)=0
intersect with a vkCmdDraw primitive
vsg::Intersector::intersects
virtual bool intersects(const dsphere &sphere)=0
check for intersection with sphere
vsg::Intersector::worldToLocalStack
std::vector< dmat4 > & worldToLocalStack()
get the current world to local matrix stack
Definition Intersector.h:81
vsg::Intersector::localToWorldStack
std::vector< dmat4 > & localToWorldStack()
get the current local to world matrix stack
Definition Intersector.h:78
vsg::Intersector::intersectDrawIndexed
virtual bool intersectDrawIndexed(uint32_t firstIndex, uint32_t indexCount, uint32_t firstInstance, uint32_t instanceCount)=0
intersect with a vkCmdDrawIndexed primitive
vsg::Intersector::pushTransform
virtual void pushTransform(const Transform &transform)=0
clone and transform this Intersector to provide a new Intersector in local coordinates
vsg::LOD
Definition LOD.h:33
vsg::Node
Definition Node.h:24
vsg::PagedLOD
Definition PagedLOD.h:36
vsg::StateGroup
Definition StateGroup.h:32
vsg::TextTechnique
Definition TextTechnique.h:25
vsg::Transform
Transform node is a pure virtual base class for positioning/scaling/rotating subgraphs.
Definition Transform.h:22
vsg::VertexDraw
Definition VertexDraw.h:25
vsg::VertexIndexDraw
Definition VertexIndexDraw.h:25
vsg::ref_ptr
Definition ref_ptr.h:22