Description
Your Godot version:
v4.4.beta4.official.93d270693
Issue description:
In the documentation for SurfaceTool, ArrayMesh, and MeshDataTool it states:
Note: Godot uses clockwise winding order for front faces of triangle primitive modes.
I've been banging my head against this problem for quite a few hours, googled all around, and I think this is just incorrect in the documentation.
I believe Godot uses counterclockwise winding order when dealing with primitive triangles.
And indeed, in the documentation that the godot docs link to on https://learnopengl.com/ it says
By default, triangles defined with counter-clockwise vertices are processed as front-facing triangles.
And on the official openGL documentation it states:
On a freshly created OpenGL Context, the default front face is GL_CCW.
I tested a project that I'll link below, but I wrote some code to do the winding order as follows:
var st = SurfaceTool.new()
st.begin(Mesh.PRIMITIVE_TRIANGLES)
st.add_vertex(Vector3(0, 2, 0))
st.add_vertex(Vector3(2, 2, 2))
st.add_vertex(Vector3(0, 2, 2))
var mesh = st.commit()
I think you can agree this is a clockwise winding order, and assuming godot is a right-handed coordinate system, you'd expect the normal face to point "down"(-Y axis in 3D godot).
However, I created a simple project, and that's simply not the case; you can see the triangle from "above" but not below, which implies that the triangle normal is actually facing "up"(+Y). See the yellow triangle below:
Looking "down"(-Y):
Here's the project with the above code:
URL to the documentation page:
https://docs.godotengine.org/en/stable/classes/class_surfacetool.html#description
https://docs.godotengine.org/en/stable/classes/class_arraymesh.html
https://docs.godotengine.org/en/stable/classes/class_meshdatatool.html
Maybe I'm misunderstanding something here, so please double check me if I've got this right. I'll attach the sample project with the above code to the issue.
If the docs are wrong, I'm happy to submit a pull request to update the docs.