@divinevoxel/vlox 0.0.7 → 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
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BinaryObject } from "@amodx/binary";
|
|
2
|
-
import { Sector } from "../../../World/index";
|
|
3
2
|
const charset = "0123456789ABCDEF";
|
|
4
3
|
function uint16To4CharString(value) {
|
|
5
4
|
if (value < 0 || value > 0xffff) {
|
|
@@ -13,7 +12,6 @@ function uint16To4CharString(value) {
|
|
|
13
12
|
const result = chars.join("").replace(/^0+(?!$)/, "");
|
|
14
13
|
return result;
|
|
15
14
|
}
|
|
16
|
-
let sectorStructInstance;
|
|
17
15
|
const processPalettes = (archiveData) => {
|
|
18
16
|
const allRegistered = new Set();
|
|
19
17
|
for (const sector of archiveData.sectors) {
|
|
@@ -107,7 +105,7 @@ const buildSectorState = (archiveData) => {
|
|
|
107
105
|
const maped = new Map();
|
|
108
106
|
const binaryObjects = new Map();
|
|
109
107
|
let count = 0;
|
|
110
|
-
const sectorStateKeys =
|
|
108
|
+
const sectorStateKeys = [];
|
|
111
109
|
const created = new Map();
|
|
112
110
|
const processSectorState = (sector, sectorStateMap) => {
|
|
113
111
|
if (typeof sector.sectorState == "string")
|
|
@@ -246,9 +244,7 @@ function SectorToArchivedAreaSector(sector) {
|
|
|
246
244
|
};
|
|
247
245
|
}
|
|
248
246
|
export default function CreateArchiveArea(archiveData) {
|
|
249
|
-
|
|
250
|
-
sectorStructInstance = Sector.StateStruct.instantiate();
|
|
251
|
-
const sectorStateKeys = sectorStructInstance.getKeys();
|
|
247
|
+
const sectorStateKeys = [];
|
|
252
248
|
const sectors = [];
|
|
253
249
|
for (const sector of archiveData.sectors) {
|
|
254
250
|
sectors.push(SectorToArchivedAreaSector(sector));
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { StringPalette } from "../../../Util/StringPalette";
|
|
2
2
|
import { NumberPalette } from "../../../Util/NumberPalette";
|
|
3
3
|
import { WorldRegister } from "../../../World/WorldRegister";
|
|
4
|
-
import {
|
|
5
|
-
import { VoxelStruct } from "../../../Voxels/Structs/VoxelStruct";
|
|
6
|
-
import { VoxelStructIds } from "../../../Voxels/Types/Voxel.types";
|
|
7
|
-
import { Section, Sector } from "../../../World/index";
|
|
8
|
-
import { convertToPaletteBuffer } from "../../../Data/Functions/Palettes";
|
|
4
|
+
import { convertToPaletteBuffer } from "../../../Util/Binary/Palettes";
|
|
9
5
|
import { SchemaRegister } from "../../../Voxels/State/SchemaRegister";
|
|
6
|
+
import { VoxelPalettesRegister } from "../../../Voxels/Data/VoxelPalettesRegister";
|
|
7
|
+
import { VoxelTagsRegister } from "../../../Voxels/Data/VoxelTagsRegister";
|
|
10
8
|
const getProcessedSection = (section) => {
|
|
11
9
|
return {
|
|
12
10
|
section,
|
|
@@ -42,8 +40,6 @@ const getProcessedSection = (section) => {
|
|
|
42
40
|
remappedSecondary: false,
|
|
43
41
|
};
|
|
44
42
|
};
|
|
45
|
-
let sectorStructInstance;
|
|
46
|
-
let sectionStructInstance;
|
|
47
43
|
function getSectionPalettes() {
|
|
48
44
|
return {
|
|
49
45
|
ids: new NumberPalette(),
|
|
@@ -69,7 +65,6 @@ function getColumnPalettes() {
|
|
|
69
65
|
};
|
|
70
66
|
}
|
|
71
67
|
function GetArchivedSection(archiveSection, sectorPalettes) {
|
|
72
|
-
sectionStructInstance.setData(archiveSection.section.sectionState);
|
|
73
68
|
const palettes = {};
|
|
74
69
|
if (archiveSection.remappedIds)
|
|
75
70
|
palettes.id = Uint16Array.from(archiveSection.palettes.ids._palette);
|
|
@@ -86,7 +81,7 @@ function GetArchivedSection(archiveSection, sectorPalettes) {
|
|
|
86
81
|
palettes.secondaryState = Uint16Array.from(archiveSection.palettes.secondaryState._palette);
|
|
87
82
|
}
|
|
88
83
|
return {
|
|
89
|
-
state:
|
|
84
|
+
state: {},
|
|
90
85
|
palettes,
|
|
91
86
|
buffers: {
|
|
92
87
|
id: archiveSection.idsAllTheSame
|
|
@@ -136,13 +131,7 @@ export default function ArchiveSector(archiveData) {
|
|
|
136
131
|
const sector = WorldRegister.sectors.get(archiveData.location[0], archiveData.location[1], archiveData.location[2], archiveData.location[3]);
|
|
137
132
|
if (!sector)
|
|
138
133
|
throw new Error(`Column at location ${location} does not exist when trying to arhicve it.`);
|
|
139
|
-
if (!sectorStructInstance)
|
|
140
|
-
sectorStructInstance = Sector.StateStruct.instantiate();
|
|
141
|
-
if (!sectionStructInstance)
|
|
142
|
-
sectionStructInstance = Section.StateStruct.instantiate();
|
|
143
134
|
const sectorPalettes = getColumnPalettes();
|
|
144
|
-
sectorStructInstance.setData(sector.sectorState);
|
|
145
|
-
const sectorState = sectorStructInstance.serialize();
|
|
146
135
|
const processedSections = [];
|
|
147
136
|
for (const section of sector.sections) {
|
|
148
137
|
const length = section.ids.length;
|
|
@@ -154,8 +143,7 @@ export default function ArchiveSector(archiveData) {
|
|
|
154
143
|
let firstSecondary = -1;
|
|
155
144
|
const processedSection = getProcessedSection(section);
|
|
156
145
|
for (let i = 0; i < length; i++) {
|
|
157
|
-
const stringId =
|
|
158
|
-
VoxelStruct.setStringVoxel(stringId);
|
|
146
|
+
const stringId = VoxelPalettesRegister.voxels.getStringId(section.ids[i]);
|
|
159
147
|
const voxelId = !sectorPalettes.ids.isRegistered(stringId)
|
|
160
148
|
? sectorPalettes.ids.register(stringId)
|
|
161
149
|
: sectorPalettes.ids.getNumberId(stringId);
|
|
@@ -163,8 +151,8 @@ export default function ArchiveSector(archiveData) {
|
|
|
163
151
|
processedSection.palettes.ids.register(voxelId);
|
|
164
152
|
if (firstId == -1)
|
|
165
153
|
firstId = voxelId;
|
|
166
|
-
const secondaryId =
|
|
167
|
-
|
|
154
|
+
const secondaryId = VoxelTagsRegister.VoxelTags[section.ids[i]]["dve_can_have_secondary"] &&
|
|
155
|
+
VoxelPalettesRegister.voxels.getStringId(section.secondary[i]);
|
|
168
156
|
const voxelSecondary = secondaryId
|
|
169
157
|
? !sectorPalettes.secondaryId.isRegistered(secondaryId)
|
|
170
158
|
? sectorPalettes.secondaryId.register(secondaryId)
|
|
@@ -283,7 +271,6 @@ export default function ArchiveSector(archiveData) {
|
|
|
283
271
|
continue;
|
|
284
272
|
const length = section.section.ids.length;
|
|
285
273
|
for (let i = 0; i < length; i++) {
|
|
286
|
-
VoxelStruct.setVoxel(section.ids[i]);
|
|
287
274
|
if (reMapIds)
|
|
288
275
|
section.ids[i] = section.palettes.ids.getId(section.ids[i]);
|
|
289
276
|
if (reMapLight)
|
|
@@ -295,16 +282,15 @@ export default function ArchiveSector(archiveData) {
|
|
|
295
282
|
if (reMapMod)
|
|
296
283
|
section.mod[i] = section.palettes.mod.getId(sectorPalettes.mod.getId(section.section.mod[i]));
|
|
297
284
|
if (reMapSecondary)
|
|
298
|
-
section.secondary[i] =
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
: section.palettes.secondaryState.getId(section.secondary[i]);
|
|
285
|
+
section.secondary[i] = VoxelTagsRegister.VoxelTags[section.ids[i]]["dve_can_have_secondary"]
|
|
286
|
+
? section.palettes.secondaryId.getId(section.secondary[i])
|
|
287
|
+
: section.palettes.secondaryState.getId(section.secondary[i]);
|
|
302
288
|
}
|
|
303
289
|
}
|
|
304
290
|
const stateMap = {};
|
|
305
291
|
for (let i = 0; i < sectorPalettes.state._palette.length; i++) {
|
|
306
292
|
const state = sectorPalettes.state._palette[i];
|
|
307
|
-
const voxelId =
|
|
293
|
+
const voxelId = VoxelPalettesRegister.voxels.getStringId(sectorPalettes.stateIdMap[i]);
|
|
308
294
|
if (!SchemaRegister.hasVoxelSchema(voxelId))
|
|
309
295
|
continue;
|
|
310
296
|
const schema = SchemaRegister.getVoxelSchemas(voxelId);
|
|
@@ -313,7 +299,7 @@ export default function ArchiveSector(archiveData) {
|
|
|
313
299
|
const modMap = {};
|
|
314
300
|
for (let i = 0; i < sectorPalettes.mod._palette.length; i++) {
|
|
315
301
|
const mod = sectorPalettes.mod._palette[i];
|
|
316
|
-
const voxelId =
|
|
302
|
+
const voxelId = VoxelPalettesRegister.voxels.getStringId(sectorPalettes.modIdMap[i]);
|
|
317
303
|
if (!SchemaRegister.hasVoxelSchema(voxelId))
|
|
318
304
|
continue;
|
|
319
305
|
const schema = SchemaRegister.getVoxelSchemas(voxelId);
|
|
@@ -343,10 +329,10 @@ export default function ArchiveSector(archiveData) {
|
|
|
343
329
|
return {
|
|
344
330
|
version: "",
|
|
345
331
|
location: [...archiveData.location],
|
|
346
|
-
sectorState,
|
|
332
|
+
sectorState: {},
|
|
347
333
|
buffers: {},
|
|
348
334
|
keys: {
|
|
349
|
-
sectionState: [
|
|
335
|
+
sectionState: [],
|
|
350
336
|
},
|
|
351
337
|
palettes,
|
|
352
338
|
sections,
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Section, Sector } from "../../index";
|
|
3
|
-
import { VoxelStruct } from "../../../Voxels/Structs/VoxelStruct";
|
|
4
|
-
import { VoxelStructIds } from "../../../Voxels/Types/Voxel.types";
|
|
1
|
+
import { Sector } from "../../index";
|
|
5
2
|
import { NumberPalette } from "../../../Util/NumberPalette";
|
|
6
3
|
import { StringPalette } from "../../../Util/StringPalette";
|
|
7
|
-
import { getPaletteArray } from "../../../
|
|
4
|
+
import { getPaletteArray } from "../../../Util/Binary/Palettes";
|
|
8
5
|
import { SchemaRegister } from "../../../Voxels/State/SchemaRegister";
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
import { VoxelPalettesRegister } from "../../../Voxels/Data/VoxelPalettesRegister";
|
|
7
|
+
import { VoxelTagsRegister } from "../../../Voxels/Data/VoxelTagsRegister";
|
|
11
8
|
const updateSectionBuffers = (sector, section) => {
|
|
12
9
|
if ((sector.palettes.id.length <= 15 ||
|
|
13
10
|
(section.palettes.id && section.palettes.id.length <= 15)) &&
|
|
@@ -33,7 +30,8 @@ const updateSectionBuffers = (sector, section) => {
|
|
|
33
30
|
section.palettes.secondaryState.length <= 15) ||
|
|
34
31
|
(sector.palettes.secondaryState &&
|
|
35
32
|
sector.palettes.secondaryState.length <= 15)) &&
|
|
36
|
-
((section.palettes.secondaryId &&
|
|
33
|
+
((section.palettes.secondaryId &&
|
|
34
|
+
section.palettes.secondaryId.length <= 15) ||
|
|
37
35
|
(sector.palettes.secondaryId &&
|
|
38
36
|
sector.palettes.secondaryId.length <= 15)) &&
|
|
39
37
|
ArrayBuffer.isView(section.buffers.secondary)) {
|
|
@@ -88,12 +86,12 @@ const getId = (value, importedColumn, importedSection) => {
|
|
|
88
86
|
if (importedSection.section.buffers.state instanceof Uint16Array)
|
|
89
87
|
return value;
|
|
90
88
|
if (typeof importedSection.section.buffers.id == "number") {
|
|
91
|
-
return
|
|
89
|
+
return VoxelPalettesRegister.voxels.getNumberId(importedColumn.sector.palettes.id[importedSection.section.buffers.id]);
|
|
92
90
|
}
|
|
93
91
|
if (importedSection.idPalette) {
|
|
94
|
-
return
|
|
92
|
+
return VoxelPalettesRegister.voxels.getNumberId(importedColumn.idPalette.getStringId(importedSection.idPalette.getValue(value)));
|
|
95
93
|
}
|
|
96
|
-
return
|
|
94
|
+
return VoxelPalettesRegister.voxels.getNumberId(importedColumn.idPalette.getStringId(value));
|
|
97
95
|
};
|
|
98
96
|
const getLight = (value, importedColumn, importedSection) => {
|
|
99
97
|
if (importedSection.section.buffers.light instanceof Uint16Array)
|
|
@@ -110,7 +108,7 @@ const getLight = (value, importedColumn, importedSection) => {
|
|
|
110
108
|
return value;
|
|
111
109
|
};
|
|
112
110
|
const getState = (voxelId, value, processedState, importedColumn, importedSection) => {
|
|
113
|
-
const voxelStringId =
|
|
111
|
+
const voxelStringId = VoxelPalettesRegister.voxels.getStringId(voxelId);
|
|
114
112
|
if (!SchemaRegister.hasVoxelSchema(voxelStringId))
|
|
115
113
|
return value;
|
|
116
114
|
let stateId = -1;
|
|
@@ -131,7 +129,7 @@ const getState = (voxelId, value, processedState, importedColumn, importedSectio
|
|
|
131
129
|
return value;
|
|
132
130
|
};
|
|
133
131
|
const getMod = (voxelId, value, processedMod, importedColumn, importedSection) => {
|
|
134
|
-
const voxelStringId =
|
|
132
|
+
const voxelStringId = VoxelPalettesRegister.voxels.getStringId(voxelId);
|
|
135
133
|
if (!SchemaRegister.hasVoxelSchema(voxelStringId))
|
|
136
134
|
return value;
|
|
137
135
|
let modId = -1;
|
|
@@ -152,15 +150,14 @@ const getMod = (voxelId, value, processedMod, importedColumn, importedSection) =
|
|
|
152
150
|
return value;
|
|
153
151
|
};
|
|
154
152
|
const getSecondary = (voxelId, value, importedColumn, importedSection) => {
|
|
155
|
-
|
|
156
|
-
if (VoxelStruct.instance[VoxelStructIds.canHaveSecondary] == 1) {
|
|
153
|
+
if (VoxelTagsRegister.VoxelTags[voxelId]["dve_can_have_secondary"]) {
|
|
157
154
|
if (typeof importedSection.section.buffers.secondary == "number") {
|
|
158
|
-
return
|
|
155
|
+
return VoxelPalettesRegister.voxels.getNumberId(importedColumn.sector.palettes.secondaryId[importedSection.section.buffers.secondary]);
|
|
159
156
|
}
|
|
160
157
|
if (importedSection.secondaryId) {
|
|
161
|
-
return
|
|
158
|
+
return VoxelPalettesRegister.voxels.getNumberId(importedColumn.secondaryId.getStringId(importedSection.secondaryId.getValue(value)));
|
|
162
159
|
}
|
|
163
|
-
return
|
|
160
|
+
return VoxelPalettesRegister.voxels.getNumberId(importedColumn.sector.palettes.secondaryId[value]);
|
|
164
161
|
}
|
|
165
162
|
if (typeof importedSection.section.buffers.secondary == "number") {
|
|
166
163
|
return value;
|
|
@@ -174,17 +171,12 @@ const getSecondary = (voxelId, value, importedColumn, importedSection) => {
|
|
|
174
171
|
return value;
|
|
175
172
|
};
|
|
176
173
|
export default function ImportSector(sector, archiveData) {
|
|
177
|
-
if (!sectorStructInstance)
|
|
178
|
-
sectorStructInstance = Sector.StateStruct.instantiate();
|
|
179
|
-
if (!sectionStructInstance)
|
|
180
|
-
sectionStructInstance = Section.StateStruct.instantiate();
|
|
181
174
|
const newSector = new Sector(Sector.CreateNew());
|
|
182
175
|
newSector.position[0] = sector.location[1];
|
|
183
176
|
newSector.position[1] = sector.location[2];
|
|
184
177
|
newSector.position[2] = sector.location[3];
|
|
185
178
|
if (!archiveData.loadColumnState) {
|
|
186
|
-
sectorStructInstance.
|
|
187
|
-
sectorStructInstance.deserialize(sector.sectorState);
|
|
179
|
+
//sectorStructInstance.deserialize(sector.sectorState);
|
|
188
180
|
}
|
|
189
181
|
else {
|
|
190
182
|
archiveData.loadColumnState(sector.sectorState, newSector);
|
|
@@ -201,13 +193,16 @@ export default function ImportSector(sector, archiveData) {
|
|
|
201
193
|
sectionState[sector.keys.sectionState[i]] = section.state[i];
|
|
202
194
|
}
|
|
203
195
|
updateSectionBuffers(sector, section);
|
|
204
|
-
if (!archiveData.loadSectionState) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
196
|
+
/* if (!archiveData.loadSectionState) {
|
|
197
|
+
sectionStructInstance.setData(newSection.sectionState);
|
|
198
|
+
sectionStructInstance.deserialize(sectionState);
|
|
199
|
+
} else {
|
|
200
|
+
archiveData.loadSectionState(
|
|
201
|
+
sector.keys.sectionState,
|
|
202
|
+
section.state,
|
|
203
|
+
newSection
|
|
204
|
+
);
|
|
205
|
+
} */
|
|
211
206
|
for (let i = 0; i < newSection.ids.length; i++) {
|
|
212
207
|
newSection.ids[i] = getId(typeof section.buffers.id == "number"
|
|
213
208
|
? section.buffers.id
|
|
@@ -218,9 +213,7 @@ export default function ImportSector(sector, archiveData) {
|
|
|
218
213
|
newSection.secondary[i] = getSecondary(newSection.ids[i], typeof section.buffers.secondary == "number"
|
|
219
214
|
? section.buffers.secondary
|
|
220
215
|
: section.buffers.secondary[i], importedSector, importedSection);
|
|
221
|
-
|
|
222
|
-
let secondary = VoxelStruct.instance[VoxelStructIds.canHaveSecondary] &&
|
|
223
|
-
newSection.secondary[i] > 0;
|
|
216
|
+
let secondary = VoxelTagsRegister.VoxelTags[newSection.ids[i]]["dve_can_have_secondary"] && newSection.secondary[i] > 0;
|
|
224
217
|
newSection.state[i] = getState(secondary ? newSection.secondary[i] : newSection.ids[i], typeof section.buffers.state == "number"
|
|
225
218
|
? section.buffers.state
|
|
226
219
|
: section.buffers.state[i], processedState, importedSector, importedSection);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WorldVoxelCursor } from "./WorldVoxelCursor";
|
|
2
2
|
import { Vector3Like } from "@amodx/math";
|
|
3
|
-
import { DataCursorInterface } from "../../
|
|
3
|
+
import { DataCursorInterface } from "../../Tools/DataCursor.interface";
|
|
4
4
|
import { WorldSectionCursorInterface } from "./WorldSectionCursor.interface";
|
|
5
5
|
import type { Section } from "../Section/index";
|
|
6
6
|
export declare class SectionCursor extends DataCursorInterface implements WorldSectionCursorInterface {
|
|
@@ -12,5 +12,6 @@ export declare class SectionCursor extends DataCursorInterface implements WorldS
|
|
|
12
12
|
inBounds(x: number, y: number, z: number): boolean;
|
|
13
13
|
setSection(section: Section): boolean;
|
|
14
14
|
setSection(dimension: string, x: number, y: number, z: number): boolean;
|
|
15
|
+
getVoxelAtIndex(index: number): WorldVoxelCursor;
|
|
15
16
|
getVoxel(x: number, y: number, z: number): WorldVoxelCursor | null;
|
|
16
17
|
}
|
|
@@ -2,7 +2,7 @@ import { WorldRegister } from "../WorldRegister";
|
|
|
2
2
|
import { WorldVoxelCursor } from "./WorldVoxelCursor";
|
|
3
3
|
import { WorldSpaces } from "../WorldSpaces";
|
|
4
4
|
import { Vector3Like } from "@amodx/math";
|
|
5
|
-
import { DataCursorInterface } from "../../
|
|
5
|
+
import { DataCursorInterface } from "../../Tools/DataCursor.interface";
|
|
6
6
|
export class SectionCursor extends DataCursorInterface {
|
|
7
7
|
_section;
|
|
8
8
|
voxel = new WorldVoxelCursor(this);
|
|
@@ -46,11 +46,17 @@ export class SectionCursor extends DataCursorInterface {
|
|
|
46
46
|
this._sectionPosition.z = sectionPos[2];
|
|
47
47
|
return true;
|
|
48
48
|
}
|
|
49
|
+
getVoxelAtIndex(index) {
|
|
50
|
+
this._voxelIndex = index;
|
|
51
|
+
WorldSpaces.voxel.getPositionFromIndex(index, this._voxelPosition);
|
|
52
|
+
this.voxel.loadIn();
|
|
53
|
+
return this.voxel;
|
|
54
|
+
}
|
|
49
55
|
getVoxel(x, y, z) {
|
|
50
56
|
if (!this._section)
|
|
51
57
|
return null;
|
|
52
|
-
this._voxelIndex = WorldSpaces.voxel.getIndex(x, y, z);
|
|
53
58
|
WorldSpaces.voxel.getPosition(x, y, z, this._voxelPosition);
|
|
59
|
+
this._voxelIndex = WorldSpaces.voxel.getIndexFromPosition(this._voxelPosition.x, this._voxelPosition.y, this._voxelPosition.z);
|
|
54
60
|
this.voxel.loadIn();
|
|
55
61
|
return this.voxel;
|
|
56
62
|
}
|
|
@@ -2,7 +2,7 @@ import type { Section } from "../Section/index";
|
|
|
2
2
|
import type { Sector } from "../Sector/index";
|
|
3
3
|
import { WorldVoxelCursor } from "./WorldVoxelCursor";
|
|
4
4
|
import { Vector3Like } from "@amodx/math";
|
|
5
|
-
import { DataCursorInterface } from "../../
|
|
5
|
+
import { DataCursorInterface } from "../../Tools/DataCursor.interface";
|
|
6
6
|
import { WorldSectionCursorInterface } from "./WorldSectionCursor.interface";
|
|
7
7
|
export declare class SectorCursor extends DataCursorInterface implements WorldSectionCursorInterface {
|
|
8
8
|
_current: Sector | null;
|
|
@@ -15,4 +15,5 @@ export declare class SectorCursor extends DataCursorInterface implements WorldSe
|
|
|
15
15
|
setSector(dimension: string, x: number, y: number, z: number): boolean;
|
|
16
16
|
getSection(x: number, y: number, z: number): Section | null;
|
|
17
17
|
getVoxel(x: number, y: number, z: number): WorldVoxelCursor | null;
|
|
18
|
+
getVoxelAtIndex(index: number): void;
|
|
18
19
|
}
|
|
@@ -2,7 +2,7 @@ import { WorldRegister } from "../WorldRegister";
|
|
|
2
2
|
import { WorldVoxelCursor } from "./WorldVoxelCursor";
|
|
3
3
|
import { WorldSpaces } from "../WorldSpaces";
|
|
4
4
|
import { Vector3Like } from "@amodx/math";
|
|
5
|
-
import { DataCursorInterface } from "../../
|
|
5
|
+
import { DataCursorInterface } from "../../Tools/DataCursor.interface";
|
|
6
6
|
export class SectorCursor extends DataCursorInterface {
|
|
7
7
|
_current = null;
|
|
8
8
|
_section;
|
|
@@ -55,9 +55,12 @@ export class SectorCursor extends DataCursorInterface {
|
|
|
55
55
|
return null;
|
|
56
56
|
const section = this.getSection(x, y, z);
|
|
57
57
|
this._section = section;
|
|
58
|
-
this._voxelIndex = WorldSpaces.voxel.getIndex(x, y, z);
|
|
59
58
|
WorldSpaces.voxel.getPosition(x, y, z, this._voxelPosition);
|
|
59
|
+
this._voxelIndex = WorldSpaces.voxel.getIndexFromPosition(this._voxelPosition.x, this._voxelPosition.y, this._voxelPosition.z);
|
|
60
60
|
this.voxel.loadIn();
|
|
61
61
|
return this.voxel;
|
|
62
62
|
}
|
|
63
|
+
getVoxelAtIndex(index) {
|
|
64
|
+
this._voxelIndex = index;
|
|
65
|
+
}
|
|
63
66
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Vector3Like } from "@amodx/math";
|
|
2
2
|
import { SectorCursor } from "./SectorCursor";
|
|
3
|
-
import { DataCursorInterface } from "../../
|
|
3
|
+
import { DataCursorInterface } from "../../Tools/DataCursor.interface";
|
|
4
4
|
export declare class WorldCursor extends DataCursorInterface {
|
|
5
5
|
sectorCursors: Map<number, Map<number, SectorCursor>>;
|
|
6
6
|
origin: Vector3Like;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Vector3Like } from "@amodx/math";
|
|
2
2
|
import { SectorCursor } from "./SectorCursor";
|
|
3
3
|
import { WorldSpaces } from "../WorldSpaces";
|
|
4
|
-
import { DataCursorInterface } from "../../
|
|
4
|
+
import { DataCursorInterface } from "../../Tools/DataCursor.interface";
|
|
5
5
|
let cursorCache = [];
|
|
6
6
|
const tempPosition = Vector3Like.Create();
|
|
7
7
|
export class WorldCursor extends DataCursorInterface {
|
|
@@ -25,6 +25,8 @@ export class WorldCursor extends DataCursorInterface {
|
|
|
25
25
|
return WorldSpaces.world.inBounds(x, y, z);
|
|
26
26
|
}
|
|
27
27
|
getSector(x, y, z) {
|
|
28
|
+
if (!this.inBounds(x, y, z))
|
|
29
|
+
return null;
|
|
28
30
|
const sectorPos = WorldSpaces.sector.getPosition(x, y, z, tempPosition);
|
|
29
31
|
const cx = sectorPos.x / WorldSpaces.sector.bounds.x - this.origin.x;
|
|
30
32
|
const cz = sectorPos.z / WorldSpaces.sector.bounds.z - this.origin.z;
|
|
@@ -32,8 +34,10 @@ export class WorldCursor extends DataCursorInterface {
|
|
|
32
34
|
let cursor = row?.get(cz);
|
|
33
35
|
if (!cursor) {
|
|
34
36
|
cursor = cursorCache.length ? cursorCache.shift() : new SectorCursor();
|
|
35
|
-
if (!cursor.setSector(this.dimension, sectorPos.x, sectorPos.y, sectorPos.z))
|
|
37
|
+
if (!cursor.setSector(this.dimension, sectorPos.x, sectorPos.y, sectorPos.z)) {
|
|
38
|
+
cursorCache.push(cursor);
|
|
36
39
|
return null;
|
|
40
|
+
}
|
|
37
41
|
if (!row) {
|
|
38
42
|
row = new Map();
|
|
39
43
|
this.sectorCursors.set(cx, row);
|
|
@@ -3,17 +3,17 @@ import { WorldSectionCursorInterface } from "./WorldSectionCursor.interface";
|
|
|
3
3
|
export declare class WorldVoxelCursor extends VoxelCursorInterface {
|
|
4
4
|
dataCursor: WorldSectionCursorInterface;
|
|
5
5
|
private _section;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
ids: Uint16Array;
|
|
7
|
+
light: Uint16Array;
|
|
8
|
+
level: Uint8Array;
|
|
9
|
+
state: Uint16Array;
|
|
10
|
+
mod: Uint16Array;
|
|
11
|
+
secondary: Uint16Array;
|
|
12
12
|
constructor(dataCursor: WorldSectionCursorInterface);
|
|
13
13
|
loadIn(): void;
|
|
14
14
|
/**
|
|
15
15
|
*
|
|
16
16
|
* @param mode 0 for add 1 for remove
|
|
17
17
|
*/
|
|
18
|
-
updateVoxel(mode: 0 | 1): boolean;
|
|
18
|
+
updateVoxel(mode: 0 | 1 | 2): boolean;
|
|
19
19
|
}
|
|
@@ -1,27 +1,13 @@
|
|
|
1
|
-
import { Section } from "../Section/index";
|
|
2
|
-
import { SectionStructProperties } from "../Section/SectionStructProperties";
|
|
3
1
|
import { VoxelCursorInterface } from "../../Voxels/Cursor/VoxelCursor.interface";
|
|
4
2
|
export class WorldVoxelCursor extends VoxelCursorInterface {
|
|
5
3
|
dataCursor;
|
|
6
4
|
_section;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
get level() {
|
|
14
|
-
return this._section.level;
|
|
15
|
-
}
|
|
16
|
-
get state() {
|
|
17
|
-
return this._section.state;
|
|
18
|
-
}
|
|
19
|
-
get secondary() {
|
|
20
|
-
return this._section.secondary;
|
|
21
|
-
}
|
|
22
|
-
get mod() {
|
|
23
|
-
return this._section.mod;
|
|
24
|
-
}
|
|
5
|
+
ids;
|
|
6
|
+
light;
|
|
7
|
+
level;
|
|
8
|
+
state;
|
|
9
|
+
mod;
|
|
10
|
+
secondary;
|
|
25
11
|
constructor(dataCursor) {
|
|
26
12
|
super();
|
|
27
13
|
this.dataCursor = dataCursor;
|
|
@@ -30,6 +16,12 @@ export class WorldVoxelCursor extends VoxelCursorInterface {
|
|
|
30
16
|
if (!this.dataCursor._section)
|
|
31
17
|
return;
|
|
32
18
|
this._section = this.dataCursor._section;
|
|
19
|
+
this.ids = this._section.ids;
|
|
20
|
+
this.light = this._section.light;
|
|
21
|
+
this.level = this._section.level;
|
|
22
|
+
this.state = this._section.state;
|
|
23
|
+
this.mod = this._section.mod;
|
|
24
|
+
this.secondary = this._section.secondary;
|
|
33
25
|
this._index = this.dataCursor._voxelIndex;
|
|
34
26
|
this.process();
|
|
35
27
|
}
|
|
@@ -38,17 +30,21 @@ export class WorldVoxelCursor extends VoxelCursorInterface {
|
|
|
38
30
|
* @param mode 0 for add 1 for remove
|
|
39
31
|
*/
|
|
40
32
|
updateVoxel(mode) {
|
|
41
|
-
Section.StateStruct.setData(this._section.sectionState);
|
|
42
33
|
const voxelPos = this.dataCursor._voxelPosition;
|
|
43
34
|
if (mode == 0) {
|
|
44
|
-
|
|
35
|
+
this.dataCursor._section?.setBuried(this.dataCursor._voxelIndex, false);
|
|
36
|
+
this.dataCursor._section?.setHasVoxel(voxelPos.y, true);
|
|
45
37
|
return true;
|
|
46
38
|
}
|
|
47
39
|
if (mode == 1) {
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
this.dataCursor._section?.setBuried(this.dataCursor._voxelIndex, false);
|
|
41
|
+
this.dataCursor._section?.setHasVoxelDirty(voxelPos.y, true);
|
|
42
|
+
this.dataCursor._section?.setHasVoxel(voxelPos.y, false);
|
|
50
43
|
return true;
|
|
51
44
|
}
|
|
45
|
+
if (mode == 2) {
|
|
46
|
+
this.dataCursor._section?.setBuried(this.dataCursor._voxelIndex, false);
|
|
47
|
+
}
|
|
52
48
|
return false;
|
|
53
49
|
}
|
|
54
50
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { RemoteBinaryStruct } from "@amodx/binary/";
|
|
2
1
|
import { Sector } from "../Sector/Sector.js";
|
|
3
2
|
import { Vec3Array } from "@amodx/math";
|
|
4
3
|
export interface VoxelDataArrays {
|
|
@@ -17,18 +16,31 @@ export interface VoxelDataArrays {
|
|
|
17
16
|
*/
|
|
18
17
|
secondary: Uint16Array;
|
|
19
18
|
}
|
|
20
|
-
export interface
|
|
19
|
+
export interface SectionData extends VoxelDataArrays {
|
|
20
|
+
/**Y slice of the section to tell if there is voxels or not. Used for height maps. */
|
|
21
|
+
voxelMap: Uint8Array;
|
|
22
|
+
/**Y slice of the section to tell if the slice is dirty and voxelMap needs to be re-checked. */
|
|
23
|
+
dirtyMap: Uint8Array;
|
|
24
|
+
/**A bit array used to cache if a voxel is exposed or not. */
|
|
25
|
+
buried: Uint8Array;
|
|
26
|
+
}
|
|
27
|
+
export interface Section extends SectionData {
|
|
21
28
|
}
|
|
22
29
|
export declare class Section {
|
|
23
30
|
sector: Sector;
|
|
24
31
|
index: number;
|
|
25
32
|
static GetBufferSize(): number;
|
|
26
33
|
static GetArrayStartIndex(index: number): number;
|
|
27
|
-
static CreateNew(index: number, sectorBuffer: ArrayBufferLike):
|
|
28
|
-
static toObject(sector: Sector, index: number, data:
|
|
29
|
-
|
|
30
|
-
sectionState: DataView;
|
|
31
|
-
constructor(sector: Sector, index: number, data: VoxelDataArrays);
|
|
34
|
+
static CreateNew(index: number, sectorBuffer: ArrayBufferLike): SectionData;
|
|
35
|
+
static toObject(sector: Sector, index: number, data: SectionData): Section;
|
|
36
|
+
constructor(sector: Sector, index: number, data: SectionData);
|
|
32
37
|
getPosition(): Readonly<Vec3Array>;
|
|
33
|
-
|
|
38
|
+
getBuried(index: number): boolean;
|
|
39
|
+
setBuried(index: number, value: boolean): void;
|
|
40
|
+
setHasVoxel(y: number, hasVoxel: boolean): void;
|
|
41
|
+
getHasVoxel(y: number): boolean;
|
|
42
|
+
setHasVoxelDirty(y: number, dirty: boolean): void;
|
|
43
|
+
getHasVoxelDirty(y: number): boolean;
|
|
44
|
+
getMinMax(): number[];
|
|
45
|
+
toJSON(): SectionData;
|
|
34
46
|
}
|