@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
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A class to help with indexing a full flat binary tree defined by the number of levels it has.
|
|
3
|
+
*/
|
|
4
|
+
export class FlatBinaryTreeIndex {
|
|
5
|
+
levels;
|
|
6
|
+
constructor(levels) {
|
|
7
|
+
this.levels = levels;
|
|
8
|
+
}
|
|
9
|
+
/** Gets the number of nodes at a level of the tree */
|
|
10
|
+
getLevelSize(level) {
|
|
11
|
+
if (level < 0 || level >= this.levels) {
|
|
12
|
+
throw new Error("Invalid level");
|
|
13
|
+
}
|
|
14
|
+
return 1 << level; // Equivalent to 2^level
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Gets the flat index of a node indexed by the level it's on and its relative index in that level.
|
|
18
|
+
*/
|
|
19
|
+
getIndexAtLevel(level, node) {
|
|
20
|
+
if (level < 0 || level >= this.levels) {
|
|
21
|
+
throw new Error("Invalid level");
|
|
22
|
+
}
|
|
23
|
+
const levelSize = this.getLevelSize(level);
|
|
24
|
+
if (node < 0 || node >= levelSize) {
|
|
25
|
+
throw new Error("Invalid node index at the given level");
|
|
26
|
+
}
|
|
27
|
+
return (1 << level) - 1 + node;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Gets the level and relative index of a node's flat index.
|
|
31
|
+
*/
|
|
32
|
+
getLevelAndIndex(index) {
|
|
33
|
+
const totalNodes = (1 << this.levels) - 1;
|
|
34
|
+
if (index < 0 || index >= totalNodes) {
|
|
35
|
+
throw new Error("Invalid node index");
|
|
36
|
+
}
|
|
37
|
+
const level = Math.floor(Math.log2(index + 1));
|
|
38
|
+
const firstIndexAtLevel = (1 << level) - 1;
|
|
39
|
+
const relativeIndex = index - firstIndexAtLevel;
|
|
40
|
+
return [level, relativeIndex];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Gets the flat left child of a node, where the node is indexed by its level and its relative index at that level.
|
|
44
|
+
* @returns -1 if no child exist
|
|
45
|
+
*/
|
|
46
|
+
getLeftChildAtLevel(level, node) {
|
|
47
|
+
if (level + 1 >= this.levels) {
|
|
48
|
+
return -1;
|
|
49
|
+
}
|
|
50
|
+
const nodeIndex = this.getIndexAtLevel(level, node);
|
|
51
|
+
return this.getLeftChild(nodeIndex);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Gets the flat right child of a node, where the node is indexed by its level and its relative index at that level.
|
|
55
|
+
* @returns -1 if no child exist
|
|
56
|
+
*/
|
|
57
|
+
getRightChildAtLevel(level, node) {
|
|
58
|
+
if (level + 1 >= this.levels) {
|
|
59
|
+
return -1;
|
|
60
|
+
}
|
|
61
|
+
const nodeIndex = this.getIndexAtLevel(level, node);
|
|
62
|
+
return this.getRightChild(nodeIndex);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Gets the flat index of the parent of a node, where the node is indexed by its level and its relative index at that level.
|
|
66
|
+
* @returns -1 if level has no parent
|
|
67
|
+
*/
|
|
68
|
+
getParentAtLevel(level, node) {
|
|
69
|
+
if (level === 0) {
|
|
70
|
+
return -1;
|
|
71
|
+
}
|
|
72
|
+
const nodeIndex = this.getIndexAtLevel(level, node);
|
|
73
|
+
return this.getParent(nodeIndex);
|
|
74
|
+
}
|
|
75
|
+
/** Gets the flat index of the left child of the node.
|
|
76
|
+
* @returns -1 if no child exist
|
|
77
|
+
*/
|
|
78
|
+
getLeftChild(node) {
|
|
79
|
+
const leftChildIndex = 2 * node + 1;
|
|
80
|
+
const totalNodes = (1 << this.levels) - 1;
|
|
81
|
+
return leftChildIndex < totalNodes ? leftChildIndex : -1;
|
|
82
|
+
}
|
|
83
|
+
/** Gets the flat index of the right child of the node.
|
|
84
|
+
* @returns -1 if no child exist
|
|
85
|
+
*/
|
|
86
|
+
getRightChild(node) {
|
|
87
|
+
const rightChildIndex = 2 * node + 2;
|
|
88
|
+
const totalNodes = (1 << this.levels) - 1;
|
|
89
|
+
return rightChildIndex < totalNodes ? rightChildIndex : -1;
|
|
90
|
+
}
|
|
91
|
+
/** Gets the flat index of the parent of the node.
|
|
92
|
+
* @returns -1 if no parent exist
|
|
93
|
+
*/
|
|
94
|
+
getParent(node) {
|
|
95
|
+
if (node === 0) {
|
|
96
|
+
return -1; // Root node has no parent
|
|
97
|
+
}
|
|
98
|
+
return Math.floor((node - 1) / 2);
|
|
99
|
+
}
|
|
100
|
+
/** Gets the total number of nodes in the tree */
|
|
101
|
+
getTotalSize() {
|
|
102
|
+
return (1 << this.levels) - 1; // Equivalent to 2^levels - 1
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -21,7 +21,7 @@ export declare abstract class VoxelCursorInterface {
|
|
|
21
21
|
abstract mod: WritableArrayLike<number>;
|
|
22
22
|
/**
|
|
23
23
|
*
|
|
24
|
-
* @param mode 0 for add 1 for remove 2 for the voxel needs a buried check only
|
|
24
|
+
* @param mode 0 for add 1 for remove 2 for the voxel needs a buried and logic check only
|
|
25
25
|
*/
|
|
26
26
|
abstract updateVoxel(mode: 0 | 1 | 2): void;
|
|
27
27
|
_lightData: VoxelLightData;
|
|
@@ -49,8 +49,13 @@ export declare abstract class VoxelCursorInterface {
|
|
|
49
49
|
hasSunLight(): boolean;
|
|
50
50
|
getLight(): number;
|
|
51
51
|
setLight(light: number): this;
|
|
52
|
-
isLightSource():
|
|
52
|
+
isLightSource(): any;
|
|
53
|
+
doesVoxelAffectLogic(): boolean;
|
|
53
54
|
getLightSourceValue(): number;
|
|
55
|
+
getPower(): number;
|
|
56
|
+
setPower(level: number): this;
|
|
57
|
+
isPowerSource(): boolean;
|
|
58
|
+
getPowerSourceValue(): number;
|
|
54
59
|
noAO(): boolean;
|
|
55
60
|
isRenderable(): boolean;
|
|
56
61
|
isAir(): boolean;
|
|
@@ -59,7 +64,7 @@ export declare abstract class VoxelCursorInterface {
|
|
|
59
64
|
setId(id: number): this;
|
|
60
65
|
setStringId(id: string): this;
|
|
61
66
|
getStringId(): string;
|
|
62
|
-
setName(name: string):
|
|
67
|
+
setName(name: string): this;
|
|
63
68
|
getName(): string;
|
|
64
69
|
isSameVoxel(voxel: VoxelCursorInterface): boolean;
|
|
65
70
|
copy(cursor: VoxelCursorInterface): this;
|
|
@@ -4,12 +4,13 @@ import { VoxelTagStates } from "../Data/VoxelTagStates";
|
|
|
4
4
|
import { VoxelTagIds, } from "../../Voxels/Data/VoxelTag.types";
|
|
5
5
|
import { VoxelTagsRegister } from "../../Voxels/Data/VoxelTagsRegister";
|
|
6
6
|
import { VoxelPalettesRegister } from "../../Voxels/Data/VoxelPalettesRegister";
|
|
7
|
+
import { VoxelLogicRegister } from "../../Voxels/Logic/VoxelLogicRegister";
|
|
7
8
|
export class VoxelCursorInterface {
|
|
8
9
|
_loadedId = 0;
|
|
9
10
|
id = 0;
|
|
10
11
|
secondaryId = 0;
|
|
11
|
-
_tags;
|
|
12
|
-
_substanceTags;
|
|
12
|
+
_tags = {};
|
|
13
|
+
_substanceTags = {};
|
|
13
14
|
__secondary = false;
|
|
14
15
|
// private _section: Section;
|
|
15
16
|
_index = 0;
|
|
@@ -54,7 +55,7 @@ export class VoxelCursorInterface {
|
|
|
54
55
|
return this._substanceTags;
|
|
55
56
|
}
|
|
56
57
|
isOpaque() {
|
|
57
|
-
return this._tags[VoxelTagIds.isTransparent];
|
|
58
|
+
return !this._tags[VoxelTagIds.isTransparent];
|
|
58
59
|
}
|
|
59
60
|
getMod() {
|
|
60
61
|
return this.mod[this._index];
|
|
@@ -105,17 +106,14 @@ export class VoxelCursorInterface {
|
|
|
105
106
|
getLight() {
|
|
106
107
|
if (this._loadedId == 0)
|
|
107
108
|
return this.light[this._index];
|
|
108
|
-
const lightValue = this._tags[VoxelTagIds.lightValue];
|
|
109
109
|
if (this.isOpaque()) {
|
|
110
|
-
if (this.isLightSource()
|
|
111
|
-
return lightValue;
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
return -1;
|
|
110
|
+
if (this.isLightSource()) {
|
|
111
|
+
return this._tags[VoxelTagIds.lightValue];
|
|
115
112
|
}
|
|
113
|
+
return -1;
|
|
116
114
|
}
|
|
117
|
-
if (this.isLightSource()
|
|
118
|
-
return this._lightData.mixLight(this.light[this._index], lightValue);
|
|
115
|
+
if (this.isLightSource()) {
|
|
116
|
+
return this._lightData.mixLight(this.light[this._index], this._tags[VoxelTagIds.lightValue]);
|
|
119
117
|
}
|
|
120
118
|
return this.light[this._index];
|
|
121
119
|
}
|
|
@@ -126,15 +124,58 @@ export class VoxelCursorInterface {
|
|
|
126
124
|
isLightSource() {
|
|
127
125
|
if (this._loadedId <= 0)
|
|
128
126
|
return false;
|
|
127
|
+
if (VoxelLogicRegister.voxels[this._loadedId]?.hasTag(VoxelTagIds.isLightSource)) {
|
|
128
|
+
return VoxelLogicRegister.voxels[this._loadedId].getTagValue(VoxelTagIds.isLightSource, this);
|
|
129
|
+
}
|
|
129
130
|
return VoxelTagStates.isRegistered(this._loadedId, VoxelTagIds.isLightSource)
|
|
130
131
|
? VoxelTagStates.getValue(this._loadedId, VoxelTagIds.isLightSource, this.getState()) === true
|
|
131
132
|
: this._tags[VoxelTagIds.isLightSource];
|
|
132
133
|
}
|
|
134
|
+
doesVoxelAffectLogic() {
|
|
135
|
+
if (this._tags["dve_can_be_powered"] ||
|
|
136
|
+
this._tags["dve_can_hold_power"] ||
|
|
137
|
+
this._tags["dve_can_carry_power"] ||
|
|
138
|
+
this._tags["dve_is_power_source"])
|
|
139
|
+
return true;
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
133
142
|
getLightSourceValue() {
|
|
134
143
|
if (this._loadedId <= 0)
|
|
135
144
|
return 0;
|
|
136
145
|
return this._tags[VoxelTagIds.lightValue];
|
|
137
146
|
}
|
|
147
|
+
getPower() {
|
|
148
|
+
if (this._loadedId == 0)
|
|
149
|
+
return -1;
|
|
150
|
+
if (this._substanceTags["dve_is_liquid"])
|
|
151
|
+
return -1;
|
|
152
|
+
if (!this._tags["dve_can_carry_power"] &&
|
|
153
|
+
!this._tags["dve_can_hold_power"] &&
|
|
154
|
+
!this._tags["dve_can_be_powered"] &&
|
|
155
|
+
!this._tags["dve_is_power_source"])
|
|
156
|
+
return -1;
|
|
157
|
+
const level = VoxelLevelReader.getLevel(this.level[this._index]);
|
|
158
|
+
if (this._tags["dve_is_power_source"] &&
|
|
159
|
+
this._tags["dve_power_value"] > level)
|
|
160
|
+
return this._tags["dve_power_value"];
|
|
161
|
+
return level;
|
|
162
|
+
}
|
|
163
|
+
setPower(level) {
|
|
164
|
+
this.level[this._index] = VoxelLevelReader.setLevel(this.level[this._index], level);
|
|
165
|
+
return this;
|
|
166
|
+
}
|
|
167
|
+
isPowerSource() {
|
|
168
|
+
if (this._loadedId <= 0)
|
|
169
|
+
return false;
|
|
170
|
+
return VoxelTagStates.isRegistered(this._loadedId, VoxelTagIds.isPowerSource)
|
|
171
|
+
? VoxelTagStates.getValue(this._loadedId, VoxelTagIds.isPowerSource, this.getState()) === true
|
|
172
|
+
: this._tags[VoxelTagIds.isPowerSource];
|
|
173
|
+
}
|
|
174
|
+
getPowerSourceValue() {
|
|
175
|
+
if (this._loadedId <= 0)
|
|
176
|
+
return 0;
|
|
177
|
+
return this._tags[VoxelTagIds.powerValue];
|
|
178
|
+
}
|
|
138
179
|
noAO() {
|
|
139
180
|
if (this._loadedId <= 0)
|
|
140
181
|
return false;
|
|
@@ -178,10 +219,10 @@ export class VoxelCursorInterface {
|
|
|
178
219
|
return VoxelPalettesRegister.voxels.getStringId(this.id);
|
|
179
220
|
}
|
|
180
221
|
setName(name) {
|
|
181
|
-
this.setStringId(VoxelPalettesRegister.
|
|
222
|
+
return this.setStringId(VoxelPalettesRegister.voxelNametoIdMap.get(name));
|
|
182
223
|
}
|
|
183
224
|
getName() {
|
|
184
|
-
return this.getStringId();
|
|
225
|
+
return VoxelPalettesRegister.voxelIdToNameMap.get(this.getStringId());
|
|
185
226
|
}
|
|
186
227
|
isSameVoxel(voxel) {
|
|
187
228
|
return this.getId() == voxel.getId();
|
|
@@ -5,9 +5,4 @@ export declare class VoxelPalettesRegister {
|
|
|
5
5
|
static voxels: StringPalette;
|
|
6
6
|
static voxelNametoIdMap: Map<string, string>;
|
|
7
7
|
static voxelIdToNameMap: Map<string, string>;
|
|
8
|
-
static loadInVoxel(voxelPalette: string[], nameToIdMap: Record<string, string>, idToNameMap: Record<string, string>): void;
|
|
9
|
-
static voxelName: {
|
|
10
|
-
getId: (name: string) => string;
|
|
11
|
-
getName: (id: string) => string;
|
|
12
|
-
};
|
|
13
8
|
}
|
|
@@ -5,13 +5,4 @@ export class VoxelPalettesRegister {
|
|
|
5
5
|
static voxels = new StringPalette();
|
|
6
6
|
static voxelNametoIdMap = new Map();
|
|
7
7
|
static voxelIdToNameMap = new Map();
|
|
8
|
-
static loadInVoxel(voxelPalette, nameToIdMap, idToNameMap) {
|
|
9
|
-
this.voxels = new StringPalette(voxelPalette);
|
|
10
|
-
this.voxelNametoIdMap = new Map(Object.entries(nameToIdMap));
|
|
11
|
-
this.voxelIdToNameMap = new Map(Object.entries(idToNameMap));
|
|
12
|
-
}
|
|
13
|
-
static voxelName = {
|
|
14
|
-
getId: (name) => this.voxelNametoIdMap.get(name),
|
|
15
|
-
getName: (id) => this.voxelIdToNameMap.get(id),
|
|
16
|
-
};
|
|
17
8
|
}
|
|
@@ -6,10 +6,15 @@ export declare enum VoxelTagIds {
|
|
|
6
6
|
colliderID = "dve_collider_id",
|
|
7
7
|
checkCollisions = "dve_check_collisions",
|
|
8
8
|
isLightSource = "dve_is_light_source",
|
|
9
|
+
lightValue = "dve_light_value",
|
|
9
10
|
noAO = "dve_no_ao",
|
|
10
11
|
isTransparent = "dve_is_transparent",
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
canHaveSecondary = "dve_can_have_secondary",
|
|
13
|
+
canBePowered = "dve_can_be_powered",
|
|
14
|
+
canCarryPower = "dve_can_carry_power",
|
|
15
|
+
canHoldPower = "dve_can_hold_power",
|
|
16
|
+
isPowerSource = "dve_is_power_source",
|
|
17
|
+
powerValue = "dve_power_value"
|
|
13
18
|
}
|
|
14
19
|
export interface VoxelTags {
|
|
15
20
|
/** The material used to render the voxel. Used by the engine to assign meshes to the proper material. */
|
|
@@ -37,6 +42,16 @@ export interface VoxelTags {
|
|
|
37
42
|
[VoxelTagIds.canHaveSecondary]: boolean;
|
|
38
43
|
/** The hardness level of the voxel, affecting how it is broken or interacted with. */
|
|
39
44
|
[VoxelTagIds.hardness]: number;
|
|
45
|
+
/** Whether or not the voxel can be powered */
|
|
46
|
+
[VoxelTagIds.canBePowered]: boolean;
|
|
47
|
+
/** Whether or not the voxel can carry power */
|
|
48
|
+
[VoxelTagIds.canCarryPower]: boolean;
|
|
49
|
+
/** Whether or not the voxel can hold power. */
|
|
50
|
+
[VoxelTagIds.canHoldPower]: boolean;
|
|
51
|
+
/** Whether or not the voxel is a power source*/
|
|
52
|
+
[VoxelTagIds.isPowerSource]: boolean;
|
|
53
|
+
/** If the voxel is a power source this is its value */
|
|
54
|
+
[VoxelTagIds.powerValue]: number;
|
|
40
55
|
}
|
|
41
56
|
export declare enum VoxelSubstanceTagIdds {
|
|
42
57
|
parent = "dve_parent_substance",
|
|
@@ -7,10 +7,15 @@ export var VoxelTagIds;
|
|
|
7
7
|
VoxelTagIds["colliderID"] = "dve_collider_id";
|
|
8
8
|
VoxelTagIds["checkCollisions"] = "dve_check_collisions";
|
|
9
9
|
VoxelTagIds["isLightSource"] = "dve_is_light_source";
|
|
10
|
+
VoxelTagIds["lightValue"] = "dve_light_value";
|
|
10
11
|
VoxelTagIds["noAO"] = "dve_no_ao";
|
|
11
12
|
VoxelTagIds["isTransparent"] = "dve_is_transparent";
|
|
12
|
-
VoxelTagIds["lightValue"] = "dve_light_value";
|
|
13
13
|
VoxelTagIds["canHaveSecondary"] = "dve_can_have_secondary";
|
|
14
|
+
VoxelTagIds["canBePowered"] = "dve_can_be_powered";
|
|
15
|
+
VoxelTagIds["canCarryPower"] = "dve_can_carry_power";
|
|
16
|
+
VoxelTagIds["canHoldPower"] = "dve_can_hold_power";
|
|
17
|
+
VoxelTagIds["isPowerSource"] = "dve_is_power_source";
|
|
18
|
+
VoxelTagIds["powerValue"] = "dve_power_value";
|
|
14
19
|
})(VoxelTagIds || (VoxelTagIds = {}));
|
|
15
20
|
export var VoxelSubstanceTagIdds;
|
|
16
21
|
(function (VoxelSubstanceTagIdds) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VoxelSubstanceTagIdds, VoxelTagIds, } from "./VoxelTag.types";
|
|
1
|
+
import { VoxelSubstanceTagIdds as VoxelSubstanceTagIds, VoxelTagIds, } from "./VoxelTag.types";
|
|
2
2
|
export class VoxelTagsRegister {
|
|
3
3
|
static IncludedVoxelTags = [
|
|
4
4
|
VoxelTagIds.substance,
|
|
@@ -12,14 +12,19 @@ export class VoxelTagsRegister {
|
|
|
12
12
|
VoxelTagIds.noAO,
|
|
13
13
|
VoxelTagIds.isTransparent,
|
|
14
14
|
VoxelTagIds.canHaveSecondary,
|
|
15
|
+
VoxelTagIds.isPowerSource,
|
|
16
|
+
VoxelTagIds.canBePowered,
|
|
17
|
+
VoxelTagIds.canCarryPower,
|
|
18
|
+
VoxelTagIds.canHoldPower,
|
|
19
|
+
VoxelTagIds.powerValue
|
|
15
20
|
];
|
|
16
21
|
static IncludedSubstnacesTags = [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
VoxelSubstanceTagIds.parent,
|
|
23
|
+
VoxelSubstanceTagIds.isSolid,
|
|
24
|
+
VoxelSubstanceTagIds.isTransparent,
|
|
25
|
+
VoxelSubstanceTagIds.isLiquid,
|
|
26
|
+
VoxelSubstanceTagIds.flowRate,
|
|
27
|
+
VoxelSubstanceTagIds.isWindAffected,
|
|
23
28
|
];
|
|
24
29
|
static VoxelTagDefaults = {
|
|
25
30
|
[VoxelTagIds.renderedMaterial]: "dve_solid",
|
|
@@ -5,21 +5,21 @@ import { VoxelEffectSyncData } from "../Effects/VoxelEffects.types";
|
|
|
5
5
|
export declare function BuildStateData(model: VoxelRulesModoel, geoPalette: StringPalette): {
|
|
6
6
|
schema: (BinarySchemaNodeData | VoxelRelationsScehmaNodeData)[];
|
|
7
7
|
effects: VoxelEffectSyncData[];
|
|
8
|
-
|
|
8
|
+
stateGeometryPalette: number[][];
|
|
9
9
|
condiotnalShapeStateGeometryPalette: number[][];
|
|
10
|
-
|
|
10
|
+
stateTree: any[];
|
|
11
11
|
geometryLinkPalette: Record<string, number>;
|
|
12
12
|
geometryLinkStateMap: number[];
|
|
13
13
|
relativeByteCount: number;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
statePalette: number[][];
|
|
15
|
+
stateRecord: Record<string, number>;
|
|
16
16
|
condiotnalNodeStateTree: any;
|
|
17
17
|
condiotnalStatements: StateLogicStatement[];
|
|
18
|
-
|
|
18
|
+
condiotnalStatePalette: number[][];
|
|
19
19
|
condiotnalShapeStateRecord: Record<string, number>;
|
|
20
20
|
condiotanlStatePalette: number[][][];
|
|
21
21
|
condiotanlGeometryStatePalette: number[][][];
|
|
22
|
-
|
|
22
|
+
stateRelativeGeometryMap: number[][];
|
|
23
23
|
relativeGeometryByteIndexMap: number[];
|
|
24
24
|
condiotnalShapeStateRelativeGeometryMap: number[][];
|
|
25
25
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StateCompareOperationsMap, StateLogicOperationsMap, } from "../State/State.types";
|
|
2
2
|
import { StringPalette } from "../../Util/StringPalette";
|
|
3
|
-
import {
|
|
3
|
+
import { VoxelModelRuleBuilderRegister } from "../../Models/Rules/VoxelModelRuleBuilderRegister";
|
|
4
4
|
import { VoxelTagStates } from "../Data/VoxelTagStates";
|
|
5
5
|
import { VoxelPalettesRegister } from "../Data/VoxelPalettesRegister";
|
|
6
6
|
import { StateSchema } from "../State/Schema/StateSchema";
|
|
@@ -170,56 +170,56 @@ function buildSchemas(binaryNodes, relationNodes) {
|
|
|
170
170
|
}
|
|
171
171
|
export function BuildStateData(model, geoPalette) {
|
|
172
172
|
const data = model.data;
|
|
173
|
-
const { baseSchema, schemaIdPalette, schemaValuePalette } = buildSchemas(data.
|
|
173
|
+
const { baseSchema, schemaIdPalette, schemaValuePalette } = buildSchemas(data.stateSchema, data.relationsSchema);
|
|
174
174
|
const geometryLinkPalette = new StringPalette();
|
|
175
175
|
//maps geo link ids to geomtry ids
|
|
176
176
|
const geometryLinkStateMap = [];
|
|
177
177
|
const log = model.data.id == "dve_simple_stair";
|
|
178
178
|
//add geomtry from main shape states
|
|
179
|
-
for (const key in data.
|
|
180
|
-
const nodeData = data.
|
|
179
|
+
for (const key in data.stateNodes) {
|
|
180
|
+
const nodeData = data.stateNodes[key];
|
|
181
181
|
for (const node of nodeData) {
|
|
182
182
|
if (geometryLinkPalette.isRegistered(node.id))
|
|
183
183
|
continue;
|
|
184
184
|
const linkId = geometryLinkPalette.register(node.id);
|
|
185
|
-
geometryLinkStateMap[linkId] = geoPalette.getNumberId(
|
|
185
|
+
geometryLinkStateMap[linkId] = geoPalette.getNumberId(VoxelModelRuleBuilderRegister.getGeometryLinkId(node));
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
//add geomtry from condiotnal shape states
|
|
189
|
-
for (const key in data.
|
|
190
|
-
const nodeData = data.
|
|
189
|
+
for (const key in data.conditonalNodes) {
|
|
190
|
+
const nodeData = data.conditonalNodes[key];
|
|
191
191
|
for (const node of nodeData) {
|
|
192
192
|
if (geometryLinkPalette.isRegistered(node.id))
|
|
193
193
|
continue;
|
|
194
194
|
const linkId = geometryLinkPalette.register(node.id);
|
|
195
|
-
geometryLinkStateMap[linkId] = geoPalette.getNumberId(
|
|
195
|
+
geometryLinkStateMap[linkId] = geoPalette.getNumberId(VoxelModelRuleBuilderRegister.getGeometryLinkId(node));
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
const
|
|
198
|
+
const stateRelativeGeometryMap = [];
|
|
199
199
|
const relativeGeometryByteIndexMap = [];
|
|
200
200
|
//build state trees
|
|
201
|
-
const
|
|
202
|
-
const
|
|
203
|
-
const
|
|
201
|
+
const stateTree = new StateTreeNode("root");
|
|
202
|
+
const stateGeoLinkPalette = [];
|
|
203
|
+
const stateGeometryPalette = [];
|
|
204
204
|
let relativeGeoId = 0;
|
|
205
205
|
let relativeByteCount = 0;
|
|
206
|
-
const
|
|
207
|
-
for (const key in data.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
const nodeData = data.
|
|
206
|
+
const stateRecord = {};
|
|
207
|
+
for (const key in data.stateNodes) {
|
|
208
|
+
stateGeoLinkPalette.push(data.stateNodes[key].map((_) => geometryLinkPalette.getNumberId(_.id)));
|
|
209
|
+
stateGeometryPalette.push(data.stateNodes[key].map((_) => geoPalette.getNumberId(VoxelModelRuleBuilderRegister.getGeometryLinkId(_))));
|
|
210
|
+
stateRecord[key] = stateGeometryPalette.length - 1;
|
|
211
|
+
stateRelativeGeometryMap[stateRecord[key]] ??= [];
|
|
212
|
+
const nodeData = data.stateNodes[key];
|
|
213
213
|
for (const node of nodeData) {
|
|
214
|
-
|
|
214
|
+
stateRelativeGeometryMap[stateRecord[key]][geoPalette.getNumberId(VoxelModelRuleBuilderRegister.getGeometryLinkId(node))] = relativeGeoId;
|
|
215
215
|
relativeGeometryByteIndexMap[relativeGeoId] = relativeByteCount;
|
|
216
216
|
relativeGeoId++;
|
|
217
|
-
relativeByteCount += Math.ceil(
|
|
217
|
+
relativeByteCount += Math.ceil(VoxelModelRuleBuilderRegister.getGeomtryFromLink(node).faceCount / 8);
|
|
218
218
|
}
|
|
219
|
-
addPathToTree(
|
|
219
|
+
addPathToTree(stateTree, key
|
|
220
220
|
.split(",")
|
|
221
221
|
.map((pair) => pair.split("="))
|
|
222
|
-
.flat(),
|
|
222
|
+
.flat(), stateGeoLinkPalette.length - 1);
|
|
223
223
|
}
|
|
224
224
|
const condiotnalShapeStateRelativeGeometryMap = [];
|
|
225
225
|
const condiotnalShapeStateNodePalette = [];
|
|
@@ -227,19 +227,19 @@ export function BuildStateData(model, geoPalette) {
|
|
|
227
227
|
const condiotnalShapeStateNodeRecord = {};
|
|
228
228
|
const condiotnalStatements = [];
|
|
229
229
|
const compareOperations = Object.keys(StateCompareOperationsMap);
|
|
230
|
-
for (const key in data.
|
|
231
|
-
condiotnalShapeStateNodePalette.push(data.
|
|
232
|
-
condiotnalShapeStateGeometryPalette.push(data.
|
|
230
|
+
for (const key in data.conditonalNodes) {
|
|
231
|
+
condiotnalShapeStateNodePalette.push(data.conditonalNodes[key].map((_) => geometryLinkPalette.getNumberId(_.id)));
|
|
232
|
+
condiotnalShapeStateGeometryPalette.push(data.conditonalNodes[key].map((_) => geoPalette.getNumberId(VoxelModelRuleBuilderRegister.getGeometryLinkId(_))));
|
|
233
233
|
condiotnalShapeStateNodeRecord[key] =
|
|
234
234
|
condiotnalShapeStateGeometryPalette.length - 1;
|
|
235
235
|
condiotnalShapeStateRelativeGeometryMap[condiotnalShapeStateNodeRecord[key]] ??= [];
|
|
236
|
-
const nodeData = data.
|
|
236
|
+
const nodeData = data.conditonalNodes[key];
|
|
237
237
|
for (const node of nodeData) {
|
|
238
|
-
condiotnalShapeStateRelativeGeometryMap[condiotnalShapeStateNodeRecord[key]][geoPalette.getNumberId(
|
|
238
|
+
condiotnalShapeStateRelativeGeometryMap[condiotnalShapeStateNodeRecord[key]][geoPalette.getNumberId(VoxelModelRuleBuilderRegister.getGeometryLinkId(node))] =
|
|
239
239
|
relativeGeoId;
|
|
240
240
|
relativeGeometryByteIndexMap[relativeGeoId] = relativeByteCount;
|
|
241
241
|
relativeGeoId++;
|
|
242
|
-
relativeByteCount += Math.ceil(
|
|
242
|
+
relativeByteCount += Math.ceil(VoxelModelRuleBuilderRegister.getGeomtryFromLink(node).faceCount / 8);
|
|
243
243
|
}
|
|
244
244
|
const statement = [];
|
|
245
245
|
const nodes = key.split(" ");
|
|
@@ -290,9 +290,9 @@ export function BuildStateData(model, geoPalette) {
|
|
|
290
290
|
condiotanlStatePalette.push(newStateCombo);
|
|
291
291
|
condiotanlGeometryStatePalette.push(newGeoCombo);
|
|
292
292
|
}
|
|
293
|
-
const
|
|
293
|
+
const stateTreeData = stateTree.toJSON();
|
|
294
294
|
const newShapeStateTree = [];
|
|
295
|
-
reMapTree(schemaIdPalette, schemaValuePalette,
|
|
295
|
+
reMapTree(schemaIdPalette, schemaValuePalette, stateTreeData, newShapeStateTree, model.data.id);
|
|
296
296
|
const modelEffects = [];
|
|
297
297
|
const tagEffects = [];
|
|
298
298
|
if (model.data.effects) {
|
|
@@ -358,21 +358,21 @@ export function BuildStateData(model, geoPalette) {
|
|
|
358
358
|
const finalData = {
|
|
359
359
|
schema: baseSchema,
|
|
360
360
|
effects: modelEffects,
|
|
361
|
-
|
|
361
|
+
stateGeometryPalette: stateGeometryPalette,
|
|
362
362
|
condiotnalShapeStateGeometryPalette,
|
|
363
|
-
|
|
363
|
+
stateTree: newShapeStateTree,
|
|
364
364
|
geometryLinkPalette: geometryLinkPalette._map,
|
|
365
365
|
geometryLinkStateMap,
|
|
366
366
|
relativeByteCount,
|
|
367
|
-
|
|
368
|
-
|
|
367
|
+
statePalette: stateGeoLinkPalette,
|
|
368
|
+
stateRecord: stateRecord,
|
|
369
369
|
condiotnalNodeStateTree,
|
|
370
370
|
condiotnalStatements,
|
|
371
|
-
|
|
371
|
+
condiotnalStatePalette: condiotnalShapeStateNodePalette,
|
|
372
372
|
condiotnalShapeStateRecord: condiotnalShapeStateNodeRecord,
|
|
373
373
|
condiotanlStatePalette,
|
|
374
374
|
condiotanlGeometryStatePalette,
|
|
375
|
-
|
|
375
|
+
stateRelativeGeometryMap: stateRelativeGeometryMap,
|
|
376
376
|
relativeGeometryByteIndexMap,
|
|
377
377
|
condiotnalShapeStateRelativeGeometryMap,
|
|
378
378
|
};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { VoxelTagsRegister } from "../Data/VoxelTagsRegister";
|
|
2
2
|
import { VoxelPalettesRegister } from "../Data/VoxelPalettesRegister";
|
|
3
3
|
export function BuildTagAndPaletteData(props) {
|
|
4
|
+
const logic = {};
|
|
4
5
|
for (const voxel of props.voxels) {
|
|
5
6
|
const tags = {};
|
|
6
7
|
const voxelId = VoxelPalettesRegister.voxels.register(voxel.id);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
VoxelPalettesRegister.voxelIdToNameMap.set(voxel.id, voxel.name || "");
|
|
9
|
+
VoxelPalettesRegister.voxelNametoIdMap.set(voxel.name || voxel.id, voxel.id);
|
|
10
|
+
if (voxel.properties["dve_logic_data"]) {
|
|
11
|
+
logic[voxel.id] = voxel.properties["dve_logic_data"];
|
|
10
12
|
}
|
|
11
13
|
for (const tag of VoxelTagsRegister.IncludedVoxelTags) {
|
|
12
14
|
if (voxel.properties[tag] === undefined) {
|
|
@@ -43,6 +45,7 @@ export function BuildTagAndPaletteData(props) {
|
|
|
43
45
|
}
|
|
44
46
|
return {
|
|
45
47
|
data: {
|
|
48
|
+
logic,
|
|
46
49
|
palette: VoxelPalettesRegister.voxels._palette,
|
|
47
50
|
tags: VoxelTagsRegister.VoxelTags,
|
|
48
51
|
idToNameMap: [...VoxelPalettesRegister.voxelIdToNameMap.entries()],
|
|
@@ -7,8 +7,8 @@ export declare class VoxelNamedState {
|
|
|
7
7
|
compiled: {
|
|
8
8
|
mod: number;
|
|
9
9
|
modAny: boolean;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
state: number;
|
|
11
|
+
stateAny: boolean;
|
|
12
12
|
};
|
|
13
13
|
constructor(voxelId: string, data: VoxelNamedStateData);
|
|
14
14
|
getPaintData(): PaintVoxelData;
|