|
@@ -13,10 +13,11 @@ namespace KairoEngine.TerrainEngine
|
|
[HideMonoScript]
|
|
[HideMonoScript]
|
|
public class ChunkTerrainGenerator : MonoBehaviour
|
|
public class ChunkTerrainGenerator : MonoBehaviour
|
|
{
|
|
{
|
|
-
|
|
|
|
[BoxGroup("Configurations")] public Vector3 voxelSize = new Vector3(1f, 1f, 1f);
|
|
[BoxGroup("Configurations")] public Vector3 voxelSize = new Vector3(1f, 1f, 1f);
|
|
[BoxGroup("Configurations")] public Vector3Int chunkSize = new Vector3Int(16, 16, 16);
|
|
[BoxGroup("Configurations")] public Vector3Int chunkSize = new Vector3Int(16, 16, 16);
|
|
[BoxGroup("Configurations")] public Vector3Int chunkLimit = new Vector3Int(2, 1, 2);
|
|
[BoxGroup("Configurations")] public Vector3Int chunkLimit = new Vector3Int(2, 1, 2);
|
|
|
|
+ [BoxGroup("Configurations")] public StartConfig startConfiguration = StartConfig.DoNothing;
|
|
|
|
+ [BoxGroup("Configurations"), ShowIf("@startConfiguration == StartConfig.WaitForEvent")] public string generateWorldEvent = "GenerateWorld";
|
|
[BoxGroup("Configurations")] public int dataProcessLimit = 4;
|
|
[BoxGroup("Configurations")] public int dataProcessLimit = 4;
|
|
[BoxGroup("Configurations")] public int parallelMeshJobs = 4;
|
|
[BoxGroup("Configurations")] public int parallelMeshJobs = 4;
|
|
[BoxGroup("Configurations")] public bool showChunkData = false;
|
|
[BoxGroup("Configurations")] public bool showChunkData = false;
|
|
@@ -46,11 +47,22 @@ namespace KairoEngine.TerrainEngine
|
|
}
|
|
}
|
|
private Dictionary<Vector3,List<VoxelUpdateData>> chunkUpdates = new Dictionary<Vector3, List<VoxelUpdateData>>();
|
|
private Dictionary<Vector3,List<VoxelUpdateData>> chunkUpdates = new Dictionary<Vector3, List<VoxelUpdateData>>();
|
|
|
|
|
|
|
|
+ private void Start()
|
|
|
|
+ {
|
|
|
|
+ if(startConfiguration == StartConfig.GenerateOnStart) GenerateWorld();
|
|
|
|
+ else if(startConfiguration == StartConfig.WaitForEvent) GenericEvents.StartListening(generateWorldEvent, GenerateWorld);
|
|
|
|
+ }
|
|
|
|
+
|
|
private void Update()
|
|
private void Update()
|
|
{
|
|
{
|
|
marchingCubes.UpdateFinishedJobs();
|
|
marchingCubes.UpdateFinishedJobs();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void OnDisable()
|
|
|
|
+ {
|
|
|
|
+ if(startConfiguration == StartConfig.WaitForEvent) GenericEvents.StopListening(generateWorldEvent, GenerateWorld);
|
|
|
|
+ }
|
|
|
|
+
|
|
private void OnDestroy()
|
|
private void OnDestroy()
|
|
{
|
|
{
|
|
marchingCubes.OnDestroy();
|
|
marchingCubes.OnDestroy();
|
|
@@ -405,5 +417,12 @@ namespace KairoEngine.TerrainEngine
|
|
{
|
|
{
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public enum StartConfig
|
|
|
|
+ {
|
|
|
|
+ DoNothing,
|
|
|
|
+ GenerateOnStart,
|
|
|
|
+ WaitForEvent
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|