예제 #1
0
        private void RecomputeMesh()
        {
            if (_simulationModule.IsUsingCustomBoundaries)
            {
                _surfaceVerticesCount = 4 + Mathf.RoundToInt(_subdivisionsPerUnit * (_simulationModule.RightCustomBoundary - _simulationModule.LeftCustomBoundary));
            }
            else
            {
                _surfaceVerticesCount = 2 + Mathf.RoundToInt(_subdivisionsPerUnit * _mainModule.Width);
            }

            Mesh.Clear(keepVertexLayout: false);
            Mesh.vertices  = _vertices = ComputeVertices();
            Mesh.uv        = ComputeUVs();
            Mesh.triangles = ComputeTriangles();
            Mesh.RecalculateNormals();
            Mesh.bounds = _bounds = new Bounds(Vector3.zero, _mainModule.WaterSize);

            if (OnRecomputeMesh != null)
            {
                OnRecomputeMesh.Invoke();
            }

            _updateMeshData    = false;
            _recomputeMeshData = false;
        }
예제 #2
0
        protected virtual void RecomputeMesh()
        {
            if (OnRecomputeMesh != null)
            {
                OnRecomputeMesh.Invoke();
            }

            _updateMeshData    = false;
            _recomputeMeshData = false;
        }