MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / _loadLegacy

Method _loadLegacy

Engine/source/terrain/terrFile.cpp:364–560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

362}
363
364void TerrainFile::_loadLegacy( FileStream &stream )
365{
366 // Some legacy constants.
367 enum
368 {
369 MaterialGroups = 8,
370 BlockSquareWidth = 256,
371 };
372
373 const U32 sampleCount = BlockSquareWidth * BlockSquareWidth;
374 mSize = BlockSquareWidth;
375
376 // Load the heightmap.
377 mHeightMap.setSize( sampleCount );
378 for ( U32 i=0; i < mHeightMap.size(); i++ )
379 stream.read( &mHeightMap[i] );
380
381 // Prior to version 7 we stored this weird material struct.
382 const U32 MATERIAL_GROUP_MASK = 0x7;
383 struct Material
384 {
385 enum Flags
386 {
387 Plain = 0,
388 Rotate = 1,
389 FlipX = 2,
390 FlipXRotate = 3,
391 FlipY = 4,
392 FlipYRotate = 5,
393 FlipXY = 6,
394 FlipXYRotate = 7,
395 RotateMask = 7,
396 Empty = 8,
397 Modified = BIT(7),
398
399 // must not clobber TerrainFile::MATERIAL_GROUP_MASK bits!
400 PersistMask = BIT(7)
401 };
402
403 U8 flags;
404 U8 index;
405 };
406
407 // Temp locals for loading before we convert to the new
408 // version 7+ format.
409 U8 baseMaterialMap[sampleCount] = { 0 };
410 U8 *materialAlphaMap[MaterialGroups] = { 0 };
411 Material materialMap[BlockSquareWidth * BlockSquareWidth];
412
413 // read the material group map and flags...
414 dMemset(materialMap, 0, sizeof(materialMap));
415
416 AssertFatal(!(Material::PersistMask & MATERIAL_GROUP_MASK),
417 "Doh! We have flag clobberage...");
418
419 for (S32 j=0; j < sampleCount; j++)
420 {
421 U8 val;

Callers 1

loadMethod · 0.80

Calls 15

avarFunction · 0.85
getVariableFunction · 0.85
substrMethod · 0.80
dMemsetFunction · 0.50
StringClass · 0.50
dFreeFunction · 0.50
setSizeMethod · 0.45
sizeMethod · 0.45
readMethod · 0.45
isEmptyMethod · 0.45
push_backMethod · 0.45
getRootMethod · 0.45

Tested by

no test coverage detected