AcTools.Render.Base.Utils.GeometryGenerator.Subdivider.Subdivide4 C# (CSharp) Method

Subdivide4() public method

public Subdivide4 ( MeshData mesh ) : void
mesh MeshData
return void
            public void Subdivide4(MeshData mesh) {
                _newVertices = new Dictionary<Tuple<int, int>, int>();
                _vertices = mesh.Vertices;
                _indices = new List<int>();
                var numTris = mesh.Indices.Count / 3;

                for (var i = 0; i < numTris; i++) {
                    //       i2
                    //       *
                    //      / \
                    //     /   \
                    //   a*-----*b
                    //   / \   / \
                    //  /   \ /   \
                    // *-----*-----*
                    // i1    c      i3

                    var i1 = mesh.Indices[i * 3];
                    var i2 = mesh.Indices[i * 3 + 1];
                    var i3 = mesh.Indices[i * 3 + 2];

                    var a = GetNewVertex(i1, i2);
                    var b = GetNewVertex(i2, i3);
                    var c = GetNewVertex(i3, i1);

                    _indices.AddRange(new[] {
                        i1, a, c,
                        i2, b, a,
                        i3, c, b,
                        a, b, c
                    });
                }

                mesh.Indices = _indices;
            }
GeometryGenerator.Subdivider