There’s something that’s bothering me about this query, particularly:
- The query is being requested as if every grid location has a top.
- Nevertheless the mesh defines the peak of the 4 corners of every grid location (not the middle of the grid itself).
Most probably every grid sq. is definitely being rendered utilizing two triangles therefore the (middle) top of the grid is the typical of solely two factors (wanting on the pictures – I believe it is the highest and backside factors).
Assuming all the pieces I’ve stated is appropriate, you would simply common the right two factors for the present location and do the identical for every of the eight instructions, so as to decide the gradient for every attainable transfer. Nevertheless since you are solely utilizing two (of the 4) factors to find out the peak of every grid location I believe there shall be some bizarre artifacts the place the sport will enable some strikes that seem like they shouldn’t be attainable.
Reducing to the chase, given the significance of the peak of the terrain to find out which routes are satisfactory I might contemplate rethinking how the maps are draw in order that:
- The peak of every grid sq. is clearly displayed.
- Its apparent which instructions are satisfactory.
- The grid “squares” are nonetheless clear.
One attainable reply could also be to double the variety of vertices horizontally and vertically that manner the middle of every grid might be on a vertex and you’ll have 8 intermediate vertices (one for every motion course) between the present location and the middle of every of the adjoining squares – which can can help you clean the heights of of these factors learn: the intermediate level is simply the typical of the present and adjoining sq..
You may additionally need to structure the triangle sample barely in a different way, for instance a single “doubled up” grid sq. might have 8 triangles:
+--+--+
| "https://gamedev.stackexchange.com/"
| "https://gamedev.stackexchange.com/"
+--+--+
"https://gamedev.stackexchange.com/" |
"https://gamedev.stackexchange.com/" |
+--+--+
The “drawback” with this strategy is, your grid “Squares” now have 8 sides….