@divinevoxel/vlox 0.0.71 → 0.0.72
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/Main/InitDataGenerator.js +0 -9
- package/Contexts/Base/Remote/DataSync.types.d.ts +0 -5
- package/Contexts/Base/Remote/InitDataSync.js +17 -31
- package/Init/StartConstructor.js +2 -4
- package/Init/StartWorld.js +0 -12
- package/Math/Indexing.d.ts +12 -3
- package/Math/Indexing.js +24 -15
- package/Mesher/Functions/CompactVoxelMesh.d.ts +1 -1
- package/Mesher/Functions/CompactVoxelMesh.js +3 -4
- package/Mesher/Functions/MeshSection.d.ts +1 -1
- package/Mesher/Functions/MeshSection.js +54 -60
- package/Mesher/Functions/MeshVoxel.js +20 -26
- package/Mesher/Geomtry/Buffers.d.ts +9 -8
- package/Mesher/Geomtry/Buffers.js +26 -58
- package/Mesher/Geomtry/Tools/MesherDataTools.d.ts +1 -1
- package/Mesher/Geomtry/Tools/MesherDataTools.js +1 -1
- package/Mesher/Geomtry/VoxelGeometryBuilder.js +107 -124
- package/Mesher/InitMesher.js +1 -10
- package/Mesher/InitTask.js +10 -4
- package/Mesher/Models/Common/BoundsFunctions.d.ts +1 -3
- package/Mesher/Models/Common/BoundsFunctions.js +0 -16
- package/Mesher/Models/Common/Calc/CalcConstants.js +14 -31
- package/Mesher/Models/Common/Calc/FaceDataCalc.d.ts +1 -7
- package/Mesher/Models/Common/Calc/FaceDataCalc.js +41 -50
- package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.d.ts +1 -5
- package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +30 -26
- package/Mesher/Models/Nodes/GeometryNode.d.ts +2 -4
- package/Mesher/Models/Nodes/GeometryNode.js +1 -2
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.d.ts +2 -6
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +37 -34
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.d.ts +2 -6
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +52 -51
- package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.d.ts +2 -6
- package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.js +18 -19
- package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.d.ts +2 -6
- package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.js +37 -40
- package/Mesher/Models/VoxelConstructor.d.ts +3 -4
- package/Mesher/Models/VoxelConstructor.js +23 -12
- package/Mesher/Models/{VoxelGeometryLookUp.d.ts → VoxelGeometryBuilderCacheSpace.d.ts} +8 -14
- package/Mesher/Models/{VoxelGeometryLookUp.js → VoxelGeometryBuilderCacheSpace.js} +49 -44
- package/Mesher/Models/VoxelModelConstructorRegister.js +3 -3
- package/Mesher/Tools/VoxelMeshBVHBuilder.d.ts +2 -9
- package/Mesher/Tools/VoxelMeshBVHBuilder.js +4 -16
- package/Mesher/Tools/VoxelMeshVertexStructCursor.d.ts +10 -0
- package/Mesher/Tools/VoxelMeshVertexStructCursor.js +10 -0
- package/Mesher/Tools/VoxelMesherDataTool.d.ts +8 -5
- package/Mesher/Tools/VoxelMesherDataTool.js +34 -13
- package/Models/Indexing/VoxelAOResultsIndex.d.ts +4 -4
- package/Models/Indexing/VoxelAOResultsIndex.js +15 -9
- package/Models/Indexing/VoxelFaceCullResultsIndex.d.ts +3 -3
- package/Models/Indexing/VoxelFaceCullResultsIndex.js +14 -9
- package/Models/Indexing/VoxelFaceTransparentResultsIndex.d.ts +1 -1
- package/Models/Indexing/VoxelFaceTransparentResultsIndex.js +1 -1
- package/Models/Rules/Functions/BuildRules.js +2 -2
- package/Tasks/IWG/Internal/Classes/Generator.js +1 -1
- package/Tasks/IWG/Internal/Functions/getSectorState.js +4 -7
- package/Tasks/IWG/Internal/Functions/runWorldUpdate.js +5 -6
- package/Tasks/IWG/Internal/IWGTasks.js +12 -21
- package/Tasks/Propagation/Flow/FlowManager.d.ts +0 -2
- package/Tasks/Propagation/Flow/FlowManager.js +86 -87
- package/Tasks/Propagation/Flow/WorldFlow.js +2 -3
- package/Tasks/Propagation/Illumanation/WorldRGB.js +1 -2
- package/Tasks/Update/InitTasks.d.ts +2 -1
- package/Tasks/Update/InitTasks.js +6 -6
- package/Tasks/Update/VoxelUpdate.js +15 -7
- package/Tasks/WorldGeneration/WorldGenBrush.js +1 -0
- package/Templates/Cursor/TemplateCursor.d.ts +1 -1
- package/Templates/Cursor/TemplateCursor.js +1 -1
- package/Templates/Functions/CreateTemplate.js +1 -1
- package/Templates/VoxelTemplate.js +6 -8
- package/Tools/Brush/Brush.d.ts +0 -2
- package/Tools/Brush/Brush.js +5 -6
- package/{Data/Cursor → Tools}/DataCursor.interface.d.ts +1 -1
- package/Util/Binary/BitArray.d.ts +4 -0
- package/Util/Binary/BitArray.js +16 -0
- package/Util/StringPalette.d.ts +1 -0
- package/Util/StringPalette.js +8 -0
- package/Voxels/Cursor/VoxelCursor.d.ts +6 -6
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +10 -15
- package/Voxels/Cursor/VoxelCursor.interface.js +30 -50
- package/Voxels/Cursor/VoxelCursor.js +13 -12
- package/Voxels/Cursor/VoxelLightData.d.ts +3 -4
- package/Voxels/Cursor/VoxelLightData.js +8 -7
- package/Voxels/Data/VoxelPalettesRegister.d.ts +13 -0
- package/Voxels/Data/VoxelPalettesRegister.js +17 -0
- package/Voxels/Data/VoxelTag.types.d.ts +56 -0
- package/Voxels/Data/VoxelTag.types.js +23 -0
- package/Voxels/{State → Data}/VoxelTagStates.d.ts +2 -2
- package/Voxels/{State → Data}/VoxelTagStates.js +5 -5
- package/Voxels/Data/VoxelTagsRegister.d.ts +9 -0
- package/Voxels/Data/VoxelTagsRegister.js +32 -0
- package/Voxels/Functions/BuildStateData.js +3 -3
- package/Voxels/Functions/BuildTagAndPaletteData.d.ts +13 -0
- package/Voxels/Functions/BuildTagAndPaletteData.js +57 -0
- package/Voxels/Indexes/VoxelIndex.js +3 -3
- package/Voxels/InitVoxelData.js +20 -61
- package/Voxels/State/Schema/StateSchema.d.ts +1 -1
- package/Voxels/Types/Voxel.types.d.ts +2 -42
- package/Voxels/Types/Voxel.types.js +0 -15
- package/Voxels/Types/VoxelModelCompiledData.types.d.ts +11 -13
- package/Voxels/Types/VoxelSubstances.types.d.ts +2 -15
- package/Voxels/Types/VoxelSubstances.types.js +1 -9
- package/World/Archive/Functions/ArchiveArea.js +2 -6
- package/World/Archive/Functions/ArchiveSector.js +14 -28
- package/World/Archive/Functions/ImportSector.js +27 -34
- package/World/Cursor/SectionCursor.d.ts +2 -1
- package/World/Cursor/SectionCursor.js +8 -2
- package/World/Cursor/SectorCursor.d.ts +2 -1
- package/World/Cursor/SectorCursor.js +5 -2
- package/World/Cursor/WorldCursor.d.ts +1 -1
- package/World/Cursor/WorldCursor.js +6 -2
- package/World/Cursor/WorldVoxelCursor.d.ts +7 -7
- package/World/Cursor/WorldVoxelCursor.js +20 -24
- package/World/Section/Section.d.ts +20 -8
- package/World/Section/Section.js +65 -9
- package/World/Sector/Sector.d.ts +13 -6
- package/World/Sector/Sector.js +30 -9
- package/World/Sector/SectorHeightMap.js +1 -3
- package/World/Sector/SectorState.d.ts +13 -0
- package/World/Sector/SectorState.js +15 -0
- package/World/WorldSpaces.d.ts +2 -0
- package/World/WorldSpaces.js +7 -1
- package/package.json +1 -1
- package/Data/Register/MappedDataRegister.d.ts +0 -5
- package/Data/Register/MappedDataRegister.js +0 -9
- package/Data/Register/MappedRegisterBase.d.ts +0 -14
- package/Data/Register/MappedRegisterBase.js +0 -50
- package/Data/Structs/StructBuilder.d.ts +0 -34
- package/Data/Structs/StructBuilder.js +0 -157
- package/Data/Structs/StructBuilder.types.d.ts +0 -30
- package/Data/Structs/StructBuilder.types.js +0 -1
- package/Tools/Data/SubstanceDataTool.d.ts +0 -13
- package/Tools/Data/SubstanceDataTool.js +0 -51
- package/Voxels/Palettes/MaterialPalette.d.ts +0 -9
- package/Voxels/Palettes/MaterialPalette.js +0 -11
- package/Voxels/Palettes/SubstancePalette.d.ts +0 -9
- package/Voxels/Palettes/SubstancePalette.js +0 -11
- package/Voxels/Palettes/VoxelPalette.d.ts +0 -11
- package/Voxels/Palettes/VoxelPalette.js +0 -15
- package/Voxels/Segments/MaterialDataGenerator.d.ts +0 -6
- package/Voxels/Segments/MaterialDataGenerator.js +0 -12
- package/Voxels/Segments/SubstanceDataGenerator.d.ts +0 -6
- package/Voxels/Segments/SubstanceDataGenerator.js +0 -35
- package/Voxels/Segments/VoxelDataGenerator.d.ts +0 -10
- package/Voxels/Segments/VoxelDataGenerator.js +0 -56
- package/Voxels/Structs/Builder/SubstanceStructBuilder.d.ts +0 -2
- package/Voxels/Structs/Builder/SubstanceStructBuilder.js +0 -42
- package/Voxels/Structs/Builder/VoxelStructBuilder.d.ts +0 -2
- package/Voxels/Structs/Builder/VoxelStructBuilder.js +0 -68
- package/Voxels/Structs/SubstanceStruct.d.ts +0 -17
- package/Voxels/Structs/SubstanceStruct.js +0 -17
- package/Voxels/Structs/VoxelStruct.d.ts +0 -27
- package/Voxels/Structs/VoxelStruct.js +0 -29
- package/World/Section/SectionHeightMap.d.ts +0 -10
- package/World/Section/SectionHeightMap.js +0 -39
- package/World/Section/SectionStruct.d.ts +0 -8
- package/World/Section/SectionStruct.js +0 -29
- package/World/Section/SectionStructProperties.d.ts +0 -10
- package/World/Section/SectionStructProperties.js +0 -11
- package/World/Sector/SectorStruct.d.ts +0 -1
- package/World/Sector/SectorStruct.js +0 -46
- package/World/Sector/SectorStructIds.d.ts +0 -13
- package/World/Sector/SectorStructIds.js +0 -14
- /package/{Data/Cursor → Tools}/DataCursor.interface.js +0 -0
- /package/{Data/Functions → Util/Binary}/Palettes.d.ts +0 -0
- /package/{Data/Functions → Util/Binary}/Palettes.js +0 -0
- /package/Voxels/{VoxelLevelReader.d.ts → Cursor/VoxelLevelReader.d.ts} +0 -0
- /package/Voxels/{VoxelLevelReader.js → Cursor/VoxelLevelReader.js} +0 -0
|
@@ -4,25 +4,29 @@ import { MesherDataTool } from "../Geomtry/Tools/MesherDataTools";
|
|
|
4
4
|
import { QuadScalarVertexData } from "../Geomtry/Primitives/QuadVertexData";
|
|
5
5
|
import { VoxelFaces, VoxelFacesArray } from "../../Math";
|
|
6
6
|
import { QuadVerticies } from "../Geomtry/Geometry.types";
|
|
7
|
-
import
|
|
7
|
+
import calculateFaceData from "../Models/Common/Calc/FaceDataCalc.js";
|
|
8
8
|
import { VoxelMesh } from "../Geomtry/VoxelMesh";
|
|
9
|
-
import { Vector3Like } from "@amodx/math";
|
|
9
|
+
import { Vector3Like, Vector4Like } from "@amodx/math";
|
|
10
10
|
class VoxelVars {
|
|
11
11
|
faceFlipped = false;
|
|
12
12
|
textureIndex = 0;
|
|
13
|
+
overlayTextures = Vector4Like.Create();
|
|
13
14
|
light = new QuadScalarVertexData();
|
|
14
15
|
ao = new QuadScalarVertexData();
|
|
15
16
|
animation = new QuadScalarVertexData();
|
|
16
17
|
level = new QuadScalarVertexData();
|
|
17
|
-
overlayTextures = new QuadScalarVertexData();
|
|
18
18
|
reset() {
|
|
19
19
|
this.faceFlipped = false;
|
|
20
20
|
this.textureIndex = 0;
|
|
21
|
+
this.overlayTextures.x = 0;
|
|
22
|
+
this.overlayTextures.y = 0;
|
|
23
|
+
this.overlayTextures.z = 0;
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
26
|
export class VoxelMesherDataTool extends MesherDataTool {
|
|
24
27
|
id;
|
|
25
28
|
materialIndex;
|
|
29
|
+
space;
|
|
26
30
|
voxel;
|
|
27
31
|
nVoxel;
|
|
28
32
|
/**The current world position */
|
|
@@ -78,27 +82,47 @@ export class VoxelMesherDataTool extends MesherDataTool {
|
|
|
78
82
|
};
|
|
79
83
|
_indexStart = 0;
|
|
80
84
|
startConstruction() {
|
|
81
|
-
this._indexStart = this.mesh.
|
|
85
|
+
this._indexStart = this.mesh.indicieCount;
|
|
82
86
|
this.bounds.min[0] = Infinity;
|
|
83
87
|
this.bounds.min[1] = Infinity;
|
|
84
88
|
this.bounds.min[2] = Infinity;
|
|
85
89
|
this.bounds.max[0] = -Infinity;
|
|
86
90
|
this.bounds.max[1] = -Infinity;
|
|
87
91
|
this.bounds.max[2] = -Infinity;
|
|
92
|
+
this._boundsUpdate = true;
|
|
88
93
|
}
|
|
89
94
|
endConstruction() {
|
|
90
|
-
|
|
91
|
-
this.bounds.max.includes(-Infinity))
|
|
92
|
-
return false;
|
|
95
|
+
this.vars.reset();
|
|
93
96
|
if (this.bvhTool) {
|
|
94
|
-
|
|
97
|
+
if (!this._boundsUpdate)
|
|
98
|
+
return false;
|
|
99
|
+
this.bvhTool.updateVoxel(this.position.x, this.position.y, this.position.z, this._indexStart, this.materialIndex, this.mesh.indicieCount, this.bounds.min[0], this.bounds.min[1], this.bounds.min[2], this.bounds.max[0], this.bounds.max[1], this.bounds.max[2]);
|
|
95
100
|
}
|
|
96
101
|
return true;
|
|
97
102
|
}
|
|
103
|
+
_boundsUpdate = false;
|
|
104
|
+
updateBounds(bounds) {
|
|
105
|
+
const origin = this.origin;
|
|
106
|
+
//min
|
|
107
|
+
if (origin.x + bounds[0][0] < this.bounds.min[0])
|
|
108
|
+
this.bounds.min[0] = origin.x + bounds[0][0];
|
|
109
|
+
if (origin.y + bounds[0][1] < this.bounds.min[1])
|
|
110
|
+
this.bounds.min[1] = origin.y + bounds[0][1];
|
|
111
|
+
if (origin.z + bounds[0][2] < this.bounds.min[2])
|
|
112
|
+
this.bounds.min[2] = origin.z + bounds[0][2];
|
|
113
|
+
//max
|
|
114
|
+
if (origin.x + bounds[1][0] > this.bounds.max[0])
|
|
115
|
+
this.bounds.max[0] = origin.x + bounds[1][0];
|
|
116
|
+
if (origin.y + bounds[1][1] > this.bounds.max[1])
|
|
117
|
+
this.bounds.max[1] = origin.y + bounds[1][1];
|
|
118
|
+
if (origin.z + bounds[1][2] > this.bounds.max[2])
|
|
119
|
+
this.bounds.max[2] = origin.z + bounds[1][2];
|
|
120
|
+
this._boundsUpdate = true;
|
|
121
|
+
}
|
|
98
122
|
calculateFaceData(direction) {
|
|
99
123
|
if (this.dataCalculated[direction])
|
|
100
124
|
return true;
|
|
101
|
-
|
|
125
|
+
calculateFaceData(direction, this);
|
|
102
126
|
this.dataCalculated[direction] = true;
|
|
103
127
|
}
|
|
104
128
|
clearCalculatedData() {
|
|
@@ -109,10 +133,7 @@ export class VoxelMesherDataTool extends MesherDataTool {
|
|
|
109
133
|
this.dataCalculated[VoxelFaces.East] = false;
|
|
110
134
|
this.dataCalculated[VoxelFaces.West] = false;
|
|
111
135
|
}
|
|
112
|
-
|
|
113
|
-
this.vars.reset();
|
|
114
|
-
}
|
|
115
|
-
resetAll() {
|
|
136
|
+
clear() {
|
|
116
137
|
this.vars.reset();
|
|
117
138
|
this.mesh.clear();
|
|
118
139
|
return this;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export type VoxelAOResultsIndexData = {
|
|
2
|
-
buffer:
|
|
2
|
+
buffer: ArrayBufferLike;
|
|
3
3
|
vertexByteCount: number;
|
|
4
4
|
};
|
|
5
5
|
export declare class VoxelAOResultsIndex {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
view: Uint8Array;
|
|
7
|
+
readonly vertexByteCount: number;
|
|
8
8
|
constructor(data: VoxelAOResultsIndexData);
|
|
9
|
-
getByteIndex(otherId: number, directionIndex: number): number;
|
|
10
9
|
getValue(otherId: number, directionIndex: number, vertexIndex: number): number;
|
|
11
10
|
setValue(otherId: number, directionIndex: number, vertexIndex: number, value?: number): void;
|
|
11
|
+
getData(): VoxelAOResultsIndexData;
|
|
12
12
|
}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { BinaryArrays } from "@amodx/binary/Util/BinaryArrays";
|
|
2
2
|
import { VoxelRelativeCubeIndex } from "./VoxelRelativeCubeIndex";
|
|
3
|
+
const flatIndexSize = VoxelRelativeCubeIndex.flatIndex.size;
|
|
4
|
+
function getByteIndex(otherId, directionIndex, vertexByteCount) {
|
|
5
|
+
return (otherId * vertexByteCount * flatIndexSize + directionIndex * vertexByteCount);
|
|
6
|
+
}
|
|
3
7
|
export class VoxelAOResultsIndex {
|
|
4
|
-
data;
|
|
5
8
|
view;
|
|
9
|
+
vertexByteCount;
|
|
6
10
|
constructor(data) {
|
|
7
|
-
this.
|
|
8
|
-
this.view = new
|
|
9
|
-
}
|
|
10
|
-
getByteIndex(otherId, directionIndex) {
|
|
11
|
-
return (otherId * this.data.vertexByteCount * VoxelRelativeCubeIndex.flatIndex.size +
|
|
12
|
-
directionIndex * this.data.vertexByteCount);
|
|
11
|
+
this.vertexByteCount = data.vertexByteCount;
|
|
12
|
+
this.view = new Uint8Array(data.buffer);
|
|
13
13
|
}
|
|
14
14
|
getValue(otherId, directionIndex, vertexIndex) {
|
|
15
|
-
return BinaryArrays.getBitArrayIndex(this.view,
|
|
15
|
+
return BinaryArrays.getBitArrayIndex(this.view, getByteIndex(otherId, directionIndex, this.vertexByteCount), vertexIndex);
|
|
16
16
|
}
|
|
17
17
|
setValue(otherId, directionIndex, vertexIndex, value = 1) {
|
|
18
|
-
BinaryArrays.setBitArrayIndex(this.view,
|
|
18
|
+
BinaryArrays.setBitArrayIndex(this.view, getByteIndex(otherId, directionIndex, this.vertexByteCount), vertexIndex, value);
|
|
19
|
+
}
|
|
20
|
+
getData() {
|
|
21
|
+
return {
|
|
22
|
+
buffer: this.view.buffer,
|
|
23
|
+
vertexByteCount: this.vertexByteCount,
|
|
24
|
+
};
|
|
19
25
|
}
|
|
20
26
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export type VoxelFaceCullResultsIndexData = {
|
|
2
|
-
buffer:
|
|
2
|
+
buffer: ArrayBufferLike;
|
|
3
3
|
faceByteCount: number;
|
|
4
4
|
};
|
|
5
5
|
export declare class VoxelFaceCullResultsIndex {
|
|
6
|
-
data: VoxelFaceCullResultsIndexData;
|
|
7
6
|
view: Uint16Array;
|
|
7
|
+
readonly faceByteCount: number;
|
|
8
8
|
constructor(data: VoxelFaceCullResultsIndexData);
|
|
9
|
-
getByteIndex(otherId: number, directionIndex: number): number;
|
|
10
9
|
getValue(otherId: number, directionIndex: number, faceIndex: number): number;
|
|
11
10
|
setValue(otherId: number, directionIndex: number, faceIndex: number, value?: number): number;
|
|
11
|
+
getData(): VoxelFaceCullResultsIndexData;
|
|
12
12
|
}
|
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { VoxelRelativeCubeIndex } from "./VoxelRelativeCubeIndex";
|
|
2
|
+
const flatIndexSize = VoxelRelativeCubeIndex.flatIndex.size;
|
|
3
|
+
function getByteIndex(otherId, directionIndex, faceByteCount) {
|
|
4
|
+
return (otherId * faceByteCount * flatIndexSize + directionIndex * faceByteCount);
|
|
5
|
+
}
|
|
2
6
|
export class VoxelFaceCullResultsIndex {
|
|
3
|
-
data;
|
|
4
7
|
view;
|
|
8
|
+
faceByteCount;
|
|
5
9
|
constructor(data) {
|
|
6
|
-
this.data = data;
|
|
7
10
|
this.view = new Uint16Array(data.buffer);
|
|
8
|
-
|
|
9
|
-
getByteIndex(otherId, directionIndex) {
|
|
10
|
-
return (otherId * this.data.faceByteCount * VoxelRelativeCubeIndex.flatIndex.size +
|
|
11
|
-
directionIndex * this.data.faceByteCount);
|
|
11
|
+
this.faceByteCount = data.faceByteCount;
|
|
12
12
|
}
|
|
13
13
|
getValue(otherId, directionIndex, faceIndex) {
|
|
14
|
-
const v = this.view[
|
|
14
|
+
const v = this.view[getByteIndex(otherId, directionIndex, this.faceByteCount) + faceIndex];
|
|
15
15
|
return v == 65535 ? -1 : v;
|
|
16
16
|
}
|
|
17
17
|
setValue(otherId, directionIndex, faceIndex, value = -1) {
|
|
18
|
-
return (this.view[
|
|
19
|
-
|
|
18
|
+
return (this.view[getByteIndex(otherId, directionIndex, this.faceByteCount) + faceIndex] = value);
|
|
19
|
+
}
|
|
20
|
+
getData() {
|
|
21
|
+
return {
|
|
22
|
+
buffer: this.view.buffer,
|
|
23
|
+
faceByteCount: this.faceByteCount,
|
|
24
|
+
};
|
|
20
25
|
}
|
|
21
26
|
}
|
|
@@ -4,7 +4,7 @@ export type VoxelFaceTransparentResultsIndexData = {
|
|
|
4
4
|
};
|
|
5
5
|
export declare class VoxelFaceTransparentResultsIndex {
|
|
6
6
|
data: VoxelFaceTransparentResultsIndexData;
|
|
7
|
-
view:
|
|
7
|
+
view: Uint8Array;
|
|
8
8
|
constructor(data: VoxelFaceTransparentResultsIndexData);
|
|
9
9
|
getValue(modState: number, faceByteIndex: number, faceIndex: number): number;
|
|
10
10
|
setValue(modState: number, faceByteIndex: number, faceIndex: number, value?: number): void;
|
|
@@ -4,7 +4,7 @@ export class VoxelFaceTransparentResultsIndex {
|
|
|
4
4
|
view;
|
|
5
5
|
constructor(data) {
|
|
6
6
|
this.data = data;
|
|
7
|
-
this.view = new
|
|
7
|
+
this.view = new Uint8Array(data.buffer);
|
|
8
8
|
}
|
|
9
9
|
getValue(modState, faceByteIndex, faceIndex) {
|
|
10
10
|
return BinaryArrays.getBitArrayIndex(this.view, this.data.resultsSize * modState + faceByteIndex, faceIndex);
|
|
@@ -26,7 +26,7 @@ export class Generator {
|
|
|
26
26
|
}
|
|
27
27
|
update() {
|
|
28
28
|
this._positonChanged = false;
|
|
29
|
-
WorldSpaces.section.getPosition(this.position.x,
|
|
29
|
+
WorldSpaces.section.getPosition(this.position.x, 0, this.position.z, this._sectorPosition);
|
|
30
30
|
if (!Vector3Like.Equals(this._sectorPosition, this._cachedPosition)) {
|
|
31
31
|
this._positonChanged = true;
|
|
32
32
|
Vector3Like.Copy(this._cachedPosition, this._sectorPosition);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { WorldRegister } from "../../../../World/WorldRegister";
|
|
2
|
-
import { SectorStateStructIds } from "../../../../World/Sector/SectorStructIds";
|
|
3
2
|
import { $2dMooreNeighborhood } from "../../../../Math/CardinalNeighbors";
|
|
4
3
|
import { WorldSpaces } from "../../../../World/WorldSpaces";
|
|
5
4
|
import { Sector } from "../../../../World/index";
|
|
@@ -8,7 +7,6 @@ const tempPosition = Vector3Like.Create();
|
|
|
8
7
|
export function getSectorState(sector, state, segment) {
|
|
9
8
|
state.resset();
|
|
10
9
|
const [cx, cy, cz] = sector.position;
|
|
11
|
-
Sector.StateStruct.setData(sector.sectorState);
|
|
12
10
|
for (let i = 0; i < $2dMooreNeighborhood.length; i++) {
|
|
13
11
|
const sectorPOS = WorldSpaces.sector.getPosition(cx + $2dMooreNeighborhood[i][0] * WorldSpaces.sector.bounds.x, cy, cz + $2dMooreNeighborhood[i][1] * WorldSpaces.sector.bounds.z, tempPosition);
|
|
14
12
|
if (!segment.vistedMap.has(sectorPOS.x, cy, sectorPOS.z)) {
|
|
@@ -24,17 +22,16 @@ export function getSectorState(sector, state, segment) {
|
|
|
24
22
|
state.allLoaded = false;
|
|
25
23
|
break;
|
|
26
24
|
}
|
|
27
|
-
Sector.
|
|
28
|
-
if (!Sector.StateStruct.getProperty(SectorStateStructIds.isWorldGenDone)) {
|
|
25
|
+
if (!sector.getBitFlag(Sector.FlagIds.isWorldGenDone)) {
|
|
29
26
|
state.nWorldGenAllDone = false;
|
|
30
27
|
}
|
|
31
|
-
if (!Sector.
|
|
28
|
+
if (!sector.getBitFlag(Sector.FlagIds.isWorldDecorDone)) {
|
|
32
29
|
state.nDecorAllDone = false;
|
|
33
30
|
}
|
|
34
|
-
if (!Sector.
|
|
31
|
+
if (!sector.getBitFlag(Sector.FlagIds.isWorldSunDone)) {
|
|
35
32
|
state.nSunAllDone = false;
|
|
36
33
|
}
|
|
37
|
-
if (!Sector.
|
|
34
|
+
if (!sector.getBitFlag(Sector.FlagIds.isWorldPropagationDone)) {
|
|
38
35
|
state.nPropagtionAllDone = false;
|
|
39
36
|
}
|
|
40
37
|
}
|
|
@@ -3,7 +3,6 @@ import { getSectorState } from "./getSectorState";
|
|
|
3
3
|
import { SectorState } from "../Classes/SectorState";
|
|
4
4
|
import { WorldRegister } from "../../../../World/WorldRegister";
|
|
5
5
|
import { Sector } from "../../../../World";
|
|
6
|
-
import { SectorStateStructIds } from "../../../../World/Sector/SectorStructIds";
|
|
7
6
|
import { WorldLock } from "../../../../World/Lock/WorldLock";
|
|
8
7
|
import { IWGTasks } from "../IWGTasks";
|
|
9
8
|
import { IWGDimensions } from "../IWGDimensions";
|
|
@@ -41,24 +40,24 @@ export function runWorldUpdate(generators) {
|
|
|
41
40
|
continue;
|
|
42
41
|
}
|
|
43
42
|
const state = getSectorState(sector, stateCursor, segment);
|
|
44
|
-
Sector.
|
|
43
|
+
sector.getBitFlag(Sector.FlagIds.isWorldGenDone);
|
|
45
44
|
if (state.allLoaded &&
|
|
46
|
-
!Sector.
|
|
45
|
+
!sector.getBitFlag(Sector.FlagIds.isWorldGenDone)) {
|
|
47
46
|
IWGTasks.worldGenTasks.add(generator._dimension, cx, cy, cz);
|
|
48
47
|
continue;
|
|
49
48
|
}
|
|
50
49
|
if (state.nWorldGenAllDone &&
|
|
51
|
-
!Sector.
|
|
50
|
+
!sector.getBitFlag(Sector.FlagIds.isWorldDecorDone)) {
|
|
52
51
|
IWGTasks.worldDecorateTasks.add(generator._dimension, cx, cy, cz);
|
|
53
52
|
continue;
|
|
54
53
|
}
|
|
55
54
|
if (state.nDecorAllDone &&
|
|
56
|
-
!Sector.
|
|
55
|
+
!sector.getBitFlag(Sector.FlagIds.isWorldPropagationDone)) {
|
|
57
56
|
IWGTasks.worldPropagationTasks.add(generator._dimension, cx, cy, cz);
|
|
58
57
|
continue;
|
|
59
58
|
}
|
|
60
59
|
if (state.nPropagtionAllDone &&
|
|
61
|
-
!Sector.
|
|
60
|
+
!sector.getBitFlag(Sector.FlagIds.isWorldSunDone)) {
|
|
62
61
|
IWGTasks.worldSunTasks.add(generator._dimension, cx, cy, cz);
|
|
63
62
|
continue;
|
|
64
63
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { WorldRegister } from "../../../World/WorldRegister";
|
|
2
2
|
import { Sector } from "../../../World/index";
|
|
3
|
-
import { SectorStateStructIds } from "../../../World/Sector/SectorStructIds";
|
|
4
3
|
import { IWGTools } from "./IWGTools";
|
|
5
4
|
import { TaskRegister } from "./TaskRegister";
|
|
6
5
|
export class IWGTasks {
|
|
@@ -38,15 +37,13 @@ export class IWGTasks {
|
|
|
38
37
|
id: "generate",
|
|
39
38
|
propagationBlocking: true,
|
|
40
39
|
async run(location, onDone) {
|
|
41
|
-
const sector = WorldRegister.sectors.get(location
|
|
40
|
+
const sector = WorldRegister.sectors.get(...location);
|
|
42
41
|
if (!sector)
|
|
43
42
|
throw new Error(`Sector at ${location.toString()} does not exist when attempting generation.`);
|
|
44
|
-
Sector.
|
|
45
|
-
if (Sector.StateStruct.getProperty(SectorStateStructIds.isWorldGenDone))
|
|
43
|
+
if (sector.getBitFlag(Sector.FlagIds.isWorldGenDone))
|
|
46
44
|
return onDone();
|
|
47
45
|
IWGTools.taskTool.generate.run([location, []], null, () => {
|
|
48
|
-
Sector.
|
|
49
|
-
Sector.StateStruct.setProperty(SectorStateStructIds.isWorldGenDone, 1);
|
|
46
|
+
sector.setBitFlag(Sector.FlagIds.isWorldGenDone, true);
|
|
50
47
|
onDone();
|
|
51
48
|
});
|
|
52
49
|
},
|
|
@@ -58,15 +55,13 @@ export class IWGTasks {
|
|
|
58
55
|
id: "decorate",
|
|
59
56
|
propagationBlocking: true,
|
|
60
57
|
async run(location, onDone) {
|
|
61
|
-
const sector = WorldRegister.sectors.get(location
|
|
58
|
+
const sector = WorldRegister.sectors.get(...location);
|
|
62
59
|
if (!sector)
|
|
63
60
|
throw new Error(`Sector at ${location.toString()} does not exist when attempting decoration.`);
|
|
64
|
-
Sector.
|
|
65
|
-
if (Sector.StateStruct.getProperty(SectorStateStructIds.isWorldDecorDone))
|
|
61
|
+
if (sector.getBitFlag(Sector.FlagIds.isWorldDecorDone))
|
|
66
62
|
return onDone();
|
|
67
63
|
IWGTools.taskTool.decorate.run([location, []], null, () => {
|
|
68
|
-
Sector.
|
|
69
|
-
Sector.StateStruct.setProperty(SectorStateStructIds.isWorldDecorDone, 1);
|
|
64
|
+
sector.setBitFlag(Sector.FlagIds.isWorldDecorDone, true);
|
|
70
65
|
onDone();
|
|
71
66
|
});
|
|
72
67
|
},
|
|
@@ -78,15 +73,13 @@ export class IWGTasks {
|
|
|
78
73
|
id: "wolrd_sun",
|
|
79
74
|
propagationBlocking: true,
|
|
80
75
|
async run(location, onDone) {
|
|
81
|
-
const sector = WorldRegister.sectors.get(location
|
|
76
|
+
const sector = WorldRegister.sectors.get(...location);
|
|
82
77
|
if (!sector)
|
|
83
78
|
throw new Error(`Sector at ${location.toString()} does not exist when attempting world sun.`);
|
|
84
|
-
Sector.
|
|
85
|
-
if (Sector.StateStruct.getProperty(SectorStateStructIds.isWorldSunDone))
|
|
79
|
+
if (sector.getBitFlag(Sector.FlagIds.isWorldSunDone))
|
|
86
80
|
return onDone();
|
|
87
81
|
IWGTools.taskTool.worldSun.run(location, null, () => {
|
|
88
|
-
Sector.
|
|
89
|
-
Sector.StateStruct.setProperty(SectorStateStructIds.isWorldSunDone, 1);
|
|
82
|
+
sector.setBitFlag(Sector.FlagIds.isWorldSunDone, true);
|
|
90
83
|
onDone();
|
|
91
84
|
});
|
|
92
85
|
},
|
|
@@ -98,15 +91,13 @@ export class IWGTasks {
|
|
|
98
91
|
id: "propagation",
|
|
99
92
|
propagationBlocking: true,
|
|
100
93
|
async run(location, onDone) {
|
|
101
|
-
const sector = WorldRegister.sectors.get(location
|
|
94
|
+
const sector = WorldRegister.sectors.get(...location);
|
|
102
95
|
if (!sector)
|
|
103
96
|
throw new Error(`Sector at ${location.toString()} does not exist when attempting propagation.`);
|
|
104
|
-
Sector.
|
|
105
|
-
if (Sector.StateStruct.getProperty(SectorStateStructIds.isWorldPropagationDone))
|
|
97
|
+
if (sector.getBitFlag(Sector.FlagIds.isWorldPropagationDone))
|
|
106
98
|
return onDone();
|
|
107
99
|
IWGTools.taskTool.propagation.run(location, null, () => {
|
|
108
|
-
Sector.
|
|
109
|
-
Sector.StateStruct.setProperty(SectorStateStructIds.isWorldPropagationDone, 1);
|
|
100
|
+
sector.setBitFlag(Sector.FlagIds.isWorldPropagationDone, true);
|
|
110
101
|
onDone();
|
|
111
102
|
});
|
|
112
103
|
},
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { BrushTool } from "../../../Tools/Brush/Brush.js";
|
|
2
|
-
import { SubstanceDataTool } from "../../../Tools/Data/SubstanceDataTool.js";
|
|
3
2
|
import { UpdateTask } from "../../Update/UpdateTask.js";
|
|
4
3
|
import { WorldCursor } from "../../../World/index.js";
|
|
5
4
|
export declare class FlowManager {
|
|
6
5
|
static _brush: BrushTool;
|
|
7
6
|
static _sDataTool: WorldCursor;
|
|
8
7
|
static _nDataTool: WorldCursor;
|
|
9
|
-
static _substanceTool: SubstanceDataTool;
|
|
10
8
|
static setVoxel(tasks: UpdateTask, vox: string, level: number, levelState: number, x: number, y: number, z: number): void;
|
|
11
9
|
static setDimension(dimension: string): void;
|
|
12
10
|
static removeVoxel(tasks: UpdateTask, x: number, y: number, z: number): void;
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import { BrushTool } from "../../../Tools/Brush/Brush.js";
|
|
2
|
-
import { SubstanceDataTool } from "../../../Tools/Data/SubstanceDataTool.js";
|
|
3
2
|
import { WorldCursor } from "../../../World/index.js";
|
|
4
3
|
export class FlowManager {
|
|
5
4
|
static _brush = new BrushTool();
|
|
6
5
|
static _sDataTool = new WorldCursor();
|
|
7
6
|
static _nDataTool = new WorldCursor();
|
|
8
|
-
static _substanceTool = new SubstanceDataTool();
|
|
9
7
|
static setVoxel(tasks, vox, level, levelState, x, y, z) {
|
|
10
8
|
/* this.sunCheck(tasks, x, y, z);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
SunRemove(tasks);
|
|
10
|
+
this._brush.setId(vox).setXYZ(x, y, z).paint();
|
|
11
|
+
this._sDataTool.loadInAt(x, y, z);
|
|
12
|
+
this._sDataTool
|
|
13
|
+
.setLevel(level)
|
|
14
|
+
.setLevelState(levelState)
|
|
15
|
+
.setLight(this.getAbsorbLight(x, y, z))
|
|
16
|
+
.commit();
|
|
17
|
+
|
|
18
|
+
SunUpdate(tasks); */
|
|
21
19
|
}
|
|
22
20
|
static setDimension(dimension) {
|
|
23
21
|
// this._sDataTool.setDimension(dimension);
|
|
@@ -27,43 +25,44 @@ export class FlowManager {
|
|
|
27
25
|
}
|
|
28
26
|
static removeVoxel(tasks, x, y, z) {
|
|
29
27
|
/* for (const n of $3dCardinalNeighbors) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
28
|
+
const nx = x + n[0];
|
|
29
|
+
const ny = y + n[1];
|
|
30
|
+
const nz = z + n[2];
|
|
31
|
+
if (!this._nDataTool.loadInAt(nx, ny, nz)) continue;
|
|
32
|
+
|
|
33
|
+
const l = this._nDataTool.getLight();
|
|
34
|
+
|
|
35
|
+
if (l <= 0) continue;
|
|
36
|
+
|
|
37
|
+
if (this.lightData.getS(l) > 0) {
|
|
38
|
+
tasks.sun.update.push(nx, ny, nz);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (this.lightData.hasRGBLight(l)) {
|
|
42
|
+
tasks.rgb.update.push(nx, ny, nz);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
this._nDataTool.loadInAt(x, y, z);
|
|
46
|
+
const currentLight = this._nDataTool.getLight();
|
|
47
|
+
this._brush.setXYZ(x, y, z).erase();
|
|
48
|
+
this._nDataTool.clear().loadInAt(x, y, z);
|
|
49
|
+
this._nDataTool.setLight(currentLight).commit();
|
|
50
|
+
tasks.rgb.remove.push(x, y, z);
|
|
51
|
+
RGBRemove(tasks);
|
|
52
|
+
SunUpdate(tasks);
|
|
53
|
+
RGBUpdate(tasks); */
|
|
56
54
|
}
|
|
57
55
|
static getFlowRate(substance) {
|
|
58
|
-
this._substanceTool.setSubstanceFromString(substance);
|
|
59
|
-
return this._substanceTool.getFlowRate();
|
|
56
|
+
// this._substanceTool.setSubstanceFromString(substance);
|
|
57
|
+
// return this._substanceTool.getFlowRate();
|
|
58
|
+
return 0;
|
|
60
59
|
}
|
|
61
60
|
static getVoxel(x, y, z) {
|
|
62
61
|
/* if (!this._sDataTool.loadInAt(x, y, z)) return false;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
if (!this._sDataTool.isRenderable()) return false;
|
|
63
|
+
|
|
64
|
+
const substance = this._sDataTool.getSubstnaceData();
|
|
65
|
+
if (!substance.isLiquid()) return false; */
|
|
67
66
|
return this._sDataTool;
|
|
68
67
|
}
|
|
69
68
|
static setLevel(level, x, y, z) {
|
|
@@ -72,39 +71,39 @@ export class FlowManager {
|
|
|
72
71
|
}
|
|
73
72
|
static getLevel(vox, x, y, z) {
|
|
74
73
|
/* if (!this._nDataTool.loadInAt(x, y, z)) return -2;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
74
|
+
const voxel = this._nDataTool.getStringId();
|
|
75
|
+
if (this._nDataTool.isAir()) {
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
if (voxel == vox) {
|
|
79
|
+
return this._nDataTool.getLevel();
|
|
80
|
+
}
|
|
81
|
+
return -1; */
|
|
83
82
|
}
|
|
84
83
|
static getLevelState(vox, x, y, z) {
|
|
85
84
|
/* if (!this._nDataTool.loadInAt(x, y, z)) return -2;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
85
|
+
const voxel = this._nDataTool.getStringId();
|
|
86
|
+
if (voxel == vox) {
|
|
87
|
+
return this._nDataTool.getLevelState();
|
|
88
|
+
}
|
|
89
|
+
if (this._nDataTool.isAir()) {
|
|
90
|
+
return -1;
|
|
91
|
+
}
|
|
92
|
+
return -3; */
|
|
94
93
|
}
|
|
95
94
|
static canFlowOutwardTest(vox, x, y, z) {
|
|
96
95
|
/* const level = this.getLevel(vox, x, y - 1, z);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
if (level == -1) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
return false; */
|
|
101
100
|
}
|
|
102
101
|
static flowDownTest(vox, x, y, z) {
|
|
103
102
|
/* const level = this.getLevel(vox, x, y - 1, z);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
if (level >= 0) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
return false; */
|
|
108
107
|
}
|
|
109
108
|
static wait(ms) {
|
|
110
109
|
return new Promise((resolve, reject) => setTimeout(resolve, ms));
|
|
@@ -114,29 +113,29 @@ export class FlowManager {
|
|
|
114
113
|
];
|
|
115
114
|
static getAbsorbLight(x, y, z) {
|
|
116
115
|
/* for (const n of $3dCardinalNeighbors) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
}
|
|
116
|
+
if (!n[0] && !n[1] && !n[2]) continue;
|
|
117
|
+
if (!this._nDataTool.loadInAt(x + n[0], y + n[1], z + n[2])) continue;
|
|
118
|
+
let l = this._nDataTool.getLight();
|
|
119
|
+
if (l <= 0) continue;
|
|
120
|
+
const v = this.lightData.getLightValues(l);
|
|
121
|
+
for (let i = 0; i < 4; i++) {
|
|
122
|
+
if (this._lightValues[i] < v[i]) {
|
|
123
|
+
this._lightValues[i] = v[i];
|
|
127
124
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
let brightest = this.lightData.setLightValues(this._lightValues);
|
|
128
|
+
for (let i = 0; i < 4; i++) {
|
|
129
|
+
this._lightValues[i] = 0;
|
|
130
|
+
} */
|
|
132
131
|
// return this.lightData.minusOneForAll(2);
|
|
133
132
|
}
|
|
134
133
|
static sunCheck(tasks, x, y, z) {
|
|
135
134
|
/* if (!this._nDataTool.loadInAt(x, y - 1, z)) return;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
if (!this._nDataTool.isAir()) return;
|
|
136
|
+
const l = this._nDataTool.getLight();
|
|
137
|
+
if (this.lightData.getS(l) == 0xf) {
|
|
138
|
+
tasks.sun.remove.push(x, y - 1, z);
|
|
139
|
+
} */
|
|
141
140
|
}
|
|
142
141
|
}
|