@divinevoxel/vlox 0.0.73 → 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 +1 -0
- package/Contexts/World/DivineVoxelEngineWorld.d.ts +1 -0
- package/Init/StartConstructor.js +2 -0
- package/Math/index.d.ts +5 -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 +15 -22
- package/Mesher/Geomtry/CompactedSectionVoxelMesh.d.ts +23 -0
- package/Mesher/Geomtry/CompactedSectionVoxelMesh.js +144 -0
- package/Mesher/Geomtry/VoxelGeometryBuilder.d.ts +1 -1
- package/Mesher/Geomtry/VoxelGeometryBuilder.js +118 -197
- package/Mesher/Geomtry/VoxelMesh.js +2 -2
- package/Mesher/Geomtry/VoxelMeshBVHBuilder.d.ts +8 -70
- package/Mesher/Geomtry/VoxelMeshBVHBuilder.js +18 -183
- package/Mesher/Geomtry/VoxelMeshBVHStructCursor.d.ts +22 -0
- package/Mesher/Geomtry/VoxelMeshBVHStructCursor.js +78 -0
- package/Mesher/Geomtry/VoxelMeshBuffers.js +2 -2
- package/Mesher/InitTask.js +5 -1
- 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/QuadGeometryNode.js +2 -2
- package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +7 -7
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +22 -25
- 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/Models/VoxelConstructor.d.ts +3 -3
- package/Mesher/Models/VoxelConstructor.js +8 -8
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.d.ts +2 -2
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.js +8 -9
- package/Mesher/Models/VoxelModelBuilder.js +1 -8
- package/Mesher/Types/Mesher.types.d.ts +1 -0
- package/Models/Defaults/CubeVoxelModels.js +16 -39
- package/Models/Defaults/LiquidVoxelModel.js +3 -3
- package/Models/Defaults/PanelVoxelModels.js +10 -36
- package/Models/Defaults/StairVoxelModel.js +6 -21
- package/Models/Examples.js +23 -44
- 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 +13 -13
- package/Models/Rules/VoxelModelRuleBuilderRegister.js +8 -8
- package/Models/VoxelModel.types.d.ts +3 -3
- package/Renderer/Classes/DVESectionMeshes.d.ts +2 -3
- package/Renderer/InitTasks.js +1 -9
- package/Renderer/MeshManager.d.ts +1 -1
- package/Renderer/MeshManager.js +24 -23
- package/Renderer/MeshRegister.d.ts +5 -5
- package/Renderer/MeshRegister.js +2 -2
- package/Settings/EngineSettings.d.ts +1 -0
- package/Settings/EngineSettings.js +6 -3
- package/Settings/EngineSettings.types.d.ts +7 -21
- package/Settings/EngineSettings.types.js +6 -14
- 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 +5 -147
- package/Tasks/{Update/UpdateTask.d.ts → VoxelUpdateTask.d.ts} +15 -7
- package/Tasks/{Update/UpdateTask.js → VoxelUpdateTask.js} +20 -7
- package/Tasks/WorldGeneration/WorldGenBrush.d.ts +3 -3
- package/Tasks/WorldGeneration/WorldGenBrush.js +2 -2
- package/Tasks/WorldGeneration/WorldGenRegister.d.ts +1 -1
- package/Templates/Functions/CreateTemplate.d.ts +1 -1
- package/Tools/Brush/AdvancedBrushTool.js +1 -1
- package/Tools/Brush/Brush.d.ts +2 -2
- package/Tools/Brush/Brush.js +1 -1
- package/Tools/Tasks/TasksTool.d.ts +1 -0
- package/Tools/Tasks/TasksTool.js +2 -0
- package/Util/Binary/BinaryBuffer.d.ts +17 -11
- package/Util/Binary/BinaryBuffer.js +65 -59
- package/Util/Binary/BinaryTree.d.ts +46 -0
- package/Util/Binary/BinaryTree.js +104 -0
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +7 -2
- package/Voxels/Cursor/VoxelCursor.interface.js +46 -2
- package/Voxels/Cursor/VoxelLightData.js +1 -1
- package/Voxels/Data/VoxelTag.types.d.ts +17 -2
- package/Voxels/Data/VoxelTag.types.js +6 -1
- package/Voxels/Data/VoxelTagsRegister.js +5 -0
- package/Voxels/Functions/BuildStateData.d.ts +6 -6
- package/Voxels/Functions/BuildStateData.js +31 -31
- package/Voxels/Functions/BuildTagAndPaletteData.js +5 -0
- package/Voxels/Indexes/VoxelIndex.d.ts +2 -2
- package/Voxels/Indexes/VoxelIndex.js +16 -18
- package/Voxels/InitVoxelData.js +12 -8
- 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/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 +3 -0
- package/Voxels/Types/VoxelModelCompiledData.types.d.ts +6 -4
- package/World/Archive/Archive.types.d.ts +31 -12
- 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 +39 -36
- package/World/Archive/Functions/ArchiveSector.js +210 -404
- package/World/Archive/Functions/CreateArchivedSection.d.ts +3 -0
- package/World/Archive/Functions/CreateArchivedSection.js +207 -0
- package/World/Archive/Functions/ImportSector.d.ts +1 -3
- package/World/Archive/Functions/ImportSector.js +13 -244
- package/World/Archive/Functions/RemoveDuplicates.d.ts +3 -0
- package/World/Archive/Functions/RemoveDuplicates.js +92 -0
- package/World/Archive/Functions/Shared.d.ts +2 -2
- package/World/Archive/Functions/Shared.js +15 -40
- package/World/Archive/InitTasks.js +7 -10
- package/World/Cursor/SectionCursor.d.ts +1 -1
- package/World/Cursor/SectorCursor.d.ts +1 -1
- package/World/Cursor/WorldCursor.d.ts +4 -3
- package/World/Cursor/WorldCursor.js +16 -13
- package/World/Cursor/WorldVoxelCursor.d.ts +0 -4
- package/World/Cursor/WorldVoxelCursor.js +23 -14
- package/World/Dimension/Dimension.d.ts +4 -1
- package/World/Dimension/Dimension.js +8 -1
- package/World/Section/Section.d.ts +17 -4
- package/World/Section/Section.js +68 -6
- package/World/Section/SectionState.d.ts +4 -2
- package/World/Section/SectionState.js +4 -2
- package/World/Sector/Sector.d.ts +7 -1
- package/World/Sector/Sector.js +37 -4
- package/World/Sector/SectorState.d.ts +3 -2
- package/World/Sector/SectorState.js +3 -2
- package/World/Types/WorldData.types.d.ts +2 -7
- package/World/WorldRegister.d.ts +9 -9
- package/World/WorldRegister.js +9 -6
- package/World/WorldSpaces.js +6 -6
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.d.ts +2 -2
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.d.ts +6 -4
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.js +9 -5
- 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/{Tasks/IWG/Internal/Classes/BuildQueue.js → WorldSimulation/Internal/Classes/TickQueue.js} +16 -7
- package/WorldSimulation/Internal/Classes/WorldSimulationTaskBase.d.ts +15 -0
- package/{Tasks/IWG/Internal/Classes/IWGTaskBase.js → WorldSimulation/Internal/Classes/WorldSimulationTaskBase.js} +6 -6
- 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} +29 -19
- 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 -14
- 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 +5 -5
- package/{Tasks/IWG/IWG.d.ts → WorldSimulation/WorldSimulation.d.ts} +5 -5
- package/{Tasks/IWG/IWG.js → WorldSimulation/WorldSimulation.js} +21 -21
- package/{Tasks/IWG → WorldSimulation}/index.d.ts +1 -1
- package/{Tasks/IWG → WorldSimulation}/index.js +1 -1
- package/package.json +1 -1
- package/Tasks/IWG/Internal/Classes/BuildQueue.d.ts +0 -11
- 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 -30
- package/Tasks/IWG/Internal/IWGTools.d.ts +0 -8
- /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,90 +1,96 @@
|
|
|
1
1
|
import { getBitArrayIndex, getHalfNibbleArrayIndex, getNibbleArrayIndex, setBitArrayIndex, setHalfNibbleArrayIndex, setNibbleArrayIndex, } from "./BinaryArrays";
|
|
2
|
-
|
|
2
|
+
export var BinaryBufferTypes;
|
|
3
|
+
(function (BinaryBufferTypes) {
|
|
4
|
+
BinaryBufferTypes[BinaryBufferTypes["Value"] = 0] = "Value";
|
|
5
|
+
BinaryBufferTypes[BinaryBufferTypes["BitArray"] = 1] = "BitArray";
|
|
6
|
+
BinaryBufferTypes[BinaryBufferTypes["HalfNibbleArray"] = 2] = "HalfNibbleArray";
|
|
7
|
+
BinaryBufferTypes[BinaryBufferTypes["NibbleArray"] = 4] = "NibbleArray";
|
|
8
|
+
BinaryBufferTypes[BinaryBufferTypes["ByteArray"] = 8] = "ByteArray";
|
|
9
|
+
BinaryBufferTypes[BinaryBufferTypes["ShortArray"] = 16] = "ShortArray";
|
|
10
|
+
})(BinaryBufferTypes || (BinaryBufferTypes = {}));
|
|
3
11
|
export class BinaryBuffer {
|
|
4
|
-
static
|
|
5
|
-
static
|
|
6
|
-
static
|
|
7
|
-
static
|
|
12
|
+
static ByteArrayMax = 256;
|
|
13
|
+
static NibbleArrayMax = 16;
|
|
14
|
+
static HalfNibbleArrayMax = 4;
|
|
15
|
+
static BitArrayMax = 2;
|
|
8
16
|
static DetermineSubByteArray = (paletteSize) => {
|
|
9
|
-
if (paletteSize == BinaryBuffer.
|
|
10
|
-
return
|
|
11
|
-
if (paletteSize > BinaryBuffer.
|
|
12
|
-
paletteSize <= BinaryBuffer.
|
|
13
|
-
return
|
|
14
|
-
if (paletteSize > BinaryBuffer.
|
|
15
|
-
paletteSize <= BinaryBuffer.
|
|
16
|
-
return
|
|
17
|
-
if (paletteSize > BinaryBuffer.
|
|
18
|
-
paletteSize <= BinaryBuffer.
|
|
19
|
-
return
|
|
17
|
+
if (paletteSize == BinaryBuffer.BitArrayMax)
|
|
18
|
+
return BinaryBufferTypes.BitArray;
|
|
19
|
+
if (paletteSize > BinaryBuffer.BitArrayMax &&
|
|
20
|
+
paletteSize <= BinaryBuffer.HalfNibbleArrayMax)
|
|
21
|
+
return BinaryBufferTypes.HalfNibbleArray;
|
|
22
|
+
if (paletteSize > BinaryBuffer.HalfNibbleArrayMax &&
|
|
23
|
+
paletteSize <= BinaryBuffer.NibbleArrayMax)
|
|
24
|
+
return BinaryBufferTypes.NibbleArray;
|
|
25
|
+
if (paletteSize > BinaryBuffer.NibbleArrayMax &&
|
|
26
|
+
paletteSize <= BinaryBuffer.ByteArrayMax)
|
|
27
|
+
return BinaryBufferTypes.ByteArray;
|
|
20
28
|
return null;
|
|
21
29
|
};
|
|
22
30
|
static CreateBufferForType(type, length) {
|
|
23
|
-
if (type ==
|
|
31
|
+
if (type == BinaryBufferTypes.ShortArray)
|
|
24
32
|
return new Uint16Array(length);
|
|
25
|
-
if (type == "8-bit")
|
|
26
|
-
return new Uint8Array(length);
|
|
27
|
-
if (type == "1-bit")
|
|
28
|
-
return new Uint8Array(length);
|
|
29
|
-
if (type == "2-bit")
|
|
30
|
-
return new Uint8Array(length);
|
|
31
|
-
if (type == "4-bit")
|
|
32
|
-
return new Uint8Array(length);
|
|
33
33
|
return new Uint8Array(length);
|
|
34
34
|
}
|
|
35
35
|
static GetConvertedBufferSize(source, type) {
|
|
36
|
-
if (type ==
|
|
36
|
+
if (type == BinaryBufferTypes.ShortArray ||
|
|
37
|
+
type == BinaryBufferTypes.ByteArray)
|
|
37
38
|
return source.length;
|
|
38
|
-
if (type ==
|
|
39
|
+
if (type == BinaryBufferTypes.BitArray)
|
|
39
40
|
return source.length / 8;
|
|
40
|
-
if (type ==
|
|
41
|
-
return source.length / 2;
|
|
42
|
-
if (type == "2-bit")
|
|
41
|
+
if (type == BinaryBufferTypes.HalfNibbleArray)
|
|
43
42
|
return source.length / 4;
|
|
44
|
-
if (type ==
|
|
43
|
+
if (type == BinaryBufferTypes.NibbleArray)
|
|
44
|
+
return source.length / 2;
|
|
45
|
+
if (type == BinaryBufferTypes.Value)
|
|
45
46
|
return 1;
|
|
46
47
|
return source.length;
|
|
47
48
|
}
|
|
48
49
|
static GetIndexLength(source, type) {
|
|
49
|
-
if (type ==
|
|
50
|
+
if (type == BinaryBufferTypes.ShortArray ||
|
|
51
|
+
type == BinaryBufferTypes.ByteArray)
|
|
50
52
|
return source.length;
|
|
51
|
-
if (type ==
|
|
53
|
+
if (type == BinaryBufferTypes.BitArray)
|
|
52
54
|
return source.length * 8;
|
|
53
|
-
if (type ==
|
|
54
|
-
return source.length * 2;
|
|
55
|
-
if (type == "2-bit")
|
|
55
|
+
if (type == BinaryBufferTypes.HalfNibbleArray)
|
|
56
56
|
return source.length * 4;
|
|
57
|
-
if (type ==
|
|
57
|
+
if (type == BinaryBufferTypes.NibbleArray)
|
|
58
|
+
return source.length * 2;
|
|
59
|
+
if (type == BinaryBufferTypes.Value)
|
|
58
60
|
return 1;
|
|
59
61
|
return source.length;
|
|
60
62
|
}
|
|
61
63
|
static ReadBufferAtIndex(source, type, index) {
|
|
62
|
-
if (type ==
|
|
64
|
+
if (type == BinaryBufferTypes.ShortArray ||
|
|
65
|
+
type == BinaryBufferTypes.ByteArray)
|
|
63
66
|
return source[index];
|
|
64
|
-
if (type ==
|
|
67
|
+
if (type == BinaryBufferTypes.BitArray)
|
|
65
68
|
return getBitArrayIndex(source, index);
|
|
66
|
-
if (type ==
|
|
69
|
+
if (type == BinaryBufferTypes.NibbleArray)
|
|
67
70
|
return getNibbleArrayIndex(source, index);
|
|
68
|
-
if (type ==
|
|
71
|
+
if (type == BinaryBufferTypes.HalfNibbleArray)
|
|
69
72
|
return getHalfNibbleArrayIndex(source, index);
|
|
70
73
|
return source[index];
|
|
71
74
|
}
|
|
72
75
|
static SetBufferAtIndex(source, type, index, value) {
|
|
73
|
-
if (type ==
|
|
76
|
+
if (type == BinaryBufferTypes.ShortArray ||
|
|
77
|
+
type == BinaryBufferTypes.ByteArray) {
|
|
74
78
|
return (source[index] = value);
|
|
75
79
|
}
|
|
76
|
-
if (type ==
|
|
80
|
+
if (type == BinaryBufferTypes.BitArray)
|
|
77
81
|
return setBitArrayIndex(source, index, value);
|
|
78
|
-
if (type ==
|
|
82
|
+
if (type == BinaryBufferTypes.NibbleArray)
|
|
79
83
|
return setNibbleArrayIndex(source, index, value);
|
|
80
|
-
if (type ==
|
|
84
|
+
if (type == BinaryBufferTypes.HalfNibbleArray)
|
|
81
85
|
return setHalfNibbleArrayIndex(source, index, value);
|
|
82
86
|
return source[index];
|
|
83
87
|
}
|
|
84
88
|
static Convert(source, sourceType, destinationType) {
|
|
85
89
|
if (sourceType == destinationType ||
|
|
86
|
-
(sourceType ==
|
|
87
|
-
|
|
90
|
+
(sourceType == BinaryBufferTypes.ShortArray &&
|
|
91
|
+
destinationType == BinaryBufferTypes.ByteArray) ||
|
|
92
|
+
(sourceType == BinaryBufferTypes.ByteArray &&
|
|
93
|
+
destinationType == BinaryBufferTypes.ShortArray)) {
|
|
88
94
|
const destination = this.CreateBufferForType(destinationType, this.GetConvertedBufferSize(source, destinationType));
|
|
89
95
|
destination.set(source);
|
|
90
96
|
return destination;
|
|
@@ -99,32 +105,32 @@ export class BinaryBuffer {
|
|
|
99
105
|
static Create(data) {
|
|
100
106
|
return {
|
|
101
107
|
buffer: 0,
|
|
108
|
+
type: BinaryBufferTypes.Value,
|
|
102
109
|
...data,
|
|
103
110
|
};
|
|
104
111
|
}
|
|
112
|
+
bufferView;
|
|
105
113
|
constructor(data) {
|
|
106
114
|
this.buffer = data.buffer;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (data.buffer instanceof Uint8Array)
|
|
116
|
-
this.type = "8-bit";
|
|
115
|
+
this.type = data.type;
|
|
116
|
+
if (typeof this.buffer !== "number") {
|
|
117
|
+
if (this.type == BinaryBufferTypes.ShortArray) {
|
|
118
|
+
this.bufferView = new Uint16Array(this.buffer);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
this.bufferView = new Uint8Array(this.buffer);
|
|
122
|
+
}
|
|
117
123
|
}
|
|
118
124
|
}
|
|
119
125
|
getValue(index) {
|
|
120
126
|
if (typeof this.buffer == "number")
|
|
121
127
|
return this.buffer;
|
|
122
|
-
return BinaryBuffer.ReadBufferAtIndex(this.
|
|
128
|
+
return BinaryBuffer.ReadBufferAtIndex(this.bufferView, this.type, index);
|
|
123
129
|
}
|
|
124
130
|
toJSON() {
|
|
125
131
|
return {
|
|
126
132
|
buffer: this.buffer,
|
|
127
|
-
|
|
133
|
+
type: this.type,
|
|
128
134
|
};
|
|
129
135
|
}
|
|
130
136
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A class to help with indexing a full flat binary tree defined by the number of levels it has.
|
|
3
|
+
*/
|
|
4
|
+
export declare class FlatBinaryTreeIndex {
|
|
5
|
+
levels: number;
|
|
6
|
+
constructor(levels: number);
|
|
7
|
+
/** Gets the number of nodes at a level of the tree */
|
|
8
|
+
getLevelSize(level: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* Gets the flat index of a node indexed by the level it's on and its relative index in that level.
|
|
11
|
+
*/
|
|
12
|
+
getIndexAtLevel(level: number, node: number): number;
|
|
13
|
+
/**
|
|
14
|
+
* Gets the level and relative index of a node's flat index.
|
|
15
|
+
*/
|
|
16
|
+
getLevelAndIndex(index: number): [level: number, relativeIndex: number];
|
|
17
|
+
/**
|
|
18
|
+
* Gets the flat left child of a node, where the node is indexed by its level and its relative index at that level.
|
|
19
|
+
* @returns -1 if no child exist
|
|
20
|
+
*/
|
|
21
|
+
getLeftChildAtLevel(level: number, node: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* Gets the flat right child of a node, where the node is indexed by its level and its relative index at that level.
|
|
24
|
+
* @returns -1 if no child exist
|
|
25
|
+
*/
|
|
26
|
+
getRightChildAtLevel(level: number, node: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* 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.
|
|
29
|
+
* @returns -1 if level has no parent
|
|
30
|
+
*/
|
|
31
|
+
getParentAtLevel(level: number, node: number): number;
|
|
32
|
+
/** Gets the flat index of the left child of the node.
|
|
33
|
+
* @returns -1 if no child exist
|
|
34
|
+
*/
|
|
35
|
+
getLeftChild(node: number): number;
|
|
36
|
+
/** Gets the flat index of the right child of the node.
|
|
37
|
+
* @returns -1 if no child exist
|
|
38
|
+
*/
|
|
39
|
+
getRightChild(node: number): number;
|
|
40
|
+
/** Gets the flat index of the parent of the node.
|
|
41
|
+
* @returns -1 if no parent exist
|
|
42
|
+
*/
|
|
43
|
+
getParent(node: number): number;
|
|
44
|
+
/** Gets the total number of nodes in the tree */
|
|
45
|
+
getTotalSize(): number;
|
|
46
|
+
}
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -123,15 +124,58 @@ export class VoxelCursorInterface {
|
|
|
123
124
|
isLightSource() {
|
|
124
125
|
if (this._loadedId <= 0)
|
|
125
126
|
return false;
|
|
127
|
+
if (VoxelLogicRegister.voxels[this._loadedId]?.hasTag(VoxelTagIds.isLightSource)) {
|
|
128
|
+
return VoxelLogicRegister.voxels[this._loadedId].getTagValue(VoxelTagIds.isLightSource, this);
|
|
129
|
+
}
|
|
126
130
|
return VoxelTagStates.isRegistered(this._loadedId, VoxelTagIds.isLightSource)
|
|
127
131
|
? VoxelTagStates.getValue(this._loadedId, VoxelTagIds.isLightSource, this.getState()) === true
|
|
128
132
|
: this._tags[VoxelTagIds.isLightSource];
|
|
129
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
|
+
}
|
|
130
142
|
getLightSourceValue() {
|
|
131
143
|
if (this._loadedId <= 0)
|
|
132
144
|
return 0;
|
|
133
145
|
return this._tags[VoxelTagIds.lightValue];
|
|
134
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
|
+
}
|
|
135
179
|
noAO() {
|
|
136
180
|
if (this._loadedId <= 0)
|
|
137
181
|
return false;
|
|
@@ -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) {
|
|
@@ -12,6 +12,11 @@ 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
22
|
VoxelSubstanceTagIds.parent,
|
|
@@ -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
|
};
|