Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Quadtree.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_QUAD_TREE
34#define DVD_QUAD_TREE
35
36namespace Divide {
37
38class Terrain;
39class GFXDevice;
40class SceneState;
41class BoundingBox;
42class IMPrimitive;
43class VertexBuffer;
44class ShaderProgram;
45class SceneGraphNode;
46class SceneRenderState;
47
48struct RenderPackage;
49
51
52class Quadtree {
53 public:
54 Quadtree();
55 ~Quadtree();
56
57 void build(const BoundingBox& terrainBBox,
58 const vec2<U16> HMSize,
59 Terrain* terrain);
60
61 [[nodiscard]] const BoundingBox& computeBoundingBox() const;
62
63 [[nodiscard]] U32 getChunkCount() const noexcept { return _chunkCount; }
64
65 void drawBBox(GFXDevice& context) const;
67
68 [[nodiscard]] QuadtreeNode* findLeaf(vec2<F32> pos) const noexcept;
69
70 const QuadtreeNode_uptr& getRoot() const noexcept { return _root; }
71
72 PROPERTY_R_IW(U32, targetChunkDimension, 0u);
73
74 private:
75 QuadtreeNode_uptr _root;
78 bool _drawBBoxes = false;
79};
80
81} // namespace Divide
82
83#endif //DVD_QUAD_TREE
#define FWD_DECLARE_MANAGED_CLASS(T)
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
Definition: GFXDevice.h:215
const QuadtreeNode_uptr & getRoot() const noexcept
Definition: Quadtree.h:70
bool _drawBBoxes
Definition: Quadtree.h:78
void build(const BoundingBox &terrainBBox, const vec2< U16 > HMSize, Terrain *terrain)
Definition: Quadtree.cpp:62
void toggleBoundingBoxes()
Definition: Quadtree.cpp:19
VertexBuffer * _parentVB
Definition: Quadtree.h:76
QuadtreeNode_uptr _root
Definition: Quadtree.h:75
PROPERTY_R_IW(U32, targetChunkDimension, 0u)
U32 getChunkCount() const noexcept
Definition: Quadtree.h:63
QuadtreeNode * findLeaf(vec2< F32 > pos) const noexcept
Definition: Quadtree.cpp:38
const BoundingBox & computeBoundingBox() const
Definition: Quadtree.cpp:72
void drawBBox(GFXDevice &context) const
Definition: Quadtree.cpp:24
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
uint32_t U32