@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
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export class VoxelMeshBVHStructCursor {
|
|
2
|
+
data;
|
|
3
|
+
get minX() {
|
|
4
|
+
return this.data[this.trueIndex];
|
|
5
|
+
}
|
|
6
|
+
get minY() {
|
|
7
|
+
return this.data[this.trueIndex + 1];
|
|
8
|
+
}
|
|
9
|
+
get minZ() {
|
|
10
|
+
return this.data[this.trueIndex + 2];
|
|
11
|
+
}
|
|
12
|
+
get maxX() {
|
|
13
|
+
return this.data[this.trueIndex + 4];
|
|
14
|
+
}
|
|
15
|
+
get maxY() {
|
|
16
|
+
return this.data[this.trueIndex + 5];
|
|
17
|
+
}
|
|
18
|
+
get maxZ() {
|
|
19
|
+
return this.data[this.trueIndex + 6];
|
|
20
|
+
}
|
|
21
|
+
get voxelIndex() {
|
|
22
|
+
return this.data[this.trueIndex + 3];
|
|
23
|
+
}
|
|
24
|
+
get active() {
|
|
25
|
+
return this.data[this.trueIndex + 3];
|
|
26
|
+
}
|
|
27
|
+
get nodeType() {
|
|
28
|
+
return this.data[this.trueIndex + 7];
|
|
29
|
+
}
|
|
30
|
+
trueIndex = 0;
|
|
31
|
+
index = 0;
|
|
32
|
+
setIndex(index) {
|
|
33
|
+
this.trueIndex = index * 8;
|
|
34
|
+
}
|
|
35
|
+
constructor(data) {
|
|
36
|
+
this.data = data;
|
|
37
|
+
}
|
|
38
|
+
setActive() {
|
|
39
|
+
this.data[this.trueIndex + 3] = 1;
|
|
40
|
+
}
|
|
41
|
+
setVoxelIndex(value) {
|
|
42
|
+
this.data[this.trueIndex + 3] = value;
|
|
43
|
+
}
|
|
44
|
+
setInnerNode() {
|
|
45
|
+
this.data[this.trueIndex + 7] = 1;
|
|
46
|
+
}
|
|
47
|
+
setGeomtryNode() {
|
|
48
|
+
this.data[this.trueIndex + 7] = 2;
|
|
49
|
+
}
|
|
50
|
+
updateMin(x, y, z) {
|
|
51
|
+
const ix = this.trueIndex;
|
|
52
|
+
const iy = this.trueIndex + 1;
|
|
53
|
+
const iz = this.trueIndex + 2;
|
|
54
|
+
if (x < this.data[ix] || this.data[ix] == -Infinity) {
|
|
55
|
+
this.data[ix] = x;
|
|
56
|
+
}
|
|
57
|
+
if (y < this.data[iy] || this.data[iy] == -Infinity) {
|
|
58
|
+
this.data[iy] = y;
|
|
59
|
+
}
|
|
60
|
+
if (z < this.data[iz] || this.data[iz] == -Infinity) {
|
|
61
|
+
this.data[iz] = z;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
updateMax(x, y, z) {
|
|
65
|
+
const ix = this.trueIndex + 4;
|
|
66
|
+
const iy = this.trueIndex + 5;
|
|
67
|
+
const iz = this.trueIndex + 6;
|
|
68
|
+
if (x > this.data[ix] || this.data[ix] == -Infinity) {
|
|
69
|
+
this.data[ix] = x;
|
|
70
|
+
}
|
|
71
|
+
if (y > this.data[iy] || this.data[iy] == -Infinity) {
|
|
72
|
+
this.data[iy] = y;
|
|
73
|
+
}
|
|
74
|
+
if (z > this.data[iz] || this.data[iz] == -Infinity) {
|
|
75
|
+
this.data[iz] = z;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -3,7 +3,7 @@ export class VoxelVertexBuffer {
|
|
|
3
3
|
sectorVertexSize;
|
|
4
4
|
_buffers = [];
|
|
5
5
|
sectorSize = 0;
|
|
6
|
-
constructor(vertexFloatSize, sectorVertexSize, startingSectorSize =
|
|
6
|
+
constructor(vertexFloatSize, sectorVertexSize, startingSectorSize = 8) {
|
|
7
7
|
this.vertexFloatSize = vertexFloatSize;
|
|
8
8
|
this.sectorVertexSize = sectorVertexSize;
|
|
9
9
|
this.sectorSize = vertexFloatSize * sectorVertexSize;
|
|
@@ -28,7 +28,7 @@ export class VoxelVertexBuffer {
|
|
|
28
28
|
export class VoxelIndiceBuffer {
|
|
29
29
|
sectorSize;
|
|
30
30
|
_buffers = [];
|
|
31
|
-
constructor(sectorSize, startingSectorSize =
|
|
31
|
+
constructor(sectorSize, startingSectorSize = 8) {
|
|
32
32
|
this.sectorSize = sectorSize;
|
|
33
33
|
for (let i = 0; i < startingSectorSize; i++) {
|
|
34
34
|
this._buffers.push(new Uint32Array(sectorSize));
|
package/Mesher/InitTask.js
CHANGED
|
@@ -10,7 +10,7 @@ export default function (rendererThread) {
|
|
|
10
10
|
return;
|
|
11
11
|
rendererThread.runTask("set-section", section, transfers);
|
|
12
12
|
});
|
|
13
|
-
Threads.registerTask(TasksIds.BuildSector, (location) => {
|
|
13
|
+
Threads.registerTask(TasksIds.BuildSector, (location, origin) => {
|
|
14
14
|
const sector = WorldRegister.sectors.getAt(location);
|
|
15
15
|
if (!sector) {
|
|
16
16
|
console.warn("Tried building a sector that does not exists.", location);
|
|
@@ -21,11 +21,15 @@ export default function (rendererThread) {
|
|
|
21
21
|
let [minY, maxY] = section.getMinMax();
|
|
22
22
|
if (Math.abs(minY) == Infinity && Math.abs(maxY) == Infinity)
|
|
23
23
|
continue;
|
|
24
|
+
const t = performance.now();
|
|
24
25
|
const transfers = [];
|
|
25
26
|
const sectionMesh = MeshSection([location[0], ...section.getPosition()], transfers);
|
|
26
27
|
if (!sectionMesh)
|
|
27
28
|
continue;
|
|
28
29
|
rendererThread.runTask("set-section", sectionMesh, transfers);
|
|
30
|
+
const buildTime = performance.now() - t;
|
|
31
|
+
origin.runTask("add-build-time", buildTime);
|
|
32
|
+
console.log("BUILD TIME", buildTime);
|
|
29
33
|
}
|
|
30
34
|
});
|
|
31
35
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Vector3Like } from "@amodx/math";
|
|
2
2
|
import { VoxelFaces } from "../../../Math";
|
|
3
3
|
import { Quad } from "../../Geomtry/Primitives/Quad";
|
|
4
|
-
import {
|
|
4
|
+
import { getQuadWeights } from "./Calc/CalcConstants";
|
|
5
5
|
import { TransformBox } from "../../../Models/Shared/Transform";
|
|
6
6
|
import { GetBounds } from "./BoundsFunctions";
|
|
7
7
|
export function GetBoxGeometryNodeData(points, transform) {
|
|
@@ -66,12 +66,12 @@ export function GetBoxGeometryNodeData(points, transform) {
|
|
|
66
66
|
}
|
|
67
67
|
quadBounds[i] = GetBounds(positions);
|
|
68
68
|
}
|
|
69
|
-
vertexWeights[VoxelFaces.Up] =
|
|
70
|
-
vertexWeights[VoxelFaces.Down] =
|
|
71
|
-
vertexWeights[VoxelFaces.North] =
|
|
72
|
-
vertexWeights[VoxelFaces.South] =
|
|
73
|
-
vertexWeights[VoxelFaces.East] =
|
|
74
|
-
vertexWeights[VoxelFaces.West] =
|
|
69
|
+
vertexWeights[VoxelFaces.Up] = getQuadWeights(quads[VoxelFaces.Up], VoxelFaces.Up);
|
|
70
|
+
vertexWeights[VoxelFaces.Down] = getQuadWeights(quads[VoxelFaces.Down], VoxelFaces.Down);
|
|
71
|
+
vertexWeights[VoxelFaces.North] = getQuadWeights(quads[VoxelFaces.North], VoxelFaces.North);
|
|
72
|
+
vertexWeights[VoxelFaces.South] = getQuadWeights(quads[VoxelFaces.South], VoxelFaces.South);
|
|
73
|
+
vertexWeights[VoxelFaces.East] = getQuadWeights(quads[VoxelFaces.East], VoxelFaces.East);
|
|
74
|
+
vertexWeights[VoxelFaces.West] = getQuadWeights(quads[VoxelFaces.West], VoxelFaces.West);
|
|
75
75
|
return {
|
|
76
76
|
quads,
|
|
77
77
|
vertexWeights,
|
|
@@ -11,5 +11,5 @@ export declare function shouldCauseFlip(topRight: number, topLeft: number, botto
|
|
|
11
11
|
export declare function getVertexWeights(face: VoxelFaces, x: number, y: number, z: number): Vec4Array;
|
|
12
12
|
export declare function getInterpolationValue(value: Vec4Array, weights: Vec4Array): number;
|
|
13
13
|
export type QuadVertexWeights = [Vec4Array, Vec4Array, Vec4Array, Vec4Array];
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const getQuadWeights: (quad: Quad, direction: VoxelFaces) => QuadVertexWeights;
|
|
15
15
|
export declare function closestUnitNormal(v: Vec3Array): Vec3Array;
|
|
@@ -326,7 +326,7 @@ export function getInterpolationValue(value, weights) {
|
|
|
326
326
|
lightData.getB(value[2]) * weights[2] +
|
|
327
327
|
lightData.getB(value[3]) * weights[3]);
|
|
328
328
|
}
|
|
329
|
-
export const
|
|
329
|
+
export const getQuadWeights = (quad, direction) => {
|
|
330
330
|
const returnArray = [];
|
|
331
331
|
for (const vertex of QuadVerticiesArray) {
|
|
332
332
|
const { x, y, z } = quad.positions.vertices[vertex];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Vector3Like } from "@amodx/math";
|
|
2
2
|
import { VoxelFaces } from "../../../Math";
|
|
3
3
|
import { Quad } from "../../Geomtry/Primitives/Quad";
|
|
4
|
-
import {
|
|
4
|
+
import { getQuadWeights, closestUnitNormal, } from "./Calc/CalcConstants";
|
|
5
5
|
import { TransformQuad } from "../../../Models/Shared/Transform";
|
|
6
6
|
import { GetBounds } from "./BoundsFunctions";
|
|
7
7
|
export function GetQuadGeometryData(data, transform) {
|
|
@@ -40,7 +40,7 @@ export function GetQuadGeometryData(data, transform) {
|
|
|
40
40
|
closestFace = VoxelFaces.North;
|
|
41
41
|
if (unitNormal[2] == -1)
|
|
42
42
|
closestFace = VoxelFaces.South;
|
|
43
|
-
const vertexWeights =
|
|
43
|
+
const vertexWeights = getQuadWeights(quad, closestFace);
|
|
44
44
|
closestFace = closestFace;
|
|
45
45
|
return {
|
|
46
46
|
quad,
|
|
@@ -8,7 +8,7 @@ import { shouldCauseFlip } from "../../../Common/Calc/CalcConstants";
|
|
|
8
8
|
import { getFlowAngle, getFlowGradient, FlowVerticies } from "./FlowGradient";
|
|
9
9
|
import { GetBoxGeometryNodeData } from "../../../Common/BoxGeometryNode";
|
|
10
10
|
import { VoxelLightData } from "../../../../../Voxels/Cursor/VoxelLightData";
|
|
11
|
-
import {
|
|
11
|
+
import { addVoxelQuad } from "../../../../Geomtry/VoxelGeometryBuilder";
|
|
12
12
|
const vertexValue = new QuadScalarVertexData();
|
|
13
13
|
const vertexLevel = new QuadScalarVertexData();
|
|
14
14
|
const lightData = new VoxelLightData();
|
|
@@ -92,7 +92,7 @@ export class LiquidGeometryNode extends GeoemtryNode {
|
|
|
92
92
|
quad.positions.vertices[1].y = vertexValue.vertices[1] * waterHeight;
|
|
93
93
|
quad.positions.vertices[2].y = vertexValue.vertices[2] * waterHeight;
|
|
94
94
|
quad.positions.vertices[3].y = vertexValue.vertices[3] * waterHeight;
|
|
95
|
-
|
|
95
|
+
addVoxelQuad(tool, tool.origin, quad);
|
|
96
96
|
tool.updateBounds(quadBounds[VoxelFaces.Up]);
|
|
97
97
|
}
|
|
98
98
|
if (this.isExposed(VoxelFaces.Down)) {
|
|
@@ -101,7 +101,7 @@ export class LiquidGeometryNode extends GeoemtryNode {
|
|
|
101
101
|
const quad = Quads[VoxelFaces.Down];
|
|
102
102
|
this.determineShading(VoxelFaces.Down);
|
|
103
103
|
quad.flip = this.shouldFlip();
|
|
104
|
-
|
|
104
|
+
addVoxelQuad(tool, tool.origin, quad);
|
|
105
105
|
tool.updateBounds(quadBounds[VoxelFaces.Down]);
|
|
106
106
|
}
|
|
107
107
|
if (this.isExposed(VoxelFaces.North)) {
|
|
@@ -126,7 +126,7 @@ export class LiquidGeometryNode extends GeoemtryNode {
|
|
|
126
126
|
quad.positions.vertices[QuadVerticies.TopLeft].y = 1;
|
|
127
127
|
quad.setUVs(uvs);
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
addVoxelQuad(tool, tool.origin, quad);
|
|
130
130
|
tool.updateBounds(quadBounds[VoxelFaces.North]);
|
|
131
131
|
}
|
|
132
132
|
if (this.isExposed(VoxelFaces.South)) {
|
|
@@ -151,7 +151,7 @@ export class LiquidGeometryNode extends GeoemtryNode {
|
|
|
151
151
|
quad.positions.vertices[QuadVerticies.TopRight].y = 1;
|
|
152
152
|
quad.setUVs(uvs);
|
|
153
153
|
}
|
|
154
|
-
|
|
154
|
+
addVoxelQuad(tool, tool.origin, quad);
|
|
155
155
|
tool.updateBounds(quadBounds[VoxelFaces.South]);
|
|
156
156
|
}
|
|
157
157
|
if (this.isExposed(VoxelFaces.East)) {
|
|
@@ -176,7 +176,7 @@ export class LiquidGeometryNode extends GeoemtryNode {
|
|
|
176
176
|
quad.positions.vertices[QuadVerticies.TopRight].y = 1;
|
|
177
177
|
quad.setUVs(uvs);
|
|
178
178
|
}
|
|
179
|
-
|
|
179
|
+
addVoxelQuad(tool, tool.origin, quad);
|
|
180
180
|
tool.updateBounds(quadBounds[VoxelFaces.East]);
|
|
181
181
|
}
|
|
182
182
|
if (this.isExposed(VoxelFaces.West)) {
|
|
@@ -201,7 +201,7 @@ export class LiquidGeometryNode extends GeoemtryNode {
|
|
|
201
201
|
quad.positions.vertices[QuadVerticies.TopRight].y = 1;
|
|
202
202
|
quad.setUVs(uvs);
|
|
203
203
|
}
|
|
204
|
-
|
|
204
|
+
addVoxelQuad(tool, tool.origin, quad);
|
|
205
205
|
tool.updateBounds(quadBounds[VoxelFaces.West]);
|
|
206
206
|
}
|
|
207
207
|
this.builder.vars.light.setAll(0);
|
|
@@ -4,7 +4,7 @@ import { getInterpolationValue, shouldCauseFlip, } from "../../Common/Calc/CalcC
|
|
|
4
4
|
import { VoxelRelativeCubeIndexPositionMap } from "../../../../Models/Indexing/VoxelRelativeCubeIndex";
|
|
5
5
|
import { GetBoxGeometryNodeData } from "../../Common/BoxGeometryNode";
|
|
6
6
|
import { VoxelLightData } from "../../../../Voxels/Cursor/VoxelLightData";
|
|
7
|
-
import {
|
|
7
|
+
import { addVoxelQuad, } from "../../../Geomtry/VoxelGeometryBuilder";
|
|
8
8
|
import { VoxelModelConstructorRegister } from "../../../Models/VoxelModelConstructorRegister";
|
|
9
9
|
const ArgIndexes = BoxVoxelGometryInputs.ArgIndexes;
|
|
10
10
|
export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
@@ -26,15 +26,15 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
26
26
|
const faceIndexes = this.geomtry.faceCullMap[trueFaceIndex];
|
|
27
27
|
if (!faceIndexes)
|
|
28
28
|
return true;
|
|
29
|
-
const
|
|
29
|
+
const builder = this.builder;
|
|
30
30
|
for (let positionIndex = 0; positionIndex < faceIndexes.length; positionIndex++) {
|
|
31
31
|
const currentIndex = faceIndexes[positionIndex];
|
|
32
32
|
const p = VoxelRelativeCubeIndexPositionMap[currentIndex];
|
|
33
|
-
const hashed = this.builder.space.getHash(
|
|
33
|
+
const hashed = this.builder.space.getHash(builder.nVoxel, builder.position.x + p[0], builder.position.y + p[1], builder.position.z + p[2]);
|
|
34
34
|
if (this.builder.space.foundHash[hashed] < 2)
|
|
35
35
|
continue;
|
|
36
|
+
const constructor = this.builder.space.getConstructor(hashed);
|
|
36
37
|
const offsetBaseGometry = this.builder.space.getGeomtry(hashed);
|
|
37
|
-
const offsetConditonalGeometry = this.builder.space.getConditionalGeomtry(hashed);
|
|
38
38
|
if (offsetBaseGometry) {
|
|
39
39
|
for (let i = 0; i < offsetBaseGometry.length; i++) {
|
|
40
40
|
const geoId = offsetBaseGometry[i];
|
|
@@ -42,27 +42,24 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
42
42
|
continue;
|
|
43
43
|
const faceIndex = this.geomtry.cullIndex.getValue(geoId, currentIndex, trueFaceIndex);
|
|
44
44
|
if (faceIndex > -1 &&
|
|
45
|
-
!this.builder.space
|
|
46
|
-
.getConstructor(hashed)
|
|
47
|
-
?.isShapeStateFaceTransparent(this.builder.space.modCache[hashed], this.builder.space.stateCache[hashed], geoId, faceIndex)) {
|
|
45
|
+
!constructor.isShapeStateFaceTransparent(this.builder.space.modCache[hashed], this.builder.space.stateCache[hashed], geoId, faceIndex)) {
|
|
48
46
|
return false;
|
|
49
47
|
}
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return false;
|
|
50
|
+
const offsetConditonalGeometry = this.builder.space.getConditionalGeomtry(hashed);
|
|
51
|
+
if (offsetConditonalGeometry) {
|
|
52
|
+
for (let i = 0; i < offsetConditonalGeometry.length; i++) {
|
|
53
|
+
const cond = offsetConditonalGeometry[i];
|
|
54
|
+
for (let k = 0; k < cond.length; k++) {
|
|
55
|
+
const geoId = cond[k];
|
|
56
|
+
if (VoxelModelConstructorRegister.rulesless[geoId])
|
|
57
|
+
continue;
|
|
58
|
+
const faceIndex = this.geomtry.cullIndex.getValue(geoId, currentIndex, trueFaceIndex);
|
|
59
|
+
if (faceIndex > -1 &&
|
|
60
|
+
!constructor.isCondtionalStateFaceTransparent(this.builder.space.modCache[hashed], this.builder.space.stateCache[hashed], geoId, faceIndex))
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
66
63
|
}
|
|
67
64
|
}
|
|
68
65
|
}
|
|
@@ -102,7 +99,7 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
102
99
|
if (this.geomtry.aoIndex.getValue(baseGeo[geoIndex], currentIndex, trueVertexIndex)) {
|
|
103
100
|
this._wasAOShaded = true;
|
|
104
101
|
worldAO.vertices[v]++;
|
|
105
|
-
if (worldAO.vertices[v]
|
|
102
|
+
if (worldAO.vertices[v] >= 3) {
|
|
106
103
|
shaded = true;
|
|
107
104
|
break;
|
|
108
105
|
}
|
|
@@ -118,7 +115,7 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
118
115
|
if (this.geomtry.aoIndex.getValue(conditonalGeo[condtionsIndex][geoIndex], currentIndex, trueVertexIndex)) {
|
|
119
116
|
this._wasAOShaded = true;
|
|
120
117
|
worldAO.vertices[v]++;
|
|
121
|
-
if (worldAO.vertices[v]
|
|
118
|
+
if (worldAO.vertices[v] >= 3) {
|
|
122
119
|
shaded = true;
|
|
123
120
|
break;
|
|
124
121
|
}
|
|
@@ -145,10 +142,10 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
145
142
|
for (let face = 0; face < 6; face++) {
|
|
146
143
|
if (args[face][ArgIndexes.Enabled] && this.isExposed(face)) {
|
|
147
144
|
added = true;
|
|
145
|
+
const quad = this.quads[face];
|
|
148
146
|
tool.calculateFaceData(face);
|
|
149
147
|
this.determineShading(face);
|
|
150
148
|
const faceArgs = args[face];
|
|
151
|
-
const quad = this.quads[face];
|
|
152
149
|
quad.flip = this.shouldFlip() || faceArgs[ArgIndexes.Fliped];
|
|
153
150
|
tool.vars.textureIndex = faceArgs[ArgIndexes.Texture];
|
|
154
151
|
const uvs = faceArgs[ArgIndexes.UVs];
|
|
@@ -164,7 +161,7 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
164
161
|
//4
|
|
165
162
|
quad.uvs.vertices[3].x = uvs[3][0];
|
|
166
163
|
quad.uvs.vertices[3].y = uvs[3][1];
|
|
167
|
-
|
|
164
|
+
addVoxelQuad(tool, this.builder.origin, quad);
|
|
168
165
|
tool.updateBounds(this.quadBounds[face]);
|
|
169
166
|
}
|
|
170
167
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VoxelFaces } from "../../../../Math";
|
|
2
|
-
import {
|
|
2
|
+
import { addVoxelQuad } from "../../../Geomtry/VoxelGeometryBuilder";
|
|
3
3
|
import { GeoemtryNode } from "../GeometryNode";
|
|
4
4
|
import { getInterpolationValue, shouldCauseFlip, } from "../../Common/Calc/CalcConstants";
|
|
5
5
|
import { VoxelRelativeCubeIndexPositionMap } from "../../../../Models/Indexing/VoxelRelativeCubeIndex";
|
|
@@ -148,7 +148,7 @@ export class QuadVoxelGometryNode extends GeoemtryNode {
|
|
|
148
148
|
//4
|
|
149
149
|
quad.uvs.vertices[3].x = uvs[3][0];
|
|
150
150
|
quad.uvs.vertices[3].y = uvs[3][1];
|
|
151
|
-
|
|
151
|
+
addVoxelQuad(this.builder, this.builder.origin, quad);
|
|
152
152
|
this.builder.updateBounds(this.quadBounds);
|
|
153
153
|
this.builder.vars.light.setAll(0);
|
|
154
154
|
this.builder.vars.ao.setAll(0);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { addVoxelQuad } from "../../../Geomtry/VoxelGeometryBuilder";
|
|
2
2
|
import { BoxVoxelGometryInputs, } from "../../../../Models/Input/BoxVoxelGometryInputs";
|
|
3
3
|
import { getInterpolationValue, shouldCauseFlip, } from "../../Common/Calc/CalcConstants";
|
|
4
4
|
import { VoxelLightData } from "../../../../Voxels/Cursor/VoxelLightData";
|
|
@@ -64,7 +64,7 @@ export class RulelessBoxVoxelGeometryNode extends GeoemtryNode {
|
|
|
64
64
|
//4
|
|
65
65
|
quad.uvs.vertices[3].x = uvs[3][0];
|
|
66
66
|
quad.uvs.vertices[3].y = uvs[3][1];
|
|
67
|
-
|
|
67
|
+
addVoxelQuad(tool, tool.position, quad);
|
|
68
68
|
this.builder.updateBounds(this.quadBounds[face]);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VoxelFaces } from "../../../../Math";
|
|
2
|
-
import {
|
|
2
|
+
import { addVoxelQuad, } from "../../../Geomtry/VoxelGeometryBuilder";
|
|
3
3
|
import { getInterpolationValue, shouldCauseFlip, } from "../../Common/Calc/CalcConstants";
|
|
4
4
|
import { QuadVoxelGometryInputs, } from "../../../../Models/Input/QuadVoxelGometryInputs";
|
|
5
5
|
import { GeoemtryNode } from "../GeometryNode";
|
|
@@ -68,7 +68,7 @@ export class RulelessQuadVoxelGeometryNode extends GeoemtryNode {
|
|
|
68
68
|
//4
|
|
69
69
|
quad.uvs.vertices[3].x = uvs[3][0];
|
|
70
70
|
quad.uvs.vertices[3].y = uvs[3][1];
|
|
71
|
-
|
|
71
|
+
addVoxelQuad(tool, tool.position, quad);
|
|
72
72
|
this.builder.updateBounds(this.quadBounds);
|
|
73
73
|
this.builder.vars.light.setAll(0);
|
|
74
74
|
this.builder.vars.ao.setAll(0);
|
|
@@ -18,10 +18,10 @@ export declare class VoxelConstructor {
|
|
|
18
18
|
conditonalInputMap: any[];
|
|
19
19
|
schema: StateSchema;
|
|
20
20
|
effects: VoxelModelEffect;
|
|
21
|
-
|
|
21
|
+
stateTree: StateTreeReader;
|
|
22
22
|
condtioanlShapeStateTree: CondtionalTreeReader;
|
|
23
23
|
constructor(id: string, builder: VoxelModelBuilder, data: CompiledVoxelModelData, voxleData: CompiledVoxelModelInputData);
|
|
24
|
-
isShapeStateFaceTransparent(modState: number,
|
|
25
|
-
isCondtionalStateFaceTransparent(modState: number,
|
|
24
|
+
isShapeStateFaceTransparent(modState: number, stateTree: number, geoId: number, faceIndex: number): boolean;
|
|
25
|
+
isCondtionalStateFaceTransparent(modState: number, state: number, geoId: number, faceIndex: number): boolean;
|
|
26
26
|
process(): boolean;
|
|
27
27
|
}
|
|
@@ -17,7 +17,7 @@ export class VoxelConstructor {
|
|
|
17
17
|
conditonalInputMap;
|
|
18
18
|
schema;
|
|
19
19
|
effects;
|
|
20
|
-
|
|
20
|
+
stateTree;
|
|
21
21
|
condtioanlShapeStateTree;
|
|
22
22
|
constructor(id, builder, data, voxleData) {
|
|
23
23
|
this.id = id;
|
|
@@ -27,17 +27,17 @@ export class VoxelConstructor {
|
|
|
27
27
|
this.conditonalInputMap = voxleData.condiotnalGeometryInputMap;
|
|
28
28
|
this.transparentIndex = new VoxelFaceTransparentResultsIndex(voxleData.transparentFaceIndex);
|
|
29
29
|
this.schema = new StateSchema(data.schema);
|
|
30
|
-
this.
|
|
30
|
+
this.stateTree = new StateTreeReader(this.schema, 0, data.stateTree);
|
|
31
31
|
this.condtioanlShapeStateTree = new CondtionalTreeReader(this.schema, data.condiotnalStatements, data.condiotnalStateTree);
|
|
32
32
|
this.modSchema = new StateSchema(voxleData.modSchema);
|
|
33
33
|
this.modTree = new StateTreeReader(this.modSchema, 0, voxleData.modStateTree);
|
|
34
34
|
this.effects = new VoxelModelEffect(this);
|
|
35
35
|
}
|
|
36
|
-
isShapeStateFaceTransparent(modState,
|
|
37
|
-
return (this.transparentIndex.getValue(modState, this.data.relativeGeometryByteIndexMap[this.data.
|
|
36
|
+
isShapeStateFaceTransparent(modState, stateTree, geoId, faceIndex) {
|
|
37
|
+
return (this.transparentIndex.getValue(modState, this.data.relativeGeometryByteIndexMap[this.data.stateRelativeGeometryMap[stateTree][geoId]], faceIndex) == 1);
|
|
38
38
|
}
|
|
39
|
-
isCondtionalStateFaceTransparent(modState,
|
|
40
|
-
return (this.transparentIndex.getValue(modState, this.data.relativeGeometryByteIndexMap[this.data.condiotnalShapeStateRelativeGeometryMap[
|
|
39
|
+
isCondtionalStateFaceTransparent(modState, state, geoId, faceIndex) {
|
|
40
|
+
return (this.transparentIndex.getValue(modState, this.data.relativeGeometryByteIndexMap[this.data.condiotnalShapeStateRelativeGeometryMap[state][geoId]], faceIndex) == 1);
|
|
41
41
|
}
|
|
42
42
|
process() {
|
|
43
43
|
let added = false;
|
|
@@ -46,8 +46,8 @@ export class VoxelConstructor {
|
|
|
46
46
|
const treeState = builder.space.stateCache[hashed];
|
|
47
47
|
const modState = builder.space.modCache[hashed];
|
|
48
48
|
if (treeState > -1) {
|
|
49
|
-
const geoLinks = this.data.
|
|
50
|
-
const geometries = this.data.
|
|
49
|
+
const geoLinks = this.data.stateMap[treeState];
|
|
50
|
+
const geometries = this.data.stateGeometryMap[treeState];
|
|
51
51
|
const geometriesLength = geoLinks.length;
|
|
52
52
|
const inputs = this.baseInputMap[modState][treeState];
|
|
53
53
|
for (let i = 0; i < geometriesLength; i++) {
|
|
@@ -15,8 +15,8 @@ export declare class VoxelGeometryBuilderCacheSpace {
|
|
|
15
15
|
start(x: number, y: number, z: number): void;
|
|
16
16
|
getIndex(x: number, y: number, z: number): number;
|
|
17
17
|
getConstructor(index: number): import("./VoxelConstructor").VoxelConstructor | null;
|
|
18
|
-
getGeomtry(index: number):
|
|
19
|
-
getConditionalGeomtry(index: number):
|
|
18
|
+
getGeomtry(index: number): number[] | null;
|
|
19
|
+
getConditionalGeomtry(index: number): number[][] | null;
|
|
20
20
|
getHash(dataCursor: DataCursorInterface, x: number, y: number, z: number): number;
|
|
21
21
|
private hashState;
|
|
22
22
|
}
|
|
@@ -42,12 +42,12 @@ export class VoxelGeometryBuilderCacheSpace {
|
|
|
42
42
|
}
|
|
43
43
|
getGeomtry(index) {
|
|
44
44
|
if (this.foundHash[index] < 2)
|
|
45
|
-
return
|
|
46
|
-
return VoxelModelConstructorRegister.constructorsPaltte[this.voxelCache[index]].data.
|
|
45
|
+
return null;
|
|
46
|
+
return VoxelModelConstructorRegister.constructorsPaltte[this.voxelCache[index]].data.stateGeometryMap[this.stateCache[index]];
|
|
47
47
|
}
|
|
48
48
|
getConditionalGeomtry(index) {
|
|
49
49
|
if (this.foundHash[index] < 2)
|
|
50
|
-
return
|
|
50
|
+
return null;
|
|
51
51
|
return VoxelModelConstructorRegister.constructorsPaltte[this.voxelCache[index]].data.condiotnalShapeStateGeometryMap[this.conditonalStateCache[index]];
|
|
52
52
|
}
|
|
53
53
|
getHash(dataCursor, x, y, z) {
|
|
@@ -59,26 +59,26 @@ export class VoxelGeometryBuilderCacheSpace {
|
|
|
59
59
|
}
|
|
60
60
|
hashState(dataCursor, index, x, y, z) {
|
|
61
61
|
if (this.foundHash[index] == 1)
|
|
62
|
-
return
|
|
62
|
+
return;
|
|
63
63
|
if (this.foundHash[index] == 2)
|
|
64
|
-
return
|
|
64
|
+
return;
|
|
65
65
|
const voxel = dataCursor.getVoxel(x, y, z);
|
|
66
66
|
if (!voxel || !voxel.isRenderable()) {
|
|
67
67
|
this.foundHash[index] = 1;
|
|
68
|
-
return
|
|
68
|
+
return;
|
|
69
69
|
}
|
|
70
70
|
const voxelId = voxel.getId();
|
|
71
71
|
const voxelConstructor = VoxelModelConstructorRegister.constructorsPaltte[voxelId];
|
|
72
72
|
if (!voxelConstructor) {
|
|
73
73
|
this.foundHash[index] = 1;
|
|
74
|
-
return
|
|
74
|
+
return;
|
|
75
75
|
}
|
|
76
76
|
this.voxelCache[index] = voxelId;
|
|
77
77
|
this.foundHash[index] = 2;
|
|
78
78
|
//no ao
|
|
79
79
|
this.noCastAO[index] = voxel.isLightSource() || voxel.noAO() ? 1 : 0;
|
|
80
80
|
//state
|
|
81
|
-
const state = voxelConstructor.
|
|
81
|
+
const state = voxelConstructor.stateTree.getState(voxel.getState());
|
|
82
82
|
this.stateCache[index] = state;
|
|
83
83
|
//mod
|
|
84
84
|
const mod = voxelConstructor.modTree.getState(voxel.getMod());
|
|
@@ -91,6 +91,5 @@ export class VoxelGeometryBuilderCacheSpace {
|
|
|
91
91
|
voxelConstructor.schema.dataCursor = dataCursor;
|
|
92
92
|
const conditonalState = voxelConstructor.condtioanlShapeStateTree.getState();
|
|
93
93
|
this.conditonalStateCache[index] = conditonalState;
|
|
94
|
-
return 1;
|
|
95
94
|
}
|
|
96
95
|
}
|
|
@@ -86,7 +86,7 @@ export class VoxelModelBuilder {
|
|
|
86
86
|
this.bounds.max[0] = -Infinity;
|
|
87
87
|
this.bounds.max[1] = -Infinity;
|
|
88
88
|
this.bounds.max[2] = -Infinity;
|
|
89
|
-
this._boundsUpdate =
|
|
89
|
+
this._boundsUpdate = false;
|
|
90
90
|
}
|
|
91
91
|
endConstruction() {
|
|
92
92
|
this.vars.reset();
|
|
@@ -94,13 +94,6 @@ export class VoxelModelBuilder {
|
|
|
94
94
|
if (!this._boundsUpdate)
|
|
95
95
|
return false;
|
|
96
96
|
this.bvhTool.updateVoxel(this.position.x, this.position.y, this.position.z, this._indexStart, this.materialIndex, this.mesh.indicieCount, this.bounds.min[0], this.bounds.min[1], this.bounds.min[2], this.bounds.max[0], this.bounds.max[1], this.bounds.max[2]);
|
|
97
|
-
this.bvhTool.structCursor.setIndex(0);
|
|
98
|
-
this.mesh.minBounds.x = this.bvhTool.structCursor.minX;
|
|
99
|
-
this.mesh.minBounds.y = this.bvhTool.structCursor.minY;
|
|
100
|
-
this.mesh.minBounds.z = this.bvhTool.structCursor.minZ;
|
|
101
|
-
this.mesh.maxBounds.x = this.bvhTool.structCursor.maxX;
|
|
102
|
-
this.mesh.maxBounds.y = this.bvhTool.structCursor.maxY;
|
|
103
|
-
this.mesh.maxBounds.z = this.bvhTool.structCursor.maxZ;
|
|
104
97
|
}
|
|
105
98
|
return true;
|
|
106
99
|
}
|