@divinevoxel/vlox 0.0.80 → 0.0.81
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/Builder/Tools/Brush/BrushTool.d.ts +12 -2
- package/Builder/Tools/Brush/BrushTool.js +53 -28
- package/Builder/Tools/Debug/DebugTool.d.ts +18 -0
- package/Builder/Tools/Debug/DebugTool.js +36 -0
- package/Builder/Tools/Path/PahtTool.d.ts +1 -1
- package/Builder/Tools/Path/PahtTool.js +1 -1
- package/Builder/Tools/Sculpt/SculptTool.js +8 -0
- package/Builder/Tools/Wrench/WrenchTool.js +10 -23
- package/Builder/Util/SurfaceBoxSelection.js +2 -0
- package/Builder/VoxelBuildSpace.js +3 -3
- package/Contexts/Base/Remote/InitDataSync.js +1 -1
- package/Math/UtilFunctions.js +7 -8
- package/Math/VoxelFaces.d.ts +2 -2
- package/Math/VoxelFaces.js +46 -55
- package/Math/WorldIndexing.d.ts +11 -0
- package/Math/WorldIndexing.js +34 -0
- package/Mesher/Geometry/Geometry.types.d.ts +2 -2
- package/Mesher/Geometry/Geometry.types.js +7 -20
- package/Mesher/Geometry/Primitives/QuadVertexData.js +118 -119
- package/Mesher/Geometry/Primitives/TriangleVertexData.js +89 -90
- package/Mesher/Geometry/Proto/ProtoMesh.d.ts +1 -1
- package/Mesher/Geometry/Proto/ProtoMesh.js +22 -29
- package/Mesher/Geometry/Proto/ProtoMeshBuffer.d.ts +4 -2
- package/Mesher/Geometry/Proto/ProtoMeshBuffer.js +14 -6
- package/Mesher/Geometry/Shapes/Box.js +6 -7
- package/Mesher/Geometry/Transform/TransformBox.js +8 -9
- package/Mesher/Geometry/Transform/TransformQuad.js +4 -5
- package/Mesher/Geometry/Transform/TransformTriangle.js +3 -4
- package/Mesher/InitMesher.js +4 -9
- package/Mesher/Items/Geometry/ItemGeometryBuilder.js +7 -8
- package/Mesher/Items/MeshTexture.js +125 -57
- package/Mesher/Voxels/Base/BuildVoxel.d.ts +6 -0
- package/Mesher/Voxels/Base/BuildVoxel.js +101 -0
- package/Mesher/Voxels/Base/CompactVoxelSectionMesh.js +1 -21
- package/Mesher/Voxels/Base/MeshSectionBase.js +3 -26
- package/Mesher/Voxels/Geometry/VoxelGeometryBuilder.js +33 -31
- package/Mesher/Voxels/Geometry/VoxelShaderData.js +3 -7
- package/Mesher/Voxels/MeshTemplate.js +6 -26
- package/Mesher/Voxels/MeshVoxel.js +5 -10
- package/Mesher/Voxels/Models/Common/Calc/CalcConstants.js +41 -42
- package/Mesher/Voxels/Models/Common/Calc/FaceDataCalc.js +6 -9
- package/Mesher/Voxels/Models/Common/Faces/CullRulledFace.js +64 -47
- package/Mesher/Voxels/Models/Common/Faces/ShadeRulledFace.js +57 -43
- package/Mesher/Voxels/Models/Nodes/Custom/Liquid/FlowGradient.js +4 -5
- package/Mesher/Voxels/Models/Nodes/Custom/Liquid/LiquidGeometryNode.d.ts +1 -1
- package/Mesher/Voxels/Models/Nodes/Custom/Liquid/LiquidGeometryNode.js +116 -118
- package/Mesher/Voxels/Models/Nodes/Default/QuadVoxelGeometryNode.js +4 -4
- package/Mesher/Voxels/Models/Nodes/VoxelGeometryConstructor.js +2 -2
- package/Mesher/Voxels/Models/Procedures/Default/OutlinedTextureProcedure.js +19 -21
- package/Mesher/Voxels/Models/Procedures/Default/PillarTextureProcedure.js +45 -38
- package/Mesher/Voxels/Models/RenderedMaterials.d.ts +1 -1
- package/Mesher/Voxels/Models/RenderedMaterials.js +8 -5
- package/Mesher/Voxels/Models/VoxelGeometryBuilderCacheSpace.d.ts +18 -4
- package/Mesher/Voxels/Models/VoxelGeometryBuilderCacheSpace.js +135 -22
- package/Mesher/Voxels/Models/VoxelGeometryBuilderCacheSpaceN.d.ts +33 -0
- package/Mesher/Voxels/Models/VoxelGeometryBuilderCacheSpaceN.js +204 -0
- package/Mesher/Voxels/Models/{VoxelModelConstructorRegister.d.ts → VoxelGeometryConstructorRegister.d.ts} +1 -6
- package/Mesher/Voxels/Models/VoxelGeometryConstructorRegister.js +20 -0
- package/Mesher/Voxels/Models/VoxelModelBuilder.js +15 -16
- package/Mesher/Voxels/Models/VoxelModelEffect.d.ts +1 -3
- package/Mesher/Voxels/Models/VoxelModelEffect.js +1 -3
- package/Renderer/DVERenderNode.types.d.ts +1 -0
- package/Renderer/InitTasks.js +2 -0
- package/Tasks/Paint/Erase/EraseVoxel.js +1 -1
- package/Tasks/Propagation/Illumanation/RGBUpdate.js +191 -48
- package/Tasks/Propagation/Illumanation/SunUpdate.d.ts +1 -1
- package/Tasks/Propagation/Illumanation/SunUpdate.js +167 -63
- package/Tasks/Propagation/Illumanation/WorldSun.js +96 -60
- package/Tasks/WorldGeneration/WorldGenBrush.d.ts +2 -0
- package/Tasks/WorldGeneration/WorldGenBrush.js +31 -0
- package/Templates/Archive/ArchivedVoxelTemplate.js +1 -1
- package/Templates/Archive/Functions/CreateArchivedTemplate.js +1 -1
- package/Templates/Archive/Functions/CreateArchivedTemplateFromFull.d.ts +6 -0
- package/Templates/Archive/Functions/CreateArchivedTemplateFromFull.js +174 -0
- package/Textures/Classes/CompactedTextureReader.d.ts +22 -0
- package/Textures/Classes/CompactedTextureReader.js +90 -0
- package/Textures/Classes/CompiledTexture.d.ts +4 -1
- package/Textures/Classes/CompiledTexture.js +36 -8
- package/Textures/Classes/TextureAtlasIndex.d.ts +7 -0
- package/Textures/Classes/TextureAtlasIndex.js +14 -0
- package/Textures/Classes/TextureLoader.d.ts +20 -0
- package/Textures/Classes/TextureLoader.js +95 -0
- package/Textures/Functions/BuildTextureData.d.ts +1 -1
- package/Textures/Functions/BuildTextureData.js +19 -122
- package/Textures/Functions/CreateCompactedTexture.d.ts +6 -0
- package/Textures/Functions/CreateCompactedTexture.js +105 -0
- package/Textures/Functions/ReadCompactedTexture.d.ts +2 -0
- package/Textures/Functions/ReadCompactedTexture.js +42 -0
- package/Textures/Texture.types.d.ts +14 -0
- package/Textures/TextureManager.d.ts +7 -1
- package/Textures/TextureManager.js +13 -0
- package/Tools/Brush/Brush.d.ts +4 -2
- package/Tools/Brush/Brush.js +28 -6
- package/Util/BinaryBuffer/Functions/BinaryBufferConvert.d.ts +1 -1
- package/Util/TickInterval.d.ts +3 -0
- package/Util/TickInterval.js +31 -3
- package/Voxels/Archive/VoxelPaletteArchiveReader.d.ts +1 -0
- package/Voxels/Archive/VoxelPaletteArchiveReader.js +9 -10
- package/Voxels/Archive/VoxelPaletteArechive.js +5 -4
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +1 -1
- package/Voxels/Cursor/VoxelCursor.interface.js +22 -16
- package/Voxels/Data/VoxelLUT.d.ts +69 -42
- package/Voxels/Data/VoxelLUT.js +110 -53
- package/Voxels/Functions/BuildLUTs.js +100 -45
- package/Voxels/Functions/Geometry/CalcFunctions.js +6 -7
- package/Voxels/Functions/Geometry/Inputs/BuildTriangleInputs.js +3 -0
- package/Voxels/Indexes/VoxelIndex.js +3 -1
- package/Voxels/InitVoxelData.js +3 -1
- package/Voxels/Interaction/Functions/PickVoxel.js +3 -5
- package/Voxels/Interaction/Functions/PickVoxelWorld.js +4 -6
- package/Voxels/Models/Defaults/Examples.d.ts +2 -0
- package/Voxels/Models/Defaults/Examples.js +151 -2
- package/Voxels/State/Reltional/ReltionalStateBuilder.js +2 -0
- package/Voxels/State/Schema/BinarySchema.d.ts +1 -0
- package/Voxels/State/Schema/BinarySchema.js +14 -0
- package/Voxels/State/VoxelSchemas.d.ts +11 -4
- package/Voxels/State/VoxelSchemas.js +42 -9
- package/Voxels/Types/PaintVoxelData.js +6 -2
- package/World/Archive/Classes/ImportedSection.js +1 -1
- package/World/Archive/Classes/ImportedSector.js +0 -1
- package/World/Archive/Functions/Sector/ArchiveSector.js +2 -2
- package/World/Archive/Functions/Sector/ImportSector.d.ts +1 -0
- package/World/Archive/Functions/Sector/ImportSector.js +183 -7
- package/World/Cursor/SectorCursor.js +1 -4
- package/World/Cursor/WorldCursor.d.ts +12 -3
- package/World/Cursor/WorldCursor.js +60 -30
- package/World/InitTasks.js +1 -1
- package/World/Lock/Function/LockSectors.js +5 -1
- package/World/Lock/Function/UnLockSectors.js +5 -1
- package/World/SnapShot/SectionSnapShot.d.ts +7 -3
- package/World/SnapShot/SectionSnapShot.js +47 -21
- package/World/SnapShot/SectionSnapShotCursor.d.ts +4 -2
- package/World/SnapShot/SectionSnapShotCursor.js +23 -11
- package/World/SnapShot/SnapShots.d.ts +1 -2
- package/World/SnapShot/SnapShots.js +3 -3
- package/World/WorldSpaces.d.ts +7 -0
- package/World/WorldSpaces.js +35 -13
- package/WorldSimulation/Dimensions/DimensionSegment.d.ts +2 -0
- package/WorldSimulation/Dimensions/DimensionSegment.js +9 -1
- package/WorldSimulation/Dimensions/DimensionSimulation.js +6 -7
- package/WorldSimulation/Dimensions/Generator.d.ts +4 -0
- package/WorldSimulation/Dimensions/Generator.js +15 -1
- package/WorldSimulation/Dimensions/SimulationSector.d.ts +1 -0
- package/WorldSimulation/Dimensions/SimulationSector.js +18 -0
- package/WorldSimulation/Internal/WorldSimulationTasks.js +11 -7
- package/WorldSimulation/Procedures/InitalLoad.d.ts +1 -0
- package/WorldSimulation/Procedures/InitalLoad.js +18 -8
- package/WorldSimulation/Tasks/SimulationTaskBase.d.ts +4 -1
- package/WorldSimulation/Tasks/SimulationTaskBase.js +13 -2
- package/WorldSimulation/Tasks/TaskSegment.d.ts +4 -2
- package/WorldSimulation/Tasks/TaskSegment.js +36 -22
- package/WorldSimulation/Voxels/Ticks/Types/LiquidVoxelUpdate.js +1 -2
- package/WorldSimulation/WorldSimulation.d.ts +6 -3
- package/WorldSimulation/WorldSimulation.js +44 -20
- package/package.json +1 -1
- package/Mesher/Items/MeshTextureO.d.ts +0 -1
- package/Mesher/Items/MeshTextureO.js +0 -277
- package/Mesher/Voxels/Models/VoxelConstructor.d.ts +0 -8
- package/Mesher/Voxels/Models/VoxelConstructor.js +0 -78
- package/Mesher/Voxels/Models/VoxelModelConstructorRegister.js +0 -37
- package/WorldSimulation/Procedures/BuildOnly.d.ts +0 -10
- package/WorldSimulation/Procedures/BuildOnly.js +0 -55
|
@@ -1,117 +1,221 @@
|
|
|
1
1
|
import { VoxelLightData } from "../../../Voxels/Cursor/VoxelLightData";
|
|
2
2
|
import { isLessThanForSunAdd, getMinusOneForSun, isLessThanForSunAddDown, getSunLightForUnderVoxel, removeSunLight, isLessThanForSunRemove, isGreaterOrEqualThanForSunRemove, sunLightCompareForDownSunRemove, } from "./CommonFunctions";
|
|
3
|
-
const FloodOutPositions = [
|
|
4
|
-
[1, 0, 0],
|
|
5
|
-
[-1, 0, 0],
|
|
6
|
-
[0, 0, 1],
|
|
7
|
-
[0, 0, -1],
|
|
8
|
-
[0, 1, 0],
|
|
9
|
-
];
|
|
10
3
|
export function SunUpdate(tasks) {
|
|
11
4
|
const queue = tasks.sun.update;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
const sDataCursor = tasks.sDataCursor;
|
|
6
|
+
const nDataCursor = tasks.nDataCursor;
|
|
7
|
+
const bounds = tasks.bounds;
|
|
8
|
+
const sunFallOff = VoxelLightData.SunFallOffValue;
|
|
9
|
+
let queueIndex = 0;
|
|
10
|
+
while (queueIndex < queue.length) {
|
|
11
|
+
const x = queue[queueIndex++];
|
|
12
|
+
const y = queue[queueIndex++];
|
|
13
|
+
const z = queue[queueIndex++];
|
|
14
|
+
const voxel = sDataCursor.getVoxel(x, y, z);
|
|
17
15
|
if (!voxel)
|
|
18
16
|
continue;
|
|
19
17
|
const sl = voxel.getLight();
|
|
20
18
|
if (sl <= 0)
|
|
21
19
|
continue;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (!tasks.nDataCursor.inBounds(nx, ny, nz))
|
|
27
|
-
continue;
|
|
28
|
-
const nVoxel = tasks.nDataCursor.getVoxel(nx, ny, nz);
|
|
20
|
+
let nx, ny, nz, nVoxel, nl;
|
|
21
|
+
nx = x + 1;
|
|
22
|
+
if (nDataCursor.inBounds(nx, y, z)) {
|
|
23
|
+
nVoxel = nDataCursor.getVoxel(nx, y, z);
|
|
29
24
|
if (nVoxel) {
|
|
30
|
-
|
|
31
|
-
if (nl > -1 && isLessThanForSunAdd(nl, sl,
|
|
32
|
-
queue.push(nx,
|
|
33
|
-
nVoxel.setLight(getMinusOneForSun(sl, nl,
|
|
25
|
+
nl = nVoxel.getLight();
|
|
26
|
+
if (nl > -1 && isLessThanForSunAdd(nl, sl, sunFallOff)) {
|
|
27
|
+
queue.push(nx, y, z);
|
|
28
|
+
nVoxel.setLight(getMinusOneForSun(sl, nl, sunFallOff));
|
|
34
29
|
}
|
|
35
30
|
}
|
|
36
31
|
}
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
nx = x - 1;
|
|
33
|
+
if (nDataCursor.inBounds(nx, y, z)) {
|
|
34
|
+
nVoxel = nDataCursor.getVoxel(nx, y, z);
|
|
39
35
|
if (nVoxel) {
|
|
40
|
-
|
|
41
|
-
if (nl > -1 &&
|
|
36
|
+
nl = nVoxel.getLight();
|
|
37
|
+
if (nl > -1 && isLessThanForSunAdd(nl, sl, sunFallOff)) {
|
|
38
|
+
queue.push(nx, y, z);
|
|
39
|
+
nVoxel.setLight(getMinusOneForSun(sl, nl, sunFallOff));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
nz = z + 1;
|
|
44
|
+
if (nDataCursor.inBounds(x, y, nz)) {
|
|
45
|
+
nVoxel = nDataCursor.getVoxel(x, y, nz);
|
|
46
|
+
if (nVoxel) {
|
|
47
|
+
nl = nVoxel.getLight();
|
|
48
|
+
if (nl > -1 && isLessThanForSunAdd(nl, sl, sunFallOff)) {
|
|
49
|
+
queue.push(x, y, nz);
|
|
50
|
+
nVoxel.setLight(getMinusOneForSun(sl, nl, sunFallOff));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
nz = z - 1;
|
|
55
|
+
if (nDataCursor.inBounds(x, y, nz)) {
|
|
56
|
+
nVoxel = nDataCursor.getVoxel(x, y, nz);
|
|
57
|
+
if (nVoxel) {
|
|
58
|
+
nl = nVoxel.getLight();
|
|
59
|
+
if (nl > -1 && isLessThanForSunAdd(nl, sl, sunFallOff)) {
|
|
60
|
+
queue.push(x, y, nz);
|
|
61
|
+
nVoxel.setLight(getMinusOneForSun(sl, nl, sunFallOff));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
ny = y + 1;
|
|
66
|
+
if (nDataCursor.inBounds(x, ny, z)) {
|
|
67
|
+
nVoxel = nDataCursor.getVoxel(x, ny, z);
|
|
68
|
+
if (nVoxel) {
|
|
69
|
+
nl = nVoxel.getLight();
|
|
70
|
+
if (nl > -1 && isLessThanForSunAdd(nl, sl, sunFallOff)) {
|
|
71
|
+
queue.push(x, ny, z);
|
|
72
|
+
nVoxel.setLight(getMinusOneForSun(sl, nl, sunFallOff));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
ny = y - 1;
|
|
77
|
+
if (nDataCursor.inBounds(x, ny, z)) {
|
|
78
|
+
nVoxel = nDataCursor.getVoxel(x, ny, z);
|
|
79
|
+
if (nVoxel) {
|
|
80
|
+
nl = nVoxel.getLight();
|
|
81
|
+
if (nl > -1 && isLessThanForSunAddDown(nl, sl, sunFallOff)) {
|
|
42
82
|
if (nVoxel.isAir()) {
|
|
43
|
-
queue.push(x,
|
|
44
|
-
nVoxel.setLight(getSunLightForUnderVoxel(sl, nl,
|
|
83
|
+
queue.push(x, ny, z);
|
|
84
|
+
nVoxel.setLight(getSunLightForUnderVoxel(sl, nl, sunFallOff));
|
|
45
85
|
}
|
|
46
|
-
else {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
nVoxel.setLight(getMinusOneForSun(sl, nl, VoxelLightData.SunFallOffValue));
|
|
50
|
-
}
|
|
86
|
+
else if (!nVoxel.isOpaque()) {
|
|
87
|
+
queue.push(x, ny, z);
|
|
88
|
+
nVoxel.setLight(getMinusOneForSun(sl, nl, sunFallOff));
|
|
51
89
|
}
|
|
52
90
|
}
|
|
53
91
|
}
|
|
54
92
|
}
|
|
55
|
-
|
|
93
|
+
bounds.updateDisplay(x, y, z);
|
|
56
94
|
}
|
|
95
|
+
queue.length = 0;
|
|
57
96
|
}
|
|
58
|
-
export function SunRemove(tasks
|
|
97
|
+
export function SunRemove(tasks) {
|
|
59
98
|
const remove = tasks.sun.remove;
|
|
60
99
|
const update = tasks.sun.update;
|
|
61
100
|
const removeMap = tasks.sun.removeMap;
|
|
62
101
|
const updateMap = tasks.sun.updateMap;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
102
|
+
const sDataCursor = tasks.sDataCursor;
|
|
103
|
+
const nDataCursor = tasks.nDataCursor;
|
|
104
|
+
const bounds = tasks.bounds;
|
|
105
|
+
let removeIndex = 0;
|
|
106
|
+
while (removeIndex < remove.length) {
|
|
107
|
+
const x = remove[removeIndex++];
|
|
108
|
+
const y = remove[removeIndex++];
|
|
109
|
+
const z = remove[removeIndex++];
|
|
67
110
|
if (removeMap.has(x, y, z))
|
|
68
111
|
continue;
|
|
69
112
|
removeMap.add(x, y, z);
|
|
70
|
-
const voxel =
|
|
113
|
+
const voxel = sDataCursor.getVoxel(x, y, z);
|
|
71
114
|
if (!voxel)
|
|
72
115
|
continue;
|
|
73
116
|
const sl = voxel.getLight();
|
|
74
117
|
if (sl <= 0)
|
|
75
118
|
continue;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
119
|
+
let nx, ny, nz, nVoxel, nl;
|
|
120
|
+
nx = x + 1;
|
|
121
|
+
if (nDataCursor.inBounds(nx, y, z)) {
|
|
122
|
+
nVoxel = nDataCursor.getVoxel(nx, y, z);
|
|
123
|
+
if (nVoxel) {
|
|
124
|
+
nl = nVoxel.getLight();
|
|
125
|
+
if (nl > 0) {
|
|
126
|
+
if (isLessThanForSunRemove(nl, sl)) {
|
|
127
|
+
remove.push(nx, y, z);
|
|
128
|
+
}
|
|
129
|
+
else if (isGreaterOrEqualThanForSunRemove(nl, sl) && !updateMap.has(nx, y, z)) {
|
|
130
|
+
updateMap.add(nx, y, z);
|
|
131
|
+
update.push(nx, y, z);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
nx = x - 1;
|
|
137
|
+
if (nDataCursor.inBounds(nx, y, z)) {
|
|
138
|
+
nVoxel = nDataCursor.getVoxel(nx, y, z);
|
|
139
|
+
if (nVoxel) {
|
|
140
|
+
nl = nVoxel.getLight();
|
|
141
|
+
if (nl > 0) {
|
|
142
|
+
if (isLessThanForSunRemove(nl, sl)) {
|
|
143
|
+
remove.push(nx, y, z);
|
|
144
|
+
}
|
|
145
|
+
else if (isGreaterOrEqualThanForSunRemove(nl, sl) && !updateMap.has(nx, y, z)) {
|
|
146
|
+
updateMap.add(nx, y, z);
|
|
147
|
+
update.push(nx, y, z);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
nz = z + 1;
|
|
153
|
+
if (nDataCursor.inBounds(x, y, nz)) {
|
|
154
|
+
nVoxel = nDataCursor.getVoxel(x, y, nz);
|
|
155
|
+
if (nVoxel) {
|
|
156
|
+
nl = nVoxel.getLight();
|
|
157
|
+
if (nl > 0) {
|
|
158
|
+
if (isLessThanForSunRemove(nl, sl)) {
|
|
159
|
+
remove.push(x, y, nz);
|
|
160
|
+
}
|
|
161
|
+
else if (isGreaterOrEqualThanForSunRemove(nl, sl) && !updateMap.has(x, y, nz)) {
|
|
162
|
+
updateMap.add(x, y, nz);
|
|
163
|
+
update.push(x, y, nz);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
nz = z - 1;
|
|
169
|
+
if (nDataCursor.inBounds(x, y, nz)) {
|
|
170
|
+
nVoxel = nDataCursor.getVoxel(x, y, nz);
|
|
171
|
+
if (nVoxel) {
|
|
172
|
+
nl = nVoxel.getLight();
|
|
173
|
+
if (nl > 0) {
|
|
174
|
+
if (isLessThanForSunRemove(nl, sl)) {
|
|
175
|
+
remove.push(x, y, nz);
|
|
176
|
+
}
|
|
177
|
+
else if (isGreaterOrEqualThanForSunRemove(nl, sl) && !updateMap.has(x, y, nz)) {
|
|
178
|
+
updateMap.add(x, y, nz);
|
|
179
|
+
update.push(x, y, nz);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
ny = y + 1;
|
|
185
|
+
if (nDataCursor.inBounds(x, ny, z)) {
|
|
186
|
+
nVoxel = nDataCursor.getVoxel(x, ny, z);
|
|
83
187
|
if (nVoxel) {
|
|
84
|
-
|
|
188
|
+
nl = nVoxel.getLight();
|
|
85
189
|
if (nl > 0) {
|
|
86
190
|
if (isLessThanForSunRemove(nl, sl)) {
|
|
87
|
-
remove.push(
|
|
191
|
+
remove.push(x, ny, z);
|
|
88
192
|
}
|
|
89
|
-
else if (isGreaterOrEqualThanForSunRemove(nl, sl) &&
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
update.push(nx, ny, nz);
|
|
193
|
+
else if (isGreaterOrEqualThanForSunRemove(nl, sl) && !updateMap.has(x, ny, z)) {
|
|
194
|
+
updateMap.add(x, ny, z);
|
|
195
|
+
update.push(x, ny, z);
|
|
93
196
|
}
|
|
94
197
|
}
|
|
95
198
|
}
|
|
96
199
|
}
|
|
97
|
-
|
|
98
|
-
|
|
200
|
+
ny = y - 1;
|
|
201
|
+
if (nDataCursor.inBounds(x, ny, z)) {
|
|
202
|
+
nVoxel = nDataCursor.getVoxel(x, ny, z);
|
|
99
203
|
if (nVoxel) {
|
|
100
|
-
|
|
204
|
+
nl = nVoxel.getLight();
|
|
101
205
|
if (nl > 0) {
|
|
102
206
|
if (sunLightCompareForDownSunRemove(nl, sl)) {
|
|
103
|
-
remove.push(x,
|
|
207
|
+
remove.push(x, ny, z);
|
|
104
208
|
}
|
|
105
|
-
else if (isGreaterOrEqualThanForSunRemove(nl, sl) &&
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
update.push(x, y - 1, z);
|
|
209
|
+
else if (isGreaterOrEqualThanForSunRemove(nl, sl) && !updateMap.has(x, ny, z)) {
|
|
210
|
+
updateMap.add(x, ny, z);
|
|
211
|
+
update.push(x, ny, z);
|
|
109
212
|
}
|
|
110
213
|
}
|
|
111
214
|
}
|
|
112
215
|
}
|
|
113
|
-
|
|
216
|
+
bounds.updateDisplay(x, y, z);
|
|
114
217
|
voxel.setLight(removeSunLight(sl));
|
|
115
218
|
}
|
|
219
|
+
remove.length = 0;
|
|
116
220
|
removeMap.clear();
|
|
117
221
|
}
|
|
@@ -3,31 +3,33 @@ import { WorldSpaces } from "../../../World/WorldSpaces.js";
|
|
|
3
3
|
import { SectorHeightMap } from "../../../World/Sector/SectorHeightMap.js";
|
|
4
4
|
import { VoxelLightData } from "../../../Voxels/Cursor/VoxelLightData.js";
|
|
5
5
|
import { getMinusOneForSun, getSunLightForUnderVoxel, isLessThanForSunAddDown, isLessThanForSunAdd, } from "./CommonFunctions.js";
|
|
6
|
-
const FloodOutPositions = [
|
|
7
|
-
[1, 0, 0],
|
|
8
|
-
[-1, 0, 0],
|
|
9
|
-
[0, 0, 1],
|
|
10
|
-
[0, 0, -1],
|
|
11
|
-
[0, 1, 0],
|
|
12
|
-
];
|
|
13
6
|
const queue = [];
|
|
14
7
|
const lightData = new VoxelLightData();
|
|
15
8
|
export function RunWorldSun(tasks) {
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
9
|
+
const origin = tasks.origin;
|
|
10
|
+
const cx = origin[1];
|
|
11
|
+
const cy = origin[2];
|
|
12
|
+
const cz = origin[3];
|
|
13
|
+
const sectorBoundsX = WorldSpaces.sector.bounds.x;
|
|
14
|
+
const sectorBoundsY = WorldSpaces.sector.bounds.y;
|
|
15
|
+
const sectorBoundsZ = WorldSpaces.sector.bounds.z;
|
|
16
|
+
const sectionBoundsY = WorldSpaces.section.bounds.y;
|
|
17
|
+
const RmaxY = SectorHeightMap.getRelative(origin);
|
|
18
|
+
const AmaxY = SectorHeightMap.getAbsolute(origin[0], origin[1], origin[2], origin[3]);
|
|
19
|
+
const maxX = cx + sectorBoundsX;
|
|
20
|
+
const maxY = cy + sectorBoundsY;
|
|
21
|
+
const maxZ = cz + sectorBoundsZ;
|
|
22
|
+
const sectorCursor = tasks.nDataCursor.getSector(origin[1], origin[2], origin[3]);
|
|
23
23
|
if (!sectorCursor) {
|
|
24
|
-
console.warn("Could not load sector when running world sun at ",
|
|
24
|
+
console.warn("Could not load sector when running world sun at ", origin.toString());
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
const minY = AmaxY - 1 < 0 ? 0 : AmaxY;
|
|
28
28
|
const section = sectorCursor.getSection(cx, minY, cz);
|
|
29
|
-
const sectionY = section.getPosition()[1] +
|
|
30
|
-
|
|
29
|
+
const sectionY = section.getPosition()[1] + sectionBoundsY;
|
|
30
|
+
const sunFallOff = VoxelLightData.SunFallOffValue;
|
|
31
|
+
const nDataCursor = tasks.nDataCursor;
|
|
32
|
+
const sDataCursor = tasks.sDataCursor;
|
|
31
33
|
for (let iy = minY; iy < sectionY; iy++) {
|
|
32
34
|
for (let ix = cx; ix < maxX; ix++) {
|
|
33
35
|
for (let iz = cz; iz < maxZ; iz++) {
|
|
@@ -41,80 +43,114 @@ export function RunWorldSun(tasks) {
|
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
const length =
|
|
46
|
+
for (let iy = sectionY; iy < maxY; iy += sectionBoundsY) {
|
|
47
|
+
const sec = sectorCursor.getSection(cx, iy, cz);
|
|
48
|
+
const light = sec.light;
|
|
49
|
+
const length = light.length;
|
|
48
50
|
for (let i = 0; i < length; i++) {
|
|
49
|
-
|
|
51
|
+
light[i] = lightData.setS(0xf, light[i]);
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
|
-
//accumulate
|
|
53
54
|
const maxAcculamteY = AmaxY == RmaxY ? RmaxY + 1 : RmaxY;
|
|
54
|
-
let
|
|
55
|
+
let queueIndex = 0;
|
|
56
|
+
queue.length = 0;
|
|
55
57
|
for (let iy = minY; iy <= maxAcculamteY; iy++) {
|
|
56
58
|
for (let ix = cx; ix < maxX; ix++) {
|
|
57
59
|
for (let iz = cz; iz < maxZ; iz++) {
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
+
const voxel = sectorCursor.getVoxel(ix, iy, iz);
|
|
61
|
+
if (!voxel)
|
|
62
|
+
continue;
|
|
63
|
+
const l = voxel.getLight();
|
|
64
|
+
if (l < 0 || lightData.getS(l) != 0xf)
|
|
60
65
|
continue;
|
|
61
66
|
for (let i = 0; i < CardinalNeighbors3D.length; i++) {
|
|
62
67
|
const n = CardinalNeighbors3D[i];
|
|
63
68
|
const nx = ix + n[0];
|
|
64
69
|
const ny = iy + n[1];
|
|
65
70
|
const nz = iz + n[2];
|
|
66
|
-
const nVoxel =
|
|
71
|
+
const nVoxel = nDataCursor.getVoxel(nx, ny, nz);
|
|
67
72
|
if (!nVoxel)
|
|
68
73
|
continue;
|
|
69
74
|
const nl = nVoxel.getLight();
|
|
70
75
|
if (nl > -1 && lightData.getS(nl) < 0xf) {
|
|
71
|
-
queue
|
|
72
|
-
queue[index++] = iy;
|
|
73
|
-
queue[index++] = iz;
|
|
76
|
+
queue.push(ix, iy, iz);
|
|
74
77
|
break;
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
if (!sl || sl < 0)
|
|
83
|
+
while (queueIndex < queue.length) {
|
|
84
|
+
const x = queue[queueIndex++];
|
|
85
|
+
const y = queue[queueIndex++];
|
|
86
|
+
const z = queue[queueIndex++];
|
|
87
|
+
const voxel = sDataCursor.getVoxel(x, y, z);
|
|
88
|
+
if (!voxel)
|
|
87
89
|
continue;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
90
|
+
const sl = voxel.getLight();
|
|
91
|
+
if (sl < 0)
|
|
92
|
+
continue;
|
|
93
|
+
let nx, ny, nz, nVoxel, nl;
|
|
94
|
+
nx = x + 1;
|
|
95
|
+
nVoxel = nDataCursor.getVoxel(nx, y, z);
|
|
96
|
+
if (nVoxel) {
|
|
97
|
+
nl = nVoxel.getLight();
|
|
98
|
+
if (nl > -1 && isLessThanForSunAdd(nl, sl, sunFallOff)) {
|
|
99
|
+
queue.push(nx, y, z);
|
|
100
|
+
nVoxel.setLight(getMinusOneForSun(sl, nl, sunFallOff));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
nx = x - 1;
|
|
104
|
+
nVoxel = nDataCursor.getVoxel(nx, y, z);
|
|
105
|
+
if (nVoxel) {
|
|
106
|
+
nl = nVoxel.getLight();
|
|
107
|
+
if (nl > -1 && isLessThanForSunAdd(nl, sl, sunFallOff)) {
|
|
108
|
+
queue.push(nx, y, z);
|
|
109
|
+
nVoxel.setLight(getMinusOneForSun(sl, nl, sunFallOff));
|
|
100
110
|
}
|
|
101
111
|
}
|
|
102
|
-
|
|
112
|
+
nz = z + 1;
|
|
113
|
+
nVoxel = nDataCursor.getVoxel(x, y, nz);
|
|
103
114
|
if (nVoxel) {
|
|
104
|
-
|
|
105
|
-
if (nl > -1 &&
|
|
106
|
-
|
|
115
|
+
nl = nVoxel.getLight();
|
|
116
|
+
if (nl > -1 && isLessThanForSunAdd(nl, sl, sunFallOff)) {
|
|
117
|
+
queue.push(x, y, nz);
|
|
118
|
+
nVoxel.setLight(getMinusOneForSun(sl, nl, sunFallOff));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
nz = z - 1;
|
|
122
|
+
nVoxel = nDataCursor.getVoxel(x, y, nz);
|
|
123
|
+
if (nVoxel) {
|
|
124
|
+
nl = nVoxel.getLight();
|
|
125
|
+
if (nl > -1 && isLessThanForSunAdd(nl, sl, sunFallOff)) {
|
|
126
|
+
queue.push(x, y, nz);
|
|
127
|
+
nVoxel.setLight(getMinusOneForSun(sl, nl, sunFallOff));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
ny = y + 1;
|
|
131
|
+
nVoxel = nDataCursor.getVoxel(x, ny, z);
|
|
132
|
+
if (nVoxel) {
|
|
133
|
+
nl = nVoxel.getLight();
|
|
134
|
+
if (nl > -1 && isLessThanForSunAdd(nl, sl, sunFallOff)) {
|
|
135
|
+
queue.push(x, ny, z);
|
|
136
|
+
nVoxel.setLight(getMinusOneForSun(sl, nl, sunFallOff));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
ny = y - 1;
|
|
140
|
+
nVoxel = nDataCursor.getVoxel(x, ny, z);
|
|
141
|
+
if (nVoxel) {
|
|
142
|
+
nl = nVoxel.getLight();
|
|
143
|
+
if (nl > -1 && isLessThanForSunAddDown(nl, sl, sunFallOff)) {
|
|
107
144
|
if (nVoxel.isAir()) {
|
|
108
|
-
queue.push(x,
|
|
109
|
-
nVoxel.setLight(getSunLightForUnderVoxel(sl, nl,
|
|
145
|
+
queue.push(x, ny, z);
|
|
146
|
+
nVoxel.setLight(getSunLightForUnderVoxel(sl, nl, sunFallOff));
|
|
110
147
|
}
|
|
111
|
-
else {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
nVoxel.setLight(getMinusOneForSun(sl, nl, VoxelLightData.SunFallOffValue));
|
|
115
|
-
}
|
|
148
|
+
else if (!nVoxel.isOpaque()) {
|
|
149
|
+
queue.push(x, ny, z);
|
|
150
|
+
nVoxel.setLight(getMinusOneForSun(sl, nl, sunFallOff));
|
|
116
151
|
}
|
|
117
152
|
}
|
|
118
153
|
}
|
|
119
154
|
}
|
|
155
|
+
queue.length = 0;
|
|
120
156
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { Vec3Array } from "@amodx/math";
|
|
2
2
|
import { BrushTool } from "../../Tools/Brush/Brush.js";
|
|
3
3
|
import { VoxelUpdateTask } from "../VoxelUpdateTask.js";
|
|
4
|
+
import { RawVoxelData } from "Voxels/index.js";
|
|
4
5
|
export declare class WorldGenBrush extends BrushTool {
|
|
5
6
|
constructor();
|
|
6
7
|
requestsId: "";
|
|
7
8
|
tasks: VoxelUpdateTask;
|
|
8
9
|
start(dimension: number, x: number, y: number, z: number): this;
|
|
10
|
+
paintRaw(raw: RawVoxelData): this;
|
|
9
11
|
paint(): this;
|
|
10
12
|
getUpdatedSections(): Vec3Array[];
|
|
11
13
|
update(): false | undefined;
|
|
@@ -22,6 +22,37 @@ export class WorldGenBrush extends BrushTool {
|
|
|
22
22
|
this.z = z;
|
|
23
23
|
return this;
|
|
24
24
|
}
|
|
25
|
+
paintRaw(raw) {
|
|
26
|
+
let voxel = this.dataCursor.getVoxel(this.x, this.y, this.z);
|
|
27
|
+
if (!voxel) {
|
|
28
|
+
if (this.requestsId != "") {
|
|
29
|
+
WorldGenRegister.addToRequest(this.requestsId, [this.dimension, this.x, this.y, this.z], this.voxelCursor.getRaw());
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
throw new Error(`Tried painting in an unloaded location ${[
|
|
33
|
+
this.dimension,
|
|
34
|
+
this.x,
|
|
35
|
+
this.y,
|
|
36
|
+
this.z,
|
|
37
|
+
].toString()}`);
|
|
38
|
+
}
|
|
39
|
+
const sl = voxel.getLight();
|
|
40
|
+
if (sl > 0 || !voxel.isAir()) {
|
|
41
|
+
this._erase();
|
|
42
|
+
voxel.setLight(sl < 0 ? 0 : sl);
|
|
43
|
+
if (lightData.hasRGBLight(sl)) {
|
|
44
|
+
this.tasks.rgb.remove.push(this.x, this.y, this.z);
|
|
45
|
+
RGBRemove(this.tasks);
|
|
46
|
+
}
|
|
47
|
+
if (lightData.hasSunLight(sl)) {
|
|
48
|
+
this.tasks.sun.remove.push(this.x, this.y, this.z);
|
|
49
|
+
SunRemove(this.tasks);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
this._paintRaw(raw);
|
|
53
|
+
this.tasks.bounds.updateDisplay(this.x, this.y, this.z);
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
25
56
|
paint() {
|
|
26
57
|
let voxel = this.dataCursor.getVoxel(this.x, this.y, this.z);
|
|
27
58
|
if (!voxel) {
|
|
@@ -45,7 +45,7 @@ export class ArchivedVoxelTemplate {
|
|
|
45
45
|
}
|
|
46
46
|
getSecondary(index) {
|
|
47
47
|
const id = this.getId(index);
|
|
48
|
-
const trueId = VoxelLUT.
|
|
48
|
+
const trueId = VoxelLUT.voxelIdToTrueId[id];
|
|
49
49
|
if (VoxelTagsRegister.VoxelTags[trueId]["dve_can_have_secondary"]) {
|
|
50
50
|
return VoxelLUT.getVoxelIdFromString(...this.voxelPalette.getVoxelData(this.secondaryPalette.getValue(this.secondary.getValue(index))));
|
|
51
51
|
}
|
|
@@ -44,7 +44,7 @@ export default function CreateArchivedTemplate(dataCursor, bounds) {
|
|
|
44
44
|
? levelPalette.register(level)
|
|
45
45
|
: levelPalette.getId(level);
|
|
46
46
|
let voxelSecondary = 0;
|
|
47
|
-
if (VoxelTagsRegister.VoxelTags[VoxelLUT.
|
|
47
|
+
if (VoxelTagsRegister.VoxelTags[VoxelLUT.voxelIdToTrueId[rawData[0]]]["dve_can_have_secondary"]) {
|
|
48
48
|
voxelSecondary = voxelPalette.register(rawData[3]);
|
|
49
49
|
if (!secondaryPalette.isRegistered(voxelSecondary))
|
|
50
50
|
secondaryPalette.register(voxelSecondary);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ArchivedVoxelTemplate } from "../ArchivedVoxelTemplate";
|
|
2
|
+
import { FullVoxelTemplateData } from "../../Full/FullVoxelTemplate.types";
|
|
3
|
+
/**
|
|
4
|
+
* Converts a FullVoxelTemplateData into an ArchivedVoxelTemplate.
|
|
5
|
+
*/
|
|
6
|
+
export default function CreateArchivedTemplateFromFull(fullData: FullVoxelTemplateData): ArchivedVoxelTemplate;
|