From d1db8c585ba2b1adc67f24e9dec8e8cb5c6d5f2f Mon Sep 17 00:00:00 2001 From: Christian Zommerfelds Date: Fri, 19 Dec 2025 11:38:36 +0100 Subject: [PATCH] Merge pull request #11529 from zommerfelds/patch-1 Clarify SurfaceTool example with index --- .../3d/procedural_geometry/surfacetool.rst | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/tutorials/3d/procedural_geometry/surfacetool.rst b/tutorials/3d/procedural_geometry/surfacetool.rst index a326f2c31..6b95d1727 100644 --- a/tutorials/3d/procedural_geometry/surfacetool.rst +++ b/tutorials/3d/procedural_geometry/surfacetool.rst @@ -121,18 +121,12 @@ shrinks the vertex array to remove duplicate vertices. st.add_vertex(Vector3(1, -1, 0)) st.add_vertex(Vector3(-1, -1, 0)) - # We can make the quad more efficient by using an index array and only utilizing 4 vertices + # We can make the quad more efficient by using an index array and only utilizing 4 vertices: - # Suppose we have a quad defined by 6 vertices as follows st.add_vertex(Vector3(-1, 1, 0)) st.add_vertex(Vector3(1, 1, 0)) st.add_vertex(Vector3(-1, -1, 0)) - - st.add_vertex(Vector3(1, 1, 0)) st.add_vertex(Vector3(1, -1, 0)) - st.add_vertex(Vector3(-1, -1, 0)) - - # We can make the quad more efficient by using an index array and only utilizing 4 vertices # Creates a quad from four corner vertices. # add_index() can be called before or after add_vertex() @@ -150,6 +144,21 @@ shrinks the vertex array to remove duplicate vertices. .. code-tab:: csharp + // Suppose we have a quad defined by 6 vertices as follows. + st.AddVertex(new Vector3(-1, 1, 0)); + st.AddVertex(new Vector3(1, 1, 0)); + st.AddVertex(new Vector3(-1, -1, 0)); + + st.AddVertex(new Vector3(1, 1, 0)); + st.AddVertex(new Vector3(1, -1, 0)); + st.AddVertex(new Vector3(-1, -1, 0)); + + // We can make the quad more efficient by using an index array and only utilizing 4 vertices: + st.AddVertex(new Vector3(-1, -1, 0)); + st.AddVertex(new Vector3(1, 1, 0)); + st.AddVertex(new Vector3(-1, -1, 0)); + st.AddVertex(new Vector3(1, 1, 0)); + // Creates a quad from four corner vertices. // AddIndex does not need to be called before AddVertex. st.AddIndex(0); @@ -160,7 +169,7 @@ shrinks the vertex array to remove duplicate vertices. st.AddIndex(3); st.AddIndex(2); - // Alternatively: + // Alternatively we can use `st.Index()` which will create the quad for us and remove the duplicate vertices. st.Index(); Similarly, if you have an index array, but you want each vertex to be unique (e.g. because