Game Development Community

getTerrainHeight and getTerrainHeightBelowPosition - LOGGED

by Guy Allard · in Torque 3D Professional · 10/06/2009 (11:18 pm) · 4 replies

GetTerrainHeight and getTerrainHeightBelowPosition do not take into account the z-position of the terrain block.
As a result, they only return the correct terrain height when the terrain is positioned at (x, y, 0).

#1
01/13/2010 (2:18 pm)
I have the same issue

DecalRoad::_getTerrainHeight is ok. It takes into account the z-position.

and

ConsoleFunction - getTerrainHeight doesn't.

I've replaced the console version of getTerrainHeight code with DecalRoad::_getTerrainHeight code.
#2
01/14/2010 (7:51 am)
I wouldn't be surprised if this goes back to TGE where you basically always had just a single terrain block.

What's important to note, though, is that these functions exclusively query the heightmap, i.e. they do a lookup and directly return a heightmap value. This is a big difference to DecalRoad::_getTerrainHeight which does a full raycast and thus gets the actual terrain height at the given coordinates whereas the the getTerrainHeight console functions return the heightmap value of the nearest grid vertex (which can be quite a bit off from the actual query position).

If the behavior of DecalRoad::_getTerrainHeight is what you actually want, you can just do a raycast in script. This is only a few lines and can be wrapped in a function if desired.
#3
01/14/2010 (8:22 am)
Ok. Yes, I'll do it.

Thanks for the explanation Rene.

This is better than modify the engine when it's not really needed.

#4
06/15/2010 (6:44 pm)
Logged: TQA-338