Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Use a queue instead of a stack
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver-makes-code committed Jan 22, 2024
1 parent be7083b commit d64b822
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Client/Rendering/World/ChunkRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ public override void Render(double delta) {
CommandList.SetIndexBuffer(RenderSystem.CommonIndexBuffer, IndexFormat.UInt32);

using (RenderKey.Push()) {
var queue = new Stack<ivec3>();
var queue = new Queue<ivec3>();
var visited = new HashSet<ivec3>();
queue.Push(ivec3.Zero);
queue.Add(ivec3.Zero);
visited.Add(ivec3.Zero);
var rootPos = Client.GameRenderer.MainCamera.position.WorldToChunkPosition();

Expand All @@ -118,7 +118,7 @@ public override void Render(double delta) {
var frustum = Client.GameRenderer.MainCamera.Frustum;

while (queue.Count > 0) {
var curr = queue.Pop();
var curr = queue.Remove();
var index = GetLoopedArrayIndex(curr + rootPos);
var chunk = renderSlots[index];
if (chunk == null)
Expand All @@ -139,7 +139,7 @@ public override void Render(double delta) {
))
)
continue;
queue.Push(pos);
queue.Add(pos);
visited.Add(pos);
}
}
Expand Down

0 comments on commit d64b822

Please sign in to comment.