Beispiel #1
0
        void SetPartInfo(DrawInfo part, int i, ref ChunkPartInfo[] parts)
        {
            int vertCount = part.VerticesCount();

            if (vertCount == 0)
            {
                return;
            }

            ChunkPartInfo info;

            fixed(VertexP3fT2fC4b *ptr = part.vertices)
            {
                // add an extra element to fix crashing on some GPUs
                info.VbId = game.Graphics.CreateVb((IntPtr)ptr, VertexFormat.P3fT2fC4b, vertCount + 1);
            }

            info.VerticesCount = vertCount;

            info.LeftCount   = (ushort)part.vCount[Side.Left];
            info.RightCount  = (ushort)part.vCount[Side.Right];
            info.FrontCount  = (ushort)part.vCount[Side.Front];
            info.BackCount   = (ushort)part.vCount[Side.Back];
            info.BottomCount = (ushort)part.vCount[Side.Bottom];
            info.TopCount    = (ushort)part.vCount[Side.Top];
            info.SpriteCount = part.spriteCount;

            // Lazy initalize part arrays so we can save time in MapRenderer for chunks that only contain 1 or 2 part types.
            if (parts == null)
            {
                parts = new ChunkPartInfo[arraysCount];
            }
            parts[i] = info;
        }
Beispiel #2
0
        void SetPartInfo(DrawInfo part, ref int offset, int i, ref ChunkPartInfo[] parts)
        {
            int vertCount = part.VerticesCount();

            if (vertCount == 0)
            {
                return;
            }

            ChunkPartInfo info;

            info.Offset = offset;
            offset     += vertCount;

                        #if GL11
            fixed(VertexP3fT2fC4b *ptr = vertices)
            {
                VertexP3fT2fC4b *ptr2 = ptr + info.Offset;

                info.Vb = game.Graphics.CreateVb((IntPtr)ptr, VertexFormat.P3fT2fC4b, vertCount);
            }
                        #endif

            info.LeftCount   = (ushort)part.vCount[Side.Left];
            info.RightCount  = (ushort)part.vCount[Side.Right];
            info.FrontCount  = (ushort)part.vCount[Side.Front];
            info.BackCount   = (ushort)part.vCount[Side.Back];
            info.BottomCount = (ushort)part.vCount[Side.Bottom];
            info.TopCount    = (ushort)part.vCount[Side.Top];
            info.SpriteCount = part.spriteCount;

            // Lazy initalize part arrays so we can save time in MapRenderer for chunks that only contain 1 or 2 part types.
            if (parts == null)
            {
                parts = new ChunkPartInfo[arraysCount];
                for (int j = 0; j < parts.Length; j++)
                {
                    parts[j].Offset = -1;
                }
            }
            parts[i] = info;
        }