Re-add occlusion culling
This commit is contained in:
parent
770f4e22d5
commit
79f7ebd7eb
|
@ -113,11 +113,11 @@ public partial class Mission : Node3D
|
||||||
};
|
};
|
||||||
|
|
||||||
MeshInstance3D mesh = GenerateMesh(surfaceArrays, material);
|
MeshInstance3D mesh = GenerateMesh(surfaceArrays, material);
|
||||||
// OccluderInstance3D occluderInstance = GenerateOccluder(vertices, indices);
|
OccluderInstance3D occluderInstance = GenerateOccluder(surfaceArrays);
|
||||||
|
|
||||||
var cellNode = new Node3D();
|
var cellNode = new Node3D();
|
||||||
cellNode.AddChild(mesh);
|
cellNode.AddChild(mesh);
|
||||||
// cellNode.AddChild(occluderInstance);
|
cellNode.AddChild(occluderInstance);
|
||||||
|
|
||||||
AddChild(cellNode);
|
AddChild(cellNode);
|
||||||
}
|
}
|
||||||
|
@ -228,8 +228,21 @@ public partial class Mission : Node3D
|
||||||
return surfacesArrays;
|
return surfacesArrays;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static OccluderInstance3D GenerateOccluder(List<Vector3> vertices, List<int> indices)
|
private static OccluderInstance3D GenerateOccluder(List<Godot.Collections.Array> surfaceArrays)
|
||||||
{
|
{
|
||||||
|
var vertices = new List<Vector3>();
|
||||||
|
var indices = new List<int>();
|
||||||
|
foreach (var array in surfaceArrays)
|
||||||
|
{
|
||||||
|
var count = vertices.Count;
|
||||||
|
vertices.AddRange(array[(int)Mesh.ArrayType.Vertex].As<Vector3[]>());
|
||||||
|
var surfaceIndices = array[(int)Mesh.ArrayType.Index].As<int[]>();
|
||||||
|
foreach (var idx in surfaceIndices)
|
||||||
|
{
|
||||||
|
indices.Add(count + idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var occluder = new ArrayOccluder3D();
|
var occluder = new ArrayOccluder3D();
|
||||||
occluder.SetArrays(vertices.ToArray(), indices.ToArray());
|
occluder.SetArrays(vertices.ToArray(), indices.ToArray());
|
||||||
var occluderInstance = new OccluderInstance3D
|
var occluderInstance = new OccluderInstance3D
|
||||||
|
|
Loading…
Reference in New Issue