vsg 1.1.3
VulkanSceneGraph library
Loading...
Searching...
No Matches
LOD.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2018 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/Allocator.h>
16#include <vsg/core/ref_ptr.h>
17#include <vsg/nodes/Node.h>
18
19#include <algorithm>
20#include <array>
21
22namespace vsg
23{
24
32 class VSG_DECLSPEC LOD : public Inherit<Node, LOD>
33 {
34 public:
35 LOD();
36 LOD(const LOD& rhs, const CopyOp& copyop = {});
37
38 struct Child
39 {
40 double minimumScreenHeightRatio = 0.0; // 0.0 is always visible
41 ref_ptr<Node> node;
42 };
43
44 using Children = std::vector<Child, allocator_affinity_nodes<Child>>;
45
46 dsphere bound;
47 Children children;
48
49 void addChild(const Child& lodChild) { children.push_back(lodChild); }
50
51 public:
52 ref_ptr<Object> clone(const CopyOp& copyop = {}) const override { return LOD::create(*this, copyop); }
53 int compare(const Object& rhs) const override;
54
55 template<class N, class V>
56 static void t_traverse(N& node, V& visitor)
57 {
58 for (auto& child : node.children) child.node->accept(visitor);
59 }
60
61 void traverse(Visitor& visitor) override { t_traverse(*this, visitor); }
62 void traverse(ConstVisitor& visitor) const override { t_traverse(*this, visitor); }
63 void traverse(RecordTraversal& visitor) const override { t_traverse(*this, visitor); }
64
65 void read(Input& input) override;
66 void write(Output& output) const override;
67
68 protected:
69 virtual ~LOD();
70 };
71 VSG_type_name(vsg::LOD);
72
73} // namespace vsg
Definition Object.h:42
Definition Inherit.h:28
Definition LOD.h:33
int compare(const Object &rhs) const override
compare two objects, return -1 if this object is less than rhs, return 0 if it's equal,...
ref_ptr< Object > clone(const CopyOp &copyop={}) const override
Definition LOD.h:52
Definition Object.h:60
Definition Visitor.h:172
Definition ref_ptr.h:22
Definition LOD.h:39