Example #1
0
        private void SolveLazy(Mesh mesh)
        {
            // record newly added vertices
            newlyAddedVertices.Clear();
            Int3 solveRegionMin = Int3.Max(data.dirtyRegionMin.Offset(-1, -1, -1), Int3.Zero);
            Int3 solveRegionMax = Int3.Min(data.dirtyRegionMax.Offset(1, 1, 1), dimension.Offset(-1, -1, -1));

            //Debug.Log("Solve region: " + solveRegionMin + "," + solveRegionMax);

            // Remove old vertices first
            for (int i = solveRegionMin.x; i <= solveRegionMax.x; i++)
            {
                for (int j = solveRegionMin.y; j <= solveRegionMax.y; j++)
                {
                    for (int k = solveRegionMin.z; k <= solveRegionMax.z; k++)
                    {
                        RemoveDeprecatedCellLazy(new Int3(i, j, k));
                    }
                }
            }

            // Add new vertices
            for (int i = solveRegionMin.x; i <= solveRegionMax.x; i++)
            {
                for (int j = solveRegionMin.y; j <= solveRegionMax.y; j++)
                {
                    for (int k = solveRegionMin.z; k <= solveRegionMax.z; k++)
                    {
                        UpdateOrAddNewCellLazy(new Int3(i, j, k));
                    }
                }
            }
        }
Example #2
0
        public override void Solve(Mesh mesh)
        {
            ResetSolver();
            if (!hasAddedBoundaryVertices)
            {
                AddCrossBoundaryVertices();
            }
            Int3 solveRegionMin = Int3.Max(data.dirtyRegionMin.Offset(-1, -1, -1), Int3.Zero);
            Int3 solveRegionMax = Int3.Min(data.dirtyRegionMax.Offset(1, 1, 1), dimension.Offset(-1, -1, -1));

            Debug.Log("Solve region: " + solveRegionMin + "," + solveRegionMax);

            for (int i = solveRegionMin.x; i <= solveRegionMax.x; i++)
            {
                for (int j = solveRegionMin.y; j <= solveRegionMax.y; j++)
                {
                    for (int k = solveRegionMin.z; k <= solveRegionMax.z; k++)
                    {
                        SolveCellVertex(new Int3(i, j, k));
                    }
                }
            }

            solveRegionMin = Int3.Zero;
            solveRegionMax = dimension.Offset(-1, -1, -1);
            for (int i = solveRegionMin.x; i <= solveRegionMax.x; i++)
            {
                for (int j = solveRegionMin.y; j <= solveRegionMax.y; j++)
                {
                    for (int k = solveRegionMin.z; k <= solveRegionMax.z; k++)
                    {
                        CollectCellMesh(new Int3(i, j, k));
                    }
                }
            }

            mesh.Clear();
            mesh.SetVertices(vertices);
            mesh.SetTriangles(triangles, 0);
            mesh.SetNormals(normals);
        }
Example #3
0
 public void SetDirty(Int3 coord)
 {
     dirtyRegionMin = Int3.Min(coord, dirtyRegionMin);
     dirtyRegionMax = Int3.Max(coord, dirtyRegionMax);
 }