-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathEvaluatedVoxelsTransaction.cs
41 lines (39 loc) · 1.45 KB
/
EvaluatedVoxelsTransaction.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System.Collections.Generic;
namespace Voxels
{
public class TouchedChunks : HashSet<Chunk>
{
public void UpdateMesh()
{
foreach (Chunk chunk in this)
chunk.UpdateAndApply();
Clear();
}
}
// public class EvaluatedVoxelsTransaction : VoxelChangesProperty
// {
// private readonly HashSet<Chunk> m_ChunksToUpdate = new HashSet<Chunk>();
//
// /// <summary>
// /// Apply changes to mesh and clear transaction for reuse.
// /// </summary>
// public void Commit(bool updateMesh = true)
// {
// foreach (KeyValuePair<Position3Int, VoxelChange> pair in m_Map)
// {
// Chunk chunk = ChunkManager.Singleton.GetChunkFromWorldPosition(pair.Key);
// if (!chunk) continue;
// Position3Int voxelChunkPosition = ChunkManager.Singleton.WorldVoxelToChunkVoxel(pair.Key, chunk);
// chunk.SetVoxelDataNoCheck(voxelChunkPosition, pair.Value);
// if (updateMesh) ChunkManager.Singleton.AddChunksToUpdateFromVoxel(voxelChunkPosition, chunk, m_ChunksToUpdate);
// }
// if (updateMesh)
// {
// foreach (Chunk chunk in m_ChunksToUpdate)
// ChunkManager.UpdateChunkMesh(chunk);
// m_ChunksToUpdate.Clear();
// }
// Clear();
// }
// }
}