mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -04:00
Fix incorrect rendering when chunk had over 65,536 vertices. (Thanks Empy)
This commit is contained in:
parent
1bcf89b212
commit
b2cacf6dc0
@ -155,13 +155,6 @@ namespace ClassicalSharp {
|
||||
info.TopCount = (ushort)part.vCount[Side.Top];
|
||||
info.SpriteCount = part.spriteCount;
|
||||
|
||||
info.LeftIndex = (ushort)(info.SpriteCount);
|
||||
info.RightIndex = (ushort)(info.LeftIndex + info.LeftCount);
|
||||
info.FrontIndex = (ushort)(info.RightIndex + info.RightCount);
|
||||
info.BackIndex = (ushort)(info.FrontIndex + info.FrontCount);
|
||||
info.BottomIndex = (ushort)(info.BackIndex + info.BackCount);
|
||||
info.TopIndex = (ushort)(info.BottomIndex + info.BottomCount);
|
||||
|
||||
// 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];
|
||||
@ -312,9 +305,7 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
public struct ChunkPartInfo {
|
||||
|
||||
public int VbId, VerticesCount, SpriteCount;
|
||||
public ushort LeftIndex, RightIndex, FrontIndex, BackIndex, BottomIndex, TopIndex;
|
||||
public ushort LeftCount, RightCount, FrontCount, BackCount, BottomCount, TopCount;
|
||||
}
|
||||
}
|
@ -218,42 +218,45 @@ namespace ClassicalSharp.Renderers {
|
||||
bool drawFront = info.DrawFront && part.FrontCount > 0;
|
||||
bool drawBack = info.DrawBack && part.BackCount > 0;
|
||||
|
||||
int offset = part.SpriteCount;
|
||||
if (drawLeft && drawRight) {
|
||||
gfx.FaceCulling = true;
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount + part.RightCount, part.LeftIndex);
|
||||
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, part.LeftIndex);
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount, offset);
|
||||
game.Vertices += part.LeftCount;
|
||||
} else if (drawRight) {
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.RightCount, part.RightIndex);
|
||||
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, part.FrontIndex);
|
||||
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, part.FrontIndex);
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.FrontCount, offset);
|
||||
game.Vertices += part.FrontCount;
|
||||
} else if (drawBack) {
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.BackCount, part.BackIndex);
|
||||
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, part.BottomIndex);
|
||||
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, part.BottomIndex);
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount, offset);
|
||||
game.Vertices += part.BottomCount;
|
||||
} else if (drawTop) {
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.TopCount, part.TopIndex);
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.TopCount, offset + part.BottomCount);
|
||||
game.Vertices += part.TopCount;
|
||||
}
|
||||
|
||||
@ -293,36 +296,39 @@ namespace ClassicalSharp.Renderers {
|
||||
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, part.LeftIndex);
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount + part.RightCount, offset);
|
||||
game.Vertices += (part.LeftCount + part.RightCount);
|
||||
} else if (drawLeft) {
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount, part.LeftIndex);
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.LeftCount, offset);
|
||||
game.Vertices += part.LeftCount;
|
||||
} else if (drawRight) {
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.RightCount, part.RightIndex);
|
||||
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, part.FrontIndex);
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.FrontCount + part.BackCount, offset);
|
||||
game.Vertices += (part.FrontCount + part.BackCount);
|
||||
} else if (drawFront) {
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.FrontCount, part.FrontIndex);
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.FrontCount, offset);
|
||||
game.Vertices += part.FrontCount;
|
||||
} else if (drawBack) {
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.BackCount, part.BackIndex);
|
||||
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, part.BottomIndex);
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount + part.TopCount, offset);
|
||||
game.Vertices += (part.BottomCount + part.TopCount);
|
||||
} else if (drawBottom) {
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount, part.BottomIndex);
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.BottomCount, offset);
|
||||
game.Vertices += part.BottomCount;
|
||||
} else if (drawTop) {
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.TopCount, part.TopIndex);
|
||||
gfx.DrawIndexedVb_TrisT2fC4b(part.TopCount, offset + part.BottomCount);
|
||||
game.Vertices += part.TopCount;
|
||||
}
|
||||
}
|
||||
|
@ -101,8 +101,7 @@ void MapRenderer_RenderNormalBatch(UInt32 batch) {
|
||||
Gfx_DrawIndexedVb_TrisT2fC4b(part.YMinCount, offset);
|
||||
Game_Vertices += part.YMinCount;
|
||||
} else if (drawYMax) {
|
||||
offset += part.YMinCount;
|
||||
Gfx_DrawIndexedVb_TrisT2fC4b(part.YMaxCount, offset);
|
||||
Gfx_DrawIndexedVb_TrisT2fC4b(part.YMaxCount, offset + part.YMinCount);
|
||||
Game_Vertices += part.YMaxCount;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user