@divinevoxel/vlox 0.0.72 → 0.0.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Contexts/Base/Remote/InitDataSync.js +4 -0
- package/Contexts/Base/Remote/InitWorldDataSync.js +1 -1
- package/Contexts/Render/DivineVoxelEngineRender.d.ts +2 -1
- package/Contexts/World/DivineVoxelEngineWorld.d.ts +2 -1
- package/Init/StartConstructor.js +8 -4
- package/Init/StartWorld.d.ts +1 -1
- package/Math/index.d.ts +5 -1
- package/Mesher/Functions/CompactVoxelMesh.d.ts +2 -2
- package/Mesher/Functions/CompactVoxelMesh.js +1 -1
- package/Mesher/Functions/CompactVoxelSectionMesh.d.ts +4 -0
- package/Mesher/Functions/CompactVoxelSectionMesh.js +112 -0
- package/Mesher/Functions/MeshSection.d.ts +1 -1
- package/Mesher/Functions/MeshSection.js +27 -22
- package/Mesher/Functions/MeshTexture.d.ts +1 -1
- package/Mesher/Functions/MeshTexture.js +3 -4
- package/Mesher/Geomtry/CompactedSectionVoxelMesh.d.ts +23 -0
- package/Mesher/Geomtry/CompactedSectionVoxelMesh.js +144 -0
- 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 +120 -199
- package/Mesher/Geomtry/VoxelMesh.d.ts +1 -1
- package/Mesher/Geomtry/VoxelMesh.js +4 -4
- package/Mesher/Geomtry/VoxelMeshBVHBuilder.d.ts +16 -0
- package/Mesher/Geomtry/VoxelMeshBVHBuilder.js +51 -0
- package/Mesher/Geomtry/VoxelMeshBVHStructCursor.d.ts +22 -0
- package/Mesher/Geomtry/VoxelMeshBVHStructCursor.js +78 -0
- package/Mesher/Geomtry/{Buffers.js → VoxelMeshBuffers.js} +2 -2
- package/Mesher/Geomtry/index.d.ts +0 -1
- package/Mesher/Geomtry/index.js +0 -1
- package/Mesher/InitMesher.js +1 -1
- package/Mesher/InitTask.js +9 -23
- package/Mesher/Models/Common/BoxGeometryNode.js +7 -7
- package/Mesher/Models/Common/Calc/CalcConstants.d.ts +1 -1
- package/Mesher/Models/Common/Calc/CalcConstants.js +1 -1
- package/Mesher/Models/Common/Calc/FaceDataCalc.d.ts +2 -2
- package/Mesher/Models/Common/Calc/FaceDataCalc.js +37 -30
- package/Mesher/Models/Common/QuadGeometryNode.js +2 -2
- 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.js +18 -24
- package/Mesher/Models/Nodes/GeometryNode.d.ts +2 -2
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.d.ts +1 -0
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +40 -31
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +2 -2
- package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.js +2 -2
- package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.js +2 -2
- 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 +6 -6
- package/Mesher/Models/VoxelConstructor.js +8 -8
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.d.ts +3 -5
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.js +8 -32
- package/Mesher/{Tools/VoxelMesherDataTool.d.ts → Models/VoxelModelBuilder.d.ts} +4 -5
- package/Mesher/{Tools/VoxelMesherDataTool.js → Models/VoxelModelBuilder.js} +5 -8
- package/Mesher/Types/Mesher.types.d.ts +1 -0
- package/Models/Defaults/CubeVoxelGeometry.js +4 -0
- package/Models/Defaults/CubeVoxelModels.js +360 -383
- package/Models/Defaults/LiquidVoxelModel.js +5 -5
- package/Models/Defaults/PanelVoxelModels.js +442 -468
- package/Models/Defaults/StairVoxelModel.js +582 -597
- package/Models/Examples.js +490 -498
- package/Models/Rules/Classes/VoxelRulesModel.d.ts +1 -1
- package/Models/Rules/Classes/VoxelRulesModel.js +3 -3
- package/Models/Rules/Functions/BuildFinalInputs.d.ts +1 -1
- package/Models/Rules/Functions/BuildFinalInputs.js +21 -19
- package/Models/Rules/Functions/BuildGeomtryInputs.js +8 -5
- package/Models/Rules/Functions/BuildRules.js +2 -2
- package/Models/Rules/{VoxelModelManager.d.ts → VoxelModelRuleBuilderRegister.d.ts} +1 -1
- package/Models/Rules/VoxelModelRuleBuilderRegister.js +178 -0
- package/Models/VoxelModel.types.d.ts +17 -8
- package/Renderer/Classes/DVESectionMeshes.d.ts +2 -3
- package/Renderer/Classes/SectorMesh.d.ts +3 -4
- package/Renderer/Classes/SectorMesh.js +6 -11
- package/Renderer/InitTasks.js +1 -10
- package/Renderer/MeshManager.d.ts +1 -1
- package/Renderer/MeshManager.js +26 -25
- package/Renderer/MeshRegister.d.ts +5 -5
- package/Renderer/MeshRegister.js +4 -3
- package/Settings/EngineSettings.d.ts +2 -1
- package/Settings/EngineSettings.js +6 -5
- package/Settings/EngineSettings.types.d.ts +24 -39
- package/Settings/EngineSettings.types.js +22 -29
- package/Tasks/Logic/InitTasks.d.ts +1 -0
- package/Tasks/Logic/InitTasks.js +10 -0
- package/Tasks/Logic/VoxelLogicUpdate.d.ts +3 -0
- package/Tasks/Logic/VoxelLogicUpdate.js +71 -0
- package/Tasks/Propagation/Explosion/ExplosionManager.d.ts +2 -2
- package/Tasks/Propagation/Explosion/ExplosionManager.js +1 -2
- package/Tasks/Propagation/Flow/FlowManager.d.ts +4 -4
- package/Tasks/Propagation/Flow/FlowRemove.d.ts +2 -2
- package/Tasks/Propagation/Flow/FlowUpdate.d.ts +2 -2
- package/Tasks/Propagation/Flow/WorldFlow.d.ts +2 -2
- package/Tasks/Propagation/Illumanation/RGBUpdate.d.ts +3 -3
- package/Tasks/Propagation/Illumanation/SunUpdate.d.ts +3 -3
- package/Tasks/Propagation/Illumanation/WorldRGB.d.ts +2 -2
- package/Tasks/Propagation/Illumanation/WorldSun.d.ts +2 -2
- package/Tasks/Propagation/Illumanation/WorldSun.js +8 -15
- package/Tasks/Propagation/InitTasks.js +4 -4
- package/Tasks/Propagation/Power/PowerUpdate.d.ts +3 -0
- package/Tasks/Propagation/Power/PowerUpdate.js +80 -0
- package/Tasks/Tasks.types.d.ts +2 -2
- package/Tasks/TasksIds.d.ts +2 -1
- package/Tasks/TasksIds.js +1 -0
- package/Tasks/Update/Common.d.ts +3 -0
- package/Tasks/Update/Common.js +41 -0
- package/Tasks/Update/EreaseUpdate.d.ts +3 -0
- package/Tasks/Update/EreaseUpdate.js +66 -0
- package/Tasks/Update/InitTasks.d.ts +2 -2
- package/Tasks/Update/InitTasks.js +3 -1
- package/Tasks/Update/PaintUpdate.d.ts +3 -0
- package/Tasks/Update/PaintUpdate.js +89 -0
- package/Tasks/Update/VoxelUpdate.d.ts +2 -5
- package/Tasks/Update/VoxelUpdate.js +7 -143
- package/Tasks/{Update/UpdateTask.d.ts → VoxelUpdateTask.d.ts} +16 -6
- package/Tasks/{Update/UpdateTask.js → VoxelUpdateTask.js} +44 -5
- package/Tasks/WorldGeneration/WorldGenBrush.d.ts +3 -3
- package/Tasks/WorldGeneration/WorldGenBrush.js +3 -3
- package/Tasks/WorldGeneration/WorldGenRegister.d.ts +1 -1
- package/Templates/Cursor/TemplateCursor.d.ts +2 -2
- package/Templates/Cursor/TemplateCursor.js +1 -2
- package/Templates/Functions/CreateTemplate.d.ts +1 -1
- 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/AdvancedBrushTool.js +1 -1
- package/Tools/Brush/Brush.d.ts +3 -3
- package/Tools/Brush/Brush.js +40 -8
- package/Tools/Tasks/TasksTool.d.ts +1 -0
- package/Tools/Tasks/TasksTool.js +2 -0
- package/Util/Binary/BinaryArrays.d.ts +6 -0
- package/Util/Binary/BinaryArrays.js +25 -0
- package/Util/Binary/BinaryBuffer.d.ts +35 -0
- package/Util/Binary/BinaryBuffer.js +136 -0
- package/Util/Binary/{BitArray.d.ts → BinaryFunctions.d.ts} +1 -2
- package/Util/Binary/BinaryFunctions.js +11 -0
- package/{Mesher/Tools/VoxelMeshBVHBuilder.d.ts → Util/Binary/BinaryTree.d.ts} +1 -33
- package/Util/Binary/BinaryTree.js +104 -0
- package/Voxels/Cursor/DataCursor.interface.d.ts +5 -0
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +8 -3
- package/Voxels/Cursor/VoxelCursor.interface.js +54 -13
- package/Voxels/Cursor/VoxelLightData.js +1 -1
- package/Voxels/Data/VoxelPalettesRegister.d.ts +0 -5
- package/Voxels/Data/VoxelPalettesRegister.js +0 -9
- package/Voxels/Data/VoxelTag.types.d.ts +17 -2
- package/Voxels/Data/VoxelTag.types.js +6 -1
- package/Voxels/Data/VoxelTagsRegister.js +12 -7
- package/Voxels/Functions/BuildStateData.d.ts +6 -6
- package/Voxels/Functions/BuildStateData.js +37 -37
- package/Voxels/Functions/BuildTagAndPaletteData.js +6 -3
- package/Voxels/Indexes/VoxelIndex.d.ts +2 -2
- package/Voxels/Indexes/VoxelIndex.js +16 -18
- package/Voxels/InitVoxelData.js +24 -21
- package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.d.ts +5 -0
- package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.js +6 -0
- package/Voxels/Logic/Classes/VoxelLogic.d.ts +11 -0
- package/Voxels/Logic/Classes/VoxelLogic.js +49 -0
- package/Voxels/Logic/Classes/VoxelLogicType.d.ts +4 -0
- package/Voxels/Logic/Classes/VoxelLogicType.js +2 -0
- package/Voxels/Logic/VoxelLogic.types.d.ts +23 -0
- package/Voxels/Logic/VoxelLogic.types.js +1 -0
- package/Voxels/Logic/VoxelLogicRegister.d.ts +9 -0
- package/Voxels/Logic/VoxelLogicRegister.js +15 -0
- package/Voxels/State/Schema/StateSchema.d.ts +1 -1
- package/Voxels/State/SchemaRegister.js +10 -5
- package/Voxels/State/State.types.d.ts +1 -1
- package/Voxels/State/StateTreeReader.d.ts +1 -1
- package/Voxels/State/StateTreeReader.js +2 -3
- package/Voxels/Types/Voxel.types.d.ts +21 -0
- package/Voxels/Types/Voxel.types.js +6 -2
- package/Voxels/Types/VoxelModelCompiledData.types.d.ts +6 -4
- package/World/Archive/Archive.types.d.ts +65 -42
- package/World/Archive/Classes/ArchiveClasses.d.ts +66 -0
- package/World/Archive/Classes/ArchiveClasses.js +78 -0
- package/World/Archive/Classes/ImportedSection.d.ts +40 -0
- package/World/Archive/Classes/ImportedSection.js +307 -0
- package/World/Archive/Classes/ImportedSector.d.ts +23 -0
- package/World/Archive/Classes/ImportedSector.js +97 -0
- package/World/Archive/Functions/ArchiveArea.d.ts +1 -1
- package/World/Archive/Functions/ArchiveArea.js +49 -54
- package/World/Archive/Functions/ArchiveSector.js +373 -282
- package/World/Archive/Functions/CreateArchivedSection.d.ts +3 -0
- package/World/Archive/Functions/CreateArchivedSection.js +207 -0
- package/World/Archive/Functions/ImportSector.d.ts +2 -4
- package/World/Archive/Functions/ImportSector.js +50 -220
- package/World/Archive/Functions/RemoveDuplicates.d.ts +3 -0
- package/World/Archive/Functions/RemoveDuplicates.js +92 -0
- package/World/Archive/Functions/Shared.d.ts +6 -0
- package/World/Archive/Functions/Shared.js +50 -0
- package/World/Archive/InitTasks.js +37 -23
- package/World/Cursor/SectionCursor.d.ts +3 -3
- package/World/Cursor/SectionCursor.js +2 -3
- package/World/Cursor/SectorCursor.d.ts +3 -3
- package/World/Cursor/SectorCursor.js +1 -2
- package/World/Cursor/WorldCursor.d.ts +6 -5
- package/World/Cursor/WorldCursor.js +17 -15
- package/World/Cursor/WorldVoxelCursor.d.ts +0 -4
- package/World/Cursor/WorldVoxelCursor.js +24 -14
- package/World/Dimension/Dimension.d.ts +4 -1
- package/World/Dimension/Dimension.js +8 -1
- package/World/InitTasks.d.ts +1 -1
- package/World/Lock/WorldLock.d.ts +1 -1
- package/World/Section/Section.d.ts +27 -18
- package/World/Section/Section.js +125 -21
- package/World/Section/SectionState.d.ts +12 -0
- package/World/Section/SectionState.js +13 -0
- package/World/Sector/Sector.d.ts +20 -6
- package/World/Sector/Sector.js +100 -17
- package/World/Sector/SectorHeightMap.js +2 -2
- package/World/Sector/SectorState.d.ts +16 -7
- package/World/Sector/SectorState.js +29 -15
- package/World/Types/WorldData.types.d.ts +2 -7
- package/World/Types/WorldStorage.interface.js +1 -0
- package/World/WorldRegister.d.ts +13 -9
- package/World/WorldRegister.js +24 -9
- package/World/WorldSpaces.d.ts +4 -0
- package/World/WorldSpaces.js +25 -12
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.d.ts +2 -2
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.d.ts +10 -3
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.js +19 -3
- package/WorldSimulation/Internal/Classes/Queues/BuildQueue.d.ts +5 -0
- package/WorldSimulation/Internal/Classes/Queues/BuildQueue.js +6 -0
- package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.d.ts +5 -0
- package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.js +6 -0
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.js +1 -1
- package/WorldSimulation/Internal/Classes/TickQueue.d.ts +12 -0
- package/WorldSimulation/Internal/Classes/TickQueue.js +58 -0
- package/WorldSimulation/Internal/Classes/WorldSimulationTaskBase.d.ts +15 -0
- package/{Tasks/IWG/Internal/Classes/IWGTaskBase.js → WorldSimulation/Internal/Classes/WorldSimulationTaskBase.js} +8 -8
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.js +9 -9
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.d.ts +1 -1
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.js +4 -4
- package/WorldSimulation/Internal/Functions/runTickUpdate.d.ts +2 -0
- package/{Tasks/IWG/Internal/Functions/runBuildUpdate.js → WorldSimulation/Internal/Functions/runTickUpdate.js} +38 -9
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.js +13 -13
- package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.d.ts +2 -2
- package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.js +1 -1
- package/WorldSimulation/Internal/WorldSimulationDimensions.d.ts +6 -0
- package/{Tasks/IWG/Internal/IWGDimensions.js → WorldSimulation/Internal/WorldSimulationDimensions.js} +1 -1
- package/WorldSimulation/Internal/WorldSimulationTasks.d.ts +30 -0
- package/{Tasks/IWG/Internal/IWGTasks.js → WorldSimulation/Internal/WorldSimulationTasks.js} +14 -24
- package/WorldSimulation/Internal/WorldSimulationTools.d.ts +8 -0
- package/{Tasks/IWG/Internal/IWGTools.js → WorldSimulation/Internal/WorldSimulationTools.js} +1 -1
- package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.d.ts +1 -1
- package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.js +11 -11
- package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.js +7 -5
- package/{Tasks/IWG/IWG.d.ts → WorldSimulation/WorldSimulation.d.ts} +6 -5
- package/{Tasks/IWG/IWG.js → WorldSimulation/WorldSimulation.js} +29 -23
- package/{Tasks/IWG → WorldSimulation}/index.d.ts +1 -1
- package/{Tasks/IWG → WorldSimulation}/index.js +1 -1
- package/package.json +1 -1
- package/Mesher/Functions/CompactMesh.d.ts +0 -2
- package/Mesher/Functions/CompactMesh.js +0 -42
- 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/Mesher/Tools/VoxelMeshBVHBuilder.js +0 -216
- package/Models/Rules/VoxelModelManager.js +0 -82
- package/Tasks/IWG/Internal/Classes/IWGTaskBase.d.ts +0 -15
- package/Tasks/IWG/Internal/Functions/runBuildUpdate.d.ts +0 -2
- package/Tasks/IWG/Internal/IWGDimensions.d.ts +0 -6
- package/Tasks/IWG/Internal/IWGTasks.d.ts +0 -34
- package/Tasks/IWG/Internal/IWGTools.d.ts +0 -8
- 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/DataCursor.interface.d.ts +0 -5
- package/Tools/DataCursor.interface.js +0 -2
- package/Util/Binary/BitArray.js +0 -16
- package/World/Structs/WorldDataStructProperties.d.ts +0 -8
- package/World/Structs/WorldDataStructProperties.js +0 -9
- /package/Mesher/Geomtry/{Buffers.d.ts → VoxelMeshBuffers.d.ts} +0 -0
- /package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.d.ts +0 -0
- /package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.js +0 -0
- /package/Mesher/{VoxelShaderData.d.ts → Geomtry/VoxelShaderData.d.ts} +0 -0
- /package/Mesher/{VoxelShaderData.js → Geomtry/VoxelShaderData.js} +0 -0
- /package/{World/Storage/WorldStorage.interface.js → Voxels/Cursor/DataCursor.interface.js} +0 -0
- /package/World/{Storage → Types}/WorldStorage.interface.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.js +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.js +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.d.ts +0 -0
|
@@ -1,340 +1,431 @@
|
|
|
1
|
-
import { StringPalette } from "../../../Util/StringPalette";
|
|
2
|
-
import { NumberPalette } from "../../../Util/NumberPalette";
|
|
3
1
|
import { WorldRegister } from "../../../World/WorldRegister";
|
|
4
|
-
import { convertToPaletteBuffer } from "../../../Util/Binary/Palettes";
|
|
5
2
|
import { SchemaRegister } from "../../../Voxels/State/SchemaRegister";
|
|
6
3
|
import { VoxelPalettesRegister } from "../../../Voxels/Data/VoxelPalettesRegister";
|
|
7
4
|
import { VoxelTagsRegister } from "../../../Voxels/Data/VoxelTagsRegister";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
light: new Uint16Array(section.light.length),
|
|
18
|
-
lightAllTheSame: true,
|
|
19
|
-
isLightPaletted: false,
|
|
20
|
-
remappedLight: false,
|
|
21
|
-
// level
|
|
22
|
-
level: new Uint8Array(section.level.length),
|
|
23
|
-
levelAllTheSame: true,
|
|
24
|
-
isLevelPaletted: false,
|
|
25
|
-
remappedLevel: false,
|
|
26
|
-
// state
|
|
27
|
-
state: new Uint16Array(section.state.length),
|
|
28
|
-
stateAllTheSame: true,
|
|
29
|
-
isStatePaletted: false,
|
|
30
|
-
remappedState: false,
|
|
31
|
-
// mod
|
|
32
|
-
mod: new Uint16Array(section.mod.length),
|
|
33
|
-
modAllTheSame: true,
|
|
34
|
-
isModPaletted: false,
|
|
35
|
-
remappedMod: false,
|
|
36
|
-
// secondary
|
|
37
|
-
secondary: new Uint16Array(section.secondary.length),
|
|
38
|
-
isSecondaryPaletted: false,
|
|
39
|
-
secondaryAllTheSame: true,
|
|
40
|
-
remappedSecondary: false,
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
function getSectionPalettes() {
|
|
44
|
-
return {
|
|
45
|
-
ids: new NumberPalette(),
|
|
46
|
-
level: new NumberPalette(),
|
|
47
|
-
light: new NumberPalette(),
|
|
48
|
-
state: new NumberPalette(),
|
|
49
|
-
mod: new NumberPalette(),
|
|
50
|
-
secondaryId: new NumberPalette(),
|
|
51
|
-
secondaryState: new NumberPalette(),
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function getColumnPalettes() {
|
|
55
|
-
return {
|
|
56
|
-
ids: new StringPalette(),
|
|
57
|
-
level: new NumberPalette(),
|
|
58
|
-
light: new NumberPalette(),
|
|
59
|
-
stateIdMap: [],
|
|
60
|
-
state: new NumberPalette(),
|
|
61
|
-
modIdMap: [],
|
|
62
|
-
mod: new NumberPalette(),
|
|
63
|
-
secondaryId: new StringPalette(),
|
|
64
|
-
secondaryState: new NumberPalette(),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function GetArchivedSection(archiveSection, sectorPalettes) {
|
|
68
|
-
const palettes = {};
|
|
69
|
-
if (archiveSection.remappedIds)
|
|
70
|
-
palettes.id = Uint16Array.from(archiveSection.palettes.ids._palette);
|
|
71
|
-
if (archiveSection.remappedLevel)
|
|
72
|
-
palettes.level = Uint8Array.from(archiveSection.palettes.level._palette);
|
|
73
|
-
if (archiveSection.remappedLight)
|
|
74
|
-
palettes.light = Uint16Array.from(archiveSection.palettes.light._palette);
|
|
75
|
-
if (archiveSection.remappedState)
|
|
76
|
-
palettes.state = Uint16Array.from(archiveSection.palettes.state._palette);
|
|
77
|
-
if (archiveSection.remappedMod)
|
|
78
|
-
palettes.mod = Uint16Array.from(archiveSection.palettes.mod._palette);
|
|
79
|
-
if (archiveSection.remappedSecondary) {
|
|
80
|
-
palettes.secondaryId = Uint16Array.from(archiveSection.palettes.secondaryId._palette);
|
|
81
|
-
palettes.secondaryState = Uint16Array.from(archiveSection.palettes.secondaryState._palette);
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
state: {},
|
|
85
|
-
palettes,
|
|
86
|
-
buffers: {
|
|
87
|
-
id: archiveSection.idsAllTheSame
|
|
88
|
-
? archiveSection.ids[0]
|
|
89
|
-
: convertToPaletteBuffer(archiveSection.remappedIds
|
|
90
|
-
? archiveSection.palettes.ids.size
|
|
91
|
-
: sectorPalettes.ids.size, archiveSection.ids),
|
|
92
|
-
level: archiveSection.isLevelPaletted
|
|
93
|
-
? archiveSection.level[0]
|
|
94
|
-
: archiveSection.isLevelPaletted
|
|
95
|
-
? convertToPaletteBuffer(archiveSection.remappedLevel
|
|
96
|
-
? archiveSection.palettes.level.size
|
|
97
|
-
: sectorPalettes.level.size, archiveSection.level)
|
|
98
|
-
: new Uint8Array(archiveSection.section.level.slice()),
|
|
99
|
-
light: archiveSection.lightAllTheSame
|
|
100
|
-
? archiveSection.light[0]
|
|
101
|
-
: archiveSection.isLightPaletted
|
|
102
|
-
? convertToPaletteBuffer(archiveSection.remappedLight
|
|
103
|
-
? archiveSection.palettes.light.size
|
|
104
|
-
: sectorPalettes.light.size, archiveSection.light)
|
|
105
|
-
: new Uint16Array(archiveSection.section.light.slice()),
|
|
106
|
-
state: archiveSection.stateAllTheSame
|
|
107
|
-
? archiveSection.state[0]
|
|
108
|
-
: archiveSection.isStatePaletted
|
|
109
|
-
? convertToPaletteBuffer(archiveSection.remappedState
|
|
110
|
-
? archiveSection.palettes.state.size
|
|
111
|
-
: sectorPalettes.state.size, archiveSection.state)
|
|
112
|
-
: new Uint16Array(archiveSection.section.state.slice()),
|
|
113
|
-
mod: archiveSection.modAllTheSame
|
|
114
|
-
? archiveSection.mod[0]
|
|
115
|
-
: archiveSection.isModPaletted
|
|
116
|
-
? convertToPaletteBuffer(archiveSection.remappedMod
|
|
117
|
-
? archiveSection.palettes.mod.size
|
|
118
|
-
: sectorPalettes.mod.size, archiveSection.mod)
|
|
119
|
-
: new Uint16Array(archiveSection.section.mod.slice()),
|
|
120
|
-
secondary: archiveSection.secondaryAllTheSame
|
|
121
|
-
? archiveSection.secondary[0]
|
|
122
|
-
: archiveSection.isSecondaryPaletted
|
|
123
|
-
? convertToPaletteBuffer(archiveSection.remappedSecondary
|
|
124
|
-
? Math.max(archiveSection.palettes.secondaryState.size, archiveSection.palettes.secondaryId.size)
|
|
125
|
-
: Math.max(sectorPalettes.secondaryState.size, sectorPalettes.secondaryId.size), archiveSection.secondary)
|
|
126
|
-
: new Uint16Array(archiveSection.secondary),
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
}
|
|
5
|
+
import { VoxelLightData } from "../../../Voxels/Cursor/VoxelLightData";
|
|
6
|
+
import { EngineSettings } from "../../../Settings/EngineSettings";
|
|
7
|
+
import { BinaryBuffer } from "../../../Util/Binary/BinaryBuffer";
|
|
8
|
+
import { lightSegments, lightSemgnetGet } from "./Shared";
|
|
9
|
+
import { ProcessedSection, SectorPalette, VoxelStateObjectMap, } from "../Classes/ArchiveClasses";
|
|
10
|
+
import { CreateArchivedSection } from "./CreateArchivedSection";
|
|
11
|
+
import { RemoveDuplicates } from "./RemoveDuplicates";
|
|
12
|
+
import { NumberPalette } from "../../../Util/NumberPalette";
|
|
13
|
+
const lightData = new VoxelLightData();
|
|
130
14
|
export default function ArchiveSector(archiveData) {
|
|
131
15
|
const sector = WorldRegister.sectors.get(archiveData.location[0], archiveData.location[1], archiveData.location[2], archiveData.location[3]);
|
|
132
16
|
if (!sector)
|
|
133
|
-
throw new Error(`
|
|
134
|
-
const sectorPalettes =
|
|
17
|
+
throw new Error(`Sector at location ${location} does not exist when trying to arhicve it.`);
|
|
18
|
+
const sectorPalettes = new SectorPalette();
|
|
135
19
|
const processedSections = [];
|
|
136
|
-
for (
|
|
20
|
+
for (let sectionIndex = 0; sectionIndex < sector.sections.length; sectionIndex++) {
|
|
21
|
+
const section = sector.sections[sectionIndex];
|
|
22
|
+
const processedSection = new ProcessedSection(section);
|
|
23
|
+
{
|
|
24
|
+
let value = section.buried[0];
|
|
25
|
+
processedSection.isBuriedAllTheSame = true;
|
|
26
|
+
for (let i = 0; i < section.buried.length; i++) {
|
|
27
|
+
if (value != section.buried[i]) {
|
|
28
|
+
processedSection.isBuriedAllTheSame = false;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
processedSection.buriedValue = value;
|
|
33
|
+
}
|
|
34
|
+
{
|
|
35
|
+
let value = section.voxelMap[0];
|
|
36
|
+
processedSection.isVoxelMapAllTheSame = true;
|
|
37
|
+
for (let i = 0; i < section.voxelMap.length; i++) {
|
|
38
|
+
if (value != section.voxelMap[i]) {
|
|
39
|
+
processedSection.isVoxelMapAllTheSame = false;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
processedSection.voxelMapValue = value;
|
|
44
|
+
}
|
|
45
|
+
{
|
|
46
|
+
let value = section.dirtyMap[0];
|
|
47
|
+
processedSection.isDirtyMapAllTheSame = true;
|
|
48
|
+
for (let i = 0; i < section.dirtyMap.length; i++) {
|
|
49
|
+
if (value != section.dirtyMap[i]) {
|
|
50
|
+
processedSection.isDirtyMapAllTheSame = false;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
processedSection.dirtyMapValue = value;
|
|
55
|
+
}
|
|
56
|
+
const firstId = section.ids[0];
|
|
57
|
+
const firstLight = section.light[0];
|
|
58
|
+
const firstLevel = section.level[0];
|
|
59
|
+
const firstState = section.state[0];
|
|
60
|
+
const firstMod = section.mod[0];
|
|
61
|
+
const firstSecondary = section.secondary[0];
|
|
62
|
+
const firstLightLevels = {
|
|
63
|
+
sun: lightData.getS(firstLight),
|
|
64
|
+
red: lightData.getR(firstLight),
|
|
65
|
+
green: lightData.getG(firstLight),
|
|
66
|
+
blue: lightData.getB(firstLight),
|
|
67
|
+
};
|
|
137
68
|
const length = section.ids.length;
|
|
138
|
-
let firstId = -1;
|
|
139
|
-
let firstLight = -1;
|
|
140
|
-
let firstLevel = -1;
|
|
141
|
-
let firstState = -1;
|
|
142
|
-
let firstMod = -1;
|
|
143
|
-
let firstSecondary = -1;
|
|
144
|
-
const processedSection = getProcessedSection(section);
|
|
145
69
|
for (let i = 0; i < length; i++) {
|
|
146
70
|
const stringId = VoxelPalettesRegister.voxels.getStringId(section.ids[i]);
|
|
147
71
|
const voxelId = !sectorPalettes.ids.isRegistered(stringId)
|
|
148
72
|
? sectorPalettes.ids.register(stringId)
|
|
149
73
|
: sectorPalettes.ids.getNumberId(stringId);
|
|
74
|
+
processedSection.ids.value = voxelId;
|
|
150
75
|
if (!processedSection.palettes.ids.isRegistered(voxelId))
|
|
151
76
|
processedSection.palettes.ids.register(voxelId);
|
|
152
|
-
if (firstId == -1)
|
|
153
|
-
firstId = voxelId;
|
|
154
77
|
const secondaryId = VoxelTagsRegister.VoxelTags[section.ids[i]]["dve_can_have_secondary"] &&
|
|
155
78
|
VoxelPalettesRegister.voxels.getStringId(section.secondary[i]);
|
|
156
79
|
const voxelSecondary = secondaryId
|
|
157
80
|
? !sectorPalettes.secondaryId.isRegistered(secondaryId)
|
|
158
81
|
? sectorPalettes.secondaryId.register(secondaryId)
|
|
159
82
|
: sectorPalettes.secondaryId.getNumberId(secondaryId)
|
|
160
|
-
: !sectorPalettes.
|
|
161
|
-
? sectorPalettes.
|
|
162
|
-
: sectorPalettes.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
processedSection.palettes.secondaryId.register(voxelSecondary)
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
83
|
+
: !sectorPalettes.secondaryValue.isRegistered(section.secondary[i])
|
|
84
|
+
? sectorPalettes.secondaryValue.register(section.secondary[i])
|
|
85
|
+
: sectorPalettes.secondaryValue.getId(section.secondary[i]);
|
|
86
|
+
if (VoxelTagsRegister.VoxelTags[section.ids[i]]["dve_can_have_secondary"]) {
|
|
87
|
+
if (!processedSection.palettes.secondaryId.isRegistered(voxelSecondary))
|
|
88
|
+
processedSection.palettes.secondaryId.register(voxelSecondary);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
if (!processedSection.palettes.secondaryValue.isRegistered(voxelSecondary))
|
|
92
|
+
processedSection.palettes.secondaryValue.register(voxelSecondary);
|
|
93
|
+
}
|
|
170
94
|
const voxelLevel = !sectorPalettes.level.isRegistered(section.level[i])
|
|
171
95
|
? sectorPalettes.level.register(section.level[i])
|
|
172
96
|
: sectorPalettes.level.getId(section.level[i]);
|
|
173
97
|
if (!processedSection.palettes.level.isRegistered(section.level[i]))
|
|
174
98
|
processedSection.palettes.level.register(section.level[i]);
|
|
175
|
-
|
|
176
|
-
|
|
99
|
+
let stateMap;
|
|
100
|
+
if (secondaryId) {
|
|
101
|
+
if (!sectorPalettes.secondaryStateMap[voxelSecondary]) {
|
|
102
|
+
stateMap = new VoxelStateObjectMap();
|
|
103
|
+
sectorPalettes.secondaryStateMap[voxelId] = stateMap;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
stateMap = sectorPalettes.secondaryStateMap[voxelSecondary];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
if (!sectorPalettes.stateMap[voxelId]) {
|
|
111
|
+
stateMap = new VoxelStateObjectMap();
|
|
112
|
+
sectorPalettes.stateMap[voxelId] = stateMap;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
stateMap = sectorPalettes.stateMap[voxelId];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
177
118
|
let voxelState = -1;
|
|
178
|
-
if (!
|
|
179
|
-
voxelState =
|
|
180
|
-
sectorPalettes.stateIdMap[voxelState] = secondaryId
|
|
181
|
-
? section.secondary[i]
|
|
182
|
-
: section.ids[i];
|
|
119
|
+
if (!stateMap.palette.isRegistered(section.state[i])) {
|
|
120
|
+
voxelState = stateMap.palette.register(section.state[i]);
|
|
183
121
|
}
|
|
184
122
|
else {
|
|
185
|
-
voxelState =
|
|
123
|
+
voxelState = stateMap.palette.getId(section.state[i]);
|
|
124
|
+
}
|
|
125
|
+
if (!processedSection.palettes.state[voxelId]) {
|
|
126
|
+
processedSection.palettes.state[voxelId] = new NumberPalette();
|
|
127
|
+
}
|
|
128
|
+
if (!processedSection.palettes.state[voxelId].isRegistered(voxelState))
|
|
129
|
+
processedSection.palettes.state[voxelId].register(voxelState);
|
|
130
|
+
let modMap;
|
|
131
|
+
if (secondaryId) {
|
|
132
|
+
if (!sectorPalettes.secondaryModMap[voxelSecondary]) {
|
|
133
|
+
modMap = new VoxelStateObjectMap();
|
|
134
|
+
sectorPalettes.secondaryModMap[voxelSecondary] = modMap;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
modMap = sectorPalettes.secondaryModMap[voxelSecondary];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
if (!sectorPalettes.modMap[voxelId]) {
|
|
142
|
+
modMap = new VoxelStateObjectMap();
|
|
143
|
+
sectorPalettes.modMap[voxelSecondary] = modMap;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
modMap = sectorPalettes.modMap[voxelId];
|
|
147
|
+
}
|
|
186
148
|
}
|
|
187
|
-
if (!processedSection.palettes.state.isRegistered(voxelState))
|
|
188
|
-
processedSection.palettes.state.register(voxelState);
|
|
189
|
-
if (firstState == -1)
|
|
190
|
-
firstState = voxelState;
|
|
191
149
|
let voxelMod = -1;
|
|
192
|
-
if (!
|
|
193
|
-
voxelMod =
|
|
194
|
-
sectorPalettes.stateIdMap[voxelMod] = secondaryId
|
|
195
|
-
? section.secondary[i]
|
|
196
|
-
: section.ids[i];
|
|
150
|
+
if (!modMap.palette.isRegistered(section.mod[i])) {
|
|
151
|
+
voxelMod = modMap.palette.register(section.mod[i]);
|
|
197
152
|
}
|
|
198
153
|
else {
|
|
199
|
-
voxelMod =
|
|
154
|
+
voxelMod = modMap.palette.getId(section.mod[i]);
|
|
155
|
+
}
|
|
156
|
+
if (!processedSection.palettes.mod[voxelId]) {
|
|
157
|
+
processedSection.palettes.mod[voxelId] = new NumberPalette();
|
|
200
158
|
}
|
|
201
|
-
if (!processedSection.palettes.mod.isRegistered(voxelMod))
|
|
202
|
-
processedSection.palettes.mod.register(voxelMod);
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
if (
|
|
217
|
-
processedSection.
|
|
218
|
-
if (
|
|
219
|
-
processedSection.
|
|
220
|
-
if (
|
|
221
|
-
processedSection.
|
|
222
|
-
if (
|
|
223
|
-
processedSection.
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
processedSection.
|
|
227
|
-
processedSection.
|
|
228
|
-
processedSection.
|
|
229
|
-
processedSection.
|
|
159
|
+
if (!processedSection.palettes.mod[voxelId].isRegistered(voxelMod))
|
|
160
|
+
processedSection.palettes.mod[voxelId].register(voxelMod);
|
|
161
|
+
for (let l = 0; l < lightSegments.length; l++) {
|
|
162
|
+
const segment = lightSegments[l];
|
|
163
|
+
const light = lightSemgnetGet[segment](section.light[i]);
|
|
164
|
+
if (light != firstLightLevels[segment])
|
|
165
|
+
processedSection.light[segment].allTheSame = false;
|
|
166
|
+
processedSection.light[segment].value = light;
|
|
167
|
+
const voxelLight = !sectorPalettes.light[segment].isRegistered(light)
|
|
168
|
+
? sectorPalettes.light[segment].register(light)
|
|
169
|
+
: sectorPalettes.light[segment].getId(light);
|
|
170
|
+
if (!processedSection.palettes.light[segment].isRegistered(light))
|
|
171
|
+
processedSection.palettes.light[segment].register(light);
|
|
172
|
+
processedSection.light[segment].buffer[i] = voxelLight;
|
|
173
|
+
}
|
|
174
|
+
if (section.ids[i] != firstId)
|
|
175
|
+
processedSection.ids.allTheSame = false;
|
|
176
|
+
if (section.level[i] != firstLevel)
|
|
177
|
+
processedSection.level.allTheSame = false;
|
|
178
|
+
if (section.state[i] != firstState)
|
|
179
|
+
processedSection.state.allTheSame = false;
|
|
180
|
+
if (section.mod[i] != firstMod)
|
|
181
|
+
processedSection.mod.allTheSame = false;
|
|
182
|
+
if (section.secondary[i] != firstSecondary)
|
|
183
|
+
processedSection.secondary.allTheSame = false;
|
|
184
|
+
processedSection.ids.buffer[i] = voxelId;
|
|
185
|
+
processedSection.level.buffer[i] = voxelLevel;
|
|
186
|
+
processedSection.state.buffer[i] = voxelState;
|
|
187
|
+
processedSection.mod.buffer[i] = voxelMod;
|
|
188
|
+
processedSection.secondary.buffer[i] = voxelSecondary;
|
|
230
189
|
}
|
|
231
|
-
processedSections
|
|
190
|
+
processedSections[sectionIndex] = processedSection;
|
|
191
|
+
}
|
|
192
|
+
let neededPalettes = {
|
|
193
|
+
level: false,
|
|
194
|
+
light: {
|
|
195
|
+
sun: false,
|
|
196
|
+
red: false,
|
|
197
|
+
green: false,
|
|
198
|
+
blue: false,
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
for (const state of sectorPalettes.stateMap) {
|
|
202
|
+
if (!state)
|
|
203
|
+
continue;
|
|
204
|
+
if (state.palette.size > sectorPalettes.maxStatePaletteSize)
|
|
205
|
+
sectorPalettes.maxStatePaletteSize = state.palette.size;
|
|
232
206
|
}
|
|
233
|
-
for (const
|
|
234
|
-
|
|
235
|
-
section.palettes.ids.size <= 255 &&
|
|
236
|
-
!section.idsAllTheSame;
|
|
237
|
-
const reMapLevel = section.palettes.level.size < sectorPalettes.level.size &&
|
|
238
|
-
section.palettes.level.size <= 255 &&
|
|
239
|
-
!section.levelAllTheSame;
|
|
240
|
-
const reMapState = section.palettes.state.size < sectorPalettes.state.size &&
|
|
241
|
-
section.palettes.state.size <= 255 &&
|
|
242
|
-
!section.stateAllTheSame;
|
|
243
|
-
const reMapMod = section.palettes.mod.size < sectorPalettes.mod.size &&
|
|
244
|
-
section.palettes.mod.size <= 255 &&
|
|
245
|
-
!section.modAllTheSame;
|
|
246
|
-
const reMapLight = section.palettes.light.size < sectorPalettes.light.size &&
|
|
247
|
-
section.palettes.light.size <= 255 &&
|
|
248
|
-
!section.lightAllTheSame;
|
|
249
|
-
const reMapSecondary = Math.max(section.palettes.secondaryId.size, section.palettes.secondaryState.size) <
|
|
250
|
-
Math.max(sectorPalettes.secondaryState.size, sectorPalettes.secondaryId.size) &&
|
|
251
|
-
Math.max(section.palettes.secondaryId.size, section.palettes.secondaryState.size) <= 255 &&
|
|
252
|
-
!section.secondaryAllTheSame;
|
|
253
|
-
section.isLightPaletted =
|
|
254
|
-
sectorPalettes.light.size < 65_535 && section.palettes.light.size < 255;
|
|
255
|
-
section.isLevelPaletted =
|
|
256
|
-
sectorPalettes.level.size < 255 && section.palettes.level.size < 255;
|
|
257
|
-
section.isStatePaletted =
|
|
258
|
-
sectorPalettes.state.size < 65_535 && section.palettes.state.size < 255;
|
|
259
|
-
section.isModPaletted =
|
|
260
|
-
sectorPalettes.mod.size < 65_535 && section.palettes.mod.size < 255;
|
|
261
|
-
section.isSecondaryPaletted =
|
|
262
|
-
sectorPalettes.secondaryState.size < 65_535 &&
|
|
263
|
-
section.palettes.secondaryState.size < 255 &&
|
|
264
|
-
section.palettes.secondaryId.size < 255;
|
|
265
|
-
section.remappedIds = reMapIds;
|
|
266
|
-
section.remappedLight = reMapLight && section.isLightPaletted;
|
|
267
|
-
section.remappedState = reMapState && section.isStatePaletted;
|
|
268
|
-
section.remappedMod = reMapMod && section.isModPaletted;
|
|
269
|
-
section.remappedSecondary = reMapSecondary && section.isSecondaryPaletted;
|
|
270
|
-
if (!reMapIds && !reMapLight && !reMapSecondary && !reMapState)
|
|
207
|
+
for (const mod of sectorPalettes.modMap) {
|
|
208
|
+
if (!mod)
|
|
271
209
|
continue;
|
|
272
|
-
|
|
210
|
+
if (mod.palette.size > sectorPalettes.maxModPaletteSize)
|
|
211
|
+
sectorPalettes.maxModPaletteSize = mod.palette.size;
|
|
212
|
+
}
|
|
213
|
+
for (const archivedSection of processedSections) {
|
|
214
|
+
for (const stateId in archivedSection.palettes.state) {
|
|
215
|
+
const state = archivedSection.palettes.state[stateId];
|
|
216
|
+
if (!state)
|
|
217
|
+
continue;
|
|
218
|
+
if (state.size > archivedSection.palettes.maxStatePaletteSize)
|
|
219
|
+
archivedSection.palettes.maxStatePaletteSize = state.size;
|
|
220
|
+
}
|
|
221
|
+
for (const modId in archivedSection.palettes.mod) {
|
|
222
|
+
const mod = archivedSection.palettes.state[modId];
|
|
223
|
+
if (!mod)
|
|
224
|
+
continue;
|
|
225
|
+
if (mod.size > archivedSection.palettes.maxModPaletteSize)
|
|
226
|
+
archivedSection.palettes.maxModPaletteSize = mod.size;
|
|
227
|
+
}
|
|
228
|
+
//ids
|
|
229
|
+
archivedSection.ids.isPaletted =
|
|
230
|
+
sectorPalettes.ids.size <= BinaryBuffer.ByteArrayMax ||
|
|
231
|
+
archivedSection.palettes.ids.size <= BinaryBuffer.ByteArrayMax;
|
|
232
|
+
archivedSection.ids.remapped =
|
|
233
|
+
sectorPalettes.ids.size > BinaryBuffer.ByteArrayMax &&
|
|
234
|
+
archivedSection.palettes.ids.size <= BinaryBuffer.ByteArrayMax &&
|
|
235
|
+
!archivedSection.ids.allTheSame;
|
|
236
|
+
//level
|
|
237
|
+
archivedSection.level.isPaletted =
|
|
238
|
+
sectorPalettes.level.size <= BinaryBuffer.NibbleArrayMax &&
|
|
239
|
+
archivedSection.palettes.level.size <= BinaryBuffer.NibbleArrayMax;
|
|
240
|
+
archivedSection.level.remapped =
|
|
241
|
+
sectorPalettes.level.size > BinaryBuffer.NibbleArrayMax &&
|
|
242
|
+
archivedSection.palettes.level.size <= BinaryBuffer.NibbleArrayMax &&
|
|
243
|
+
!archivedSection.level.allTheSame;
|
|
244
|
+
if (archivedSection.level.isPaletted && !archivedSection.level.remapped) {
|
|
245
|
+
neededPalettes.level = true;
|
|
246
|
+
}
|
|
247
|
+
//state
|
|
248
|
+
archivedSection.state.isPaletted =
|
|
249
|
+
sectorPalettes.maxStatePaletteSize <= BinaryBuffer.ByteArrayMax ||
|
|
250
|
+
archivedSection.palettes.maxStatePaletteSize <= BinaryBuffer.ByteArrayMax;
|
|
251
|
+
archivedSection.state.remapped =
|
|
252
|
+
sectorPalettes.maxStatePaletteSize > BinaryBuffer.ByteArrayMax &&
|
|
253
|
+
archivedSection.palettes.maxStatePaletteSize <=
|
|
254
|
+
BinaryBuffer.ByteArrayMax &&
|
|
255
|
+
!archivedSection.state.allTheSame;
|
|
256
|
+
//mod
|
|
257
|
+
archivedSection.mod.isPaletted =
|
|
258
|
+
sectorPalettes.maxModPaletteSize <= BinaryBuffer.ByteArrayMax ||
|
|
259
|
+
archivedSection.palettes.maxModPaletteSize <= BinaryBuffer.ByteArrayMax;
|
|
260
|
+
archivedSection.mod.remapped =
|
|
261
|
+
sectorPalettes.maxModPaletteSize > BinaryBuffer.ByteArrayMax &&
|
|
262
|
+
archivedSection.palettes.maxModPaletteSize <= BinaryBuffer.ByteArrayMax &&
|
|
263
|
+
!archivedSection.mod.allTheSame;
|
|
264
|
+
for (const semgnet of lightSegments) {
|
|
265
|
+
archivedSection.light[semgnet].isPaletted =
|
|
266
|
+
sectorPalettes.light[semgnet].size <= BinaryBuffer.HalfNibbleArrayMax ||
|
|
267
|
+
archivedSection.palettes.light[semgnet].size <=
|
|
268
|
+
BinaryBuffer.HalfNibbleArrayMax;
|
|
269
|
+
archivedSection.light[semgnet].remapped =
|
|
270
|
+
sectorPalettes.light[semgnet].size > BinaryBuffer.HalfNibbleArrayMax &&
|
|
271
|
+
archivedSection.palettes.light[semgnet].size <=
|
|
272
|
+
BinaryBuffer.HalfNibbleArrayMax &&
|
|
273
|
+
!archivedSection.light[semgnet].allTheSame;
|
|
274
|
+
if (archivedSection.light[semgnet].isPaletted &&
|
|
275
|
+
!archivedSection.light[semgnet].remapped) {
|
|
276
|
+
neededPalettes.light[semgnet] = true;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
//secondary
|
|
280
|
+
archivedSection.secondary.isPaletted =
|
|
281
|
+
(sectorPalettes.secondaryValue.size <= BinaryBuffer.ByteArrayMax &&
|
|
282
|
+
sectorPalettes.secondaryId.size <= BinaryBuffer.ByteArrayMax) ||
|
|
283
|
+
(archivedSection.palettes.secondaryValue.size <=
|
|
284
|
+
BinaryBuffer.ByteArrayMax &&
|
|
285
|
+
archivedSection.palettes.secondaryId.size <= BinaryBuffer.ByteArrayMax);
|
|
286
|
+
archivedSection.secondary.remapped =
|
|
287
|
+
Math.max(sectorPalettes.secondaryValue.size, sectorPalettes.secondaryId.size) > BinaryBuffer.ByteArrayMax &&
|
|
288
|
+
Math.max(archivedSection.palettes.secondaryId.size, archivedSection.palettes.secondaryValue.size) <= BinaryBuffer.ByteArrayMax &&
|
|
289
|
+
!archivedSection.secondary.allTheSame;
|
|
290
|
+
if (!archivedSection.ids.remapped &&
|
|
291
|
+
!archivedSection.light.sun.remapped &&
|
|
292
|
+
!archivedSection.light.red.remapped &&
|
|
293
|
+
!archivedSection.light.green.remapped &&
|
|
294
|
+
!archivedSection.light.blue.remapped &&
|
|
295
|
+
!archivedSection.secondary.remapped &&
|
|
296
|
+
!archivedSection.mod.remapped &&
|
|
297
|
+
!archivedSection.level.remapped)
|
|
298
|
+
continue;
|
|
299
|
+
const length = archivedSection.original.ids.length;
|
|
273
300
|
for (let i = 0; i < length; i++) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
if (
|
|
283
|
-
|
|
284
|
-
if (
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
301
|
+
let secondary = false;
|
|
302
|
+
if (VoxelTagsRegister.VoxelTags[archivedSection.original.ids[i]]["dve_can_have_secondary"] &&
|
|
303
|
+
archivedSection.original.secondary[i] !== 0) {
|
|
304
|
+
secondary = true;
|
|
305
|
+
}
|
|
306
|
+
let stateId = !secondary
|
|
307
|
+
? archivedSection.ids.buffer[i]
|
|
308
|
+
: archivedSection.secondary.buffer[i];
|
|
309
|
+
if (archivedSection.state.remapped)
|
|
310
|
+
archivedSection.state.buffer[i] = archivedSection.palettes.state[stateId].getId(sectorPalettes.stateMap[stateId].palette.getId(archivedSection.state.buffer[i]));
|
|
311
|
+
if (archivedSection.mod.remapped)
|
|
312
|
+
archivedSection.mod.buffer[i] = archivedSection.palettes.mod[stateId].getId(sectorPalettes.modMap[archivedSection.ids.buffer[i]].palette.getId(stateId));
|
|
313
|
+
if (archivedSection.ids.remapped)
|
|
314
|
+
archivedSection.ids.buffer[i] =
|
|
315
|
+
archivedSection.palettes.ids.getId(stateId);
|
|
316
|
+
for (let l = 0; l < lightSegments.length; l++) {
|
|
317
|
+
const segment = lightSegments[l];
|
|
318
|
+
if (archivedSection.light[segment].remapped) {
|
|
319
|
+
archivedSection.light[segment].buffer[i] =
|
|
320
|
+
archivedSection.palettes.light[segment].getId(lightSemgnetGet[segment](archivedSection.original.light[i]));
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (archivedSection.level.remapped)
|
|
324
|
+
archivedSection.level.buffer[i] = archivedSection.palettes.level.getId(archivedSection.original.level[i]);
|
|
325
|
+
if (archivedSection.secondary.remapped)
|
|
326
|
+
archivedSection.secondary.buffer[i] = secondary
|
|
327
|
+
? archivedSection.palettes.secondaryId.getId(archivedSection.secondary.buffer[i])
|
|
328
|
+
: archivedSection.palettes.secondaryValue.getId(archivedSection.secondary.buffer[i]);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
const palettes = {
|
|
332
|
+
id: sectorPalettes.ids._palette,
|
|
333
|
+
stateMap: [],
|
|
334
|
+
secondaryStateMap: [],
|
|
335
|
+
modMap: [],
|
|
336
|
+
secondaryModMap: [],
|
|
337
|
+
light: {},
|
|
338
|
+
secondaryId: sectorPalettes.secondaryId._palette,
|
|
339
|
+
secondaryValue: new Uint16Array(sectorPalettes.secondaryValue._palette),
|
|
340
|
+
};
|
|
341
|
+
const stateMap = palettes.stateMap;
|
|
342
|
+
for (let i = 0; i < sectorPalettes.stateMap.length; i++) {
|
|
343
|
+
const states = sectorPalettes.stateMap[i]?.palette;
|
|
344
|
+
if (!states)
|
|
345
|
+
continue;
|
|
346
|
+
const voxelId = sectorPalettes.ids._palette[i];
|
|
347
|
+
if (!SchemaRegister.hasVoxelSchema(voxelId))
|
|
348
|
+
continue;
|
|
349
|
+
const schema = SchemaRegister.getVoxelSchemas(voxelId);
|
|
350
|
+
const voxelStates = [];
|
|
351
|
+
stateMap[i] = voxelStates;
|
|
352
|
+
for (let k = 0; k < states._palette.length; k++) {
|
|
353
|
+
voxelStates[k] = schema.state.getStateObject(states._palette[k]);
|
|
288
354
|
}
|
|
289
355
|
}
|
|
290
|
-
const
|
|
291
|
-
for (let i = 0; i < sectorPalettes.
|
|
292
|
-
const
|
|
293
|
-
|
|
356
|
+
const secondaryStateMap = palettes.secondaryStateMap;
|
|
357
|
+
for (let i = 0; i < sectorPalettes.secondaryStateMap.length; i++) {
|
|
358
|
+
const states = sectorPalettes.secondaryStateMap[i]?.palette;
|
|
359
|
+
if (!states)
|
|
360
|
+
continue;
|
|
361
|
+
const voxelId = sectorPalettes.secondaryId._palette[i];
|
|
294
362
|
if (!SchemaRegister.hasVoxelSchema(voxelId))
|
|
295
363
|
continue;
|
|
296
364
|
const schema = SchemaRegister.getVoxelSchemas(voxelId);
|
|
297
|
-
|
|
365
|
+
const voxelStates = [];
|
|
366
|
+
secondaryStateMap[i] = voxelStates;
|
|
367
|
+
for (let k = 0; k < states._palette.length; k++) {
|
|
368
|
+
voxelStates[k] = schema.state.getStateObject(states._palette[k]);
|
|
369
|
+
}
|
|
298
370
|
}
|
|
299
|
-
const modMap =
|
|
300
|
-
for (let i = 0; i < sectorPalettes.
|
|
301
|
-
const
|
|
302
|
-
|
|
371
|
+
const modMap = palettes.modMap;
|
|
372
|
+
for (let i = 0; i < sectorPalettes.modMap.length; i++) {
|
|
373
|
+
const mods = sectorPalettes.modMap[i]?.palette;
|
|
374
|
+
if (!mods)
|
|
375
|
+
continue;
|
|
376
|
+
const voxelId = sectorPalettes.ids._palette[i];
|
|
303
377
|
if (!SchemaRegister.hasVoxelSchema(voxelId))
|
|
304
378
|
continue;
|
|
305
379
|
const schema = SchemaRegister.getVoxelSchemas(voxelId);
|
|
306
|
-
|
|
380
|
+
const voxelMods = [];
|
|
381
|
+
modMap[i] = voxelMods;
|
|
382
|
+
for (let k = 0; k < mods._palette.length; k++) {
|
|
383
|
+
voxelMods[k] = schema.mod.getStateObject(mods._palette[k]);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
const secondaryModMap = palettes.modMap;
|
|
387
|
+
for (let i = 0; i < sectorPalettes.secondaryModMap.length; i++) {
|
|
388
|
+
const mods = sectorPalettes.secondaryModMap[i]?.palette;
|
|
389
|
+
if (!mods)
|
|
390
|
+
continue;
|
|
391
|
+
const voxelId = sectorPalettes.secondaryId._palette[i];
|
|
392
|
+
if (!SchemaRegister.hasVoxelSchema(voxelId))
|
|
393
|
+
continue;
|
|
394
|
+
const schema = SchemaRegister.getVoxelSchemas(voxelId);
|
|
395
|
+
const voxelMods = [];
|
|
396
|
+
secondaryModMap[i] = voxelMods;
|
|
397
|
+
for (let k = 0; k < mods._palette.length; k++) {
|
|
398
|
+
voxelMods[k] = schema.mod.getStateObject(mods._palette[k]);
|
|
399
|
+
}
|
|
307
400
|
}
|
|
308
401
|
const sections = [];
|
|
309
|
-
for (
|
|
310
|
-
sections
|
|
402
|
+
for (let sectionIndex = 0; sectionIndex < processedSections.length; sectionIndex++) {
|
|
403
|
+
sections[sectionIndex] = CreateArchivedSection(processedSections[sectionIndex], sectorPalettes);
|
|
311
404
|
}
|
|
312
|
-
|
|
313
|
-
id: sectorPalettes.ids._palette,
|
|
314
|
-
stateMap,
|
|
315
|
-
modMap,
|
|
316
|
-
state: new Uint16Array(sectorPalettes.state._palette),
|
|
317
|
-
mod: new Uint16Array(sectorPalettes.mod._palette),
|
|
318
|
-
};
|
|
319
|
-
if (sectorPalettes.light.size < 255)
|
|
320
|
-
palettes.light = new Uint16Array(sectorPalettes.light._palette);
|
|
321
|
-
if (sectorPalettes.level.size < 255)
|
|
405
|
+
if (neededPalettes.level) {
|
|
322
406
|
palettes.level = new Uint8Array(sectorPalettes.level._palette);
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
407
|
+
}
|
|
408
|
+
for (const segment of lightSegments) {
|
|
409
|
+
if (neededPalettes.light[segment]) {
|
|
410
|
+
palettes.light[segment] = new Uint8Array(sectorPalettes.light[segment]._palette);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
const archivedSector = {
|
|
330
414
|
version: "",
|
|
331
|
-
|
|
332
|
-
|
|
415
|
+
vloxVersion: EngineSettings.version,
|
|
416
|
+
dimension: WorldRegister.dimensions.get(archiveData.location[0]).id,
|
|
417
|
+
location: [
|
|
418
|
+
archiveData.location[1],
|
|
419
|
+
archiveData.location[2],
|
|
420
|
+
archiveData.location[3],
|
|
421
|
+
],
|
|
422
|
+
flags: sector.storeFlags(),
|
|
423
|
+
timestamps: sector.storeTimestamps(),
|
|
333
424
|
buffers: {},
|
|
334
|
-
keys: {
|
|
335
|
-
sectionState: [],
|
|
336
|
-
},
|
|
337
425
|
palettes,
|
|
426
|
+
duplicates: {},
|
|
338
427
|
sections,
|
|
339
428
|
};
|
|
429
|
+
RemoveDuplicates(archivedSector);
|
|
430
|
+
return archivedSector;
|
|
340
431
|
}
|