WIreframes - How to invert wireframe triangles

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By gisburger

Hi all,

Background
I am relatively new to Godot, I have just converted from Game Maker Studio 2.

I have created an island similar to this one: https://www.youtube.com/watch?v=tV-S9CY3F1o

Psudo code:
noise
plane mesh
surface tool
mesh data tool
create MeshInstance

Problem
I have rounded the height values to ten possible levels which makes the island terraced, a style I am going after.

The issue is that any edge that is on an angle NW to SE is rendered as a saw tooth, any line NE to SW is fine. This is due to how the mesh works.

A typical wire frame for 4 vertices as I understand it:

12
34

Would render the triangles 1,2,3 and 2,3,4

In the NE-SW direction this is fine as 2-3 is an edge. In the NW-SE case there is not an edge, so two edges will be used 1-2 and 2-4 (along with 1-3 and 3-4).

In picture form, in picture a) if we assume that dark grey is higher than white I would like to be able to swap which vertices are used to draw the triangles for that particular set of four vertices.

I have tried
PRIMITIVE_TRIANGLES
PRIMITIVE_TRIANGLE_STRIP
PRIMITIVE_TRIANGLE_FAN

I had a quick exploration into how the data_tool (I think?) stores the vertices. My thinking was that I could iterate through and check relative heights to neighbor vertices, and swap the order of two vertices accordingly, however between tests and the documentation I could not work out how the data is stored/used.

If any additional information is required please ask. I appreciate any help that can be given.

Thanks

UPDATE: I now think I need to change something in the surface_tool step, although the documentation is very high level and I’m not sure how to change it.