Exemple #1
0
        protected override void BuildVerticiesAndIndicies()
        {
            List <int> indices;

            using (LargeObjectPools.IndexListPool.Borrow(out indices))
            {
                List <WCell.Util.Graphics.Vector3> vertices;

                using (LargeObjectPools.Vector3ListPool.Borrow(out vertices))
                {
                    indices.Clear();
                    vertices.Clear();
                    var tempVertices = new List <VertexPositionNormalColored>();

                    tile.GenerateLiquidMesh(indices, vertices);

                    if (vertices.Count == 0)
                    {
                        return;
                    }

                    foreach (var vertex in vertices)
                    {
                        var vertexPosNmlCol = new VertexPositionNormalColored(vertex.ToXna(),
                                                                              WaterColor,
                                                                              Vector3.Zero);
                        tempVertices.Add(vertexPosNmlCol);
                    }

                    _cachedIndices  = indices.ToArray();
                    _cachedVertices = tempVertices.ToArray();
                }
            }

            _renderCached = true;
        }