Subversion Repository Public Repository

Divide-Framework

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

Diff Revisions 330 vs 331 for /trunk/Source Code/Environment/Terrain/Quadtree/QuadtreeNode.cpp

Diff revisions: vs.
  @@ -22,14 +22,19 @@
22 22
23 23 QuadtreeNode::~QuadtreeNode()
24 24 {
25 - MemoryManager::SAFE_DELETE( _children[CHILD_NW] );
26 - MemoryManager::SAFE_DELETE( _children[CHILD_NE] );
27 - MemoryManager::SAFE_DELETE( _children[CHILD_SW] );
28 - MemoryManager::SAFE_DELETE( _children[CHILD_SE] );
29 - MemoryManager::SAFE_DELETE( _terrainChunk );
25 + MemoryManager::DELETE( _children[CHILD_NW] );
26 + MemoryManager::DELETE( _children[CHILD_NE] );
27 + MemoryManager::DELETE( _children[CHILD_SW] );
28 + MemoryManager::DELETE( _children[CHILD_SE] );
29 + MemoryManager::DELETE( _terrainChunk );
30 30 }
31 31
32 - void QuadtreeNode::Build( U8 depth, const vec2<U32>& pos, const vec2<U32>& HMsize, U32 minHMSize, Terrain* const terrain, U32& chunkCount ) {
32 + void QuadtreeNode::Build(U8 depth,
33 + const vec2<U32>& pos,
34 + const vec2<U32>& HMsize,
35 + U32 minHMSize,
36 + Terrain* const terrain,
37 + U32& chunkCount ) {
33 38 _LOD = 0;
34 39 _minHMSize = minHMSize;
35 40 U32 div = (U32)std::pow(2.0f, (F32)depth);
  @@ -41,23 +46,25 @@
41 46 _terLoDOffset = (_minHMSize * 5.0f) / 100.0f;
42 47
43 48 if (std::max(newsize.x, newsize.y) < _minHMSize) {
44 - _terrainChunk = New TerrainChunk(terrain, this);
49 + _terrainChunk = MemoryManager_NEW TerrainChunk(terrain, this);
45 50 _terrainChunk->Load(depth, pos, _minHMSize, HMsize, terrain);
46 51 chunkCount++;
47 52 return;
48 53 }
49 54
50 55 // Create 4 children
51 - _children[CHILD_NW] = New QuadtreeNode();
52 - _children[CHILD_NE] = New QuadtreeNode();
53 - _children[CHILD_SW] = New QuadtreeNode();
54 - _children[CHILD_SE] = New QuadtreeNode();
56 + _children[CHILD_NW] = MemoryManager_NEW QuadtreeNode();
57 + _children[CHILD_NE] = MemoryManager_NEW QuadtreeNode();
58 + _children[CHILD_SW] = MemoryManager_NEW QuadtreeNode();
59 + _children[CHILD_SE] = MemoryManager_NEW QuadtreeNode();
55 60
56 61 // Compute children bounding boxes
57 62 const vec3<F32>& center = _boundingBox.getCenter();
58 63 _children[CHILD_NW]->setBoundingBox(BoundingBox(_boundingBox.getMin(), center));
59 - _children[CHILD_NE]->setBoundingBox(BoundingBox(vec3<F32>(center.x, 0.0f, _boundingBox.getMin().z), vec3<F32>(_boundingBox.getMax().x, 0.0f, center.z)));
60 - _children[CHILD_SW]->setBoundingBox(BoundingBox(vec3<F32>(_boundingBox.getMin().x, 0.0f, center.z), vec3<F32>(center.x, 0.0f, _boundingBox.getMax().z)));
64 + _children[CHILD_NE]->setBoundingBox(BoundingBox(vec3<F32>(center.x, 0.0f, _boundingBox.getMin().z),
65 + vec3<F32>(_boundingBox.getMax().x, 0.0f, center.z)));
66 + _children[CHILD_SW]->setBoundingBox(BoundingBox(vec3<F32>(_boundingBox.getMin().x, 0.0f, center.z),
67 + vec3<F32>(center.x, 0.0f, _boundingBox.getMax().z)));
61 68 _children[CHILD_SE]->setBoundingBox(BoundingBox(center, _boundingBox.getMax()));
62 69 // Compute children positions
63 70 vec2<U32> tNewHMpos[4];
  @@ -82,11 +89,15 @@
82 89 _children[i]->computeBoundingBox();
83 90
84 91 if (_boundingBox.getMin().y > _children[i]->_boundingBox.getMin().y){
85 - _boundingBox.setMin(vec3<F32>(_boundingBox.getMin().x, _children[i]->_boundingBox.getMin().y, _boundingBox.getMin().z));
92 + _boundingBox.setMin(vec3<F32>(_boundingBox.getMin().x,
93 + _children[i]->_boundingBox.getMin().y,
94 + _boundingBox.getMin().z));
86 95 }
87 96
88 97 if (_boundingBox.getMax().y < _children[i]->_boundingBox.getMax().y){
89 - _boundingBox.setMax(vec3<F32>(_boundingBox.getMax().x, _children[i]->_boundingBox.getMax().y, _boundingBox.getMax().z));
98 + _boundingBox.setMax(vec3<F32>(_boundingBox.getMax().x,
99 + _children[i]->_boundingBox.getMax().y,
100 + _boundingBox.getMax().z));
90 101 }
91 102 }
92 103 }
  @@ -117,7 +128,8 @@
117 128 const vec3<F32>& eye = cam.getEye();
118 129 F32 visibilityDistance = GET_ACTIVE_SCENE()->state().getGeneralVisibility() + _boundingSphere.getRadius();
119 130 if (_boundingSphere.getCenter().distance(eye) > visibilityDistance){
120 - if (_boundingBox.nearestDistanceFromPointSquared(eye) - _terLoDOffset > std::min(visibilityDistance, sceneRenderState.getCameraConst().getZPlanes().y))
131 + if (_boundingBox.nearestDistanceFromPointSquared(eye) - _terLoDOffset >
132 + std::min(visibilityDistance, sceneRenderState.getCameraConst().getZPlanes().y))
121 133 return false;
122 134 }
123 135 }
  @@ -151,15 +163,18 @@
151 163 }
152 164 }
153 165
154 - void QuadtreeNode::createDrawCommand(U32 options, const SceneRenderState& sceneRenderState, vectorImpl<GenericDrawCommand>& drawCommandsOut) {
155 -
166 + void QuadtreeNode::createDrawCommand(U32 options,
167 + const SceneRenderState& sceneRenderState,
168 + vectorImpl<GenericDrawCommand>& drawCommandsOut) {
156 169 if (!isInView(options, sceneRenderState)) {
157 170 return;
158 171 }
159 172
160 173 if (isALeaf()) {
161 174 assert(_terrainChunk);
162 - _terrainChunk->createDrawCommand(bitCompare(options, CHUNK_BIT_WATERREFLECTION) ? Config::TERRAIN_CHUNKS_LOD - 1 : _LOD, drawCommandsOut);
175 + _terrainChunk->createDrawCommand(bitCompare(options, CHUNK_BIT_WATERREFLECTION) ? Config::TERRAIN_CHUNKS_LOD - 1 :
176 + _LOD,
177 + drawCommandsOut);
163 178 }else{
164 179 _children[CHILD_NW]->createDrawCommand(options, sceneRenderState, drawCommandsOut);
165 180 _children[CHILD_NE]->createDrawCommand(options, sceneRenderState, drawCommandsOut);