Skip to content

Commit fed4417

Browse files
authored
Release v1.1.0 (#77)
* CanProcess & Processing Separate scheduler flags added * Distance fog and fixes (#76) * Fog Enabled * Y limits removed * Dynamic fog distance * Reclaim Issue Fixed
1 parent 3fed126 commit fed4417

File tree

14 files changed

+186
-125
lines changed

14 files changed

+186
-125
lines changed

Assets/Scenes/World.unity

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ OcclusionCullingSettings:
1414
RenderSettings:
1515
m_ObjectHideFlags: 0
1616
serializedVersion: 9
17-
m_Fog: 0
18-
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
19-
m_FogMode: 3
17+
m_Fog: 1
18+
m_FogColor: {r: 0.5294118, g: 0.80784315, b: 0.92156863, a: 1}
19+
m_FogMode: 1
2020
m_FogDensity: 0.01
2121
m_LinearFogStart: 0
2222
m_LinearFogEnd: 300
23-
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
23+
m_AmbientSkyColor: {r: 0.07618539, g: 0.12477186, b: 0.22696589, a: 1}
2424
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
2525
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
2626
m_AmbientIntensity: 1
@@ -365,6 +365,7 @@ MonoBehaviour:
365365
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
366366
m_Name:
367367
m_EditorClassIdentifier:
368+
m_SendPointerHoverToParent: 1
368369
m_MoveRepeatDelay: 0.5
369370
m_MoveRepeatRate: 0.1
370371
m_XRTrackingOrigin: {fileID: 0}
@@ -381,6 +382,7 @@ MonoBehaviour:
381382
m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
382383
m_DeselectOnBackgroundClick: 1
383384
m_PointerBehavior: 0
385+
m_CursorLockBehavior: 0
384386
--- !u!1 &705507993
385387
GameObject:
386388
m_ObjectHideFlags: 0
@@ -526,7 +528,7 @@ MonoBehaviour:
526528
m_Name:
527529
m_EditorClassIdentifier:
528530
_Focus: {fileID: 963194228}
529-
_Settings: {fileID: 11400000, guid: 52a6b2026aad8ff419d583b5a88c620f, type: 2}
531+
Settings: {fileID: 11400000, guid: 52a6b2026aad8ff419d583b5a88c620f, type: 2}
530532
--- !u!4 &892864101
531533
Transform:
532534
m_ObjectHideFlags: 0
@@ -579,8 +581,8 @@ Camera:
579581
m_GameObject: {fileID: 963194225}
580582
m_Enabled: 1
581583
serializedVersion: 2
582-
m_ClearFlags: 1
583-
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
584+
m_ClearFlags: 2
585+
m_BackGroundColor: {r: 0.5294118, g: 0.80784315, b: 0.92156863, a: 1}
584586
m_projectionMatrixMode: 1
585587
m_GateFitMode: 2
586588
m_FOVAxisMode: 0
-16 Bytes
Binary file not shown.

Assets/Scenes/World/LightingData.asset.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Scenes/World/ReflectionProbe-0.exr.meta

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Scripts/Vloxy/Engine/Data/ChunkManager.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public ChunkManager(VloxySettings settings) {
3434
Accessor = new ChunkAccessor(Store.Chunks, _ChunkSettings.ChunkSize);
3535

3636
var viewRegionSize = _ChunkSettings.DrawDistance.CubedSize();
37-
37+
3838
_Claim = new HashSet<int3>(viewRegionSize);
3939
_Reclaim = new HashSet<int3>(viewRegionSize);
4040
}
@@ -84,14 +84,13 @@ internal void Dispose() {
8484

8585
internal NativeArray<int3> InitialChunkRegion(Allocator handle) {
8686
var size = _ChunkSettings.LoadDistance;
87-
var y_size = _ChunkSettings.HeightSize;
88-
89-
var result = new NativeArray<int3>(size.YCubedSize(y_size), handle);
87+
88+
var result = new NativeArray<int3>(size.CubedSize(), handle);
9089
var index = 0;
9190

9291
for (int x = -size; x <= size; x++) {
9392
for (int z = -size; z <= size; z++) {
94-
for (int y = -y_size; y <= y_size; y++) {
93+
for (int y = -size; y <= size; y++) {
9594
var position = new int3(x, y, z) * _ChunkSettings.ChunkSize;
9695
result[index] = position;
9796
State.SetState(position, ChunkState.State.STREAMING);
@@ -119,15 +118,21 @@ private void Update(ISet<int3> set, int3 focus, int3 diff, int distance) {
119118
for (int i = -distance; i <= distance; i++) {
120119
for (int j = -distance; j <= distance; j++) {
121120
if (diff.x != 0) {
122-
set.Add(new int3(focus + new int3(diff.x * distance, i * size.y, j * size.z)));
121+
var position = new int3(focus + new int3(diff.x * distance, i * size.y, j * size.z));
122+
123+
set.Add(position);
123124
}
124125

125126
if (diff.y != 0) {
126-
set.Add(new int3(focus + new int3(i * size.x, diff.y * distance, j * size.z)));
127+
var position = new int3(focus + new int3(i * size.x, diff.y * distance, j * size.z));
128+
129+
set.Add(position);
127130
}
128131

129132
if (diff.z != 0) {
130-
set.Add(new int3(focus + new int3(i * size.x, j * size.y, diff.z * distance)));
133+
var position = new int3(focus + new int3(i * size.x, j * size.y, diff.z * distance));
134+
135+
set.Add(position);
131136
}
132137
}
133138
}

Assets/Scripts/Vloxy/Engine/Jobs/Data/ChunkDataScheduler.cs

Lines changed: 69 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace CodeBlaze.Vloxy.Engine.Jobs.Data {
1818

1919
public class ChunkDataScheduler {
2020

21+
internal bool CanProcess { get; private set; }
2122
internal bool Processing { get; private set; }
2223

2324
private int3 _ChunkSize;
@@ -26,16 +27,17 @@ public class ChunkDataScheduler {
2627
private NoiseProfile _NoiseProfile;
2728
private BurstFunctionPointers _BurstFunctionPointers;
2829

30+
private bool _Scheduled;
31+
private int _BatchSize;
32+
33+
private List<int3> _ReclaimBatches;
34+
private Queue<VloxyBatch<int3>> _ClaimBatches;
35+
private VloxyBatch<int3> _CurrentClaimBatch;
36+
2937
private JobHandle _Handle;
30-
3138
private NativeList<int3> _Jobs;
3239
private NativeParallelHashMap<int3, Chunk> _Results;
33-
private Queue<VloxyBatch<int3>> _Batches;
34-
private VloxyBatch<int3> _CurrentBatch;
3540

36-
private bool _Scheduled;
37-
private int _BatchSize;
38-
3941
#if VLOXY_LOGGING
4042
private Queue<long> _Timings;
4143
private Stopwatch _Watch;
@@ -53,8 +55,9 @@ BurstFunctionPointers burstFunctionPointers
5355
_ChunkStore = chunkStore;
5456
_NoiseProfile = noiseProfile;
5557
_BurstFunctionPointers = burstFunctionPointers;
56-
57-
_Batches = new Queue<VloxyBatch<int3>>();
58+
59+
_ReclaimBatches = new List<int3>();
60+
_ClaimBatches = new Queue<VloxyBatch<int3>>();
5861

5962
_Jobs = new NativeList<int3>(Allocator.Persistent);
6063
_Results = new NativeParallelHashMap<int3, Chunk>(settings.Chunk.LoadDistance.CubedSize(), Allocator.Persistent);
@@ -66,7 +69,7 @@ BurstFunctionPointers burstFunctionPointers
6669
}
6770

6871
internal bool Update() {
69-
if (_Scheduled || !Processing) return false;
72+
if (_Scheduled || !(Processing || CanProcess)) return false;
7073

7174
Process();
7275

@@ -114,39 +117,9 @@ internal void GenerateChunks(NativeArray<int3> jobs) {
114117
jobs.Dispose();
115118
}
116119

117-
internal void Reclaim(List<int3> positions) {
118-
for (int i = 0; i < positions.Count; i++) {
119-
var position = positions[i];
120-
var state = _ChunkState.GetState(position);
121-
122-
switch (state) {
123-
case ChunkState.State.UNLOADED:
124-
#if VLOXY_LOGGING
125-
VloxyLogger.Warn<ChunkDataScheduler>($"Invalid state : {state} for : {position}");
126-
#endif
127-
break;
128-
case ChunkState.State.STREAMING:
129-
_ChunkState.RemoveState(position);
130-
break;
131-
case ChunkState.State.LOADED:
132-
_ChunkStore.RemoveChunk(position);
133-
_ChunkState.RemoveState(position);
134-
break;
135-
case ChunkState.State.MESHING:
136-
_ChunkStore.RemoveChunk(position);
137-
_ChunkState.RemoveState(position);
138-
break;
139-
case ChunkState.State.ACTIVE:
140-
_ChunkStore.RemoveChunk(position);
141-
_ChunkState.RemoveState(position);
142-
break;
143-
default:
144-
throw new ArgumentOutOfRangeException();
145-
}
146-
}
147-
}
120+
internal void ScheduleReclaim(List<int3> positions) => _ReclaimBatches = positions;
148121

149-
internal void Schedule(List<int3> jobs) {
122+
internal void ScheduleClaim(List<int3> jobs) {
150123
var batch = new VloxyBatch<int3>(jobs.Count);
151124

152125
for (int i = 0; i < jobs.Count; i++) {
@@ -175,18 +148,61 @@ internal void Schedule(List<int3> jobs) {
175148
}
176149
}
177150

178-
_Batches.Enqueue(batch);
151+
_ClaimBatches.Enqueue(batch);
179152

180-
Processing = _Batches.Count > 0;
153+
CanProcess = _ClaimBatches.Count > 0;
181154
}
182155

183156
private void Process() {
184-
_CurrentBatch ??= _Batches.Dequeue();
157+
ProcessReclaim();
158+
ProcessClaim();
159+
}
160+
161+
private void ProcessReclaim() {
162+
if (_ReclaimBatches.Count == 0) return;
163+
164+
for (int i = 0; i < _ReclaimBatches.Count; i++) {
165+
var position = _ReclaimBatches[i];
166+
var state = _ChunkState.GetState(position);
167+
168+
switch (state) {
169+
case ChunkState.State.UNLOADED:
170+
#if VLOXY_LOGGING
171+
VloxyLogger.Warn<ChunkDataScheduler>($"Invalid state : {state} for : {position}");
172+
#endif
173+
break;
174+
case ChunkState.State.STREAMING:
175+
_ChunkState.RemoveState(position);
176+
break;
177+
case ChunkState.State.LOADED:
178+
_ChunkStore.RemoveChunk(position);
179+
_ChunkState.RemoveState(position);
180+
break;
181+
case ChunkState.State.MESHING:
182+
_ChunkStore.RemoveChunk(position);
183+
_ChunkState.RemoveState(position);
184+
break;
185+
case ChunkState.State.ACTIVE:
186+
_ChunkStore.RemoveChunk(position);
187+
_ChunkState.RemoveState(position);
188+
break;
189+
default:
190+
throw new ArgumentOutOfRangeException();
191+
}
192+
}
193+
194+
_ReclaimBatches.Clear();
195+
}
196+
197+
private void ProcessClaim() {
198+
Processing = true;
199+
200+
_CurrentClaimBatch ??= _ClaimBatches.Dequeue();
185201

186202
var count = _BatchSize;
187203

188-
while (count > 0 && _CurrentBatch.Count > 0) {
189-
var position = _CurrentBatch.Dequeue();
204+
while (count > 0 && _CurrentClaimBatch.Count > 0) {
205+
var position = _CurrentClaimBatch.Dequeue();
190206

191207
if (_ChunkState.GetState(position) != ChunkState.State.STREAMING) continue;
192208

@@ -234,11 +250,13 @@ private bool Complete() {
234250
_Results.Clear();
235251

236252
_Scheduled = false;
237-
238-
if (_CurrentBatch.Count == 0) _CurrentBatch = null;
239-
240-
Processing = _Batches.Count > 0 || _CurrentBatch != null;
241-
253+
254+
if (_CurrentClaimBatch.Count == 0) {
255+
_CurrentClaimBatch = null;
256+
Processing = false;
257+
CanProcess = _ClaimBatches.Count > 0;
258+
}
259+
242260
#if VLOXY_LOGGING
243261
_Watch.Stop();
244262
Timestamp(_Watch.ElapsedMilliseconds);

0 commit comments

Comments
 (0)