Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
   Copyright (c) 2017 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   Permission 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:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE 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.

 */

#ifndef _QUAD_TREE_NODE
#define _QUAD_TREE_NODE

#include "Platform/Video/Headers/RenderAPIWrapper.h"
#include "Core/Math/BoundingVolumes/Headers/BoundingBox.h"
#include "Core/Math/BoundingVolumes/Headers/BoundingSphere.h"

namespace Divide {

enum class ChildPosition :U32 { 
    CHILD_NW = 0, 
    CHILD_NE = 1, 
    CHILD_SW = 2, 
    CHILD_SE = 3
};

enum class ChunkBit : U32 {
    CHUNK_BIT_TESTCHILDREN = toBit(1),
    CHUNK_BIT_WATERREFLECTION = toBit(2),
    CHUNK_BIT_SHADOWMAP = toBit(3)
};

class Terrain;
class TerrainChunk;
class Transform;
class SceneState;
class IMPrimitive;
class VertexBuffer;
class ShaderProgram;
class SceneGraphNode;
class SceneRenderState;

class QuadtreeChildren;

class QuadtreeNode {
   public:
     QuadtreeNode();
     ~QuadtreeNode();

    /// recursive node building function
    void Build(GFXDevice& context,
               const U8 depth,
               const vec2<U32>& pos,
               const vec2<U32>& HMsize,
               U32 targetChunkDimension,
               Terrain* const terrain,
               U32& chunkCount);

    bool computeBoundingBox();
    
    void drawBBox(GFXDevice& context, GenericDrawCommands& commandsOut);

    void sceneUpdate(const U64 deltaTime, SceneGraphNode& sgn,
                     SceneState& sceneState);

    inline bool isALeaf() const { return _children == nullptr; }

    inline BoundingBox& getBoundingBox() { return _boundingBox; }
    inline void setBoundingBox(const BoundingBox& bbox) { _boundingBox = bbox; }
    inline TerrainChunk* getChunk() { return _terrainChunk; }

    inline QuadtreeNode& getChild(ChildPosition pos) const;
    inline QuadtreeNode& getChild(U32 index) const;
    
    U8 getLoD(const vec3<F32>& eyePos) const;

   protected:
    bool isInView(U32 options, const SceneRenderState& sceneState) const;

   private:
    mutable I8 _frustPlaneCache;
    U32 _targetChunkDimension;
    BoundingBox _boundingBox;        ///< Node BoundingBox
    BoundingSphere _boundingSphere;  ///< Node BoundingSphere
    QuadtreeChildren* _children;     ///< Node children
    TerrainChunk* _terrainChunk;     ///< Terrain Chunk contained in node
    IMPrimitive*  _bbPrimitive;
};

class QuadtreeChildren {
private:
    friend class QuadtreeNode;

    typedef std::array<QuadtreeNode, 4> QuadtreeNodes;

    inline QuadtreeNodes& operator()() { return _nodes; }
    inline QuadtreeNode& operator[](ChildPosition pos) { return _nodes[to_U32(pos)]; }

    inline const QuadtreeNodes& operator()() const { return _nodes; }
    inline const QuadtreeNode& operator[](ChildPosition pos) const { return _nodes[to_U32(pos)]; }

    QuadtreeNodes _nodes;
};

inline QuadtreeNode& QuadtreeNode::getChild(ChildPosition pos) const {
    return (*_children)[pos];
}

inline QuadtreeNode& QuadtreeNode::getChild(U32 index) const {
    return (*_children)[static_cast<ChildPosition>(index)];
}

};  // namespace Divide

#endif

Commits for Divide-Framework/trunk/Source Code/Environment/Terrain/Quadtree/Headers/QuadtreeNode.h

Diff revisions: vs.
Revision Author Commited Message
881 Diff Diff IonutCava picture IonutCava Tue 21 Mar, 2017 22:07:37 +0000

[IonutCava]
- Multi draw command bug fix: drawCount > 1 should properly register all commands in the command buffer
- More tessellated terrain updates and fixes (still Work In Progress)

880 Diff Diff IonutCava picture IonutCava Mon 20 Mar, 2017 17:27:13 +0000

[IonutCava]
- New tessellated terrain system based on this: http://victorbush.com/2015/01/tessellated-terrain/
— Work in progress: hardcoded values, new code is in Test namespace
- Split terrain geometry in two:
— tessellated rendering data
— physics verts + indices (used for collisions, vegetation, etc)
- Old Chunk system is used only for culling objects and speeding up collision detection

874 Diff Diff IonutCava picture IonutCava Mon 13 Mar, 2017 17:29:45 +0000

[IonutCava]
- Fix boundingbox skewing bug.
- Optimise frustum collision checks by adding a plane-cache system.
— ToDo: solve mutable status of _frustPlaneCache
— ToDo: TRIPLE check results to avoid false-positives
- Speedup terrain by not stack-allocating QuadtreeNodes in a QuadtreeChildren container instead of new-ing each one of them.

871 Diff Diff IonutCava picture IonutCava Sun 05 Mar, 2017 20:13:56 +0000

[IonutCava]
- Terrain LOD system tweaks

867 Diff Diff IonutCava picture IonutCava Mon 20 Feb, 2017 17:01:12 +0000

[IonutCava]
- Rename to_XNN and to_const_XNN functions to reflect the target data type they are converting to.
- Cleanup Angle namespace and remove all “inDegrees” parameters from rotation functions. Use aliases to differentiate between Degree and Radian parameters.
- Profile guided optimizations.

866 Diff Diff IonutCava picture IonutCava Mon 20 Feb, 2017 13:57:52 +0000

[IonutCava]
- Cleanup terrain chunk generation

847 Diff Diff IonutCava picture IonutCava Sun 05 Feb, 2017 21:16:24 +0000

[IonutCava]
- Code rot fixes:
— Terrain loading (8 bit heightmap only for now)
— Terrain rendering
— Water Plane loading and rendering
— Reflection and Refraction rendering passes (hack for now: need environment cubemaps as separate from reflect/refract maps for planar rendering)
-— ToDo: Separate Reflection / Refraction render targets to Planar R/R and Cube R/R. Environment probes should use Cube Reflections, Water should use planar reflection targets.
- Added a way to register debug views: texture, shader and params. Viewports get automatically scaled and positioned
— ToDo: Add a hover-preview feature
— ToDo: Add a click-lock preview feature

836 Diff Diff IonutCava picture IonutCava Fri 27 Jan, 2017 14:59:56 +0000

[IonutCava]
- Update copyright notice

804 Diff Diff IonutCava picture IonutCava Thu 01 Dec, 2016 17:20:59 +0000

[IonutCava]
- Singleton elimination update Part I: get it to compile
— The following classes are no longer Singletons: GFXDevice, GL_API, DX_API, SFXWrapper, FmodWrapper, SDLWrapper, ALWrapper, PXDevice, InputInterface, RenderPassManager, SceneManager and ResourceManager;
— Refactor system to a Context / Component based implementation (Pass relevant context to objects: e.g. GFXDevice object to Textures, GUI to GUIElements, etc)
— Make devices and managers components of the kernel
— Allow multiple Resource caches to co-exist. This may prove useful for later when a more fragmented memory model is need (per frame / per scene / global caches / etc)

  • next steps: part II – cleanup/refactor new code, part III – optimise code, part IV – remove remaining Singletons (e.g. Application, ParamHandler, FrameListenerManager, Recast, PostFX and DebugInterface)
777 IonutCava picture IonutCava Fri 07 Oct, 2016 16:14:48 +0000

[IonutCava]
- Continue to implement CommandBuffer / RenderPass / RenderSubPass system.
— Rendering artefacts are still present.