Cleaned up project with better structure.

This commit is contained in:
2026-05-09 11:29:48 +02:00
parent 1ad3454f6a
commit 6708aa277f
95 changed files with 711 additions and 700 deletions
+45
View File
@@ -0,0 +1,45 @@
using Godot;
using System.Collections.Generic;
public class MultiMeshHandler
{
private readonly Dictionary<string, MultiMeshInstance3D> multiMeshes;
public MultiMeshHandler(Dictionary<string, MultiMeshInstance3D> multiMeshes)
{
this.multiMeshes = multiMeshes;
}
public void Build(List<TileRenderData> tiles)
{
foreach (MultiMeshInstance3D multiMeshInstance in multiMeshes.Values)
{
multiMeshInstance.Multimesh.InstanceCount = 0;
}
Dictionary<string, List<Transform3D>> batches = new Dictionary<string, List<Transform3D>>();
foreach (TileRenderData tile in tiles)
{
if (!batches.ContainsKey(tile.MeshKey))
{
batches[tile.MeshKey] = new List<Transform3D>();
}
batches[tile.MeshKey].Add(tile.Transform);
}
foreach (KeyValuePair<string, List<Transform3D>> kvp in batches)
{
MultiMesh multiMesh = multiMeshes[kvp.Key].Multimesh;
List<Transform3D> transforms = kvp.Value;
multiMesh.InstanceCount = transforms.Count;
for (int i = 0; i < transforms.Count; i++)
{
multiMesh.SetInstanceTransform(i, transforms[i]);
}
}
}
}