@divinevoxel/vlox 0.0.71 → 0.0.73
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/Contexts/Render/DivineVoxelEngineRender.d.ts +1 -1
- package/Contexts/World/DivineVoxelEngineWorld.d.ts +1 -1
- package/Init/StartConstructor.js +7 -7
- package/Init/StartWorld.d.ts +1 -1
- 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 +2 -2
- package/Mesher/Functions/CompactVoxelMesh.js +4 -5
- package/Mesher/Functions/MeshSection.d.ts +1 -1
- package/Mesher/Functions/MeshSection.js +72 -66
- package/Mesher/Functions/MeshTexture.d.ts +1 -1
- package/Mesher/Functions/MeshTexture.js +3 -4
- package/Mesher/Functions/MeshVoxel.js +20 -26
- package/Mesher/Geomtry/Primitives/QuadVertexData.d.ts +12 -10
- package/Mesher/Geomtry/Primitives/QuadVertexData.js +49 -56
- package/Mesher/Geomtry/VoxelGeometryBuilder.d.ts +2 -2
- package/Mesher/Geomtry/VoxelGeometryBuilder.js +108 -125
- package/Mesher/Geomtry/VoxelMesh.d.ts +1 -1
- package/Mesher/Geomtry/VoxelMesh.js +2 -2
- package/Mesher/{Tools → Geomtry}/VoxelMeshBVHBuilder.d.ts +2 -9
- package/Mesher/{Tools → Geomtry}/VoxelMeshBVHBuilder.js +4 -16
- package/Mesher/Geomtry/{Buffers.d.ts → VoxelMeshBuffers.d.ts} +9 -8
- package/Mesher/Geomtry/VoxelMeshBuffers.js +49 -0
- package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.d.ts +10 -0
- package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.js +10 -0
- package/Mesher/Geomtry/index.d.ts +0 -1
- package/Mesher/Geomtry/index.js +0 -1
- package/Mesher/InitMesher.js +2 -11
- package/Mesher/InitTask.js +10 -22
- 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 +2 -8
- package/Mesher/Models/Common/Calc/FaceDataCalc.js +50 -52
- package/Mesher/Models/Nodes/Custom/Liquid/FlowGradient.d.ts +2 -2
- package/Mesher/Models/Nodes/Custom/Liquid/FlowGradient.js +1 -1
- package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.d.ts +1 -5
- package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +40 -42
- package/Mesher/Models/Nodes/GeometryNode.d.ts +3 -5
- package/Mesher/Models/Nodes/GeometryNode.js +1 -2
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.d.ts +3 -6
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +55 -40
- 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/{Tools → Models/Protocols}/OutlinedVoxelTool.d.ts +1 -1
- package/Mesher/{Tools → Models/Protocols}/OutlinedVoxelTool.js +1 -1
- package/Mesher/Models/RenderedMaterials.d.ts +6 -0
- package/Mesher/{RenderedMaterials.js → Models/RenderedMaterials.js} +2 -2
- package/Mesher/Models/VoxelConstructor.d.ts +4 -5
- package/Mesher/Models/VoxelConstructor.js +23 -12
- package/Mesher/Models/{VoxelGeometryLookUp.d.ts → VoxelGeometryBuilderCacheSpace.d.ts} +6 -14
- package/Mesher/Models/{VoxelGeometryLookUp.js → VoxelGeometryBuilderCacheSpace.js} +26 -44
- package/Mesher/{Tools/VoxelMesherDataTool.d.ts → Models/VoxelModelBuilder.d.ts} +10 -8
- package/Mesher/{Tools/VoxelMesherDataTool.js → Models/VoxelModelBuilder.js} +44 -19
- package/Mesher/Models/VoxelModelConstructorRegister.js +3 -3
- package/Models/Defaults/CubeVoxelGeometry.js +4 -0
- package/Models/Defaults/CubeVoxelModels.js +344 -344
- package/Models/Defaults/LiquidVoxelModel.js +2 -2
- package/Models/Defaults/PanelVoxelModels.js +432 -432
- package/Models/Defaults/StairVoxelModel.js +576 -576
- package/Models/Examples.js +469 -456
- 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/BuildFinalInputs.js +9 -7
- package/Models/Rules/Functions/BuildGeomtryInputs.js +8 -5
- package/Models/Rules/Functions/BuildRules.js +4 -4
- package/Models/Rules/{VoxelModelManager.d.ts → VoxelModelRuleBuilderRegister.d.ts} +1 -1
- package/Models/Rules/VoxelModelRuleBuilderRegister.js +178 -0
- package/Models/VoxelModel.types.d.ts +14 -5
- package/Renderer/Classes/SectorMesh.d.ts +3 -4
- package/Renderer/Classes/SectorMesh.js +6 -11
- package/Renderer/InitTasks.js +6 -7
- package/Renderer/MeshManager.js +2 -2
- package/Renderer/MeshRegister.js +2 -1
- package/Settings/EngineSettings.d.ts +1 -1
- package/Settings/EngineSettings.js +3 -5
- package/Settings/EngineSettings.types.d.ts +17 -18
- package/Settings/EngineSettings.types.js +16 -15
- package/Tasks/IWG/IWG.d.ts +2 -1
- package/Tasks/IWG/IWG.js +9 -3
- package/Tasks/IWG/Internal/Classes/BuildQueue.d.ts +11 -0
- package/Tasks/IWG/Internal/Classes/BuildQueue.js +49 -0
- package/Tasks/IWG/Internal/Classes/Generator.d.ts +6 -1
- package/Tasks/IWG/Internal/Classes/Generator.js +14 -2
- package/Tasks/IWG/Internal/Classes/IWGTaskBase.js +2 -2
- package/Tasks/IWG/Internal/Functions/getSectorState.js +4 -7
- package/Tasks/IWG/Internal/Functions/runBuildUpdate.js +21 -2
- package/Tasks/IWG/Internal/Functions/runWorldUpdate.js +5 -6
- package/Tasks/IWG/Internal/IWGTasks.d.ts +0 -4
- package/Tasks/IWG/Internal/IWGTasks.js +12 -31
- package/Tasks/IWG/Internal/IWGTools.d.ts +1 -1
- package/Tasks/IWG/Procedures/SaveAllSectors.js +2 -0
- 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/UpdateTask.d.ts +3 -1
- package/Tasks/Update/UpdateTask.js +28 -2
- package/Tasks/Update/VoxelUpdate.js +21 -7
- package/Tasks/WorldGeneration/WorldGenBrush.js +2 -1
- package/Templates/Cursor/TemplateCursor.d.ts +2 -2
- package/Templates/Cursor/TemplateCursor.js +1 -2
- package/Templates/Functions/CreateTemplate.js +1 -1
- package/Templates/VoxelTemplate.js +6 -8
- package/Templates/VoxelTemplates.types.d.ts +1 -1
- package/Textures/Classes/CompiledTexture.d.ts +18 -0
- package/Textures/Classes/CompiledTexture.js +50 -0
- package/Textures/Classes/CompiledTextureAnimation.d.ts +12 -0
- package/Textures/Classes/CompiledTextureAnimation.js +27 -0
- package/Textures/Classes/TextureAnimationTexture.d.ts +10 -0
- package/Textures/Classes/TextureAnimationTexture.js +32 -0
- package/Textures/Functions/BuildTextureData.d.ts +10 -0
- package/Textures/Functions/BuildTextureData.js +205 -0
- package/Textures/Texture.types.d.ts +50 -64
- package/Textures/TextureManager.d.ts +8 -19
- package/Textures/TextureManager.js +28 -166
- package/Tools/Brush/Brush.d.ts +1 -3
- package/Tools/Brush/Brush.js +43 -12
- package/Util/Binary/BinaryArrays.d.ts +6 -0
- package/Util/Binary/BinaryArrays.js +25 -0
- package/Util/Binary/BinaryBuffer.d.ts +29 -0
- package/Util/Binary/BinaryBuffer.js +130 -0
- package/Util/Binary/BinaryFunctions.d.ts +3 -0
- package/Util/Binary/BinaryFunctions.js +11 -0
- package/Util/StringPalette.d.ts +1 -0
- package/Util/StringPalette.js +8 -0
- package/Voxels/Cursor/DataCursor.interface.d.ts +5 -0
- package/Voxels/Cursor/VoxelCursor.d.ts +6 -6
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +11 -16
- package/Voxels/Cursor/VoxelCursor.interface.js +35 -58
- 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 +8 -0
- package/Voxels/Data/VoxelPalettesRegister.js +8 -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 +12 -12
- package/Voxels/Functions/BuildTagAndPaletteData.d.ts +13 -0
- package/Voxels/Functions/BuildTagAndPaletteData.js +55 -0
- package/Voxels/Indexes/VoxelIndex.js +3 -3
- package/Voxels/InitVoxelData.js +31 -73
- package/Voxels/State/Schema/StateSchema.d.ts +1 -1
- package/Voxels/Types/Voxel.types.d.ts +20 -42
- package/Voxels/Types/Voxel.types.js +6 -17
- 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/Archive.types.d.ts +38 -34
- package/World/Archive/Functions/ArchiveArea.js +18 -30
- package/World/Archive/Functions/ArchiveSector.js +484 -213
- package/World/Archive/Functions/ImportSector.d.ts +3 -3
- package/World/Archive/Functions/ImportSector.js +205 -151
- package/World/Archive/Functions/Shared.d.ts +6 -0
- package/World/Archive/Functions/Shared.js +75 -0
- package/World/Archive/InitTasks.js +30 -13
- package/World/Cursor/SectionCursor.d.ts +3 -2
- package/World/Cursor/SectionCursor.js +9 -4
- package/World/Cursor/SectorCursor.d.ts +3 -2
- package/World/Cursor/SectorCursor.js +5 -3
- package/World/Cursor/WorldCursor.d.ts +2 -2
- package/World/Cursor/WorldCursor.js +6 -3
- package/World/Cursor/WorldVoxelCursor.d.ts +7 -7
- package/World/Cursor/WorldVoxelCursor.js +21 -24
- package/World/InitTasks.d.ts +1 -1
- package/World/Lock/WorldLock.d.ts +1 -1
- package/World/Section/Section.d.ts +31 -23
- package/World/Section/Section.js +116 -18
- package/World/Section/SectionState.d.ts +10 -0
- package/World/Section/SectionState.js +11 -0
- package/World/Sector/Sector.d.ts +24 -9
- package/World/Sector/Sector.js +92 -21
- package/World/Sector/SectorHeightMap.js +3 -5
- package/World/Sector/SectorState.d.ts +21 -0
- package/World/Sector/SectorState.js +28 -0
- package/World/WorldRegister.d.ts +4 -0
- package/World/WorldRegister.js +15 -3
- package/World/WorldSpaces.d.ts +6 -0
- package/World/WorldSpaces.js +25 -6
- package/package.json +1 -1
- package/Data/Cursor/DataCursor.interface.d.ts +0 -5
- package/Data/Cursor/DataCursor.interface.js +0 -2
- 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/Mesher/Functions/CompactMesh.d.ts +0 -2
- package/Mesher/Functions/CompactMesh.js +0 -42
- package/Mesher/Geomtry/Buffers.js +0 -81
- package/Mesher/Geomtry/GeometryNormals.d.ts +0 -10
- package/Mesher/Geomtry/GeometryNormals.js +0 -52
- package/Mesher/Geomtry/MeshData.types.d.ts +0 -13
- package/Mesher/Geomtry/MeshData.types.js +0 -6
- package/Mesher/Geomtry/Tools/MesherDataTools.d.ts +0 -7
- package/Mesher/Geomtry/Tools/MesherDataTools.js +0 -12
- package/Mesher/Geomtry/Tools/index.d.ts +0 -1
- package/Mesher/Geomtry/Tools/index.js +0 -1
- package/Mesher/RenderedMaterials.d.ts +0 -6
- package/Models/Rules/VoxelModelManager.js +0 -82
- package/Textures/TextureAnimations.d.ts +0 -4
- package/Textures/TextureAnimations.js +0 -35
- package/Textures/TextureArray.d.ts +0 -47
- package/Textures/TextureArray.js +0 -202
- package/Textures/TextureBuilder.d.ts +0 -13
- package/Textures/TextureBuilder.js +0 -120
- package/Textures/TextureRegister.d.ts +0 -9
- package/Textures/TextureRegister.js +0 -28
- 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/World/Structs/WorldDataStructProperties.d.ts +0 -8
- package/World/Structs/WorldDataStructProperties.js +0 -9
- /package/Mesher/{VoxelShaderData.d.ts → Geomtry/VoxelShaderData.d.ts} +0 -0
- /package/Mesher/{VoxelShaderData.js → Geomtry/VoxelShaderData.js} +0 -0
- /package/{Data/Functions → Util/Binary}/Palettes.d.ts +0 -0
- /package/{Data/Functions → Util/Binary}/Palettes.js +0 -0
- /package/{Data/Structs/StructBuilder.types.js → Voxels/Cursor/DataCursor.interface.js} +0 -0
- /package/Voxels/{VoxelLevelReader.d.ts → Cursor/VoxelLevelReader.d.ts} +0 -0
- /package/Voxels/{VoxelLevelReader.js → Cursor/VoxelLevelReader.js} +0 -0
- /package/World/{Storage → Types}/WorldStorage.interface.d.ts +0 -0
- /package/World/{Storage → Types}/WorldStorage.interface.js +0 -0
|
@@ -1,54 +1,65 @@
|
|
|
1
1
|
import { StringPalette } from "../../../Util/StringPalette";
|
|
2
2
|
import { NumberPalette } from "../../../Util/NumberPalette";
|
|
3
3
|
import { WorldRegister } from "../../../World/WorldRegister";
|
|
4
|
-
import { VoxelPalette } from "../../../Voxels/Palettes/VoxelPalette";
|
|
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";
|
|
9
4
|
import { SchemaRegister } from "../../../Voxels/State/SchemaRegister";
|
|
5
|
+
import { VoxelPalettesRegister } from "../../../Voxels/Data/VoxelPalettesRegister";
|
|
6
|
+
import { VoxelTagsRegister } from "../../../Voxels/Data/VoxelTagsRegister";
|
|
7
|
+
import { VoxelLightData } from "../../../Voxels/Cursor/VoxelLightData";
|
|
8
|
+
import { EngineSettings } from "../../../Settings/EngineSettings";
|
|
9
|
+
import { setNibbleArrayIndex } from "../../../Util/Binary/BinaryArrays";
|
|
10
|
+
import { BinaryBuffer } from "../../../Util/Binary/BinaryBuffer";
|
|
11
|
+
import { compareSection, lightSegments, lightSemgnetGet, uint16To4CharString, } from "./Shared";
|
|
12
|
+
function getProcessedData(buffer) {
|
|
13
|
+
return {
|
|
14
|
+
buffer,
|
|
15
|
+
allTheSame: true,
|
|
16
|
+
isPaletted: false,
|
|
17
|
+
remapped: false,
|
|
18
|
+
value: 0,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
10
21
|
const getProcessedSection = (section) => {
|
|
11
22
|
return {
|
|
12
|
-
section,
|
|
23
|
+
original: section,
|
|
13
24
|
palettes: getSectionPalettes(),
|
|
25
|
+
isBuriedAllTheSame: false,
|
|
26
|
+
buriedValue: 0,
|
|
27
|
+
isVoxelMapAllTheSame: false,
|
|
28
|
+
voxelMapValue: 0,
|
|
29
|
+
isDirtyMapAllTheSame: false,
|
|
30
|
+
dirtyMapValue: 0,
|
|
14
31
|
// ids
|
|
15
|
-
ids: new Uint16Array(section.ids.length),
|
|
16
|
-
idsAllTheSame: true,
|
|
17
|
-
remappedIds: false,
|
|
32
|
+
ids: getProcessedData(new Uint16Array(section.ids.length)),
|
|
18
33
|
// light
|
|
19
|
-
light:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
34
|
+
light: {
|
|
35
|
+
sun: getProcessedData(new Uint8Array(section.light.length)),
|
|
36
|
+
red: getProcessedData(new Uint8Array(section.light.length)),
|
|
37
|
+
green: getProcessedData(new Uint8Array(section.light.length)),
|
|
38
|
+
blue: getProcessedData(new Uint8Array(section.light.length)),
|
|
39
|
+
},
|
|
23
40
|
// level
|
|
24
|
-
level: new Uint8Array(section.level.length),
|
|
25
|
-
levelAllTheSame: true,
|
|
26
|
-
isLevelPaletted: false,
|
|
27
|
-
remappedLevel: false,
|
|
41
|
+
level: getProcessedData(new Uint8Array(section.level.length)),
|
|
28
42
|
// state
|
|
29
|
-
state: new Uint16Array(section.
|
|
30
|
-
stateAllTheSame: true,
|
|
31
|
-
isStatePaletted: false,
|
|
32
|
-
remappedState: false,
|
|
43
|
+
state: getProcessedData(new Uint16Array(section.level.length)),
|
|
33
44
|
// mod
|
|
34
|
-
mod: new Uint16Array(section.mod.length),
|
|
35
|
-
modAllTheSame: true,
|
|
36
|
-
isModPaletted: false,
|
|
37
|
-
remappedMod: false,
|
|
45
|
+
mod: getProcessedData(new Uint16Array(section.mod.length)),
|
|
38
46
|
// secondary
|
|
39
|
-
secondary: new Uint16Array(section.
|
|
40
|
-
isSecondaryPaletted: false,
|
|
41
|
-
secondaryAllTheSame: true,
|
|
42
|
-
remappedSecondary: false,
|
|
47
|
+
secondary: getProcessedData(new Uint16Array(section.mod.length)),
|
|
43
48
|
};
|
|
44
49
|
};
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
function getLightPalette() {
|
|
51
|
+
return {
|
|
52
|
+
sun: new NumberPalette(),
|
|
53
|
+
red: new NumberPalette(),
|
|
54
|
+
green: new NumberPalette(),
|
|
55
|
+
blue: new NumberPalette(),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
47
58
|
function getSectionPalettes() {
|
|
48
59
|
return {
|
|
49
60
|
ids: new NumberPalette(),
|
|
50
61
|
level: new NumberPalette(),
|
|
51
|
-
light:
|
|
62
|
+
light: getLightPalette(),
|
|
52
63
|
state: new NumberPalette(),
|
|
53
64
|
mod: new NumberPalette(),
|
|
54
65
|
secondaryId: new NumberPalette(),
|
|
@@ -59,7 +70,7 @@ function getColumnPalettes() {
|
|
|
59
70
|
return {
|
|
60
71
|
ids: new StringPalette(),
|
|
61
72
|
level: new NumberPalette(),
|
|
62
|
-
light:
|
|
73
|
+
light: getLightPalette(),
|
|
63
74
|
stateIdMap: [],
|
|
64
75
|
state: new NumberPalette(),
|
|
65
76
|
modIdMap: [],
|
|
@@ -68,103 +79,315 @@ function getColumnPalettes() {
|
|
|
68
79
|
secondaryState: new NumberPalette(),
|
|
69
80
|
};
|
|
70
81
|
}
|
|
82
|
+
function getLightBuffer(light, buffer) {
|
|
83
|
+
const array = new Uint8Array(buffer.length / 2);
|
|
84
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
85
|
+
let l = 0;
|
|
86
|
+
if (light == "sun")
|
|
87
|
+
l = lightData.getS(buffer[i]);
|
|
88
|
+
if (light == "red")
|
|
89
|
+
l = lightData.getR(buffer[i]);
|
|
90
|
+
if (light == "green")
|
|
91
|
+
l = lightData.getG(buffer[i]);
|
|
92
|
+
if (light == "blue")
|
|
93
|
+
l = lightData.getB(buffer[i]);
|
|
94
|
+
setNibbleArrayIndex(array, i, l);
|
|
95
|
+
}
|
|
96
|
+
return array;
|
|
97
|
+
}
|
|
71
98
|
function GetArchivedSection(archiveSection, sectorPalettes) {
|
|
72
|
-
sectionStructInstance.setData(archiveSection.section.sectionState);
|
|
73
99
|
const palettes = {};
|
|
74
|
-
if (archiveSection.
|
|
100
|
+
if (archiveSection.ids.remapped)
|
|
75
101
|
palettes.id = Uint16Array.from(archiveSection.palettes.ids._palette);
|
|
76
|
-
if (archiveSection.
|
|
102
|
+
if (archiveSection.level.remapped)
|
|
77
103
|
palettes.level = Uint8Array.from(archiveSection.palettes.level._palette);
|
|
78
|
-
if (archiveSection.
|
|
79
|
-
palettes.light
|
|
80
|
-
|
|
104
|
+
if (archiveSection.light.sun.remapped) {
|
|
105
|
+
palettes.light ??= {};
|
|
106
|
+
palettes.light.sun = Uint8Array.from(archiveSection.palettes.light.sun._palette);
|
|
107
|
+
}
|
|
108
|
+
if (archiveSection.light.red.remapped) {
|
|
109
|
+
palettes.light ??= {};
|
|
110
|
+
palettes.light.red = Uint8Array.from(archiveSection.palettes.light.red._palette);
|
|
111
|
+
}
|
|
112
|
+
if (archiveSection.light.green.remapped) {
|
|
113
|
+
palettes.light ??= {};
|
|
114
|
+
palettes.light.green = Uint8Array.from(archiveSection.palettes.light.green._palette);
|
|
115
|
+
}
|
|
116
|
+
if (archiveSection.light.blue.remapped) {
|
|
117
|
+
palettes.light ??= {};
|
|
118
|
+
palettes.light.blue = Uint8Array.from(archiveSection.palettes.light.blue._palette);
|
|
119
|
+
}
|
|
120
|
+
if (archiveSection.state.remapped)
|
|
81
121
|
palettes.state = Uint16Array.from(archiveSection.palettes.state._palette);
|
|
82
|
-
if (archiveSection.
|
|
122
|
+
if (archiveSection.mod.remapped)
|
|
83
123
|
palettes.mod = Uint16Array.from(archiveSection.palettes.mod._palette);
|
|
84
|
-
if (archiveSection.
|
|
124
|
+
if (archiveSection.secondary.remapped) {
|
|
85
125
|
palettes.secondaryId = Uint16Array.from(archiveSection.palettes.secondaryId._palette);
|
|
86
126
|
palettes.secondaryState = Uint16Array.from(archiveSection.palettes.secondaryState._palette);
|
|
87
127
|
}
|
|
128
|
+
const buffers = {};
|
|
129
|
+
//id
|
|
130
|
+
if (archiveSection.ids.allTheSame) {
|
|
131
|
+
if (archiveSection.ids.buffer[0] !== 0) {
|
|
132
|
+
buffers.id = archiveSection.ids.buffer[0];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else if (archiveSection.ids.isPaletted) {
|
|
136
|
+
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.ids.remapped
|
|
137
|
+
? archiveSection.palettes.ids.size
|
|
138
|
+
: sectorPalettes.ids.size);
|
|
139
|
+
buffers.id = BinaryBuffer.Create({
|
|
140
|
+
buffer: BinaryBuffer.Convert(archiveSection.ids.buffer, "16-bit", type),
|
|
141
|
+
type,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
buffers.id = BinaryBuffer.Create({
|
|
146
|
+
buffer: archiveSection.ids.buffer,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
//level
|
|
150
|
+
if (archiveSection.level.allTheSame) {
|
|
151
|
+
if (archiveSection.level.buffer[0] !== 0) {
|
|
152
|
+
buffers.level = archiveSection.level.buffer[0];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
else if (archiveSection.level.isPaletted) {
|
|
156
|
+
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.level.remapped
|
|
157
|
+
? archiveSection.palettes.level.size
|
|
158
|
+
: sectorPalettes.level.size);
|
|
159
|
+
buffers.level = BinaryBuffer.Create({
|
|
160
|
+
buffer: BinaryBuffer.Convert(archiveSection.level.buffer, "8-bit", type),
|
|
161
|
+
type,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
buffers.level = BinaryBuffer.Create({
|
|
166
|
+
buffer: archiveSection.original.level.slice(),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
for (const semgnet of lightSegments) {
|
|
170
|
+
if (archiveSection.light[semgnet].allTheSame) {
|
|
171
|
+
if (archiveSection.light[semgnet].value !== 0) {
|
|
172
|
+
buffers.light ??= {};
|
|
173
|
+
buffers.light[semgnet] = archiveSection.light[semgnet].value;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
else if (archiveSection.light[semgnet].isPaletted) {
|
|
177
|
+
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.light[semgnet].remapped
|
|
178
|
+
? archiveSection.palettes.light[semgnet].size
|
|
179
|
+
: sectorPalettes.light[semgnet].size);
|
|
180
|
+
buffers.light ??= {};
|
|
181
|
+
buffers.light[semgnet] = BinaryBuffer.Create({
|
|
182
|
+
buffer: BinaryBuffer.Convert(archiveSection.light[semgnet].buffer, "8-bit", type),
|
|
183
|
+
type,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
buffers.light ??= {};
|
|
188
|
+
buffers.light[semgnet] = BinaryBuffer.Create({
|
|
189
|
+
buffer: getLightBuffer(semgnet, archiveSection.original.light),
|
|
190
|
+
type: "4-bit",
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (archiveSection.state.allTheSame) {
|
|
195
|
+
if (archiveSection.state.buffer[0] !== 0) {
|
|
196
|
+
buffers.state = archiveSection.state.buffer[0];
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
else if (archiveSection.state.isPaletted) {
|
|
200
|
+
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.state.remapped
|
|
201
|
+
? archiveSection.palettes.state.size
|
|
202
|
+
: sectorPalettes.state.size);
|
|
203
|
+
buffers.state = BinaryBuffer.Create({
|
|
204
|
+
buffer: BinaryBuffer.Convert(archiveSection.state.buffer, "16-bit", type),
|
|
205
|
+
type,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
buffers.state = BinaryBuffer.Create({
|
|
210
|
+
buffer: archiveSection.state.buffer,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
if (archiveSection.mod.allTheSame) {
|
|
214
|
+
if (archiveSection.mod.buffer[0] !== 0) {
|
|
215
|
+
buffers.mod = archiveSection.mod.buffer[0];
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
else if (archiveSection.mod.isPaletted) {
|
|
219
|
+
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.mod.remapped
|
|
220
|
+
? archiveSection.palettes.mod.size
|
|
221
|
+
: sectorPalettes.mod.size);
|
|
222
|
+
buffers.mod = BinaryBuffer.Create({
|
|
223
|
+
buffer: BinaryBuffer.Convert(archiveSection.mod.buffer, "16-bit", type),
|
|
224
|
+
type,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
buffers.mod = BinaryBuffer.Create({
|
|
229
|
+
buffer: archiveSection.mod.buffer,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
if (archiveSection.secondary.allTheSame) {
|
|
233
|
+
if (archiveSection.secondary.buffer[0] !== 0) {
|
|
234
|
+
buffers.secondary = archiveSection.secondary.buffer[0];
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
else if (archiveSection.secondary.isPaletted) {
|
|
238
|
+
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.secondary.remapped
|
|
239
|
+
? Math.max(archiveSection.palettes.secondaryState.size, archiveSection.palettes.secondaryId.size)
|
|
240
|
+
: Math.max(sectorPalettes.secondaryState.size, sectorPalettes.secondaryId.size));
|
|
241
|
+
buffers.secondary = BinaryBuffer.Create({
|
|
242
|
+
buffer: BinaryBuffer.Convert(archiveSection.secondary.buffer, "16-bit", type),
|
|
243
|
+
type,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
buffers.secondary = BinaryBuffer.Create({
|
|
248
|
+
buffer: archiveSection.secondary.buffer,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
if (archiveSection.isBuriedAllTheSame) {
|
|
252
|
+
if (archiveSection.buriedValue !== 0) {
|
|
253
|
+
buffers.buried = archiveSection.buriedValue;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
buffers.buried = archiveSection.original.buried.slice();
|
|
258
|
+
}
|
|
259
|
+
if (archiveSection.isVoxelMapAllTheSame) {
|
|
260
|
+
if (archiveSection.voxelMapValue !== 0) {
|
|
261
|
+
buffers.voxelMap = archiveSection.voxelMapValue;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
buffers.voxelMap = archiveSection.original.voxelMap.slice();
|
|
266
|
+
}
|
|
267
|
+
if (archiveSection.isDirtyMapAllTheSame) {
|
|
268
|
+
if (archiveSection.dirtyMapValue !== 0) {
|
|
269
|
+
buffers.dirtyMap = archiveSection.dirtyMapValue;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
buffers.dirtyMap = archiveSection.original.dirtyMap.slice();
|
|
274
|
+
}
|
|
275
|
+
const flags = archiveSection.original.storeFlags();
|
|
88
276
|
return {
|
|
89
|
-
|
|
90
|
-
palettes,
|
|
91
|
-
buffers
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
277
|
+
...(Object.keys(flags).length ? { flags } : {}),
|
|
278
|
+
...(Object.keys(palettes).length ? { palettes } : {}),
|
|
279
|
+
buffers,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function RemoveDuplicates(data) {
|
|
283
|
+
const duplicateSectionMap = new Map();
|
|
284
|
+
let duplicateSections = [];
|
|
285
|
+
for (let i = 0; i < data.sections.length; i++) {
|
|
286
|
+
for (let j = 0; j < data.sections.length; j++) {
|
|
287
|
+
const section1 = data.sections[i];
|
|
288
|
+
const section2 = data.sections[j];
|
|
289
|
+
if (i == j)
|
|
290
|
+
continue;
|
|
291
|
+
if (typeof section1 == "string" || typeof section2 == "string")
|
|
292
|
+
continue;
|
|
293
|
+
let index = -1;
|
|
294
|
+
if (compareSection(section1, section2)) {
|
|
295
|
+
if (duplicateSectionMap.has(section2)) {
|
|
296
|
+
index = duplicateSectionMap.get(section2)[1];
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
let found = false;
|
|
300
|
+
for (let k = 0; k < duplicateSections.length; k++) {
|
|
301
|
+
if (compareSection(section1, duplicateSections[k])) {
|
|
302
|
+
index = k;
|
|
303
|
+
found = true;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
if (!found) {
|
|
307
|
+
duplicateSections.push(section1);
|
|
308
|
+
index = duplicateSections.length - 1;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
duplicateSectionMap.set(section1, [i, index]);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
const sections = {};
|
|
316
|
+
for (const [object, [sectionIndex, index]] of duplicateSectionMap) {
|
|
317
|
+
const id = uint16To4CharString(index);
|
|
318
|
+
if (!sections[id])
|
|
319
|
+
sections[id] = object;
|
|
320
|
+
data.sections[sectionIndex] = id;
|
|
321
|
+
}
|
|
322
|
+
data.duplicates = {
|
|
323
|
+
sections,
|
|
133
324
|
};
|
|
134
325
|
}
|
|
326
|
+
const lightData = new VoxelLightData();
|
|
135
327
|
export default function ArchiveSector(archiveData) {
|
|
136
328
|
const sector = WorldRegister.sectors.get(archiveData.location[0], archiveData.location[1], archiveData.location[2], archiveData.location[3]);
|
|
137
329
|
if (!sector)
|
|
138
330
|
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
331
|
const sectorPalettes = getColumnPalettes();
|
|
144
|
-
sectorStructInstance.setData(sector.sectorState);
|
|
145
|
-
const sectorState = sectorStructInstance.serialize();
|
|
146
332
|
const processedSections = [];
|
|
147
333
|
for (const section of sector.sections) {
|
|
148
|
-
const length = section.ids.length;
|
|
149
|
-
let firstId = -1;
|
|
150
|
-
let firstLight = -1;
|
|
151
|
-
let firstLevel = -1;
|
|
152
|
-
let firstState = -1;
|
|
153
|
-
let firstMod = -1;
|
|
154
|
-
let firstSecondary = -1;
|
|
155
334
|
const processedSection = getProcessedSection(section);
|
|
335
|
+
{
|
|
336
|
+
let value = section.buried[0];
|
|
337
|
+
processedSection.isBuriedAllTheSame = true;
|
|
338
|
+
for (let i = 0; i < section.buried.length; i++) {
|
|
339
|
+
if (value != section.buried[i]) {
|
|
340
|
+
processedSection.isBuriedAllTheSame = false;
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
processedSection.buriedValue = value;
|
|
345
|
+
}
|
|
346
|
+
{
|
|
347
|
+
let value = section.voxelMap[0];
|
|
348
|
+
processedSection.isVoxelMapAllTheSame = true;
|
|
349
|
+
for (let i = 0; i < section.voxelMap.length; i++) {
|
|
350
|
+
if (value != section.voxelMap[i]) {
|
|
351
|
+
processedSection.isVoxelMapAllTheSame = false;
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
processedSection.voxelMapValue = value;
|
|
356
|
+
}
|
|
357
|
+
{
|
|
358
|
+
let value = section.dirtyMap[0];
|
|
359
|
+
processedSection.isDirtyMapAllTheSame = true;
|
|
360
|
+
for (let i = 0; i < section.dirtyMap.length; i++) {
|
|
361
|
+
if (value != section.dirtyMap[i]) {
|
|
362
|
+
processedSection.isDirtyMapAllTheSame = false;
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
processedSection.dirtyMapValue = value;
|
|
367
|
+
}
|
|
368
|
+
const firstId = section.ids[0];
|
|
369
|
+
const firstLight = section.light[0];
|
|
370
|
+
const firstLevel = section.level[0];
|
|
371
|
+
const firstState = section.state[0];
|
|
372
|
+
const firstMod = section.mod[0];
|
|
373
|
+
const firstSecondary = section.secondary[0];
|
|
374
|
+
const firstLightLevels = {
|
|
375
|
+
sun: lightData.getS(firstLight),
|
|
376
|
+
red: lightData.getR(firstLight),
|
|
377
|
+
green: lightData.getG(firstLight),
|
|
378
|
+
blue: lightData.getB(firstLight),
|
|
379
|
+
};
|
|
380
|
+
const length = section.ids.length;
|
|
156
381
|
for (let i = 0; i < length; i++) {
|
|
157
|
-
const stringId =
|
|
158
|
-
VoxelStruct.setStringVoxel(stringId);
|
|
382
|
+
const stringId = VoxelPalettesRegister.voxels.getStringId(section.ids[i]);
|
|
159
383
|
const voxelId = !sectorPalettes.ids.isRegistered(stringId)
|
|
160
384
|
? sectorPalettes.ids.register(stringId)
|
|
161
385
|
: sectorPalettes.ids.getNumberId(stringId);
|
|
386
|
+
processedSection.ids.value = voxelId;
|
|
162
387
|
if (!processedSection.palettes.ids.isRegistered(voxelId))
|
|
163
388
|
processedSection.palettes.ids.register(voxelId);
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const secondaryId = VoxelStruct.instance[VoxelStructIds.canHaveSecondary] == 1 &&
|
|
167
|
-
VoxelPalette.ids.getStringId(section.secondary[i]);
|
|
389
|
+
const secondaryId = VoxelTagsRegister.VoxelTags[section.ids[i]]["dve_can_have_secondary"] &&
|
|
390
|
+
VoxelPalettesRegister.voxels.getStringId(section.secondary[i]);
|
|
168
391
|
const voxelSecondary = secondaryId
|
|
169
392
|
? !sectorPalettes.secondaryId.isRegistered(secondaryId)
|
|
170
393
|
? sectorPalettes.secondaryId.register(secondaryId)
|
|
@@ -172,20 +395,19 @@ export default function ArchiveSector(archiveData) {
|
|
|
172
395
|
: !sectorPalettes.secondaryState.isRegistered(section.secondary[i])
|
|
173
396
|
? sectorPalettes.secondaryState.register(section.secondary[i])
|
|
174
397
|
: sectorPalettes.secondaryState.getId(section.secondary[i]);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
processedSection.palettes.secondaryId.register(voxelSecondary)
|
|
178
|
-
|
|
398
|
+
if (VoxelTagsRegister.VoxelTags[section.ids[i]]["dve_can_have_secondary"]) {
|
|
399
|
+
if (!processedSection.palettes.secondaryId.isRegistered(voxelSecondary))
|
|
400
|
+
processedSection.palettes.secondaryId.register(voxelSecondary);
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
if (!processedSection.palettes.secondaryState.isRegistered(voxelSecondary))
|
|
179
404
|
processedSection.palettes.secondaryState.register(voxelSecondary);
|
|
180
|
-
|
|
181
|
-
firstSecondary = section.secondary[i];
|
|
405
|
+
}
|
|
182
406
|
const voxelLevel = !sectorPalettes.level.isRegistered(section.level[i])
|
|
183
407
|
? sectorPalettes.level.register(section.level[i])
|
|
184
408
|
: sectorPalettes.level.getId(section.level[i]);
|
|
185
409
|
if (!processedSection.palettes.level.isRegistered(section.level[i]))
|
|
186
410
|
processedSection.palettes.level.register(section.level[i]);
|
|
187
|
-
if (firstLevel == -1)
|
|
188
|
-
firstLevel = voxelLevel;
|
|
189
411
|
let voxelState = -1;
|
|
190
412
|
if (!sectorPalettes.state.isRegistered(section.state[i])) {
|
|
191
413
|
voxelState = sectorPalettes.state.register(section.state[i]);
|
|
@@ -198,12 +420,10 @@ export default function ArchiveSector(archiveData) {
|
|
|
198
420
|
}
|
|
199
421
|
if (!processedSection.palettes.state.isRegistered(voxelState))
|
|
200
422
|
processedSection.palettes.state.register(voxelState);
|
|
201
|
-
if (firstState == -1)
|
|
202
|
-
firstState = voxelState;
|
|
203
423
|
let voxelMod = -1;
|
|
204
424
|
if (!sectorPalettes.mod.isRegistered(section.mod[i])) {
|
|
205
425
|
voxelMod = sectorPalettes.mod.register(section.mod[i]);
|
|
206
|
-
sectorPalettes.
|
|
426
|
+
sectorPalettes.modIdMap[voxelMod] = secondaryId
|
|
207
427
|
? section.secondary[i]
|
|
208
428
|
: section.ids[i];
|
|
209
429
|
}
|
|
@@ -212,99 +432,147 @@ export default function ArchiveSector(archiveData) {
|
|
|
212
432
|
}
|
|
213
433
|
if (!processedSection.palettes.mod.isRegistered(voxelMod))
|
|
214
434
|
processedSection.palettes.mod.register(voxelMod);
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (
|
|
229
|
-
processedSection.
|
|
230
|
-
if (
|
|
231
|
-
processedSection.
|
|
232
|
-
if (
|
|
233
|
-
processedSection.
|
|
234
|
-
if (
|
|
235
|
-
processedSection.
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
processedSection.
|
|
239
|
-
processedSection.
|
|
240
|
-
processedSection.
|
|
241
|
-
processedSection.
|
|
435
|
+
for (let l = 0; l < lightSegments.length; l++) {
|
|
436
|
+
const segment = lightSegments[l];
|
|
437
|
+
const light = lightSemgnetGet[segment](section.light[i]);
|
|
438
|
+
if (light != firstLightLevels[segment])
|
|
439
|
+
processedSection.light[segment].allTheSame = false;
|
|
440
|
+
processedSection.light[segment].value = light;
|
|
441
|
+
const voxelLight = !sectorPalettes.light[segment].isRegistered(light)
|
|
442
|
+
? sectorPalettes.light[segment].register(light)
|
|
443
|
+
: sectorPalettes.light[segment].getId(light);
|
|
444
|
+
if (!processedSection.palettes.light[segment].isRegistered(light))
|
|
445
|
+
processedSection.palettes.light[segment].register(light);
|
|
446
|
+
processedSection.light[segment].buffer[i] = voxelLight;
|
|
447
|
+
}
|
|
448
|
+
if (section.ids[i] != firstId)
|
|
449
|
+
processedSection.ids.allTheSame = false;
|
|
450
|
+
if (section.level[i] != firstLevel)
|
|
451
|
+
processedSection.level.allTheSame = false;
|
|
452
|
+
if (section.state[i] != firstState)
|
|
453
|
+
processedSection.state.allTheSame = false;
|
|
454
|
+
if (section.mod[i] != firstMod)
|
|
455
|
+
processedSection.mod.allTheSame = false;
|
|
456
|
+
if (section.secondary[i] != firstSecondary)
|
|
457
|
+
processedSection.secondary.allTheSame = false;
|
|
458
|
+
processedSection.ids.buffer[i] = voxelId;
|
|
459
|
+
processedSection.level.buffer[i] = voxelLevel;
|
|
460
|
+
processedSection.state.buffer[i] = voxelState;
|
|
461
|
+
processedSection.mod.buffer[i] = voxelMod;
|
|
462
|
+
processedSection.secondary.buffer[i] = voxelSecondary;
|
|
242
463
|
}
|
|
243
464
|
processedSections.push(processedSection);
|
|
244
465
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
sectorPalettes.level.size
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
466
|
+
let neededPalettes = {
|
|
467
|
+
level: false,
|
|
468
|
+
light: {
|
|
469
|
+
sun: false,
|
|
470
|
+
red: false,
|
|
471
|
+
green: false,
|
|
472
|
+
blue: false,
|
|
473
|
+
},
|
|
474
|
+
};
|
|
475
|
+
for (const archivedSection of processedSections) {
|
|
476
|
+
//ids
|
|
477
|
+
archivedSection.ids.isPaletted =
|
|
478
|
+
sectorPalettes.ids.size <= BinaryBuffer.BytePaletteMax ||
|
|
479
|
+
archivedSection.palettes.ids.size <= BinaryBuffer.BytePaletteMax;
|
|
480
|
+
archivedSection.ids.remapped =
|
|
481
|
+
sectorPalettes.ids.size > BinaryBuffer.BytePaletteMax &&
|
|
482
|
+
archivedSection.palettes.ids.size <= BinaryBuffer.BytePaletteMax &&
|
|
483
|
+
!archivedSection.ids.allTheSame;
|
|
484
|
+
//level
|
|
485
|
+
archivedSection.level.isPaletted =
|
|
486
|
+
sectorPalettes.level.size <= BinaryBuffer.NibblePaletteMax &&
|
|
487
|
+
archivedSection.palettes.level.size <= BinaryBuffer.NibblePaletteMax;
|
|
488
|
+
archivedSection.level.remapped =
|
|
489
|
+
sectorPalettes.level.size > BinaryBuffer.NibblePaletteMax &&
|
|
490
|
+
archivedSection.palettes.level.size <= BinaryBuffer.NibblePaletteMax &&
|
|
491
|
+
!archivedSection.level.allTheSame;
|
|
492
|
+
if (archivedSection.level.isPaletted && !archivedSection.level.remapped) {
|
|
493
|
+
neededPalettes.level = true;
|
|
494
|
+
}
|
|
495
|
+
//state
|
|
496
|
+
archivedSection.state.isPaletted =
|
|
497
|
+
sectorPalettes.state.size <= BinaryBuffer.BytePaletteMax ||
|
|
498
|
+
archivedSection.palettes.state.size <= BinaryBuffer.BytePaletteMax;
|
|
499
|
+
archivedSection.state.remapped =
|
|
500
|
+
sectorPalettes.state.size > BinaryBuffer.BytePaletteMax &&
|
|
501
|
+
archivedSection.palettes.state.size <= BinaryBuffer.BytePaletteMax &&
|
|
502
|
+
!archivedSection.state.allTheSame;
|
|
503
|
+
//mod
|
|
504
|
+
archivedSection.mod.isPaletted =
|
|
505
|
+
sectorPalettes.mod.size <= BinaryBuffer.BytePaletteMax ||
|
|
506
|
+
archivedSection.palettes.mod.size <= BinaryBuffer.BytePaletteMax;
|
|
507
|
+
archivedSection.mod.remapped =
|
|
508
|
+
sectorPalettes.mod.size > BinaryBuffer.BytePaletteMax &&
|
|
509
|
+
archivedSection.palettes.mod.size <= BinaryBuffer.BytePaletteMax &&
|
|
510
|
+
!archivedSection.mod.allTheSame;
|
|
511
|
+
for (const semgnet of lightSegments) {
|
|
512
|
+
archivedSection.light[semgnet].isPaletted =
|
|
513
|
+
sectorPalettes.light[semgnet].size <=
|
|
514
|
+
BinaryBuffer.HalfNibblePaletteMax ||
|
|
515
|
+
archivedSection.palettes.light[semgnet].size <=
|
|
516
|
+
BinaryBuffer.HalfNibblePaletteMax;
|
|
517
|
+
archivedSection.light[semgnet].remapped =
|
|
518
|
+
sectorPalettes.light[semgnet].size >
|
|
519
|
+
BinaryBuffer.HalfNibblePaletteMax &&
|
|
520
|
+
archivedSection.palettes.light[semgnet].size <=
|
|
521
|
+
BinaryBuffer.HalfNibblePaletteMax &&
|
|
522
|
+
!archivedSection.light[semgnet].allTheSame;
|
|
523
|
+
if (archivedSection.light[semgnet].isPaletted &&
|
|
524
|
+
!archivedSection.light[semgnet].remapped) {
|
|
525
|
+
neededPalettes.light[semgnet] = true;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
//secondary
|
|
529
|
+
archivedSection.secondary.isPaletted =
|
|
530
|
+
(sectorPalettes.secondaryState.size <= BinaryBuffer.BytePaletteMax &&
|
|
531
|
+
sectorPalettes.secondaryId.size <= BinaryBuffer.BytePaletteMax) ||
|
|
532
|
+
(archivedSection.palettes.secondaryState.size <=
|
|
533
|
+
BinaryBuffer.BytePaletteMax &&
|
|
534
|
+
archivedSection.palettes.secondaryId.size <=
|
|
535
|
+
BinaryBuffer.BytePaletteMax);
|
|
536
|
+
archivedSection.secondary.remapped =
|
|
537
|
+
Math.max(sectorPalettes.secondaryState.size, sectorPalettes.secondaryId.size) > BinaryBuffer.BytePaletteMax &&
|
|
538
|
+
Math.max(archivedSection.palettes.secondaryId.size, archivedSection.palettes.secondaryState.size) <= BinaryBuffer.BytePaletteMax &&
|
|
539
|
+
!archivedSection.secondary.allTheSame;
|
|
540
|
+
if (!archivedSection.ids.remapped &&
|
|
541
|
+
!archivedSection.light.sun.remapped &&
|
|
542
|
+
!archivedSection.light.red.remapped &&
|
|
543
|
+
!archivedSection.light.green.remapped &&
|
|
544
|
+
!archivedSection.light.blue.remapped &&
|
|
545
|
+
!archivedSection.secondary.remapped &&
|
|
546
|
+
!archivedSection.mod.remapped &&
|
|
547
|
+
!archivedSection.level.remapped)
|
|
283
548
|
continue;
|
|
284
|
-
const length =
|
|
549
|
+
const length = archivedSection.original.ids.length;
|
|
285
550
|
for (let i = 0; i < length; i++) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if (
|
|
296
|
-
|
|
297
|
-
if (
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
551
|
+
if (archivedSection.ids.remapped)
|
|
552
|
+
archivedSection.ids.buffer[i] = archivedSection.palettes.ids.getId(archivedSection.ids.buffer[i]);
|
|
553
|
+
for (let l = 0; l < lightSegments.length; l++) {
|
|
554
|
+
const segment = lightSegments[l];
|
|
555
|
+
if (archivedSection.light[segment].remapped) {
|
|
556
|
+
archivedSection.light[segment].buffer[i] =
|
|
557
|
+
archivedSection.palettes.light[segment].getId(lightSemgnetGet[segment](archivedSection.original.light[i]));
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
if (archivedSection.level.remapped)
|
|
561
|
+
archivedSection.level.buffer[i] = archivedSection.palettes.level.getId(archivedSection.original.level[i]);
|
|
562
|
+
if (archivedSection.state.remapped)
|
|
563
|
+
archivedSection.state.buffer[i] = archivedSection.palettes.state.getId(sectorPalettes.state.getId(archivedSection.state.buffer[i]));
|
|
564
|
+
if (archivedSection.mod.remapped)
|
|
565
|
+
archivedSection.mod.buffer[i] = archivedSection.palettes.mod.getId(sectorPalettes.mod.getId(archivedSection.mod.buffer[i]));
|
|
566
|
+
if (archivedSection.secondary.remapped)
|
|
567
|
+
archivedSection.secondary.buffer[i] = VoxelTagsRegister.VoxelTags[archivedSection.original.ids[i]]["dve_can_have_secondary"]
|
|
568
|
+
? archivedSection.palettes.secondaryId.getId(archivedSection.secondary.buffer[i])
|
|
569
|
+
: archivedSection.palettes.secondaryState.getId(archivedSection.secondary.buffer[i]);
|
|
302
570
|
}
|
|
303
571
|
}
|
|
304
572
|
const stateMap = {};
|
|
305
573
|
for (let i = 0; i < sectorPalettes.state._palette.length; i++) {
|
|
306
574
|
const state = sectorPalettes.state._palette[i];
|
|
307
|
-
const voxelId =
|
|
575
|
+
const voxelId = VoxelPalettesRegister.voxels.getStringId(sectorPalettes.stateIdMap[i]);
|
|
308
576
|
if (!SchemaRegister.hasVoxelSchema(voxelId))
|
|
309
577
|
continue;
|
|
310
578
|
const schema = SchemaRegister.getVoxelSchemas(voxelId);
|
|
@@ -313,7 +581,7 @@ export default function ArchiveSector(archiveData) {
|
|
|
313
581
|
const modMap = {};
|
|
314
582
|
for (let i = 0; i < sectorPalettes.mod._palette.length; i++) {
|
|
315
583
|
const mod = sectorPalettes.mod._palette[i];
|
|
316
|
-
const voxelId =
|
|
584
|
+
const voxelId = VoxelPalettesRegister.voxels.getStringId(sectorPalettes.modIdMap[i]);
|
|
317
585
|
if (!SchemaRegister.hasVoxelSchema(voxelId))
|
|
318
586
|
continue;
|
|
319
587
|
const schema = SchemaRegister.getVoxelSchemas(voxelId);
|
|
@@ -329,26 +597,29 @@ export default function ArchiveSector(archiveData) {
|
|
|
329
597
|
modMap,
|
|
330
598
|
state: new Uint16Array(sectorPalettes.state._palette),
|
|
331
599
|
mod: new Uint16Array(sectorPalettes.mod._palette),
|
|
600
|
+
light: {},
|
|
601
|
+
secondaryId: sectorPalettes.secondaryId._palette,
|
|
602
|
+
secondaryState: new Uint16Array(sectorPalettes.secondaryState._palette),
|
|
332
603
|
};
|
|
333
|
-
if (
|
|
334
|
-
palettes.light = new Uint16Array(sectorPalettes.light._palette);
|
|
335
|
-
if (sectorPalettes.level.size < 255)
|
|
604
|
+
if (neededPalettes.level) {
|
|
336
605
|
palettes.level = new Uint8Array(sectorPalettes.level._palette);
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
606
|
+
}
|
|
607
|
+
for (const segment of lightSegments) {
|
|
608
|
+
if (neededPalettes.light[segment]) {
|
|
609
|
+
palettes.light[segment] = new Uint8Array(sectorPalettes.light[segment]._palette);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
const archivedSector = {
|
|
344
613
|
version: "",
|
|
614
|
+
vloxVersion: EngineSettings.version,
|
|
345
615
|
location: [...archiveData.location],
|
|
346
|
-
|
|
616
|
+
flags: sector.storeFlags(),
|
|
617
|
+
timestamps: sector.storeTimestamps(),
|
|
347
618
|
buffers: {},
|
|
348
|
-
keys: {
|
|
349
|
-
sectionState: [...sectionStructInstance.getKeys()],
|
|
350
|
-
},
|
|
351
619
|
palettes,
|
|
620
|
+
duplicates: {},
|
|
352
621
|
sections,
|
|
353
622
|
};
|
|
623
|
+
RemoveDuplicates(archivedSector);
|
|
624
|
+
return archivedSector;
|
|
354
625
|
}
|