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

vsg 1.1.9 VulkanSceneGraph library |

Loading...
Searching...
No Matches
PropagateDynamicObjects.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2024 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/core/ConstVisitor.h>
16#include <vsg/core/Inherit.h>
17
18#include <stack>
19
20namespace vsg
21{
22
24 class VSG_DECLSPEC PropagateDynamicObjects : public Inherit<ConstVisitor, PropagateDynamicObjects>
25 {
26 public:
27 PropagateDynamicObjects();
28
29 std::mutex mutex;
30 std::set<const Object*> dynamicObjects;
31 std::stack<bool> taggedStack;
32
33 inline void tag(const Object* object)
34 {
35 dynamicObjects.insert(object);
36 }
37
38 inline bool tagged(const Object* object)
39 {
40 return dynamicObjects.count(object) != 0;
41 }
42
43 protected:
44 struct TagIfChildIsDynamic
45 {
46 inline TagIfChildIsDynamic(PropagateDynamicObjects* in_rd, const Object* in_object) :
47 rd(in_rd),
48 object(in_object)
49 {
50 if (rd->tagged(object)) rd->taggedStack.top() = true;
51 rd->taggedStack.push(false);
52 }
53
54 inline ~TagIfChildIsDynamic()
55 {
56 if (rd->taggedStack.top())
57 {
58 rd->tag(object);
59 rd->taggedStack.pop();
60 rd->taggedStack.top() = true;
61 }
62 else
63 {
64 rd->taggedStack.pop();
65 }
66 }
67
68 PropagateDynamicObjects* rd = nullptr;
69 const Object* object = nullptr;
70 };
71
72 void apply(const Object& object) override;
73 void apply(const AnimationGroup& ag) override;
74 void apply(const Animation& animation) override;
75 void apply(const AnimationSampler& sampler) override;
76 void apply(const TransformSampler& sampler) override;
77 void apply(const MorphSampler& sampler) override;
78 void apply(const JointSampler& sampler) override;
79 void apply(const BufferInfo& info) override;
80 void apply(const Image& image) override;
81 void apply(const ImageView& imageView) override;
82 void apply(const ImageInfo& info) override;
83 void apply(const DescriptorBuffer& db) override;
84 void apply(const DescriptorImage& di) override;
85 void apply(const BindIndexBuffer& bib) override;
86 void apply(const BindVertexBuffers& bvb) override;
87 void apply(const VertexDraw& vd) override;
88 void apply(const VertexIndexDraw& vid) override;
89 void apply(const Geometry& geom) override;
90 };
91 VSG_type_name(PropagateDynamicObjects);
92
93} // namespace vsg
vsg::AnimationGroup
AnimationGroup node provides a list of child nodes and a list of animations to animate them.
Definition AnimationGroup.h:24
vsg::Animation
Animation class that controls a single animation made up of one more samplers.
Definition Animation.h:44
vsg::AnimationSampler
Base class for animation samplers that sample animation data and set associated scene graph objects.
Definition Animation.h:24
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::DescriptorBuffer
Definition DescriptorBuffer.h:24
vsg::DescriptorImage
Definition DescriptorImage.h:24
vsg::Geometry
Definition Geometry.h:30
vsg::Image
Image class encapsulates VkImage and VkImageCreateInfo settings used to set it up.
Definition Image.h:25
vsg::ImageInfo
ImageInfo class provides the VkDescriptorImageInfo settings used when setting up vsg::/vkDescriptorIm...
Definition ImageInfo.h:23
vsg::ImageView
ImageView class encapsulates VkImageView and VkImageViewCreateInfo settings used to set it up.
Definition ImageView.h:25
vsg::JointSampler
Animation sampler for acumulating vsg::Joint hierarchies and assigned accumulated transform matrices ...
Definition JointSampler.h:23
vsg::MorphSampler
Animation sampler for morphing geometry, implementation not yet completed.
Definition MorphSampler.h:48
vsg::Object
Definition Object.h:60
vsg::PropagateDynamicObjects
Propagate classification of objects as dynamic to all parents.
Definition PropagateDynamicObjects.h:25
vsg::TransformSampler
Animation sampler for sampling position, rotation and scale keyframes for setting transforms/joints.
Definition TransformSampler.h:70
vsg::VertexDraw
Definition VertexDraw.h:25
vsg::VertexIndexDraw
Definition VertexIndexDraw.h:25