void RenderTranslucentBatchDepthPass(int batch) { for (int i = 0; i < chunks.Length; i++) { ChunkInfo info = chunks[i]; #if OCCLUSION if (info.TranslucentParts == null || !info.Visible || info.Occluded) { continue; } #else if (info.TranslucentParts == null || !info.Visible) { continue; } #endif ChunkPartInfo part = info.TranslucentParts[batch]; if (part.IndicesCount == 0) { continue; } usedTranslucent[batch] = true; DrawTranslucentPart(info, ref part); } }
void DrawTranslucentPart(ChunkInfo info, ref ChunkPartInfo part, int m) { gfx.BindVb(part.VbId); bool drawLeft = (inTranslucent || info.DrawLeft) && part.LeftCount > 0; bool drawRight = (inTranslucent || info.DrawRight) && part.RightCount > 0; bool drawBottom = (inTranslucent || info.DrawBottom) && part.BottomCount > 0; bool drawTop = (inTranslucent || info.DrawTop) && part.TopCount > 0; bool drawFront = (inTranslucent || info.DrawFront) && part.FrontCount > 0; bool drawBack = (inTranslucent || info.DrawBack) && part.BackCount > 0; if (drawLeft && drawRight) { gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount + part.RightCount, part.LeftIndex); game.Vertices += m * (part.LeftCount + part.RightCount); } else if (drawLeft) { gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount, part.LeftIndex); game.Vertices += m * part.LeftCount; } else if (drawRight) { gfx.DrawIndexedVb_TrisT2fC4b(part.RightCount, part.RightIndex); game.Vertices += m * part.RightCount; } if (drawFront && drawBack) { gfx.DrawIndexedVb_TrisT2fC4b(part.FrontCount + part.BackCount, part.FrontIndex); game.Vertices += m * (part.FrontCount + part.BackCount); } else if (drawFront) { gfx.DrawIndexedVb_TrisT2fC4b(part.FrontCount, part.FrontIndex); game.Vertices += m * part.FrontCount; } else if (drawBack) { gfx.DrawIndexedVb_TrisT2fC4b(part.BackCount, part.BackIndex); game.Vertices += m * part.BackCount; } if (drawBottom && drawTop) { gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount + part.TopCount, part.BottomIndex); game.Vertices += m * (part.BottomCount + part.TopCount); } else if (drawBottom) { gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount, part.BottomIndex); game.Vertices += m * part.BottomCount; } else if (drawTop) { gfx.DrawIndexedVb_TrisT2fC4b(part.TopCount, part.TopIndex); game.Vertices += m * part.TopCount; } }
void RenderNormalBatch(int batch) { for (int i = 0; i < chunks.Length; i++) { ChunkInfo info = chunks[i]; #if OCCLUSION if (info.NormalParts == null || !info.Visible || info.Occluded) { continue; } #else if (info.NormalParts == null || !info.Visible) { continue; } #endif ChunkPartInfo part = info.NormalParts[batch]; if (part.IndicesCount == 0) { continue; } usedNormal[batch] = true; if (part.IndicesCount > maxIndices) { DrawBigPart(info, ref part); } else { DrawPart(info, ref part); } if (part.SpriteCount > 0) { int groupCount = part.SpriteCount / 4; api.FaceCulling = true; if (info.DrawRight || info.DrawFront) { api.DrawIndexedVb_TrisT2fC4b(groupCount, 0); } if (info.DrawLeft || info.DrawBack) { api.DrawIndexedVb_TrisT2fC4b(groupCount, groupCount); } if (info.DrawLeft || info.DrawFront) { api.DrawIndexedVb_TrisT2fC4b(groupCount, groupCount * 2); } if (info.DrawRight || info.DrawBack) { api.DrawIndexedVb_TrisT2fC4b(groupCount, groupCount * 3); } api.FaceCulling = false; } game.Vertices += part.IndicesCount; } }
void DrawPart(ChunkInfo info, ref ChunkPartInfo part) { api.BindVb(part.VbId); bool drawLeft = info.DrawLeft && part.LeftCount > 0; bool drawRight = info.DrawRight && part.RightCount > 0; bool drawBottom = info.DrawBottom && part.BottomCount > 0; bool drawTop = info.DrawTop && part.TopCount > 0; bool drawFront = info.DrawFront && part.FrontCount > 0; bool drawBack = info.DrawBack && part.BackCount > 0; if (drawLeft && drawRight) { api.FaceCulling = true; api.DrawIndexedVb_TrisT2fC4b(part.LeftCount + part.RightCount, part.LeftIndex); api.FaceCulling = false; } else if (drawLeft) { api.DrawIndexedVb_TrisT2fC4b(part.LeftCount, part.LeftIndex); } else if (drawRight) { api.DrawIndexedVb_TrisT2fC4b(part.RightCount, part.RightIndex); } if (drawFront && drawBack) { api.FaceCulling = true; api.DrawIndexedVb_TrisT2fC4b(part.FrontCount + part.BackCount, part.FrontIndex); api.FaceCulling = false; } else if (drawFront) { api.DrawIndexedVb_TrisT2fC4b(part.FrontCount, part.FrontIndex); } else if (drawBack) { api.DrawIndexedVb_TrisT2fC4b(part.BackCount, part.BackIndex); } if (drawBottom && drawTop) { api.FaceCulling = true; api.DrawIndexedVb_TrisT2fC4b(part.BottomCount + part.TopCount, part.BottomIndex); api.FaceCulling = false; } else if (drawBottom) { api.DrawIndexedVb_TrisT2fC4b(part.BottomCount, part.BottomIndex); } else if (drawTop) { api.DrawIndexedVb_TrisT2fC4b(part.TopCount, part.TopIndex); } }
void RenderNormalBatch(int batch) { for (int i = 0; i < renderCount; i++) { ChunkInfo info = renderChunks[i]; if (info.NormalParts == null) { continue; } ChunkPartInfo part = info.NormalParts[batch]; if (part.IndicesCount == 0) { continue; } usedNormal[batch] = true; if (part.IndicesCount > maxIndices) { DrawBigPart(info, ref part); } else { DrawPart(info, ref part); } if (part.SpriteCount > 0) { int count = part.SpriteCount / 4; // 4 per sprite gfx.FaceCulling = true; if (info.DrawRight || info.DrawFront) { gfx.DrawIndexedVb_TrisT2fC4b(count, 0); game.Vertices += count; } if (info.DrawLeft || info.DrawBack) { gfx.DrawIndexedVb_TrisT2fC4b(count, count); game.Vertices += count; } if (info.DrawLeft || info.DrawFront) { gfx.DrawIndexedVb_TrisT2fC4b(count, count * 2); game.Vertices += count; } if (info.DrawRight || info.DrawBack) { gfx.DrawIndexedVb_TrisT2fC4b(count, count * 3); game.Vertices += count; } gfx.FaceCulling = false; } } }
void DrawTranslucentPart(ChunkInfo info, ref ChunkPartInfo part) { api.BindVb(part.VbId); bool drawLeft = (drawAllFaces || info.DrawLeft) && part.LeftCount > 0; bool drawRight = (drawAllFaces || info.DrawRight) && part.RightCount > 0; bool drawBottom = (drawAllFaces || info.DrawBottom) && part.BottomCount > 0; bool drawTop = (drawAllFaces || info.DrawTop) && part.TopCount > 0; bool drawFront = (drawAllFaces || info.DrawFront) && part.FrontCount > 0; bool drawBack = (drawAllFaces || info.DrawBack) && part.BackCount > 0; if (drawLeft && drawRight) { api.DrawIndexedVb_TrisT2fC4b(part.LeftCount + part.RightCount, part.LeftIndex); } else if (drawLeft) { api.DrawIndexedVb_TrisT2fC4b(part.LeftCount, part.LeftIndex); } else if (drawRight) { api.DrawIndexedVb_TrisT2fC4b(part.RightCount, part.RightIndex); } if (drawFront && drawBack) { api.DrawIndexedVb_TrisT2fC4b(part.FrontCount + part.BackCount, part.FrontIndex); } else if (drawFront) { api.DrawIndexedVb_TrisT2fC4b(part.FrontCount, part.FrontIndex); } else if (drawBack) { api.DrawIndexedVb_TrisT2fC4b(part.BackCount, part.BackIndex); } if (drawBottom && drawTop) { api.DrawIndexedVb_TrisT2fC4b(part.BottomCount + part.TopCount, part.BottomIndex); } else if (drawBottom) { api.DrawIndexedVb_TrisT2fC4b(part.BottomCount, part.BottomIndex); } else if (drawTop) { api.DrawIndexedVb_TrisT2fC4b(part.TopCount, part.TopIndex); } }
void RenderTranslucentBatch(int batch) { for (int i = 0; i < renderCount; i++) { ChunkInfo info = renderChunks[i]; if (info.TranslucentParts == null) { continue; } ChunkPartInfo part = info.TranslucentParts[batch]; if (part.IndicesCount == 0) { continue; } DrawTranslucentPart(info, ref part, 1); } }
void DrawBigPart(ChunkInfo info, ref ChunkPartInfo part) { gfx.BindVb(part.VbId); bool drawLeft = info.DrawLeft && part.LeftCount > 0; bool drawRight = info.DrawRight && part.RightCount > 0; bool drawBottom = info.DrawBottom && part.BottomCount > 0; bool drawTop = info.DrawTop && part.TopCount > 0; bool drawFront = info.DrawFront && part.FrontCount > 0; bool drawBack = info.DrawBack && part.BackCount > 0; if (drawLeft && drawRight) { gfx.FaceCulling = true; gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount + part.RightCount, part.LeftIndex); gfx.FaceCulling = false; game.Vertices += part.LeftCount + part.RightCount; } else if (drawLeft) { gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount, part.LeftIndex); game.Vertices += part.LeftCount; } else if (drawRight) { gfx.DrawIndexedVb_TrisT2fC4b(part.RightCount, part.RightIndex); game.Vertices += part.RightCount; } if (drawFront && drawBack) { gfx.FaceCulling = true; gfx.DrawIndexedVb_TrisT2fC4b(part.FrontCount + part.BackCount, part.FrontIndex); gfx.FaceCulling = false; game.Vertices += part.FrontCount + part.BackCount; } else if (drawFront) { gfx.DrawIndexedVb_TrisT2fC4b(part.FrontCount, part.FrontIndex); game.Vertices += part.FrontCount; } else if (drawBack) { gfx.DrawIndexedVb_TrisT2fC4b(part.BackCount, part.BackIndex); game.Vertices += part.BackCount; } // Special handling for top and bottom as these can go over 65536 vertices and we need to adjust the indices in this case. if (drawBottom && drawTop) { gfx.FaceCulling = true; if (part.IndicesCount > maxIndices) { int part1Count = maxIndices - part.BottomIndex; gfx.DrawIndexedVb_TrisT2fC4b(part1Count, part.BottomIndex); gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount + part.TopCount - part1Count, maxVertex, 0); } else { gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount + part.TopCount, part.BottomIndex); } gfx.FaceCulling = false; game.Vertices += part.TopCount + part.BottomCount; } else if (drawBottom) { int part1Count; if (part.IndicesCount > maxIndices && (part1Count = maxIndices - part.BottomIndex) < part.BottomCount) { gfx.DrawIndexedVb_TrisT2fC4b(part1Count, part.BottomIndex); gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount - part1Count, maxVertex, 0); } else { gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount, part.BottomIndex); } game.Vertices += part.BottomCount; } else if (drawTop) { int part1Count; if (part.IndicesCount > maxIndices && (part1Count = maxIndices - part.TopIndex) < part.TopCount) { gfx.DrawIndexedVb_TrisT2fC4b(part1Count, part.TopIndex); gfx.DrawIndexedVb_TrisT2fC4b(part.TopCount - part1Count, maxVertex, 0); } else { gfx.DrawIndexedVb_TrisT2fC4b(part.TopCount, part.TopIndex); } game.Vertices += part.TopCount; } }
void RenderTranslucentBatch(int batch) { IGraphicsApi gfx = game.Graphics; for (int i = 0; i < renderCount; i++) { ChunkInfo info = renderChunks[i]; if (info.TranslucentParts == null) { continue; } ChunkPartInfo part = info.TranslucentParts[batch]; if (part.VerticesCount == 0) { continue; } usedTranslucent[batch] = true; gfx.BindVb(part.VbId); bool drawLeft = (inTranslucent || info.DrawLeft) && part.LeftCount > 0; bool drawRight = (inTranslucent || info.DrawRight) && part.RightCount > 0; bool drawBottom = (inTranslucent || info.DrawBottom) && part.BottomCount > 0; bool drawTop = (inTranslucent || info.DrawTop) && part.TopCount > 0; bool drawFront = (inTranslucent || info.DrawFront) && part.FrontCount > 0; bool drawBack = (inTranslucent || info.DrawBack) && part.BackCount > 0; int offset = 0; if (drawLeft && drawRight) { gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount + part.RightCount, offset); game.Vertices += (part.LeftCount + part.RightCount); } else if (drawLeft) { gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount, offset); game.Vertices += part.LeftCount; } else if (drawRight) { gfx.DrawIndexedVb_TrisT2fC4b(part.RightCount, offset + part.LeftCount); game.Vertices += part.RightCount; } offset += part.LeftCount + part.RightCount; if (drawFront && drawBack) { gfx.DrawIndexedVb_TrisT2fC4b(part.FrontCount + part.BackCount, offset); game.Vertices += (part.FrontCount + part.BackCount); } else if (drawFront) { gfx.DrawIndexedVb_TrisT2fC4b(part.FrontCount, offset); game.Vertices += part.FrontCount; } else if (drawBack) { gfx.DrawIndexedVb_TrisT2fC4b(part.BackCount, offset + part.FrontCount); game.Vertices += part.BackCount; } offset += part.FrontCount + part.BackCount; if (drawBottom && drawTop) { gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount + part.TopCount, offset); game.Vertices += (part.BottomCount + part.TopCount); } else if (drawBottom) { gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount, offset); game.Vertices += part.BottomCount; } else if (drawTop) { gfx.DrawIndexedVb_TrisT2fC4b(part.TopCount, offset + part.BottomCount); game.Vertices += part.TopCount; } } }
void RenderLiquidBatch(int batch) { IGraphicsApi gfx = game.Graphics; for (int i = 0; i < renderCount; i++) { ChunkInfo info = renderChunks[i]; if (info.LiquidParts == null) { continue; } ChunkPartInfo part = info.LiquidParts[batch]; if (part.VerticesCount == 0) { continue; } usedLiquid[batch] = true; gfx.BindVb(part.VbId); bool drawLeft = (inLiquid || info.DrawLeft) && part.LeftCount > 0; bool drawRight = (inLiquid || info.DrawRight) && part.RightCount > 0; bool drawBottom = (inLiquid || info.DrawBottom) && part.BottomCount > 0; bool drawTop = (inLiquid || info.DrawTop) && part.TopCount > 0; bool drawFront = (inLiquid || info.DrawFront) && part.FrontCount > 0; bool drawBack = (inLiquid || info.DrawBack) && part.BackCount > 0; int offset = 0; if (drawLeft && drawRight) { gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount + part.RightCount, offset); game.Vertices += part.LeftCount + part.RightCount; } else if (drawLeft) { gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount, offset); game.Vertices += part.LeftCount; } else if (drawRight) { gfx.DrawIndexedVb_TrisT2fC4b(part.RightCount, offset + part.LeftCount); game.Vertices += part.RightCount; } offset += part.LeftCount + part.RightCount; if (drawFront && drawBack) { gfx.DrawIndexedVb_TrisT2fC4b(part.FrontCount + part.BackCount, offset); game.Vertices += part.FrontCount + part.BackCount; } else if (drawFront) { gfx.DrawIndexedVb_TrisT2fC4b(part.FrontCount, offset); game.Vertices += part.FrontCount; } else if (drawBack) { gfx.DrawIndexedVb_TrisT2fC4b(part.BackCount, offset + part.FrontCount); game.Vertices += part.BackCount; } offset += part.FrontCount + part.BackCount; if (drawBottom && drawTop) { gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount + part.TopCount, offset); game.Vertices += part.TopCount + part.BottomCount; } else if (drawBottom) { gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount, offset); game.Vertices += part.BottomCount; } else if (drawTop) { gfx.DrawIndexedVb_TrisT2fC4b(part.TopCount, offset + part.BottomCount); game.Vertices += part.TopCount; } /*if (part.SpriteCount == 0) continue; * int count = part.SpriteCount / 4; // 4 per sprite * gfx.FaceCulling = true; * if (info.DrawRight || info.DrawFront) { * gfx.DrawIndexedVb_TrisT2fC4b(count, 0); game.Vertices += count; * } * if (info.DrawLeft || info.DrawBack) { * gfx.DrawIndexedVb_TrisT2fC4b(count, count); game.Vertices += count; * } * if (info.DrawLeft || info.DrawFront) { * gfx.DrawIndexedVb_TrisT2fC4b(count, count * 2); game.Vertices += count; * } * if (info.DrawRight || info.DrawBack) { * gfx.DrawIndexedVb_TrisT2fC4b(count, count * 3); game.Vertices += count; * } * gfx.FaceCulling = false;*/ } }
void RenderNormalBatch(int batch) { IGraphicsApi gfx = game.Graphics; for (int i = 0; i < renderCount; i++) { ChunkInfo info = renderChunks[i]; if (info.NormalParts == null) { continue; } ChunkPartInfo part = info.NormalParts[batch]; if (part.VerticesCount == 0) { continue; } usedNormal[batch] = true; gfx.BindVb(part.VbId); bool drawLeft = info.DrawLeft && part.LeftCount > 0; bool drawRight = info.DrawRight && part.RightCount > 0; bool drawBottom = info.DrawBottom && part.BottomCount > 0; bool drawTop = info.DrawTop && part.TopCount > 0; bool drawFront = info.DrawFront && part.FrontCount > 0; bool drawBack = info.DrawBack && part.BackCount > 0; bool camCloseX = Math.Abs(info.CentreX - game.CurrentCameraPos.X) < 8; bool camCloseY = Math.Abs(info.CentreY - game.CurrentCameraPos.Y) < 8; bool camCloseZ = Math.Abs(info.CentreZ - game.CurrentCameraPos.Z) < 8; //camCloseX = true; //camCloseY = true; //camCloseZ = true; int offset = part.SpriteCount; if (drawLeft && drawRight) { gfx.FaceCulling = true; gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount + part.RightCount, offset); gfx.FaceCulling = false; game.Vertices += part.LeftCount + part.RightCount; } else if (drawLeft && camCloseX) { gfx.FaceCulling = true; gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount, offset); gfx.FaceCulling = false; game.Vertices += part.LeftCount; } else if (drawRight && camCloseX) { gfx.FaceCulling = true; gfx.DrawIndexedVb_TrisT2fC4b(part.RightCount, offset + part.LeftCount); gfx.FaceCulling = false; game.Vertices += part.RightCount; } else if (drawLeft) { gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount, offset); game.Vertices += part.LeftCount; } else if (drawRight) { gfx.DrawIndexedVb_TrisT2fC4b(part.RightCount, offset + part.LeftCount); game.Vertices += part.RightCount; } offset += part.LeftCount + part.RightCount; if (drawFront && drawBack) { gfx.FaceCulling = true; gfx.DrawIndexedVb_TrisT2fC4b(part.FrontCount + part.BackCount, offset); gfx.FaceCulling = false; game.Vertices += part.FrontCount + part.BackCount; } else if (drawFront && camCloseZ) { gfx.FaceCulling = true; gfx.DrawIndexedVb_TrisT2fC4b(part.FrontCount, offset); gfx.FaceCulling = false; game.Vertices += part.FrontCount; } else if (drawBack && camCloseZ) { gfx.FaceCulling = true; gfx.DrawIndexedVb_TrisT2fC4b(part.BackCount, offset + part.FrontCount); gfx.FaceCulling = false; game.Vertices += part.BackCount; } else if (drawFront) { gfx.DrawIndexedVb_TrisT2fC4b(part.FrontCount, offset); game.Vertices += part.FrontCount; } else if (drawBack) { gfx.DrawIndexedVb_TrisT2fC4b(part.BackCount, offset + part.FrontCount); game.Vertices += part.BackCount; } offset += part.FrontCount + part.BackCount; if (drawBottom && drawTop) { gfx.FaceCulling = true; gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount + part.TopCount, offset); gfx.FaceCulling = false; game.Vertices += part.TopCount + part.BottomCount; } else if (drawBottom && camCloseY) { gfx.FaceCulling = true; gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount, offset); gfx.FaceCulling = false; game.Vertices += part.BottomCount; } else if (drawTop && camCloseY) { gfx.FaceCulling = true; gfx.DrawIndexedVb_TrisT2fC4b(part.TopCount, offset + part.BottomCount); gfx.FaceCulling = false; game.Vertices += part.TopCount; } else if (drawBottom) { gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount, offset); game.Vertices += part.BottomCount; } else if (drawTop) { gfx.DrawIndexedVb_TrisT2fC4b(part.TopCount, offset + part.BottomCount); game.Vertices += part.TopCount; } if (part.SpriteCount == 0) { continue; } int count = part.SpriteCount / 4; // 4 per sprite gfx.FaceCulling = true; if (info.DrawRight || info.DrawFront) { gfx.DrawIndexedVb_TrisT2fC4b(count, 0); game.Vertices += count; } if (info.DrawLeft || info.DrawBack) { gfx.DrawIndexedVb_TrisT2fC4b(count, count); game.Vertices += count; } if (info.DrawLeft || info.DrawFront) { gfx.DrawIndexedVb_TrisT2fC4b(count, count * 2); game.Vertices += count; } if (info.DrawRight || info.DrawBack) { gfx.DrawIndexedVb_TrisT2fC4b(count, count * 3); game.Vertices += count; } gfx.FaceCulling = false; } }
void RenderNormalBatch(int batch) { for (int i = 0; i < renderCount; i++) { ChunkInfo info = renderChunks[i]; if (info.NormalParts == null) { continue; } ChunkPartInfo part = info.NormalParts[batch]; if (part.VerticesCount == 0) { continue; } usedNormal[batch] = true; gfx.BindVb(part.VbId); bool drawLeft = info.DrawLeft && part.LeftCount > 0; bool drawRight = info.DrawRight && part.RightCount > 0; bool drawBottom = info.DrawBottom && part.BottomCount > 0; bool drawTop = info.DrawTop && part.TopCount > 0; bool drawFront = info.DrawFront && part.FrontCount > 0; bool drawBack = info.DrawBack && part.BackCount > 0; if (drawLeft && drawRight) { gfx.FaceCulling = true; gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount + part.RightCount, part.LeftIndex); gfx.FaceCulling = false; game.Vertices += part.LeftCount + part.RightCount; } else if (drawLeft) { gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount, part.LeftIndex); game.Vertices += part.LeftCount; } else if (drawRight) { gfx.DrawIndexedVb_TrisT2fC4b(part.RightCount, part.RightIndex); game.Vertices += part.RightCount; } if (drawFront && drawBack) { gfx.FaceCulling = true; gfx.DrawIndexedVb_TrisT2fC4b(part.FrontCount + part.BackCount, part.FrontIndex); gfx.FaceCulling = false; game.Vertices += part.FrontCount + part.BackCount; } else if (drawFront) { gfx.DrawIndexedVb_TrisT2fC4b(part.FrontCount, part.FrontIndex); game.Vertices += part.FrontCount; } else if (drawBack) { gfx.DrawIndexedVb_TrisT2fC4b(part.BackCount, part.BackIndex); game.Vertices += part.BackCount; } if (drawBottom && drawTop) { gfx.FaceCulling = true; gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount + part.TopCount, part.BottomIndex); gfx.FaceCulling = false; game.Vertices += part.TopCount + part.BottomCount; } else if (drawBottom) { gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount, part.BottomIndex); game.Vertices += part.BottomCount; } else if (drawTop) { gfx.DrawIndexedVb_TrisT2fC4b(part.TopCount, part.TopIndex); game.Vertices += part.TopCount; } if (part.SpriteCount == 0) { continue; } int count = part.SpriteCount / 4; // 4 per sprite gfx.FaceCulling = true; if (info.DrawRight || info.DrawFront) { gfx.DrawIndexedVb_TrisT2fC4b(count, 0); game.Vertices += count; } if (info.DrawLeft || info.DrawBack) { gfx.DrawIndexedVb_TrisT2fC4b(count, count); game.Vertices += count; } if (info.DrawLeft || info.DrawFront) { gfx.DrawIndexedVb_TrisT2fC4b(count, count * 2); game.Vertices += count; } if (info.DrawRight || info.DrawBack) { gfx.DrawIndexedVb_TrisT2fC4b(count, count * 3); game.Vertices += count; } gfx.FaceCulling = false; } }
void RenderNormalBatch(int batch) { IGraphicsApi gfx = game.Graphics; for (int i = 0; i < renderCount; i++) { ChunkInfo info = renderChunks[i]; if (info.NormalParts == null) { continue; } ChunkPartInfo part = info.NormalParts[batch]; if (part.Offset < 0) { continue; } usedNormal[batch] = true; #if !GL11 gfx.BindVb(info.Vb); #else gfx.BindVb(part.Vb); #endif bool drawLeft = info.DrawLeft && part.LeftCount > 0; bool drawRight = info.DrawRight && part.RightCount > 0; bool drawBottom = info.DrawBottom && part.BottomCount > 0; bool drawTop = info.DrawTop && part.TopCount > 0; bool drawFront = info.DrawFront && part.FrontCount > 0; bool drawBack = info.DrawBack && part.BackCount > 0; int offset = part.Offset + part.SpriteCount; if (drawLeft && drawRight) { gfx.FaceCulling = true; gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount + part.RightCount, offset); gfx.FaceCulling = false; game.Vertices += part.LeftCount + part.RightCount; } else if (drawLeft) { gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount, offset); game.Vertices += part.LeftCount; } else if (drawRight) { gfx.DrawIndexedVb_TrisT2fC4b(part.RightCount, offset + part.LeftCount); game.Vertices += part.RightCount; } offset += part.LeftCount + part.RightCount; if (drawFront && drawBack) { gfx.FaceCulling = true; gfx.DrawIndexedVb_TrisT2fC4b(part.FrontCount + part.BackCount, offset); gfx.FaceCulling = false; game.Vertices += part.FrontCount + part.BackCount; } else if (drawFront) { gfx.DrawIndexedVb_TrisT2fC4b(part.FrontCount, offset); game.Vertices += part.FrontCount; } else if (drawBack) { gfx.DrawIndexedVb_TrisT2fC4b(part.BackCount, offset + part.FrontCount); game.Vertices += part.BackCount; } offset += part.FrontCount + part.BackCount; if (drawBottom && drawTop) { gfx.FaceCulling = true; gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount + part.TopCount, offset); gfx.FaceCulling = false; game.Vertices += part.TopCount + part.BottomCount; } else if (drawBottom) { gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount, offset); game.Vertices += part.BottomCount; } else if (drawTop) { gfx.DrawIndexedVb_TrisT2fC4b(part.TopCount, offset + part.BottomCount); game.Vertices += part.TopCount; } if (part.SpriteCount == 0) { continue; } offset = part.Offset; int count = part.SpriteCount / 4; // 4 per sprite gfx.FaceCulling = true; if (info.DrawRight || info.DrawFront) { gfx.DrawIndexedVb_TrisT2fC4b(count, offset); game.Vertices += count; } offset += count; if (info.DrawLeft || info.DrawBack) { gfx.DrawIndexedVb_TrisT2fC4b(count, offset); game.Vertices += count; } offset += count; if (info.DrawLeft || info.DrawFront) { gfx.DrawIndexedVb_TrisT2fC4b(count, offset); game.Vertices += count; } offset += count; if (info.DrawRight || info.DrawBack) { gfx.DrawIndexedVb_TrisT2fC4b(count, offset); game.Vertices += count; } offset += count; gfx.FaceCulling = false; } }