Improved GetHeightAt

Topics: Developer Forum
Jan 3, 2008 at 5:27 AM
Edited Jan 3, 2008 at 5:38 AM
I must say, I'm loving your terrain component. I was dreading the learning curve to figure out quad-tree optimisation myself so when I found this one I was delighted.

I thought I'd share some slight improvements I've made to the GetHeightAt() function. I may have simply used it wrong, but I found that things popped up and down a bit. My method is more accurate (although not perfect) but is good enough for most uses. I've named the new function GetTerrainDisplacement().

Code at:

I cheated a bit and treat each cell like a properly formed square. You could go one step further and using the example from GetHeightAt() test which triangle the point is in, then eliminate the second Lerp(). This would give you an exact result. If I end up trying this myself I'll post it.