1
0
forked from 0ad/0ad

Made CTerrain::getSlopeAngleFace even more "continous" at places where the slope changes rapidly (before, it only checked elevation forward and right, now it also looks left and up).

This was SVN commit r4340.
This commit is contained in:
Matei 2006-09-16 20:16:42 +00:00
parent 0baca62d61
commit 04b9809e0b

View File

@ -217,17 +217,16 @@ CVector2D CTerrain::getSlopeAngleFace( CEntity* entity ) const
const float D = 0.1f; // Amount to look forward to calculate the slope
float x = entity->m_position.X;
float z = entity->m_position.Z;
float y = getExactGroundLevel(x, z);
// Get forward slope and use it as the x angle
CVector2D d = entity->m_ahead.normalize() * D;
float dy = getExactGroundLevel(x+d.x, z+d.y) - y;
ret.x = atan2(dy, D);
float dy = getExactGroundLevel(x+d.x, z+d.y) - getExactGroundLevel(x-d.x, z-d.y);
ret.x = atan2(dy, 2*D);
// Get sideways slope and use it as the y angle
CVector2D d2(-d.y, d.x);
float dy2 = getExactGroundLevel(x+d2.x, z+d2.y) - y;
ret.y = atan2(dy2, D);
float dy2 = getExactGroundLevel(x+d2.x, z+d2.y) - getExactGroundLevel(x-d2.x, z-d2.y);
ret.y = atan2(dy2, 2*D);
return ret;
}