AcidFaucet wrote:
Only issue I've seen is that terrain blocks like to disappear when the camera nears a corner and is looking at an upward angle. Not familiar enough with the terrain code yet to know whether its an issue with the bounds size or the clipping of the bounds.
Yesterday we had a look at the code again and it might be fixed by replacing some code in the
buildBlockInfo function in terrain.cpp.
Code:
const float stepU = (maxU - minU) / (_blockSize - 1);
const float stepV = (maxV - minV) / (_blockSize - 1);
for( uint32 v = 0; v < _blockSize - 1; ++v )
{
for( uint32 u = 0; u < _blockSize - 1; ++u )
instead of
Code:
const float stepU = (maxU - minU) / _blockSize;
const float stepV = (maxV - minV) / _blockSize;
for( uint32 v = 0; v < _blockSize - 1; ++v )
{
for( uint32 u = 0; u < _blockSize; ++u )
and
Code:
for( float vv = 0; vv <= stepV; vv += pixelStep )
{
for( float uu = 0; uu <= stepU; uu += pixelStep )
instead of
Code:
for( float vv = 0; vv < stepV; vv += pixelStep )
{
for( float uu = 0; uu < stepU; uu += pixelStep )
additionally in the terrain.h you have to add 0.5f before casting to int
Code:
{ return _heightData[(int)(y * (_hmapSize - 1) + 0.5f) * _hmapSize + (int)(x * (_hmapSize - 1) + 0.5f) ] / 65535.0f; }
We still had some very small culling problems with this code, but couldn't figure out why. It may be a problem with floating point precision, but we weren't motivated enough to go into more detail