Hack to load large terrains faster
by Dan Keller · 01/30/2012 (7:01 am) · 4 comments
In terrFile.cpp around line 163 comment out
This code seems to be related to terrain collision, but I don't see any reduced performance or things not working because of it. A better way to do this would, of course, be to embed this information in the terrain file, especially because the rest of buildGridMap takes about 6 seconds on my machine for a 2048 terrain. However, that is another problem for another day.
So if you, like me, want to use excessively high resolution terrains, this is a decent stopgap measure until that happens (meaning, until I get around to implementing it).
/*
Point3F pt( (F32)sizeX, (F32)sizeY, (F32)ht );
U16 dev;
if(sizeX < sizeY)
dev = calcDev(pl1, pt);
else if(sizeX > sizeY)
dev = calcDev(pl2, pt);
else
dev = Umax(calcDev(pl1, pt), calcDev(pl2, pt));
if(dev > mindev45)
mindev45 = dev;
if(sizeX + sizeY < squareSize)
dev = calcDev(pl3, pt);
else if(sizeX + sizeY > squareSize)
dev = calcDev(pl4, pt);
else
dev = Umax(calcDev(pl3, pt), calcDev(pl4, pt));
if(dev > mindev135)
mindev135 = dev;*/and at line 196 comment out/*
bool shouldSplit45 = ((squareX ^ squareY) & 1) == 0;
bool split45;
//split45 = shouldSplit45;
if ( i == 0 )
split45 = shouldSplit45;
else if( i < 4 && shouldSplit45 == parentSplit45 )
split45 = shouldSplit45;
else
split45 = mindev45 < mindev135;
//split45 = shouldSplit45;
if(split45)
{
sq->flags |= TerrainSquare::Split45;
sq->heightDeviance = mindev45;
}
else
sq->heightDeviance = mindev135;
if( parent )
if ( parent->heightDeviance < sq->heightDeviance )
parent->heightDeviance = sq->heightDeviance;*/This code seems to be related to terrain collision, but I don't see any reduced performance or things not working because of it. A better way to do this would, of course, be to embed this information in the terrain file, especially because the rest of buildGridMap takes about 6 seconds on my machine for a 2048 terrain. However, that is another problem for another day.
So if you, like me, want to use excessively high resolution terrains, this is a decent stopgap measure until that happens (meaning, until I get around to implementing it).
About the author
#2
01/30/2012 (12:14 pm)
Nice find, we'll have to keep a look out for any potential "issues" that come up from this.
#3
Haven't looked any further into it.
01/30/2012 (6:35 pm)
Gave this a jam and it seems to cause some rendering problems with decal roads in patches. Haven't looked any further into it.
#4
02/16/2013 (8:57 pm)
Revisited this just now, and the problems with decal roads can be resolved by tweaking the decal bias setting on LevelInfo. 
Torque 3D Owner Paul Yoskowitz
WinterLeaf Entertainment
if this affects the terrain collision, im rather curious what its SUPPOSED to be doin before taking it out.