Example #1
0
    public override void BuildFace(Chunk chunk, Vector3Int localPos, Direction direction)
    {
        VertexData[]      vertexData      = chunk.pools.PopVertexDataArray(4);
        VertexDataFixed[] vertexDataFixed = chunk.pools.PopVertexDataFixedArray(4);
        {
            for (int i = 0; i < 4; i++)
            {
                vertexData[i] = chunk.pools.PopVertexData();
            }

            BlockUtils.PrepareVertices(localPos, vertexData, direction);
            BlockUtils.PrepareTexture(chunk, localPos, vertexData, direction, textures);
            BlockUtils.PrepareColors(chunk, localPos, vertexData, direction);

            for (int i = 0; i < 4; i++)
            {
                vertexDataFixed[i] = VertexDataUtils.ClassToStruct(vertexData[i]);
            }
            chunk.GeometryHandler.Batcher.AddFace(vertexDataFixed);

            for (int i = 0; i < 4; i++)
            {
                chunk.pools.PushVertexData(vertexData[i]);
            }
        }
        chunk.pools.PushVertexDataFixedArray(vertexDataFixed);
        chunk.pools.PushVertexDataArray(vertexData);
    }
Example #2
0
    public override void BuildFace(Chunk chunk, Vector3[] vertices, Color32[] palette, ref BlockFace face, bool rotated)
    {
        bool backface = DirectionUtils.IsBackface(face.side);
        int  d        = DirectionUtils.Get(face.side);

        LocalPools pools = chunk.pools;
        var        verts = pools.Vector3ArrayPool.PopExact(4);
        var        uvs   = pools.Vector2ArrayPool.PopExact(4);
        var        cols  = pools.Color32ArrayPool.PopExact(4);

        {
            if (vertices == null)
            {
                Vector3 pos = face.pos;

                verts[0] = pos + BlockUtils.PaddingOffsets[d][0];
                verts[1] = pos + BlockUtils.PaddingOffsets[d][1];
                verts[2] = pos + BlockUtils.PaddingOffsets[d][2];
                verts[3] = pos + BlockUtils.PaddingOffsets[d][3];
            }
            else
            {
                verts[0] = vertices[0];
                verts[1] = vertices[1];
                verts[2] = vertices[2];
                verts[3] = vertices[3];
            }

            BlockUtils.PrepareTexture(chunk, ref face.pos, uvs, face.side, textures, rotated);
            BlockUtils.PrepareColors(chunk, cols, ref face.light);

            RenderGeometryBatcher batcher = chunk.GeometryHandler.Batcher;
            batcher.AddFace(face.materialID, verts, cols, uvs, backface);
        }

        pools.Color32ArrayPool.Push(cols);
        pools.Vector2ArrayPool.Push(uvs);
        pools.Vector3ArrayPool.Push(verts);
    }