@divinevoxel/vlox 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Contexts/Base/Remote/InitWorldDataSync.js +2 -4
- package/Contexts/Render/DVERenderThreads.d.ts +1 -1
- package/Contexts/Render/DVERenderThreads.js +2 -2
- package/Contexts/Render/DivineVoxelEngineRender.js +1 -1
- package/Init/StartRenderer.js +5 -5
- package/Math/Indexing.js +6 -6
- package/Mesher/Functions/CompactVoxelMesh.js +40 -7
- package/Mesher/Functions/MeshSection.js +12 -8
- package/Mesher/Functions/MeshTexture.d.ts +1 -1
- package/Mesher/Functions/MeshVoxel.js +2 -1
- package/Mesher/Geomtry/Buffers.d.ts +19 -0
- package/Mesher/Geomtry/Buffers.js +81 -0
- package/Mesher/Geomtry/Tools/MesherDataTools.d.ts +3 -3
- package/Mesher/Geomtry/Tools/MesherDataTools.js +2 -2
- package/Mesher/Geomtry/VoxelGeometryBuilder.js +3 -3
- package/Mesher/Geomtry/VoxelMesh.d.ts +13 -0
- package/Mesher/Geomtry/VoxelMesh.js +28 -0
- package/Mesher/InitTask.js +1 -2
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +7 -7
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +7 -7
- package/Mesher/Models/VoxelConstructor.js +3 -3
- package/Mesher/Models/VoxelGeometryLookUp.d.ts +20 -11
- package/Mesher/Models/VoxelGeometryLookUp.js +73 -39
- package/Mesher/Tools/VoxelMeshBVHBuilder.js +20 -25
- package/Mesher/Tools/VoxelMeshVertexStructCursor.d.ts +3 -1
- package/Mesher/Tools/VoxelMesherDataTool.d.ts +2 -2
- package/Mesher/Tools/VoxelMesherDataTool.js +3 -3
- package/Renderer/Classes/DVESectionMeshes.d.ts +1 -0
- package/Renderer/Classes/SectionMesh.d.ts +1 -2
- package/Renderer/Classes/SectionMesh.js +0 -3
- package/Renderer/InitTasks.js +13 -1
- package/Renderer/MeshManager.js +4 -0
- package/Renderer/MeshRegister.d.ts +1 -6
- package/Renderer/index.d.ts +0 -1
- package/Renderer/index.js +0 -1
- package/Tasks/IWG/Internal/Functions/cullSectors.js +1 -2
- package/Tasks/IWG/Internal/Functions/getSectorState.js +1 -1
- package/Tasks/IWG/Internal/Functions/runBuildUpdate.js +1 -2
- package/Tasks/IWG/Internal/Functions/runWorldUpdate.js +1 -2
- package/Tasks/IWG/Internal/IWGTasks.js +7 -13
- package/Tasks/Propagation/Flow/WorldFlow.js +2 -4
- package/Tasks/Propagation/Illumanation/WorldRGB.js +1 -2
- package/Tasks/Propagation/Illumanation/WorldSun.js +1 -4
- package/Tasks/WorldGeneration/WorldGenRegister.js +5 -8
- package/Tasks/WorldGeneration/WorldGeneration.d.ts +0 -2
- package/Tasks/WorldGeneration/WorldGeneration.js +0 -2
- package/Tools/Brush/Brush.js +1 -2
- package/World/Archive/Functions/ArchiveSector.d.ts +1 -1
- package/World/Archive/Functions/ArchiveSector.js +2 -3
- package/World/Archive/InitTasks.js +2 -3
- package/World/Cursor/SectionCursor.js +1 -2
- package/World/Cursor/SectorCursor.js +1 -2
- package/World/Cursor/WorldCursor.js +1 -2
- package/World/InitTasks.js +5 -10
- package/World/Lock/WorldLock.js +4 -5
- package/World/Sector/SectorHeightMap.js +4 -6
- package/World/WorldRegister.d.ts +4 -6
- package/World/WorldRegister.js +24 -20
- package/World/WorldSpaces.d.ts +21 -0
- package/World/WorldSpaces.js +58 -7
- package/package.json +1 -1
- package/Mesher/Geomtry/Mesh.d.ts +0 -11
- package/Mesher/Geomtry/Mesh.js +0 -23
- package/Renderer/Classes/DVESectionMeshInterface.d.ts +0 -3
- package/Renderer/Classes/DVESectionMeshInterface.js +0 -1
- package/World/WorldBounds.d.ts +0 -20
- package/World/WorldBounds.js +0 -53
|
@@ -1,67 +1,106 @@
|
|
|
1
1
|
import { VoxelModelConstructorRegister } from "./VoxelModelConstructorRegister";
|
|
2
|
-
import { Vector3Like } from "@amodx/math";
|
|
3
2
|
import { VoxelCursor } from "../../Voxels/Cursor/VoxelCursor";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
import { GetYXZOrderArrayIndex } from "../../Math/Indexing";
|
|
4
|
+
export class VoxelGeometryLookUpSpace {
|
|
5
|
+
bounds;
|
|
6
|
+
foundHash;
|
|
7
|
+
voxelHash;
|
|
8
|
+
modCache;
|
|
9
|
+
stateCache;
|
|
10
|
+
conditonalStateCache;
|
|
11
|
+
noCastAO;
|
|
12
|
+
offset = [0, 0, 0];
|
|
13
|
+
constructor(bounds) {
|
|
14
|
+
this.bounds = bounds;
|
|
15
|
+
const volume = bounds.x * bounds.y * bounds.z;
|
|
16
|
+
this.foundHash = new Uint8Array(volume);
|
|
17
|
+
this.voxelHash = new Uint16Array(volume);
|
|
18
|
+
this.modCache = new Int32Array(volume);
|
|
19
|
+
this.stateCache = new Int32Array(volume);
|
|
20
|
+
this.conditonalStateCache = new Int32Array(volume);
|
|
21
|
+
this.noCastAO = new Uint8Array(volume);
|
|
22
|
+
}
|
|
23
|
+
start(x, y, z) {
|
|
16
24
|
this.offset[0] = x;
|
|
17
25
|
this.offset[1] = y;
|
|
18
26
|
this.offset[2] = z;
|
|
27
|
+
this.foundHash.fill(0);
|
|
28
|
+
this.conditonalStateCache.fill(-1);
|
|
29
|
+
this.stateCache.fill(-1);
|
|
30
|
+
this.modCache.fill(-1);
|
|
31
|
+
}
|
|
32
|
+
getIndex(x, y, z) {
|
|
33
|
+
return GetYXZOrderArrayIndex(x - this.offset[0], y - this.offset[1], z - this.offset[2], this.bounds.x, this.bounds.y, this.bounds.z);
|
|
34
|
+
}
|
|
35
|
+
getConstructor(index) {
|
|
36
|
+
if (this.foundHash[index] !== 2)
|
|
37
|
+
return null;
|
|
38
|
+
return VoxelModelConstructorRegister.constructorsPaltte[this.voxelHash[index]];
|
|
39
|
+
}
|
|
40
|
+
getGeomtry(index) {
|
|
41
|
+
if (this.foundHash[index] !== 2)
|
|
42
|
+
return false;
|
|
43
|
+
return VoxelModelConstructorRegister.constructorsPaltte[this.voxelHash[index]].data.shapeStateGeometryMap[this.stateCache[index]];
|
|
44
|
+
}
|
|
45
|
+
getConditionalGeomtry(index) {
|
|
46
|
+
if (this.foundHash[index] !== 2)
|
|
47
|
+
return false;
|
|
48
|
+
return VoxelModelConstructorRegister.constructorsPaltte[this.voxelHash[index]].data.condiotnalShapeStateGeometryMap[this.conditonalStateCache[index]];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export class VoxelGeometryLookUp {
|
|
52
|
+
static space = null;
|
|
53
|
+
static voxelCursor = new VoxelCursor();
|
|
54
|
+
static createSpace(x, y, z) {
|
|
55
|
+
return new VoxelGeometryLookUpSpace({ x, y, z });
|
|
56
|
+
}
|
|
57
|
+
static init() { }
|
|
58
|
+
static start(space) {
|
|
59
|
+
this.space = space;
|
|
19
60
|
}
|
|
20
61
|
static isRulesless(geoId) {
|
|
21
62
|
return VoxelModelConstructorRegister.rulesless[geoId] == true;
|
|
22
63
|
}
|
|
23
|
-
static stop() {
|
|
24
|
-
this.stateCache.length = 0;
|
|
25
|
-
this.voxelHash.length = 0;
|
|
26
|
-
this.modCache.length = 0;
|
|
27
|
-
this.geometryCache.length = 0;
|
|
28
|
-
this.conditionalGeometryCache.length = 0;
|
|
29
|
-
this.conditonalStateCache.length = 0;
|
|
30
|
-
this.noCastAO.length = 0;
|
|
31
|
-
}
|
|
64
|
+
static stop() { }
|
|
32
65
|
static getHash(dataCursor, x, y, z) {
|
|
33
|
-
|
|
34
|
-
|
|
66
|
+
if (!this.space)
|
|
67
|
+
throw new Error(`Voxel geomtry look up must have space set`);
|
|
68
|
+
const hashed = this.space?.getIndex(x, y, z);
|
|
69
|
+
if (this.space.foundHash[hashed] == 0)
|
|
35
70
|
this.hashState(dataCursor, hashed, x, y, z);
|
|
36
71
|
return hashed;
|
|
37
72
|
}
|
|
38
|
-
static hashState(dataCursor,
|
|
39
|
-
if (this.
|
|
40
|
-
|
|
73
|
+
static hashState(dataCursor, index, x, y, z) {
|
|
74
|
+
if (!this.space)
|
|
75
|
+
throw new Error(`Voxel geomtry look up must have space set`);
|
|
76
|
+
if (this.space.foundHash[index] == 2)
|
|
77
|
+
return this.space.stateCache[index];
|
|
41
78
|
const voxel = dataCursor.getVoxel(x, y, z);
|
|
42
79
|
if (!voxel) {
|
|
43
|
-
this.
|
|
80
|
+
this.space.foundHash[index] = 1;
|
|
44
81
|
return -1;
|
|
45
82
|
}
|
|
46
83
|
if (!voxel.isRenderable()) {
|
|
47
|
-
this.
|
|
84
|
+
this.space.foundHash[index] = 1;
|
|
48
85
|
return -1;
|
|
49
86
|
}
|
|
50
87
|
const voxelConstructor = VoxelModelConstructorRegister.constructorsPaltte[voxel.getId()];
|
|
88
|
+
this.space.voxelHash[index] = voxel.getId();
|
|
51
89
|
if (!voxelConstructor || !voxelConstructor.isModel) {
|
|
52
|
-
this.
|
|
90
|
+
this.space.foundHash[index] = 1;
|
|
53
91
|
return -1;
|
|
54
92
|
}
|
|
93
|
+
this.space.foundHash[index] = 2;
|
|
55
94
|
//no ao
|
|
56
|
-
this.noCastAO[
|
|
95
|
+
this.space.noCastAO[index] = voxel.isLightSource() || voxel.noAO() ? 1 : 0;
|
|
57
96
|
//state
|
|
58
97
|
const shapeState = voxel.getState();
|
|
59
98
|
const state = voxelConstructor.shapeStateTree.getState(shapeState);
|
|
60
|
-
this.stateCache[
|
|
99
|
+
this.space.stateCache[index] = state;
|
|
61
100
|
//mod
|
|
62
101
|
const mod = voxel.getMod();
|
|
63
102
|
const modState = voxelConstructor.modTree.getState(mod);
|
|
64
|
-
this.modCache[
|
|
103
|
+
this.space.modCache[index] = modState;
|
|
65
104
|
this.voxelCursor.copy(voxel).process();
|
|
66
105
|
voxelConstructor.schema.position.x = x;
|
|
67
106
|
voxelConstructor.schema.position.y = y;
|
|
@@ -69,12 +108,7 @@ export class VoxelGeometryLookUp {
|
|
|
69
108
|
voxelConstructor.schema.voxel = this.voxelCursor;
|
|
70
109
|
voxelConstructor.schema.dataCursor = dataCursor;
|
|
71
110
|
const conditonalState = voxelConstructor.condtioanlShapeStateTree.getState();
|
|
72
|
-
this.
|
|
73
|
-
this.conditonalStateCache[hashed] = conditonalState;
|
|
74
|
-
this.geometryCache[hashed] =
|
|
75
|
-
voxelConstructor.data.shapeStateGeometryMap[state];
|
|
76
|
-
this.conditionalGeometryCache[hashed] =
|
|
77
|
-
voxelConstructor.data.condiotnalShapeStateGeometryMap[conditonalState];
|
|
111
|
+
this.space.conditonalStateCache[index] = conditonalState;
|
|
78
112
|
return state;
|
|
79
113
|
}
|
|
80
114
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { WorldSpaces } from "../../World/WorldSpaces";
|
|
2
|
+
const MAX_FLOAT32 = new Float32Array([Infinity])[0];
|
|
2
3
|
/**
|
|
3
4
|
* A class to help with indexing a full flat binary tree defined by the number of levels it has.
|
|
4
5
|
*/
|
|
@@ -160,23 +161,29 @@ export class StructCursor {
|
|
|
160
161
|
const ix = this.trueIndex;
|
|
161
162
|
const iy = this.trueIndex + 1;
|
|
162
163
|
const iz = this.trueIndex + 2;
|
|
163
|
-
this.data[ix]
|
|
164
|
-
this.data[ix]
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
if (x < this.data[ix] || this.data[ix] == -MAX_FLOAT32) {
|
|
165
|
+
this.data[ix] = x;
|
|
166
|
+
}
|
|
167
|
+
if (y < this.data[iy] || this.data[iy] == -MAX_FLOAT32) {
|
|
168
|
+
this.data[iy] = y;
|
|
169
|
+
}
|
|
170
|
+
if (z < this.data[iz] || this.data[iz] == -MAX_FLOAT32) {
|
|
171
|
+
this.data[iz] = z;
|
|
172
|
+
}
|
|
169
173
|
}
|
|
170
174
|
updateMax(x, y, z) {
|
|
171
175
|
const ix = this.trueIndex + 4;
|
|
172
176
|
const iy = this.trueIndex + 5;
|
|
173
177
|
const iz = this.trueIndex + 6;
|
|
174
|
-
this.data[ix]
|
|
175
|
-
this.data[ix]
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
if (x > this.data[ix] || this.data[ix] == -MAX_FLOAT32) {
|
|
179
|
+
this.data[ix] = x;
|
|
180
|
+
}
|
|
181
|
+
if (y > this.data[iy] || this.data[iy] == -MAX_FLOAT32) {
|
|
182
|
+
this.data[iy] = y;
|
|
183
|
+
}
|
|
184
|
+
if (z > this.data[iz] || this.data[iz] == -MAX_FLOAT32) {
|
|
185
|
+
this.data[iz] = z;
|
|
186
|
+
}
|
|
180
187
|
}
|
|
181
188
|
toJSON() {
|
|
182
189
|
return {
|
|
@@ -194,7 +201,7 @@ export class VoxelMeshBVHBuilder {
|
|
|
194
201
|
structCursor = new StructCursor(this.tree);
|
|
195
202
|
indices = new Uint32Array(this.treeIndex.getLevelSize(12) * 2);
|
|
196
203
|
reset() {
|
|
197
|
-
this.tree.fill(-
|
|
204
|
+
this.tree.fill(-MAX_FLOAT32);
|
|
198
205
|
this.indices.fill(0);
|
|
199
206
|
}
|
|
200
207
|
updateVoxel(voxelX, voxelY, voxelZ, meshIndex, indicesStart, indicesEnd, minX, minY, minZ, maxX, maxY, maxZ) {
|
|
@@ -219,15 +226,3 @@ export class VoxelMeshBVHBuilder {
|
|
|
219
226
|
}
|
|
220
227
|
}
|
|
221
228
|
}
|
|
222
|
-
/*
|
|
223
|
-
console.warn(
|
|
224
|
-
[voxelX, voxelY, voxelZ],
|
|
225
|
-
"add gometry",
|
|
226
|
-
[minX, minY, minZ],
|
|
227
|
-
[maxX, maxY, maxZ],
|
|
228
|
-
[voxelX, voxelY, voxelZ],
|
|
229
|
-
[indicesStart, indicesEnd],
|
|
230
|
-
indicesEnd - indicesStart,
|
|
231
|
-
(indicesEnd - indicesStart) / 3
|
|
232
|
-
);
|
|
233
|
-
*/
|
|
@@ -39,7 +39,9 @@ export declare class VoxelMeshVertexStructCursor {
|
|
|
39
39
|
set colorB(value: number);
|
|
40
40
|
trueIndex: number;
|
|
41
41
|
_index: number;
|
|
42
|
-
data:
|
|
42
|
+
data: {
|
|
43
|
+
[index: number]: number;
|
|
44
|
+
};
|
|
43
45
|
get index(): number;
|
|
44
46
|
set index(index: number);
|
|
45
47
|
constructor(data?: Float32Array);
|
|
@@ -2,7 +2,7 @@ import { MesherDataTool } from "../Geomtry/Tools/MesherDataTools";
|
|
|
2
2
|
import { QuadScalarVertexData } from "../Geomtry/Primitives/QuadVertexData";
|
|
3
3
|
import { VoxelFaces } from "../../Math";
|
|
4
4
|
import { QuadVerticies } from "../Geomtry/Geometry.types";
|
|
5
|
-
import {
|
|
5
|
+
import { VoxelMesh } from "../Geomtry/VoxelMesh";
|
|
6
6
|
import { VoxelMeshBVHBuilder } from "./VoxelMeshBVHBuilder";
|
|
7
7
|
import { Vec3Array, Vector3Like } from "@amodx/math";
|
|
8
8
|
import { VoxelCursorInterface } from "../../Voxels/Cursor/VoxelCursor.interface.js";
|
|
@@ -26,7 +26,7 @@ export declare class VoxelMesherDataTool extends MesherDataTool {
|
|
|
26
26
|
position: Vector3Like;
|
|
27
27
|
/**The current local origin */
|
|
28
28
|
origin: Vector3Like;
|
|
29
|
-
mesh:
|
|
29
|
+
mesh: VoxelMesh;
|
|
30
30
|
bvhTool: VoxelMeshBVHBuilder | null;
|
|
31
31
|
vars: VoxelVars;
|
|
32
32
|
dataCalculated: Record<VoxelFaces, boolean>;
|
|
@@ -5,7 +5,7 @@ import { QuadScalarVertexData } from "../Geomtry/Primitives/QuadVertexData";
|
|
|
5
5
|
import { VoxelFaces, VoxelFacesArray } from "../../Math";
|
|
6
6
|
import { QuadVerticies } from "../Geomtry/Geometry.types";
|
|
7
7
|
import { FaceDataCalc } from "../Models/Common/Calc/FaceDataCalc.js";
|
|
8
|
-
import {
|
|
8
|
+
import { VoxelMesh } from "../Geomtry/VoxelMesh";
|
|
9
9
|
import { Vector3Like } from "@amodx/math";
|
|
10
10
|
class VoxelVars {
|
|
11
11
|
faceFlipped = false;
|
|
@@ -29,7 +29,7 @@ export class VoxelMesherDataTool extends MesherDataTool {
|
|
|
29
29
|
position = Vector3Like.Create();
|
|
30
30
|
/**The current local origin */
|
|
31
31
|
origin = Vector3Like.Create();
|
|
32
|
-
mesh = new
|
|
32
|
+
mesh = new VoxelMesh();
|
|
33
33
|
bvhTool = null;
|
|
34
34
|
vars = new VoxelVars();
|
|
35
35
|
dataCalculated;
|
|
@@ -70,7 +70,7 @@ export class VoxelMesherDataTool extends MesherDataTool {
|
|
|
70
70
|
this.lightData[face][QuadVerticies.BottomLeft] = 0;
|
|
71
71
|
this.lightData[face][QuadVerticies.BottomRight] = 0;
|
|
72
72
|
}
|
|
73
|
-
this.startNewMesh(new
|
|
73
|
+
this.startNewMesh(new VoxelMesh());
|
|
74
74
|
}
|
|
75
75
|
bounds = {
|
|
76
76
|
min: [0, 0, 0],
|
|
@@ -3,4 +3,5 @@ import { CompactMeshData } from "../../Mesher/Types/Mesher.types";
|
|
|
3
3
|
import { SectionMesh } from "./SectionMesh";
|
|
4
4
|
export declare abstract class DVESectionMeshes {
|
|
5
5
|
abstract updateVertexData(section: SectionMesh, position: Vec3Array, data: CompactMeshData): SectionMesh;
|
|
6
|
+
abstract returnMesh(mesh: any): void;
|
|
6
7
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { DVESectionMeshInterface } from "./DVESectionMeshInterface";
|
|
2
1
|
import { VoxelEffect } from "../../Voxels/Effects/VoxelEffect";
|
|
3
2
|
import { SectorMesh } from "./SectorMesh";
|
|
4
3
|
import { Vec3Array } from "@amodx/math";
|
|
5
4
|
export declare class SectionMesh {
|
|
6
5
|
sector: SectorMesh;
|
|
7
6
|
index: number;
|
|
8
|
-
meshes: Map<string,
|
|
7
|
+
meshes: Map<string, any>;
|
|
9
8
|
effects: Map<string, VoxelEffect>;
|
|
10
9
|
constructor(sector: SectorMesh, index: number);
|
|
11
10
|
getPosition(): Vec3Array;
|
package/Renderer/InitTasks.js
CHANGED
|
@@ -4,7 +4,19 @@ import { MeshRegister } from "./MeshRegister";
|
|
|
4
4
|
import { TaskTool } from "../Tools/Tasks/TasksTool";
|
|
5
5
|
export default function RendererTasks(threads) {
|
|
6
6
|
const tasks = new TaskTool(threads);
|
|
7
|
-
Threads.registerTask("set-section", (data) =>
|
|
7
|
+
Threads.registerTask("set-section", (data, origin) => {
|
|
8
|
+
MeshManager.updateSection(data);
|
|
9
|
+
const tranfers = [];
|
|
10
|
+
for (const comp of data[1]) {
|
|
11
|
+
if (comp[0] !== 0)
|
|
12
|
+
continue;
|
|
13
|
+
for (const mesh of comp[1]) {
|
|
14
|
+
tranfers.push(mesh[1]);
|
|
15
|
+
tranfers.push(mesh[2]);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
origin.sendMessage(data, tranfers);
|
|
19
|
+
});
|
|
8
20
|
Threads.registerTask("remove-sector", (data) => {
|
|
9
21
|
MeshManager.removeSector(data);
|
|
10
22
|
});
|
package/Renderer/MeshManager.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type LocationData } from "../Math/index.js";
|
|
2
2
|
import { SectorMesh } from "./Classes/SectorMesh.js";
|
|
3
|
-
import { DVESectionMeshInterface } from "./Classes/DVESectionMeshInterface.js";
|
|
4
3
|
export type MeshRegisterDimensions = Map<string, Map<string, SectorMesh>>;
|
|
5
4
|
declare class Sectors {
|
|
6
5
|
static add(location: LocationData): SectorMesh;
|
|
@@ -10,11 +9,7 @@ declare class Sectors {
|
|
|
10
9
|
declare class Dimensions {
|
|
11
10
|
static add(id: string): Map<any, any>;
|
|
12
11
|
static get(id: string): Map<string, SectorMesh> | undefined;
|
|
13
|
-
static getAllMeshes(id: string): Generator<[
|
|
14
|
-
location: LocationData,
|
|
15
|
-
substance: string,
|
|
16
|
-
mesh: DVESectionMeshInterface
|
|
17
|
-
]>;
|
|
12
|
+
static getAllMeshes(id: string): Generator<[location: LocationData, substance: string, mesh: any]>;
|
|
18
13
|
static remove(id: string): boolean;
|
|
19
14
|
}
|
|
20
15
|
export declare class MeshRegister {
|
package/Renderer/index.d.ts
CHANGED
package/Renderer/index.js
CHANGED
|
@@ -70,13 +70,12 @@ export function cullSectors(generatos, cullGenerators) {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
else {
|
|
73
|
-
WorldRegister.sectors.remove(cx, cy, cz);
|
|
73
|
+
WorldRegister.sectors.remove(dimension.id, cx, cy, cz);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
if (!cullGenerators.length)
|
|
78
78
|
continue;
|
|
79
|
-
WorldRegister.setDimension(dimension.id);
|
|
80
79
|
const worldDimension = WorldRegister.dimensions.get(dimension.id);
|
|
81
80
|
for (const [, sector] of worldDimension.sectors) {
|
|
82
81
|
const [cx, cy, cz] = sector.position;
|
|
@@ -14,7 +14,7 @@ export function getSectorState(sector, state, segment) {
|
|
|
14
14
|
if (!segment.vistedMap.has(sectorPOS.x, cy, sectorPOS.z)) {
|
|
15
15
|
segment.queue.push(sectorPOS.x, cy, sectorPOS.z);
|
|
16
16
|
}
|
|
17
|
-
const sector = WorldRegister.sectors.get(sectorPOS.x, cy, sectorPOS.z);
|
|
17
|
+
const sector = WorldRegister.sectors.get(segment.id, sectorPOS.x, cy, sectorPOS.z);
|
|
18
18
|
if (!sector) {
|
|
19
19
|
state.genAlldone = false;
|
|
20
20
|
state.nWorldGenAllDone = false;
|
|
@@ -32,8 +32,7 @@ export function runBuildUpdate(generators) {
|
|
|
32
32
|
sectorSquare.center.y = cz + WorldSpaces.sector.bounds.z / 2;
|
|
33
33
|
if (!Circle.IsSquareInsideOrTouchingCircle(sectorSquare, generator._renderCircle))
|
|
34
34
|
continue;
|
|
35
|
-
WorldRegister.
|
|
36
|
-
const sector = WorldRegister.sectors.get(cx, cy, cz);
|
|
35
|
+
const sector = WorldRegister.sectors.get(generator._dimension, cx, cy, cz);
|
|
37
36
|
if (!sector)
|
|
38
37
|
continue;
|
|
39
38
|
const state = getSectorState(sector, stateCursor, segment);
|
|
@@ -35,8 +35,7 @@ export function runWorldUpdate(generators) {
|
|
|
35
35
|
sectorSquare.center.y = cz + WorldSpaces.sector.bounds.z / 2;
|
|
36
36
|
if (!Circle.IsSquareInsideOrTouchingCircle(sectorSquare, generator._genCircle))
|
|
37
37
|
continue;
|
|
38
|
-
WorldRegister.
|
|
39
|
-
const sector = WorldRegister.sectors.get(cx, cy, cz);
|
|
38
|
+
const sector = WorldRegister.sectors.get(generator._dimension, cx, cy, cz);
|
|
40
39
|
if (!sector) {
|
|
41
40
|
IWGTasks.worldLoadTasks.add(generator._dimension, cx, cy, cz);
|
|
42
41
|
continue;
|
|
@@ -12,12 +12,11 @@ export class IWGTasks {
|
|
|
12
12
|
propagationBlocking: true,
|
|
13
13
|
async run(location, onDone) {
|
|
14
14
|
const [dimension, x, y, z] = location;
|
|
15
|
-
WorldRegister.
|
|
16
|
-
const sector = WorldRegister.sectors.get(x, y, z);
|
|
15
|
+
const sector = WorldRegister.sectors.get(location[0], x, y, z);
|
|
17
16
|
if (sector)
|
|
18
17
|
return onDone();
|
|
19
18
|
if (!IWGTools.worldStorage) {
|
|
20
|
-
WorldRegister.sectors.new(x, y, z);
|
|
19
|
+
WorldRegister.sectors.new(location[0], x, y, z);
|
|
21
20
|
return onDone();
|
|
22
21
|
}
|
|
23
22
|
const loaded = await IWGTools.worldStorage.loadSector([
|
|
@@ -27,8 +26,7 @@ export class IWGTasks {
|
|
|
27
26
|
z,
|
|
28
27
|
]);
|
|
29
28
|
if (!loaded) {
|
|
30
|
-
WorldRegister.
|
|
31
|
-
WorldRegister.sectors.new(x, y, z);
|
|
29
|
+
WorldRegister.sectors.new(location[0], x, y, z);
|
|
32
30
|
}
|
|
33
31
|
onDone();
|
|
34
32
|
},
|
|
@@ -40,8 +38,7 @@ export class IWGTasks {
|
|
|
40
38
|
id: "generate",
|
|
41
39
|
propagationBlocking: true,
|
|
42
40
|
async run(location, onDone) {
|
|
43
|
-
WorldRegister.
|
|
44
|
-
const sector = WorldRegister.sectors.get(location[1], location[2], location[3]);
|
|
41
|
+
const sector = WorldRegister.sectors.get(location[0], location[1], location[2], location[3]);
|
|
45
42
|
if (!sector)
|
|
46
43
|
throw new Error(`Sector at ${location.toString()} does not exist when attempting generation.`);
|
|
47
44
|
Sector.StateStruct.setBuffer(sector.buffer);
|
|
@@ -61,8 +58,7 @@ export class IWGTasks {
|
|
|
61
58
|
id: "decorate",
|
|
62
59
|
propagationBlocking: true,
|
|
63
60
|
async run(location, onDone) {
|
|
64
|
-
WorldRegister.
|
|
65
|
-
const sector = WorldRegister.sectors.get(location[1], location[2], location[3]);
|
|
61
|
+
const sector = WorldRegister.sectors.get(location[0], location[1], location[2], location[3]);
|
|
66
62
|
if (!sector)
|
|
67
63
|
throw new Error(`Sector at ${location.toString()} does not exist when attempting decoration.`);
|
|
68
64
|
Sector.StateStruct.setBuffer(sector.buffer);
|
|
@@ -82,8 +78,7 @@ export class IWGTasks {
|
|
|
82
78
|
id: "wolrd_sun",
|
|
83
79
|
propagationBlocking: true,
|
|
84
80
|
async run(location, onDone) {
|
|
85
|
-
WorldRegister.
|
|
86
|
-
const sector = WorldRegister.sectors.get(location[1], location[2], location[3]);
|
|
81
|
+
const sector = WorldRegister.sectors.get(location[0], location[1], location[2], location[3]);
|
|
87
82
|
if (!sector)
|
|
88
83
|
throw new Error(`Sector at ${location.toString()} does not exist when attempting world sun.`);
|
|
89
84
|
Sector.StateStruct.setBuffer(sector.buffer);
|
|
@@ -103,8 +98,7 @@ export class IWGTasks {
|
|
|
103
98
|
id: "propagation",
|
|
104
99
|
propagationBlocking: true,
|
|
105
100
|
async run(location, onDone) {
|
|
106
|
-
WorldRegister.
|
|
107
|
-
const sector = WorldRegister.sectors.get(location[1], location[2], location[3]);
|
|
101
|
+
const sector = WorldRegister.sectors.get(location[0], location[1], location[2], location[3]);
|
|
108
102
|
if (!sector)
|
|
109
103
|
throw new Error(`Sector at ${location.toString()} does not exist when attempting propagation.`);
|
|
110
104
|
Sector.StateStruct.setBuffer(sector.buffer);
|
|
@@ -4,7 +4,6 @@ import { SectionHeightMap } from "../../../World/Section/SectionHeightMap";
|
|
|
4
4
|
import { EngineSettings } from "../../../Settings/EngineSettings";
|
|
5
5
|
import { SunRemove, SunUpdate } from "../Illumanation/SunUpdate";
|
|
6
6
|
import { RGBRemove, RGBUpdate } from "../Illumanation/RGBUpdate";
|
|
7
|
-
import { WorldBounds } from "../../../World/WorldBounds";
|
|
8
7
|
const flowUpdateChecks = [
|
|
9
8
|
[0, -1, 0],
|
|
10
9
|
[1, 0, 0],
|
|
@@ -72,7 +71,7 @@ function Flood(task, voxel) {
|
|
|
72
71
|
}
|
|
73
72
|
continue;
|
|
74
73
|
}
|
|
75
|
-
if (!
|
|
74
|
+
if (!WorldSpaces.world.inBounds(x, y - 1, z) && levelState != 1)
|
|
76
75
|
continue;
|
|
77
76
|
let nVoxel = task.nDataCursor.getVoxel(x, y - 1, z);
|
|
78
77
|
const nLevel = nVoxel.isAir()
|
|
@@ -108,8 +107,7 @@ function Flood(task, voxel) {
|
|
|
108
107
|
export function WorldFlow(task) {
|
|
109
108
|
if (!EngineSettings.doFlow())
|
|
110
109
|
return false;
|
|
111
|
-
WorldRegister.
|
|
112
|
-
const sector = WorldRegister.sectors.get(task.origin[1], task.origin[2], task.origin[3]);
|
|
110
|
+
const sector = WorldRegister.sectors.get(task.origin[0], task.origin[1], task.origin[2], task.origin[3]);
|
|
113
111
|
if (!sector) {
|
|
114
112
|
console.error(`Tried running world flow on a sector that does not exist ${task.origin.toString()}`);
|
|
115
113
|
return false;
|
|
@@ -8,8 +8,7 @@ const sectionCursor = new SectionCursor();
|
|
|
8
8
|
export function WorldRGB(task) {
|
|
9
9
|
if (!EngineSettings.doLight())
|
|
10
10
|
return false;
|
|
11
|
-
WorldRegister.
|
|
12
|
-
const sector = WorldRegister.sectors.get(task.origin[1], task.origin[2], task.origin[3]);
|
|
11
|
+
const sector = WorldRegister.sectors.get(task.origin[0], task.origin[1], task.origin[2], task.origin[3]);
|
|
13
12
|
if (!sector) {
|
|
14
13
|
console.error(`Tried running world rgb on a sector that does not exist ${task.origin.toString()}`);
|
|
15
14
|
return false;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
//types
|
|
2
2
|
//data
|
|
3
|
-
import { WorldBounds } from "../../../World/WorldBounds.js";
|
|
4
|
-
import { WorldRegister } from "../../../World/WorldRegister.js";
|
|
5
3
|
import { $3dCardinalNeighbors } from "../../../Math/CardinalNeighbors.js";
|
|
6
4
|
import { WorldSpaces } from "../../../World/WorldSpaces.js";
|
|
7
5
|
import { SectorHeightMap } from "../../../World/Sector/SectorHeightMap.js";
|
|
@@ -17,12 +15,11 @@ const FloodOutPositions = [
|
|
|
17
15
|
const queue = [];
|
|
18
16
|
const lightData = new VoxelLightData();
|
|
19
17
|
export function RunWorldSun(tasks) {
|
|
20
|
-
WorldRegister.setDimension(tasks.origin[0]);
|
|
21
18
|
const [dimension, cx, cy, cz] = tasks.origin;
|
|
22
19
|
const RmaxY = SectorHeightMap.getRelative(tasks.origin);
|
|
23
20
|
const AmaxY = SectorHeightMap.getAbsolute(tasks.origin);
|
|
24
21
|
const maxX = cx + WorldSpaces.sector.bounds.x;
|
|
25
|
-
const maxY =
|
|
22
|
+
const maxY = WorldSpaces.world.bounds.MaxY;
|
|
26
23
|
const maxZ = cz + WorldSpaces.sector.bounds.z;
|
|
27
24
|
const sectorCursor = tasks.nDataCursor.getSector(tasks.origin[1], tasks.origin[2], tasks.origin[3]);
|
|
28
25
|
if (!sectorCursor) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { WorldSpaces } from "../../World/WorldSpaces.js";
|
|
2
2
|
import { BrushTool } from "../../Tools/Brush/Brush";
|
|
3
|
-
import { WorldBounds } from "../../World/WorldBounds";
|
|
4
3
|
import { DivineVoxelEngineConstructor } from "../../Contexts/Constructor";
|
|
5
4
|
import { WorldRegister } from "../../World/WorldRegister";
|
|
6
5
|
const brush = new BrushTool();
|
|
@@ -19,14 +18,13 @@ export class WorldGenRegister {
|
|
|
19
18
|
return id;
|
|
20
19
|
}
|
|
21
20
|
static addToRequest(registerId, location, rawData) {
|
|
22
|
-
if (location[2] <
|
|
23
|
-
location[2] >=
|
|
21
|
+
if (location[2] < WorldSpaces.world.bounds.MinY ||
|
|
22
|
+
location[2] >= WorldSpaces.world.bounds.MaxY)
|
|
24
23
|
return false;
|
|
25
24
|
const requests = this._requests.get(registerId);
|
|
26
25
|
if (!requests)
|
|
27
26
|
return;
|
|
28
|
-
WorldRegister.
|
|
29
|
-
const sector = WorldRegister.sectors.get(location[1], location[2], location[3]);
|
|
27
|
+
const sector = WorldRegister.sectors.get(location[0], location[1], location[2], location[3]);
|
|
30
28
|
if (!sector) {
|
|
31
29
|
const sectorPos = WorldSpaces.sector.getPosition(location[1], location[2], location[3]);
|
|
32
30
|
const sectorKey = WorldSpaces.hash.hashVec3(sectorPos);
|
|
@@ -46,12 +44,11 @@ export class WorldGenRegister {
|
|
|
46
44
|
const requests = this._requests.get(registerId);
|
|
47
45
|
if (!requests || !requests.voxels.length)
|
|
48
46
|
return true;
|
|
49
|
-
WorldRegister.setDimension(requests.dimension);
|
|
50
47
|
let done = true;
|
|
51
48
|
for (const [key, pos] of requests.sections) {
|
|
52
|
-
if (!
|
|
49
|
+
if (!WorldSpaces.world.inBounds(pos[0], pos[1], pos[2]))
|
|
53
50
|
continue;
|
|
54
|
-
const sector = WorldRegister.sectors.get(pos[0], pos[1], pos[2]);
|
|
51
|
+
const sector = WorldRegister.sectors.get(requests.dimension, pos[0], pos[1], pos[2]);
|
|
55
52
|
if (!sector) {
|
|
56
53
|
done = false;
|
|
57
54
|
DivineVoxelEngineConstructor.instance.threads.world.runTask("add-sector", [requests.dimension, pos[0], pos[1], pos[2]]);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { WorldBounds } from "../../World/WorldBounds.js";
|
|
2
1
|
import { WorldGenRegister } from "./WorldGenRegister.js";
|
|
3
2
|
import { WorldGenBrush } from "./WorldGenBrush.js";
|
|
4
3
|
import { WorldGenInterface } from "./WorldGen.types.js";
|
|
@@ -6,7 +5,6 @@ import { GenerateTasks } from "../Tasks.types.js";
|
|
|
6
5
|
export declare class WorldGeneration {
|
|
7
6
|
static worldGen: WorldGenInterface | null;
|
|
8
7
|
static register: typeof WorldGenRegister;
|
|
9
|
-
static worldBounds: typeof WorldBounds;
|
|
10
8
|
static _brushes: any[];
|
|
11
9
|
static setWorldGen(worldGen: WorldGenInterface): void;
|
|
12
10
|
static generate(data: GenerateTasks, mode: "generate" | "decorate", onDone: Function): Promise<void>;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
//types
|
|
2
2
|
//objects
|
|
3
|
-
import { WorldBounds } from "../../World/WorldBounds.js";
|
|
4
3
|
import { WorldGenRegister } from "./WorldGenRegister.js";
|
|
5
4
|
//tools
|
|
6
5
|
import { WorldGenBrush } from "./WorldGenBrush.js";
|
|
7
6
|
export class WorldGeneration {
|
|
8
7
|
static worldGen = null;
|
|
9
8
|
static register = WorldGenRegister;
|
|
10
|
-
static worldBounds = WorldBounds;
|
|
11
9
|
static _brushes = [];
|
|
12
10
|
static setWorldGen(worldGen) {
|
|
13
11
|
this.worldGen = worldGen;
|
package/Tools/Brush/Brush.js
CHANGED
|
@@ -29,8 +29,7 @@ export class BrushTool {
|
|
|
29
29
|
return this;
|
|
30
30
|
}
|
|
31
31
|
newSector() {
|
|
32
|
-
WorldRegister.
|
|
33
|
-
WorldRegister.sectors.new(this.x, this.y, this.z);
|
|
32
|
+
WorldRegister.sectors.new(this.dimension, this.x, this.y, this.z);
|
|
34
33
|
}
|
|
35
34
|
setData(data) {
|
|
36
35
|
this.data.id = data.id ? data.id : airId;
|
|
@@ -3,5 +3,5 @@ import { ArchivedSectorData } from "../Archive.types";
|
|
|
3
3
|
type ArchiveColumnProps = {
|
|
4
4
|
location: LocationData;
|
|
5
5
|
};
|
|
6
|
-
export default function
|
|
6
|
+
export default function ArchiveSector(archiveData: ArchiveColumnProps): ArchivedSectorData;
|
|
7
7
|
export {};
|