Subversion Repository Public Repository

Divide-Framework

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

Diff Revisions 259 vs 264 for /trunk/Source Code/Environment/Terrain/Quadtree/Headers/QuadtreeNode.h

Diff revisions: vs.
  @@ -25,6 +25,7 @@
25 25
26 26 #include "core.h"
27 27 #include "Core/Math/BoundingVolumes/Headers/BoundingBox.h"
28 + #include "Core/Math/BoundingVolumes/Headers/BoundingSphere.h"
28 29
29 30 enum ChildPosition{
30 31 CHILD_NW = 0,
  @@ -34,50 +35,54 @@
34 35 };
35 36
36 37 enum ChunkBit{
37 - CHUNK_BIT_TESTCHILDREN = toBit(1),
38 + CHUNK_BIT_TESTCHILDREN = toBit(1),
38 39 CHUNK_BIT_WATERREFLECTION = toBit(2),
39 - CHUNK_BIT_DEPTHMAP = toBit(3)
40 + CHUNK_BIT_DEPTHMAP = toBit(3)
40 41 };
41 42
42 - class Frustum;
43 - class TerrainChunk;
44 43 class Terrain;
44 + class TerrainChunk;
45 45 class Transform;
46 - class ShaderProgram;
46 + class SceneState;
47 47 class VertexBuffer;
48 + class ShaderProgram;
49 + class SceneGraphNode;
50 + class SceneRenderState;
51 +
48 52 class QuadtreeNode {
49 53 public:
50 54 ///recursive node building function
51 - void Build(const U8 depth,const vec2<U32>& pos,const vec2<U32>& HMsize, U32 minHMSize, VertexBuffer* const groundVB, U32& chunkCount);
52 - bool computeBoundingBox(const vectorImpl<vec3<F32> >& vertices);
55 + void Build(const U8 depth, const vec2<U32>& pos, const vec2<U32>& HMsize, U32 minHMSize, VertexBuffer* const groundVB, Terrain* const parentTerrain, U32& chunkCount);
56 + bool computeBoundingBox();
53 57 void Destroy();
54 58
55 - inline void setParentShaderProgram(ShaderProgram* const shaderProgram) {_parentShaderProgram = shaderProgram;}
59 + void DrawGround(U32 options, const SceneRenderState& sceneRenderState) const;
60 + void DrawBBox() const;
56 61
57 - void DrawGround(I32 options,VertexBuffer* const terrainVB);
58 - void DrawGrass(U32 geometryIndex, Transform* const parentTransform);
59 - void DrawBBox();
60 - void GenerateGrassIndexBuffer(U32 bilboardCount);
62 + void sceneUpdate(const U64 deltaTime, SceneGraphNode* const sgn, SceneState& sceneState);
61 63
62 - inline bool isALeaf() const {return _children==0;}
64 + inline bool isALeaf() const { return !(_children[CHILD_NW] && _children[CHILD_NE] && _children[CHILD_SW] && _children[CHILD_SE]); }
63 65 inline BoundingBox& getBoundingBox() {return _boundingBox;}
64 66 inline void setBoundingBox(const BoundingBox& bbox) {_boundingBox = bbox;}
65 - inline QuadtreeNode* getChildren() {return _children;}
66 67 inline TerrainChunk* getChunk() {return _terrainChunk;}
67 68
68 - QuadtreeNode() {_children = nullptr; _terrainChunk = nullptr; _LOD = 0;}
69 - ~QuadtreeNode() {Destroy();}
69 + inline QuadtreeNode* getChild(ChildPosition pos) { return _children[pos]; }
70 + inline QuadtreeNode* getChild(U32 index) { return _children[index]; }
71 +
72 + QuadtreeNode();
73 + ~QuadtreeNode();
70 74
71 75 protected:
72 - bool isInView(I32 options);
76 + bool isInView(U32 options, const SceneRenderState& sceneState) const;
73 77
74 78 private:
79 + F32 _terLoDOffset; ///<Small offset to prevent wrong LoD selection on border cases
80 + U32 _minHMSize;
75 81 I8 _LOD; ///< LOD level
76 - F32 _camDistance; ///< Distance to camera
77 82 BoundingBox _boundingBox; ///< Node BoundingBox
78 - QuadtreeNode* _children; ///< Node children
83 + BoundingSphere _boundingSphere; ///< Node BoundingSphere
84 + QuadtreeNode* _children[4]; ///< Node children
79 85 TerrainChunk* _terrainChunk; ///< Terrain Chunk contained in node
80 - ShaderProgram* _parentShaderProgram; ///< A reference to the terrain shader in case we need special rendering for this node
81 86 };
82 87
83 88 #endif