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/TerrainLoader.cpp

Diff revisions: vs.
  @@ -11,13 +11,13 @@
11 11
12 12 TerrainLoader::TerrainLoader() : Singleton()
13 13 {
14 - _albedoSampler = New SamplerDescriptor();
14 + _albedoSampler = MemoryManager_NEW SamplerDescriptor();
15 15 _albedoSampler->setWrapMode(TEXTURE_REPEAT);
16 16 _albedoSampler->setAnisotropy(8);
17 17 _albedoSampler->toggleMipMaps(true);
18 18 _albedoSampler->toggleSRGBColorSpace(true);
19 19
20 - _normalSampler = New SamplerDescriptor();
20 + _normalSampler = MemoryManager_NEW SamplerDescriptor();
21 21 _normalSampler->setWrapMode(TEXTURE_REPEAT);
22 22 _normalSampler->setAnisotropy(8);
23 23 _normalSampler->toggleMipMaps(true);
  @@ -25,8 +25,8 @@
25 25
26 26 TerrainLoader::~TerrainLoader()
27 27 {
28 - MemoryManager::SAFE_DELETE( _albedoSampler );
29 - MemoryManager::SAFE_DELETE( _normalSampler );
28 + MemoryManager::DELETE( _albedoSampler );
29 + MemoryManager::DELETE( _normalSampler );
30 30 }
31 31
32 32 bool TerrainLoader::loadTerrain(Terrain* terrain, TerrainDescriptor* terrainDescriptor){
  @@ -52,7 +52,7 @@
52 52 textureCountDetail = 0;
53 53
54 54 layerOffsetStr = stringAlg::toBase(Util::toString(i));
55 - textureLayer = New TerrainTextureLayer();
55 + textureLayer = MemoryManager_NEW TerrainTextureLayer();
56 56
57 57 ResourceDescriptor textureBlendMap("Terrain Blend Map_" + name + "_layer_" + layerOffsetStr);
58 58 textureBlendMap.setResourceLocation(terrainDescriptor->getVariable("blendMap" + layerOffsetStr));
  @@ -65,28 +65,32 @@
65 65 arrayLocation = currentTexture;
66 66 textureCount++;
67 67 textureCountAlbedo++;
68 - textureLayer->setDiffuseScale(TerrainTextureLayer::TEXTURE_RED_CHANNEL, terrainDescriptor->getVariablef("diffuseScaleR" + layerOffsetStr));
68 + textureLayer->setDiffuseScale(TerrainTextureLayer::TEXTURE_RED_CHANNEL,
69 + terrainDescriptor->getVariablef("diffuseScaleR" + layerOffsetStr));
69 70 }
70 71 currentTexture = terrainDescriptor->getVariable("greenAlbedo" + layerOffsetStr);
71 72 if (!currentTexture.empty()){
72 73 arrayLocation += "," + currentTexture;
73 74 textureCount++;
74 75 textureCountAlbedo++;
75 - textureLayer->setDiffuseScale(TerrainTextureLayer::TEXTURE_GREEN_CHANNEL, terrainDescriptor->getVariablef("diffuseScaleG" + layerOffsetStr));
76 + textureLayer->setDiffuseScale(TerrainTextureLayer::TEXTURE_GREEN_CHANNEL,
77 + terrainDescriptor->getVariablef("diffuseScaleG" + layerOffsetStr));
76 78 }
77 79 currentTexture = terrainDescriptor->getVariable("blueAlbedo" + layerOffsetStr);
78 80 if (!currentTexture.empty()){
79 81 arrayLocation += "," + currentTexture;
80 82 textureCount++;
81 83 textureCountAlbedo++;
82 - textureLayer->setDiffuseScale(TerrainTextureLayer::TEXTURE_BLUE_CHANNEL, terrainDescriptor->getVariablef("diffuseScaleB" + layerOffsetStr));
84 + textureLayer->setDiffuseScale(TerrainTextureLayer::TEXTURE_BLUE_CHANNEL,
85 + terrainDescriptor->getVariablef("diffuseScaleB" + layerOffsetStr));
83 86 }
84 87 currentTexture = terrainDescriptor->getVariable("alphaAlbedo" + layerOffsetStr);
85 88 if (!currentTexture.empty()){
86 89 arrayLocation += "," + currentTexture;
87 90 textureCount++;
88 91 textureCountAlbedo++;
89 - textureLayer->setDiffuseScale(TerrainTextureLayer::TEXTURE_ALPHA_CHANNEL, terrainDescriptor->getVariablef("diffuseScaleA" + layerOffsetStr));
92 + textureLayer->setDiffuseScale(TerrainTextureLayer::TEXTURE_ALPHA_CHANNEL,
93 + terrainDescriptor->getVariablef("diffuseScaleA" + layerOffsetStr));
90 94 }
91 95
92 96 ResourceDescriptor textureTileMaps("Terrain Tile Maps_" + name + "_layer_" + layerOffsetStr);
  @@ -101,25 +105,29 @@
101 105 if (!currentTexture.empty()){
102 106 arrayLocation += "," + currentTexture;
103 107 textureCountDetail++;
104 - textureLayer->setDetailScale(TerrainTextureLayer::TEXTURE_RED_CHANNEL, terrainDescriptor->getVariablef("detailScaleR" + layerOffsetStr));
108 + textureLayer->setDetailScale(TerrainTextureLayer::TEXTURE_RED_CHANNEL,
109 + terrainDescriptor->getVariablef("detailScaleR" + layerOffsetStr));
105 110 }
106 111 currentTexture = terrainDescriptor->getVariable("greenDetail" + layerOffsetStr);
107 112 if (!currentTexture.empty()){
108 113 arrayLocation += "," + currentTexture;
109 114 textureCountDetail++;
110 - textureLayer->setDetailScale(TerrainTextureLayer::TEXTURE_GREEN_CHANNEL, terrainDescriptor->getVariablef("detailScaleG" + layerOffsetStr));
115 + textureLayer->setDetailScale(TerrainTextureLayer::TEXTURE_GREEN_CHANNEL,
116 + terrainDescriptor->getVariablef("detailScaleG" + layerOffsetStr));
111 117 }
112 118 currentTexture = terrainDescriptor->getVariable("blueDetail" + layerOffsetStr);
113 119 if (!currentTexture.empty()){
114 120 arrayLocation += "," + currentTexture;
115 121 textureCountDetail++;
116 - textureLayer->setDetailScale(TerrainTextureLayer::TEXTURE_BLUE_CHANNEL, terrainDescriptor->getVariablef("detailScaleB" + layerOffsetStr));
122 + textureLayer->setDetailScale(TerrainTextureLayer::TEXTURE_BLUE_CHANNEL,
123 + terrainDescriptor->getVariablef("detailScaleB" + layerOffsetStr));
117 124 }
118 125 currentTexture = terrainDescriptor->getVariable("alphaDetail" + layerOffsetStr);
119 126 if (!currentTexture.empty()){
120 127 arrayLocation += "," + currentTexture;
121 128 textureCountDetail++;
122 - textureLayer->setDetailScale(TerrainTextureLayer::TEXTURE_ALPHA_CHANNEL, terrainDescriptor->getVariablef("detailScaleA" + layerOffsetStr));
129 + textureLayer->setDetailScale(TerrainTextureLayer::TEXTURE_ALPHA_CHANNEL,
130 + terrainDescriptor->getVariablef("detailScaleA" + layerOffsetStr));
123 131 }
124 132
125 133 ResourceDescriptor textureNormalMaps("Terrain Normal Maps_" + name + "_layer_" + layerOffsetStr);
  @@ -214,7 +222,8 @@
214 222 if ( terrainDescriptor->is16Bit() ) {
215 223 assert( heightmapWidth != 0 && heightmapHeight != 0 );
216 224 stringImpl terrainRawFile( terrainDescriptor->getVariable( "heightmap" ) );
217 - assert( terrainRawFile.substr( terrainRawFile.length() - 4, terrainRawFile.length() ).compare( ".raw" ) == 0 ); // only raw files for 16 bit support
225 + // only raw files for 16 bit support
226 + assert( terrainRawFile.substr( terrainRawFile.length() - 4, terrainRawFile.length() ).compare( ".raw" ) == 0 );
218 227 // Read File Data
219 228 FILE* terrainFile = nullptr;
220 229 fopen_s( &terrainFile, terrainRawFile.c_str(), "rb" );
  @@ -224,7 +233,7 @@
224 233 U32 positionCount = ftell( terrainFile );
225 234 fseek( terrainFile, lCurPos, SEEK_SET );
226 235 heightValues.reserve( positionCount / 2 );
227 - U8* dataTemp = New U8[positionCount];
236 + U8* dataTemp = MemoryManager_NEW U8[positionCount];
228 237 rewind( terrainFile );
229 238 assert( dataTemp );
230 239 fread( dataTemp, 1, positionCount, terrainFile );
  @@ -232,7 +241,7 @@
232 241 for ( U32 i = 0; i < positionCount + 1; i += 2 ) {
233 242 heightValues.push_back( ( (U8)dataTemp[i + 1] << 8 ) | (U8)dataTemp[i] );
234 243 }
235 - MemoryManager::SAFE_DELETE_ARRAY( dataTemp );
244 + MemoryManager::DELETE_ARRAY( dataTemp );
236 245 } else {
237 246 ImageTools::ImageData img;
238 247 img.create( terrainDescriptor->getVariable( "heightmap" ) );
  @@ -286,7 +295,8 @@
286 295 vertexData.x = bMin.x + ((F32)i) * (bMax.x - bMin.x) / (terrainWidth - 1);
287 296 vertexData.z = bMin.z + ((F32)j) * (bMax.z - bMin.z) / (terrainHeight - 1);
288 297
289 - U32 idxIMG = TER_COORD<U32>(i < (I32)heightmapWidth ? i : i - 1, j < (I32)heightmapHeight ? j : j - 1, heightmapWidth);
298 + U32 idxIMG = TER_COORD<U32>(i < (I32)heightmapWidth ? i : i - 1,
299 + j < (I32)heightmapHeight ? j : j - 1, heightmapWidth);
290 300
291 301 vertexData.y = minAltitude + altitudeRange * (F32)heightValues[idxIMG] / 65536.0f;
292 302 vertexData.y *= yScaleFactor;
  @@ -307,7 +317,8 @@
307 317 vertexData.x = bMin.x + ((F32)i) * (bMax.x - bMin.x) / (terrainWidth - 1);
308 318 vertexData.z = bMin.z + ((F32)j) * (bMax.z - bMin.z) / (terrainHeight - 1);
309 319
310 - U32 idxIMG = TER_COORD<U32>(i < (I32)heightmapWidth ? i : i - 1, j < (I32)heightmapHeight ? j : j - 1, heightmapWidth);
320 + U32 idxIMG = TER_COORD<U32>(i < (I32)heightmapWidth ? i : i - 1,
321 + j < (I32)heightmapHeight ? j : j - 1, heightmapWidth);
311 322
312 323 F32 h = (F32)(heightValues[idxIMG * 3 + 0] + heightValues[idxIMG * 3 + 1] + heightValues[idxIMG * 3 + 2]) / 3.0f;
313 324