@divinevoxel/vlox 0.0.7 → 0.0.72
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/Main/InitDataGenerator.js +0 -9
- package/Contexts/Base/Remote/DataSync.types.d.ts +0 -5
- package/Contexts/Base/Remote/InitDataSync.js +17 -31
- package/Init/StartConstructor.js +2 -4
- package/Init/StartWorld.js +0 -12
- package/Math/Indexing.d.ts +12 -3
- package/Math/Indexing.js +24 -15
- package/Mesher/Functions/CompactVoxelMesh.d.ts +1 -1
- package/Mesher/Functions/CompactVoxelMesh.js +3 -4
- package/Mesher/Functions/MeshSection.d.ts +1 -1
- package/Mesher/Functions/MeshSection.js +54 -60
- package/Mesher/Functions/MeshVoxel.js +20 -26
- package/Mesher/Geomtry/Buffers.d.ts +9 -8
- package/Mesher/Geomtry/Buffers.js +26 -58
- package/Mesher/Geomtry/Tools/MesherDataTools.d.ts +1 -1
- package/Mesher/Geomtry/Tools/MesherDataTools.js +1 -1
- package/Mesher/Geomtry/VoxelGeometryBuilder.js +107 -124
- package/Mesher/InitMesher.js +1 -10
- package/Mesher/InitTask.js +10 -4
- package/Mesher/Models/Common/BoundsFunctions.d.ts +1 -3
- package/Mesher/Models/Common/BoundsFunctions.js +0 -16
- package/Mesher/Models/Common/Calc/CalcConstants.js +14 -31
- package/Mesher/Models/Common/Calc/FaceDataCalc.d.ts +1 -7
- package/Mesher/Models/Common/Calc/FaceDataCalc.js +41 -50
- package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.d.ts +1 -5
- package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +30 -26
- package/Mesher/Models/Nodes/GeometryNode.d.ts +2 -4
- package/Mesher/Models/Nodes/GeometryNode.js +1 -2
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.d.ts +2 -6
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +37 -34
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.d.ts +2 -6
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +52 -51
- package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.d.ts +2 -6
- package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.js +18 -19
- package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.d.ts +2 -6
- package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.js +37 -40
- package/Mesher/Models/VoxelConstructor.d.ts +3 -4
- package/Mesher/Models/VoxelConstructor.js +23 -12
- package/Mesher/Models/{VoxelGeometryLookUp.d.ts → VoxelGeometryBuilderCacheSpace.d.ts} +8 -14
- package/Mesher/Models/{VoxelGeometryLookUp.js → VoxelGeometryBuilderCacheSpace.js} +49 -44
- package/Mesher/Models/VoxelModelConstructorRegister.js +3 -3
- package/Mesher/Tools/VoxelMeshBVHBuilder.d.ts +2 -9
- package/Mesher/Tools/VoxelMeshBVHBuilder.js +4 -16
- package/Mesher/Tools/VoxelMeshVertexStructCursor.d.ts +10 -0
- package/Mesher/Tools/VoxelMeshVertexStructCursor.js +10 -0
- package/Mesher/Tools/VoxelMesherDataTool.d.ts +8 -5
- package/Mesher/Tools/VoxelMesherDataTool.js +34 -13
- package/Models/Indexing/VoxelAOResultsIndex.d.ts +4 -4
- package/Models/Indexing/VoxelAOResultsIndex.js +15 -9
- package/Models/Indexing/VoxelFaceCullResultsIndex.d.ts +3 -3
- package/Models/Indexing/VoxelFaceCullResultsIndex.js +14 -9
- package/Models/Indexing/VoxelFaceTransparentResultsIndex.d.ts +1 -1
- package/Models/Indexing/VoxelFaceTransparentResultsIndex.js +1 -1
- package/Models/Rules/Functions/BuildRules.js +2 -2
- package/Tasks/IWG/Internal/Classes/Generator.js +1 -1
- package/Tasks/IWG/Internal/Functions/getSectorState.js +4 -7
- package/Tasks/IWG/Internal/Functions/runWorldUpdate.js +5 -6
- package/Tasks/IWG/Internal/IWGTasks.js +12 -21
- package/Tasks/Propagation/Flow/FlowManager.d.ts +0 -2
- package/Tasks/Propagation/Flow/FlowManager.js +86 -87
- package/Tasks/Propagation/Flow/WorldFlow.js +2 -3
- package/Tasks/Propagation/Illumanation/WorldRGB.js +1 -2
- package/Tasks/Update/InitTasks.d.ts +2 -1
- package/Tasks/Update/InitTasks.js +6 -6
- package/Tasks/Update/VoxelUpdate.js +15 -7
- package/Tasks/WorldGeneration/WorldGenBrush.js +1 -0
- package/Templates/Cursor/TemplateCursor.d.ts +1 -1
- package/Templates/Cursor/TemplateCursor.js +1 -1
- package/Templates/Functions/CreateTemplate.js +1 -1
- package/Templates/VoxelTemplate.js +6 -8
- package/Tools/Brush/Brush.d.ts +0 -2
- package/Tools/Brush/Brush.js +5 -6
- package/{Data/Cursor → Tools}/DataCursor.interface.d.ts +1 -1
- package/Util/Binary/BitArray.d.ts +4 -0
- package/Util/Binary/BitArray.js +16 -0
- package/Util/StringPalette.d.ts +1 -0
- package/Util/StringPalette.js +8 -0
- package/Voxels/Cursor/VoxelCursor.d.ts +6 -6
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +10 -15
- package/Voxels/Cursor/VoxelCursor.interface.js +30 -50
- package/Voxels/Cursor/VoxelCursor.js +13 -12
- package/Voxels/Cursor/VoxelLightData.d.ts +3 -4
- package/Voxels/Cursor/VoxelLightData.js +8 -7
- package/Voxels/Data/VoxelPalettesRegister.d.ts +13 -0
- package/Voxels/Data/VoxelPalettesRegister.js +17 -0
- package/Voxels/Data/VoxelTag.types.d.ts +56 -0
- package/Voxels/Data/VoxelTag.types.js +23 -0
- package/Voxels/{State → Data}/VoxelTagStates.d.ts +2 -2
- package/Voxels/{State → Data}/VoxelTagStates.js +5 -5
- package/Voxels/Data/VoxelTagsRegister.d.ts +9 -0
- package/Voxels/Data/VoxelTagsRegister.js +32 -0
- package/Voxels/Functions/BuildStateData.js +3 -3
- package/Voxels/Functions/BuildTagAndPaletteData.d.ts +13 -0
- package/Voxels/Functions/BuildTagAndPaletteData.js +57 -0
- package/Voxels/Indexes/VoxelIndex.js +3 -3
- package/Voxels/InitVoxelData.js +20 -61
- package/Voxels/State/Schema/StateSchema.d.ts +1 -1
- package/Voxels/Types/Voxel.types.d.ts +2 -42
- package/Voxels/Types/Voxel.types.js +0 -15
- package/Voxels/Types/VoxelModelCompiledData.types.d.ts +11 -13
- package/Voxels/Types/VoxelSubstances.types.d.ts +2 -15
- package/Voxels/Types/VoxelSubstances.types.js +1 -9
- package/World/Archive/Functions/ArchiveArea.js +2 -6
- package/World/Archive/Functions/ArchiveSector.js +14 -28
- package/World/Archive/Functions/ImportSector.js +27 -34
- package/World/Cursor/SectionCursor.d.ts +2 -1
- package/World/Cursor/SectionCursor.js +8 -2
- package/World/Cursor/SectorCursor.d.ts +2 -1
- package/World/Cursor/SectorCursor.js +5 -2
- package/World/Cursor/WorldCursor.d.ts +1 -1
- package/World/Cursor/WorldCursor.js +6 -2
- package/World/Cursor/WorldVoxelCursor.d.ts +7 -7
- package/World/Cursor/WorldVoxelCursor.js +20 -24
- package/World/Section/Section.d.ts +20 -8
- package/World/Section/Section.js +65 -9
- package/World/Sector/Sector.d.ts +13 -6
- package/World/Sector/Sector.js +30 -9
- package/World/Sector/SectorHeightMap.js +1 -3
- package/World/Sector/SectorState.d.ts +13 -0
- package/World/Sector/SectorState.js +15 -0
- package/World/WorldSpaces.d.ts +2 -0
- package/World/WorldSpaces.js +7 -1
- package/package.json +1 -1
- package/Data/Register/MappedDataRegister.d.ts +0 -5
- package/Data/Register/MappedDataRegister.js +0 -9
- package/Data/Register/MappedRegisterBase.d.ts +0 -14
- package/Data/Register/MappedRegisterBase.js +0 -50
- package/Data/Structs/StructBuilder.d.ts +0 -34
- package/Data/Structs/StructBuilder.js +0 -157
- package/Data/Structs/StructBuilder.types.d.ts +0 -30
- package/Data/Structs/StructBuilder.types.js +0 -1
- package/Tools/Data/SubstanceDataTool.d.ts +0 -13
- package/Tools/Data/SubstanceDataTool.js +0 -51
- package/Voxels/Palettes/MaterialPalette.d.ts +0 -9
- package/Voxels/Palettes/MaterialPalette.js +0 -11
- package/Voxels/Palettes/SubstancePalette.d.ts +0 -9
- package/Voxels/Palettes/SubstancePalette.js +0 -11
- package/Voxels/Palettes/VoxelPalette.d.ts +0 -11
- package/Voxels/Palettes/VoxelPalette.js +0 -15
- package/Voxels/Segments/MaterialDataGenerator.d.ts +0 -6
- package/Voxels/Segments/MaterialDataGenerator.js +0 -12
- package/Voxels/Segments/SubstanceDataGenerator.d.ts +0 -6
- package/Voxels/Segments/SubstanceDataGenerator.js +0 -35
- package/Voxels/Segments/VoxelDataGenerator.d.ts +0 -10
- package/Voxels/Segments/VoxelDataGenerator.js +0 -56
- package/Voxels/Structs/Builder/SubstanceStructBuilder.d.ts +0 -2
- package/Voxels/Structs/Builder/SubstanceStructBuilder.js +0 -42
- package/Voxels/Structs/Builder/VoxelStructBuilder.d.ts +0 -2
- package/Voxels/Structs/Builder/VoxelStructBuilder.js +0 -68
- package/Voxels/Structs/SubstanceStruct.d.ts +0 -17
- package/Voxels/Structs/SubstanceStruct.js +0 -17
- package/Voxels/Structs/VoxelStruct.d.ts +0 -27
- package/Voxels/Structs/VoxelStruct.js +0 -29
- package/World/Section/SectionHeightMap.d.ts +0 -10
- package/World/Section/SectionHeightMap.js +0 -39
- package/World/Section/SectionStruct.d.ts +0 -8
- package/World/Section/SectionStruct.js +0 -29
- package/World/Section/SectionStructProperties.d.ts +0 -10
- package/World/Section/SectionStructProperties.js +0 -11
- package/World/Sector/SectorStruct.d.ts +0 -1
- package/World/Sector/SectorStruct.js +0 -46
- package/World/Sector/SectorStructIds.d.ts +0 -13
- package/World/Sector/SectorStructIds.js +0 -14
- /package/{Data/Cursor → Tools}/DataCursor.interface.js +0 -0
- /package/{Data/Functions → Util/Binary}/Palettes.d.ts +0 -0
- /package/{Data/Functions → Util/Binary}/Palettes.js +0 -0
- /package/Voxels/{VoxelLevelReader.d.ts → Cursor/VoxelLevelReader.d.ts} +0 -0
- /package/Voxels/{VoxelLevelReader.js → Cursor/VoxelLevelReader.js} +0 -0
|
@@ -4,7 +4,6 @@ import { Quad } from "../../../../Geomtry/Primitives/Quad";
|
|
|
4
4
|
import { QuadVerticies } from "../../../../Geomtry/Geometry.types";
|
|
5
5
|
import { QuadScalarVertexData } from "../../../../Geomtry/Primitives/QuadVertexData";
|
|
6
6
|
import { VoxelFaceDirections, VoxelFaces } from "../../../../../Math";
|
|
7
|
-
import { UpdateBounds } from "../../../Common/BoundsFunctions";
|
|
8
7
|
import { shouldCauseFlip } from "../../../Common/Calc/CalcConstants";
|
|
9
8
|
import { getFlowAngle, getFlowGradient, FlowVerticies } from "./FlowGradient";
|
|
10
9
|
import { GetBoxGeometryNodeData } from "../../../Common/BoxGeometryNode";
|
|
@@ -37,41 +36,40 @@ const { quads: Quads, vertexWeights, quadBounds, } = GetBoxGeometryNodeData([
|
|
|
37
36
|
Quads[VoxelFaces.Up].setUVs(uvs);
|
|
38
37
|
Quads[VoxelFaces.Down].setUVs(uvs);
|
|
39
38
|
export class LiquidGeometryNode extends GeoemtryNode {
|
|
40
|
-
worldLight;
|
|
41
39
|
init() {
|
|
42
40
|
this.faceCount = 1;
|
|
43
41
|
this.vertexCount = 0;
|
|
44
42
|
}
|
|
45
43
|
isExposed(face) {
|
|
46
|
-
const nv = this.
|
|
44
|
+
const nv = this.builder.nVoxel.getVoxel(VoxelFaceDirections[face][0] + this.builder.position.x, VoxelFaceDirections[face][1] + this.builder.position.y, VoxelFaceDirections[face][2] + this.builder.position.z);
|
|
47
45
|
if (!nv ||
|
|
48
46
|
nv.isAir() ||
|
|
49
|
-
(!this.
|
|
47
|
+
(!this.builder.voxel.isSameVoxel(nv) && face == VoxelFaces.Up))
|
|
50
48
|
return true;
|
|
51
49
|
return false;
|
|
52
50
|
}
|
|
53
51
|
determineShading(face) {
|
|
54
|
-
const tool = this.
|
|
52
|
+
const tool = this.builder;
|
|
55
53
|
const lightData = tool.lightData[face];
|
|
56
|
-
const worldLight = this.
|
|
54
|
+
const worldLight = this.builder.vars.light;
|
|
57
55
|
for (let v = 0; v < 4; v++) {
|
|
58
56
|
worldLight.vertices[v] = lightData[v];
|
|
59
57
|
}
|
|
60
58
|
}
|
|
61
59
|
shouldFlip() {
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
const worldLight = this.builder.vars.light;
|
|
61
|
+
return (shouldCauseFlip(lightData.getS(worldLight.vertices[0]), lightData.getS(worldLight.vertices[1]), lightData.getS(worldLight.vertices[2]), lightData.getS(worldLight.vertices[3])) ||
|
|
62
|
+
shouldCauseFlip(lightData.sumRGB(worldLight.vertices[0]), lightData.sumRGB(worldLight.vertices[1]), lightData.sumRGB(worldLight.vertices[2]), lightData.sumRGB(worldLight.vertices[3])));
|
|
64
63
|
}
|
|
65
|
-
add(
|
|
64
|
+
add(args) {
|
|
66
65
|
vertexLevel.setAll(15);
|
|
67
66
|
vertexValue.setAll(0);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this.origin = tool.position;
|
|
71
|
-
this.worldLight = tool.vars.light;
|
|
67
|
+
const tool = this.builder;
|
|
68
|
+
let added = false;
|
|
72
69
|
let upFaceExposed = false;
|
|
73
70
|
if (this.isExposed(VoxelFaces.Up)) {
|
|
74
71
|
upFaceExposed = true;
|
|
72
|
+
added = true;
|
|
75
73
|
getFlowGradient(tool, vertexLevel);
|
|
76
74
|
const quad = Quads[VoxelFaces.Up];
|
|
77
75
|
tool.calculateFaceData(VoxelFaces.Up);
|
|
@@ -94,20 +92,22 @@ export class LiquidGeometryNode extends GeoemtryNode {
|
|
|
94
92
|
quad.positions.vertices[1].y = vertexValue.vertices[1] * waterHeight;
|
|
95
93
|
quad.positions.vertices[2].y = vertexValue.vertices[2] * waterHeight;
|
|
96
94
|
quad.positions.vertices[3].y = vertexValue.vertices[3] * waterHeight;
|
|
97
|
-
VoxelGeometryBuilder.addQuad(tool, origin, quad);
|
|
98
|
-
|
|
95
|
+
VoxelGeometryBuilder.addQuad(tool, tool.origin, quad);
|
|
96
|
+
tool.updateBounds(quadBounds[VoxelFaces.Up]);
|
|
99
97
|
}
|
|
100
98
|
if (this.isExposed(VoxelFaces.Down)) {
|
|
99
|
+
added = true;
|
|
101
100
|
tool.vars.textureIndex = args.stillTexture;
|
|
102
101
|
const quad = Quads[VoxelFaces.Down];
|
|
103
102
|
tool.calculateFaceData(VoxelFaces.Down);
|
|
104
103
|
this.determineShading(VoxelFaces.Down);
|
|
105
104
|
quad.flip = this.shouldFlip();
|
|
106
105
|
tool.vars.textureIndex = args.stillTexture;
|
|
107
|
-
VoxelGeometryBuilder.addQuad(tool, origin, quad);
|
|
108
|
-
|
|
106
|
+
VoxelGeometryBuilder.addQuad(tool, tool.origin, quad);
|
|
107
|
+
tool.updateBounds(quadBounds[VoxelFaces.Down]);
|
|
109
108
|
}
|
|
110
109
|
if (this.isExposed(VoxelFaces.North)) {
|
|
110
|
+
added = true;
|
|
111
111
|
tool.vars.textureIndex = args.stillTexture;
|
|
112
112
|
const quad = Quads[VoxelFaces.North];
|
|
113
113
|
tool.vars.animation.setAll(1);
|
|
@@ -129,10 +129,11 @@ export class LiquidGeometryNode extends GeoemtryNode {
|
|
|
129
129
|
quad.positions.vertices[QuadVerticies.TopLeft].y = 1;
|
|
130
130
|
quad.setUVs(uvs);
|
|
131
131
|
}
|
|
132
|
-
VoxelGeometryBuilder.addQuad(tool, origin, quad);
|
|
133
|
-
|
|
132
|
+
VoxelGeometryBuilder.addQuad(tool, tool.origin, quad);
|
|
133
|
+
tool.updateBounds(quadBounds[VoxelFaces.North]);
|
|
134
134
|
}
|
|
135
135
|
if (this.isExposed(VoxelFaces.South)) {
|
|
136
|
+
added = true;
|
|
136
137
|
tool.vars.textureIndex = args.stillTexture;
|
|
137
138
|
const quad = Quads[VoxelFaces.South];
|
|
138
139
|
tool.vars.animation.setAll(1);
|
|
@@ -154,10 +155,11 @@ export class LiquidGeometryNode extends GeoemtryNode {
|
|
|
154
155
|
quad.positions.vertices[QuadVerticies.TopRight].y = 1;
|
|
155
156
|
quad.setUVs(uvs);
|
|
156
157
|
}
|
|
157
|
-
VoxelGeometryBuilder.addQuad(tool, origin, quad);
|
|
158
|
-
|
|
158
|
+
VoxelGeometryBuilder.addQuad(tool, tool.origin, quad);
|
|
159
|
+
tool.updateBounds(quadBounds[VoxelFaces.South]);
|
|
159
160
|
}
|
|
160
161
|
if (this.isExposed(VoxelFaces.East)) {
|
|
162
|
+
added = true;
|
|
161
163
|
tool.vars.textureIndex = args.stillTexture;
|
|
162
164
|
const quad = Quads[VoxelFaces.East];
|
|
163
165
|
tool.vars.animation.setAll(1);
|
|
@@ -179,10 +181,11 @@ export class LiquidGeometryNode extends GeoemtryNode {
|
|
|
179
181
|
quad.positions.vertices[QuadVerticies.TopRight].y = 1;
|
|
180
182
|
quad.setUVs(uvs);
|
|
181
183
|
}
|
|
182
|
-
VoxelGeometryBuilder.addQuad(tool, origin, quad);
|
|
183
|
-
|
|
184
|
+
VoxelGeometryBuilder.addQuad(tool, tool.origin, quad);
|
|
185
|
+
tool.updateBounds(quadBounds[VoxelFaces.East]);
|
|
184
186
|
}
|
|
185
187
|
if (this.isExposed(VoxelFaces.West)) {
|
|
188
|
+
added = true;
|
|
186
189
|
tool.vars.textureIndex = args.stillTexture;
|
|
187
190
|
const quad = Quads[VoxelFaces.West];
|
|
188
191
|
tool.vars.animation.setAll(1);
|
|
@@ -204,9 +207,10 @@ export class LiquidGeometryNode extends GeoemtryNode {
|
|
|
204
207
|
quad.positions.vertices[QuadVerticies.TopRight].y = 1;
|
|
205
208
|
quad.setUVs(uvs);
|
|
206
209
|
}
|
|
207
|
-
VoxelGeometryBuilder.addQuad(tool, origin, quad);
|
|
208
|
-
|
|
210
|
+
VoxelGeometryBuilder.addQuad(tool, tool.origin, quad);
|
|
211
|
+
tool.updateBounds(quadBounds[VoxelFaces.West]);
|
|
209
212
|
}
|
|
210
|
-
this.
|
|
213
|
+
this.builder.vars.light.setAll(0);
|
|
214
|
+
return added;
|
|
211
215
|
}
|
|
212
216
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { VoxelMesherDataTool } from "../../../Mesher/Tools/VoxelMesherDataTool";
|
|
2
|
-
import { Vector3Like } from "@amodx/math";
|
|
3
2
|
import { VoxelGeometryConstructor } from "./VoxelGeometryConstructor";
|
|
4
3
|
import { VoxelGeometryTransform } from "../../../Voxels/Types/VoxelModelCompiledData.types";
|
|
5
4
|
export interface GeoemtryNodeConstructor<Data = any, Args = any> {
|
|
@@ -14,9 +13,8 @@ export declare abstract class GeoemtryNode<Data = any, Args = any> {
|
|
|
14
13
|
vertexIndex: number;
|
|
15
14
|
faceCount: number;
|
|
16
15
|
vertexCount: number;
|
|
17
|
-
|
|
18
|
-
origin: Vector3Like;
|
|
16
|
+
builder: VoxelMesherDataTool;
|
|
19
17
|
constructor(geometryPaletteId: number, geomtry: VoxelGeometryConstructor, data: Data, transform: VoxelGeometryTransform);
|
|
20
18
|
abstract init(): void;
|
|
21
|
-
abstract add(
|
|
19
|
+
abstract add(args: Args): boolean;
|
|
22
20
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { Vec3Array, Vec4Array
|
|
1
|
+
import { Vec3Array, Vec4Array } from "@amodx/math";
|
|
2
2
|
import { VoxelFaces } from "../../../../Math";
|
|
3
|
-
import { QuadScalarVertexData } from "../../../Geomtry/Primitives/QuadVertexData";
|
|
4
3
|
import { VoxelBoxGeometryNode } from "../../../../Models/VoxelModel.types";
|
|
5
4
|
import { Quad } from "../../../Geomtry/Primitives/Quad";
|
|
6
|
-
import { VoxelMesherDataTool } from "../../../../Mesher/Tools/VoxelMesherDataTool";
|
|
7
5
|
import { BoxVoxelGometryArgs } from "../../../../Models/Input/BoxVoxelGometryInputs";
|
|
8
6
|
import { GeoemtryNode } from "../GeometryNode";
|
|
9
7
|
import { VoxelLightData } from "../../../../Voxels/Cursor/VoxelLightData";
|
|
@@ -16,12 +14,10 @@ export declare class BoxVoxelGometryNode extends GeoemtryNode<VoxelBoxGeometryNo
|
|
|
16
14
|
Vec4Array,
|
|
17
15
|
Vec4Array
|
|
18
16
|
]>;
|
|
19
|
-
worldLight: QuadScalarVertexData;
|
|
20
|
-
worldAO: QuadScalarVertexData;
|
|
21
17
|
lightData: VoxelLightData;
|
|
22
18
|
init(): void;
|
|
23
19
|
isExposed(face: VoxelFaces): boolean;
|
|
24
20
|
determineShading(face: VoxelFaces): void;
|
|
25
21
|
shouldFlip(): boolean;
|
|
26
|
-
add(
|
|
22
|
+
add(args: BoxVoxelGometryArgs): boolean;
|
|
27
23
|
}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { BoxVoxelGometryInputs, } from "../../../../Models/Input/BoxVoxelGometryInputs";
|
|
2
|
-
import { VoxelGeometryLookUp } from "../../VoxelGeometryLookUp";
|
|
3
2
|
import { GeoemtryNode } from "../GeometryNode";
|
|
4
3
|
import { getInterpolationValue, shouldCauseFlip, } from "../../Common/Calc/CalcConstants";
|
|
5
4
|
import { VoxelRelativeCubeIndexPositionMap } from "../../../../Models/Indexing/VoxelRelativeCubeIndex";
|
|
6
5
|
import { GetBoxGeometryNodeData } from "../../Common/BoxGeometryNode";
|
|
7
|
-
import { UpdateBounds } from "../../Common/BoundsFunctions";
|
|
8
6
|
import { VoxelLightData } from "../../../../Voxels/Cursor/VoxelLightData";
|
|
9
7
|
import { VoxelGeometryBuilder } from "../../../Geomtry/VoxelGeometryBuilder";
|
|
8
|
+
import { VoxelModelConstructorRegister } from "../../../Models/VoxelModelConstructorRegister";
|
|
10
9
|
const ArgIndexes = BoxVoxelGometryInputs.ArgIndexes;
|
|
11
10
|
export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
12
11
|
quads;
|
|
13
12
|
quadBounds = [];
|
|
14
13
|
vertexWeights;
|
|
15
|
-
worldLight;
|
|
16
|
-
worldAO;
|
|
17
14
|
lightData = new VoxelLightData();
|
|
18
15
|
init() {
|
|
19
16
|
this.faceCount = 6;
|
|
@@ -28,23 +25,25 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
28
25
|
const faceIndexes = this.geomtry.faceCullMap[trueFaceIndex];
|
|
29
26
|
if (!faceIndexes)
|
|
30
27
|
return true;
|
|
31
|
-
const tool = this.
|
|
28
|
+
const tool = this.builder;
|
|
32
29
|
for (let positionIndex = 0; positionIndex < faceIndexes.length; positionIndex++) {
|
|
33
30
|
const currentIndex = faceIndexes[positionIndex];
|
|
34
31
|
const p = VoxelRelativeCubeIndexPositionMap[currentIndex];
|
|
35
|
-
const hashed =
|
|
36
|
-
if (
|
|
32
|
+
const hashed = this.builder.space.getHash(tool.nVoxel, tool.position.x + p[0], tool.position.y + p[1], tool.position.z + p[2]);
|
|
33
|
+
if (this.builder.space.foundHash[hashed] < 2)
|
|
37
34
|
continue;
|
|
38
|
-
const offsetBaseGometry =
|
|
39
|
-
const offsetConditonalGeometry =
|
|
35
|
+
const offsetBaseGometry = this.builder.space.getGeomtry(hashed);
|
|
36
|
+
const offsetConditonalGeometry = this.builder.space.getConditionalGeomtry(hashed);
|
|
40
37
|
if (offsetBaseGometry) {
|
|
41
38
|
for (let i = 0; i < offsetBaseGometry.length; i++) {
|
|
42
39
|
const geoId = offsetBaseGometry[i];
|
|
43
|
-
if (
|
|
40
|
+
if (VoxelModelConstructorRegister.rulesless[geoId])
|
|
44
41
|
continue;
|
|
45
42
|
const faceIndex = this.geomtry.cullIndex.getValue(geoId, currentIndex, trueFaceIndex);
|
|
46
43
|
if (faceIndex > -1 &&
|
|
47
|
-
!
|
|
44
|
+
!this.builder
|
|
45
|
+
.space.getConstructor(hashed)
|
|
46
|
+
?.isShapeStateFaceTransparent(this.builder.space.modCache[hashed], this.builder.space.stateCache[hashed], geoId, faceIndex)) {
|
|
48
47
|
return false;
|
|
49
48
|
}
|
|
50
49
|
}
|
|
@@ -55,11 +54,13 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
55
54
|
const cond = offsetConditonalGeometry[i];
|
|
56
55
|
for (let k = 0; k < cond.length; k++) {
|
|
57
56
|
const geoId = cond[k];
|
|
58
|
-
if (
|
|
57
|
+
if (VoxelModelConstructorRegister.rulesless[geoId])
|
|
59
58
|
continue;
|
|
60
59
|
const faceIndex = this.geomtry.cullIndex.getValue(geoId, currentIndex, trueFaceIndex);
|
|
61
60
|
if (faceIndex > -1 &&
|
|
62
|
-
!
|
|
61
|
+
!this.builder
|
|
62
|
+
.space.getConstructor(hashed)
|
|
63
|
+
?.isCondtionalStateFaceTransparent(this.builder.space.modCache[hashed], this.builder.space.stateCache[hashed], geoId, faceIndex))
|
|
63
64
|
return false;
|
|
64
65
|
}
|
|
65
66
|
}
|
|
@@ -67,11 +68,11 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
67
68
|
return true;
|
|
68
69
|
}
|
|
69
70
|
determineShading(face) {
|
|
70
|
-
const tool = this.
|
|
71
|
+
const tool = this.builder;
|
|
71
72
|
const lightData = tool.lightData[face];
|
|
72
|
-
const noAO = this.
|
|
73
|
-
const worldLight = this.
|
|
74
|
-
const worldAO = this.
|
|
73
|
+
const noAO = this.builder.voxel.isLightSource() || this.builder.voxel.noAO();
|
|
74
|
+
const worldLight = this.builder.vars.light;
|
|
75
|
+
const worldAO = this.builder.vars.ao;
|
|
75
76
|
for (let v = 0; v < 4; v++) {
|
|
76
77
|
worldAO.vertices[v] = 0;
|
|
77
78
|
worldLight.vertices[v] = getInterpolationValue(lightData, this.vertexWeights[face][v]);
|
|
@@ -84,12 +85,12 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
84
85
|
for (let positionIndex = 0; positionIndex < aoIndexes.length; positionIndex++) {
|
|
85
86
|
const currentIndex = aoIndexes[positionIndex];
|
|
86
87
|
const p = VoxelRelativeCubeIndexPositionMap[currentIndex];
|
|
87
|
-
const hashed =
|
|
88
|
-
if (
|
|
89
|
-
|
|
88
|
+
const hashed = this.builder.space.getHash(tool.nVoxel, tool.position.x + p[0], tool.position.y + p[1], tool.position.z + p[2]);
|
|
89
|
+
if (this.builder.space.foundHash[hashed] < 2 ||
|
|
90
|
+
this.builder.space.noCastAO[hashed] === 1)
|
|
90
91
|
continue;
|
|
91
|
-
const baseGeo =
|
|
92
|
-
const conditonalGeo =
|
|
92
|
+
const baseGeo = this.builder.space.getGeomtry(hashed);
|
|
93
|
+
const conditonalGeo = this.builder.space.getConditionalGeomtry(hashed);
|
|
93
94
|
if (!baseGeo && !conditonalGeo)
|
|
94
95
|
continue;
|
|
95
96
|
let length = 0;
|
|
@@ -120,18 +121,19 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
shouldFlip() {
|
|
123
|
-
|
|
124
|
+
const worldAO = this.builder.vars.ao;
|
|
125
|
+
const worldLight = this.builder.vars.light;
|
|
126
|
+
if (shouldCauseFlip(worldAO.vertices[0], worldAO.vertices[1], worldAO.vertices[2], worldAO.vertices[3]))
|
|
124
127
|
return true;
|
|
125
|
-
return (shouldCauseFlip(this.lightData.getS(
|
|
126
|
-
shouldCauseFlip(this.lightData.sumRGB(
|
|
128
|
+
return (shouldCauseFlip(this.lightData.getS(worldLight.vertices[0]), this.lightData.getS(worldLight.vertices[1]), this.lightData.getS(worldLight.vertices[2]), this.lightData.getS(worldLight.vertices[3])) ||
|
|
129
|
+
shouldCauseFlip(this.lightData.sumRGB(worldLight.vertices[0]), this.lightData.sumRGB(worldLight.vertices[1]), this.lightData.sumRGB(worldLight.vertices[2]), this.lightData.sumRGB(worldLight.vertices[3])));
|
|
127
130
|
}
|
|
128
|
-
add(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
this.worldAO = tool.vars.ao;
|
|
132
|
-
this.worldLight = tool.vars.light;
|
|
131
|
+
add(args) {
|
|
132
|
+
let added = false;
|
|
133
|
+
const tool = this.builder;
|
|
133
134
|
for (let face = 0; face < 6; face++) {
|
|
134
135
|
if (args[face][ArgIndexes.Enabled] && this.isExposed(face)) {
|
|
136
|
+
added = true;
|
|
135
137
|
tool.calculateFaceData(face);
|
|
136
138
|
this.determineShading(face);
|
|
137
139
|
const faceArgs = args[face];
|
|
@@ -151,11 +153,12 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
151
153
|
//4
|
|
152
154
|
quad.uvs.vertices[3].x = uvs[3][0];
|
|
153
155
|
quad.uvs.vertices[3].y = uvs[3][1];
|
|
154
|
-
VoxelGeometryBuilder.addQuad(tool, origin, quad);
|
|
155
|
-
|
|
156
|
+
VoxelGeometryBuilder.addQuad(tool, this.builder.origin, quad);
|
|
157
|
+
tool.updateBounds(this.quadBounds[face]);
|
|
156
158
|
}
|
|
157
159
|
}
|
|
158
|
-
this.
|
|
159
|
-
this.
|
|
160
|
+
this.builder.vars.ao.setAll(0);
|
|
161
|
+
this.builder.vars.light.setAll(0);
|
|
162
|
+
return added;
|
|
160
163
|
}
|
|
161
164
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { Vec3Array, Vec4Array
|
|
1
|
+
import { Vec3Array, Vec4Array } from "@amodx/math";
|
|
2
2
|
import { VoxelFaces } from "../../../../Math";
|
|
3
|
-
import { QuadScalarVertexData } from "../../../Geomtry/Primitives/QuadVertexData";
|
|
4
3
|
import { VoxelQuadGeometryNode } from "../../../../Models/VoxelModel.types";
|
|
5
4
|
import { Quad } from "../../../Geomtry/Primitives/Quad";
|
|
6
|
-
import { VoxelMesherDataTool } from "../../../../Mesher/Tools/VoxelMesherDataTool";
|
|
7
5
|
import { GeoemtryNode } from "../GeometryNode";
|
|
8
6
|
import { QuadVoxelGometryArgs } from "../../../../Models/Input/QuadVoxelGometryInputs";
|
|
9
7
|
import { VoxelLightData } from "../../../../Voxels/Cursor/VoxelLightData";
|
|
@@ -11,13 +9,11 @@ export declare class QuadVoxelGometryNode extends GeoemtryNode<VoxelQuadGeometry
|
|
|
11
9
|
quad: Quad;
|
|
12
10
|
quadBounds: [Vec3Array, Vec3Array];
|
|
13
11
|
vertexWeights: [Vec4Array, Vec4Array, Vec4Array, Vec4Array];
|
|
14
|
-
worldLight: QuadScalarVertexData;
|
|
15
|
-
worldAO: QuadScalarVertexData;
|
|
16
12
|
closestFace: VoxelFaces;
|
|
17
13
|
lightData: VoxelLightData;
|
|
18
14
|
init(): void;
|
|
19
15
|
isExposed(): boolean;
|
|
20
16
|
determineShading(): void;
|
|
21
17
|
shouldFlip(): boolean;
|
|
22
|
-
add(
|
|
18
|
+
add(args: QuadVoxelGometryArgs): boolean;
|
|
23
19
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { VoxelFaces } from "../../../../Math";
|
|
2
2
|
import { VoxelGeometryBuilder } from "../../../Geomtry/VoxelGeometryBuilder";
|
|
3
|
-
import { VoxelGeometryLookUp } from "../../VoxelGeometryLookUp";
|
|
4
3
|
import { GeoemtryNode } from "../GeometryNode";
|
|
5
4
|
import { getInterpolationValue, shouldCauseFlip, } from "../../Common/Calc/CalcConstants";
|
|
6
5
|
import { VoxelRelativeCubeIndexPositionMap } from "../../../../Models/Indexing/VoxelRelativeCubeIndex";
|
|
7
6
|
import { QuadVoxelGometryInputs, } from "../../../../Models/Input/QuadVoxelGometryInputs";
|
|
8
7
|
import { GetQuadGeometryData } from "../../Common/QuadGeometryNode";
|
|
9
|
-
import { UpdateBounds } from "../../Common/BoundsFunctions";
|
|
10
8
|
import { VoxelLightData } from "../../../../Voxels/Cursor/VoxelLightData";
|
|
11
9
|
const ArgIndexes = QuadVoxelGometryInputs.ArgIndexes;
|
|
12
10
|
export class QuadVoxelGometryNode extends GeoemtryNode {
|
|
@@ -16,8 +14,6 @@ export class QuadVoxelGometryNode extends GeoemtryNode {
|
|
|
16
14
|
[0, 0, 0],
|
|
17
15
|
];
|
|
18
16
|
vertexWeights;
|
|
19
|
-
worldLight;
|
|
20
|
-
worldAO;
|
|
21
17
|
closestFace;
|
|
22
18
|
lightData = new VoxelLightData();
|
|
23
19
|
init() {
|
|
@@ -34,18 +30,20 @@ export class QuadVoxelGometryNode extends GeoemtryNode {
|
|
|
34
30
|
const faceIndexes = this.geomtry.faceCullMap[trueFaceIndex];
|
|
35
31
|
if (!faceIndexes)
|
|
36
32
|
return true;
|
|
37
|
-
const tool = this.
|
|
33
|
+
const tool = this.builder;
|
|
38
34
|
for (let positionIndex = 0; positionIndex < faceIndexes.length; positionIndex++) {
|
|
39
35
|
const currentIndex = faceIndexes[positionIndex];
|
|
40
36
|
const p = VoxelRelativeCubeIndexPositionMap[currentIndex];
|
|
41
|
-
const hashed =
|
|
42
|
-
const offsetBaseGometry =
|
|
43
|
-
const offsetConditonalGeometry =
|
|
37
|
+
const hashed = this.builder.space.getHash(tool.nVoxel, tool.position.x + p[0], tool.position.y + p[1], tool.position.z + p[2]);
|
|
38
|
+
const offsetBaseGometry = this.builder.space.getGeomtry(hashed);
|
|
39
|
+
const offsetConditonalGeometry = this.builder.space.getConditionalGeomtry(hashed);
|
|
44
40
|
if (offsetBaseGometry) {
|
|
45
41
|
for (let i = 0; i < offsetBaseGometry.length; i++) {
|
|
46
42
|
const faceIndex = this.geomtry.cullIndex.getValue(offsetBaseGometry[i], currentIndex, trueFaceIndex);
|
|
47
43
|
if (faceIndex > -1 &&
|
|
48
|
-
!
|
|
44
|
+
!this.builder
|
|
45
|
+
.space.getConstructor(hashed)
|
|
46
|
+
?.isShapeStateFaceTransparent(this.builder.space.modCache[hashed], this.builder.space.stateCache[hashed], offsetBaseGometry[i], faceIndex)) {
|
|
49
47
|
return false;
|
|
50
48
|
}
|
|
51
49
|
}
|
|
@@ -57,7 +55,9 @@ export class QuadVoxelGometryNode extends GeoemtryNode {
|
|
|
57
55
|
for (let k = 0; k < cond.length; k++) {
|
|
58
56
|
const faceIndex = this.geomtry.cullIndex.getValue(cond[k], currentIndex, trueFaceIndex);
|
|
59
57
|
if (faceIndex > -1 &&
|
|
60
|
-
!
|
|
58
|
+
!this.builder
|
|
59
|
+
.space.getConstructor(hashed)
|
|
60
|
+
?.isCondtionalStateFaceTransparent(this.builder.space.modCache[hashed], this.builder.space.stateCache[hashed], cond[i], faceIndex))
|
|
61
61
|
return false;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -65,11 +65,11 @@ export class QuadVoxelGometryNode extends GeoemtryNode {
|
|
|
65
65
|
return true;
|
|
66
66
|
}
|
|
67
67
|
determineShading() {
|
|
68
|
-
const tool = this.
|
|
68
|
+
const tool = this.builder;
|
|
69
69
|
const lightData = tool.lightData[VoxelFaces.Up];
|
|
70
|
-
const noAO = this.
|
|
71
|
-
const worldLight =
|
|
72
|
-
const worldAO =
|
|
70
|
+
const noAO = this.builder.voxel.isLightSource() || this.builder.voxel.noAO();
|
|
71
|
+
const worldLight = tool.vars.light;
|
|
72
|
+
const worldAO = tool.vars.ao;
|
|
73
73
|
for (let v = 0; v < 4; v++) {
|
|
74
74
|
worldAO.vertices[v] = 0;
|
|
75
75
|
worldLight.vertices[v] = getInterpolationValue(lightData, this.vertexWeights[v]);
|
|
@@ -82,11 +82,11 @@ export class QuadVoxelGometryNode extends GeoemtryNode {
|
|
|
82
82
|
for (let positionIndex = 0; positionIndex < aoIndexes.length; positionIndex++) {
|
|
83
83
|
const currentIndex = aoIndexes[positionIndex];
|
|
84
84
|
const p = VoxelRelativeCubeIndexPositionMap[currentIndex];
|
|
85
|
-
const hashed =
|
|
86
|
-
if (
|
|
85
|
+
const hashed = this.builder.space.getHash(tool.nVoxel, tool.position.x + p[0], tool.position.y + p[1], tool.position.z + p[2]);
|
|
86
|
+
if (this.builder.space.noCastAO[hashed] === 1)
|
|
87
87
|
continue;
|
|
88
|
-
const baseGeo =
|
|
89
|
-
const conditonalGeo =
|
|
88
|
+
const baseGeo = this.builder.space.getGeomtry(hashed);
|
|
89
|
+
const conditonalGeo = this.builder.space.getConditionalGeomtry(hashed);
|
|
90
90
|
if (!baseGeo && !conditonalGeo)
|
|
91
91
|
continue;
|
|
92
92
|
let length = 0;
|
|
@@ -117,40 +117,41 @@ export class QuadVoxelGometryNode extends GeoemtryNode {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
shouldFlip() {
|
|
120
|
-
|
|
120
|
+
const worldAO = this.builder.vars.ao;
|
|
121
|
+
const worldLight = this.builder.vars.light;
|
|
122
|
+
if (shouldCauseFlip(worldAO.vertices[0], worldAO.vertices[1], worldAO.vertices[2], worldAO.vertices[3]))
|
|
121
123
|
return true;
|
|
122
|
-
return (shouldCauseFlip(this.lightData.getS(
|
|
123
|
-
shouldCauseFlip(this.lightData.sumRGB(
|
|
124
|
+
return (shouldCauseFlip(this.lightData.getS(worldLight.vertices[0]), this.lightData.getS(worldLight.vertices[1]), this.lightData.getS(worldLight.vertices[2]), this.lightData.getS(worldLight.vertices[3])) ||
|
|
125
|
+
shouldCauseFlip(this.lightData.sumRGB(worldLight.vertices[0]), this.lightData.sumRGB(worldLight.vertices[1]), this.lightData.sumRGB(worldLight.vertices[2]), this.lightData.sumRGB(worldLight.vertices[3])));
|
|
124
126
|
}
|
|
125
|
-
add(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
this.worldAO.setAll(0);
|
|
127
|
+
add(args) {
|
|
128
|
+
if (!args[ArgIndexes.Enabled])
|
|
129
|
+
return false;
|
|
130
|
+
if (!this.isExposed())
|
|
131
|
+
return false;
|
|
132
|
+
this.builder.calculateFaceData(this.closestFace);
|
|
133
|
+
this.determineShading();
|
|
134
|
+
const quad = this.quad;
|
|
135
|
+
quad.flip = this.shouldFlip() || args[ArgIndexes.Fliped];
|
|
136
|
+
this.builder.vars.textureIndex = args[ArgIndexes.Texture];
|
|
137
|
+
quad.doubleSided = args[ArgIndexes.DoubleSided];
|
|
138
|
+
const uvs = args[ArgIndexes.UVs];
|
|
139
|
+
//1
|
|
140
|
+
quad.uvs.vertices[0].x = uvs[0][0];
|
|
141
|
+
quad.uvs.vertices[0].y = uvs[0][1];
|
|
142
|
+
//2
|
|
143
|
+
quad.uvs.vertices[1].x = uvs[1][0];
|
|
144
|
+
quad.uvs.vertices[1].y = uvs[1][1];
|
|
145
|
+
//3
|
|
146
|
+
quad.uvs.vertices[2].x = uvs[2][0];
|
|
147
|
+
quad.uvs.vertices[2].y = uvs[2][1];
|
|
148
|
+
//4
|
|
149
|
+
quad.uvs.vertices[3].x = uvs[3][0];
|
|
150
|
+
quad.uvs.vertices[3].y = uvs[3][1];
|
|
151
|
+
VoxelGeometryBuilder.addQuad(this.builder, this.builder.origin, quad);
|
|
152
|
+
this.builder.updateBounds(this.quadBounds);
|
|
153
|
+
this.builder.vars.light.setAll(0);
|
|
154
|
+
this.builder.vars.ao.setAll(0);
|
|
155
|
+
return true;
|
|
155
156
|
}
|
|
156
157
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { Vec3Array, Vec4Array
|
|
1
|
+
import { Vec3Array, Vec4Array } from "@amodx/math";
|
|
2
2
|
import { VoxelFaces } from "../../../../Math";
|
|
3
|
-
import { QuadScalarVertexData } from "../../../Geomtry/Primitives/QuadVertexData";
|
|
4
3
|
import { VoxelBoxGeometryNode } from "../../../../Models/VoxelModel.types";
|
|
5
4
|
import { Quad } from "../../../Geomtry/Primitives/Quad";
|
|
6
|
-
import { VoxelMesherDataTool } from "../../../../Mesher/Tools/VoxelMesherDataTool";
|
|
7
5
|
import { BoxVoxelGometryArgs } from "../../../../Models/Input/BoxVoxelGometryInputs";
|
|
8
6
|
import { VoxelLightData } from "../../../../Voxels/Cursor/VoxelLightData";
|
|
9
7
|
import { GeoemtryNode } from "../GeometryNode";
|
|
@@ -16,11 +14,9 @@ export declare class RulelessBoxVoxelGeometryNode extends GeoemtryNode<VoxelBoxG
|
|
|
16
14
|
Vec4Array,
|
|
17
15
|
Vec4Array
|
|
18
16
|
]>;
|
|
19
|
-
worldLight: QuadScalarVertexData;
|
|
20
|
-
worldAO: QuadScalarVertexData;
|
|
21
17
|
lightData: VoxelLightData;
|
|
22
18
|
init(): void;
|
|
23
19
|
determineShading(face: VoxelFaces): void;
|
|
24
20
|
shouldFlip(): boolean;
|
|
25
|
-
add(
|
|
21
|
+
add(args: BoxVoxelGometryArgs): boolean;
|
|
26
22
|
}
|
|
@@ -4,14 +4,11 @@ import { getInterpolationValue, shouldCauseFlip, } from "../../Common/Calc/CalcC
|
|
|
4
4
|
import { VoxelLightData } from "../../../../Voxels/Cursor/VoxelLightData";
|
|
5
5
|
import { GeoemtryNode } from "../GeometryNode";
|
|
6
6
|
import { GetBoxGeometryNodeData } from "../../Common/BoxGeometryNode";
|
|
7
|
-
import { UpdateBounds } from "../../Common/BoundsFunctions";
|
|
8
7
|
const ArgIndexes = BoxVoxelGometryInputs.ArgIndexes;
|
|
9
8
|
export class RulelessBoxVoxelGeometryNode extends GeoemtryNode {
|
|
10
9
|
quads;
|
|
11
10
|
quadBounds = [];
|
|
12
11
|
vertexWeights;
|
|
13
|
-
worldLight;
|
|
14
|
-
worldAO;
|
|
15
12
|
lightData = new VoxelLightData();
|
|
16
13
|
init() {
|
|
17
14
|
this.faceCount = 6;
|
|
@@ -22,11 +19,11 @@ export class RulelessBoxVoxelGeometryNode extends GeoemtryNode {
|
|
|
22
19
|
this.vertexWeights = vertexWeights;
|
|
23
20
|
}
|
|
24
21
|
determineShading(face) {
|
|
25
|
-
const tool = this.
|
|
22
|
+
const tool = this.builder;
|
|
26
23
|
const lightData = tool.lightData[face];
|
|
27
|
-
const noAO = this.
|
|
28
|
-
const worldLight = this.
|
|
29
|
-
const worldAO = this.
|
|
24
|
+
const noAO = this.builder.voxel.isLightSource() || this.builder.voxel.noAO();
|
|
25
|
+
const worldLight = this.builder.vars.light;
|
|
26
|
+
const worldAO = this.builder.vars.ao;
|
|
30
27
|
for (let v = 0; v < 4; v++) {
|
|
31
28
|
worldAO.vertices[v] = 0;
|
|
32
29
|
worldLight.vertices[v] = getInterpolationValue(lightData, this.vertexWeights[face][v]);
|
|
@@ -35,18 +32,19 @@ export class RulelessBoxVoxelGeometryNode extends GeoemtryNode {
|
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
34
|
shouldFlip() {
|
|
38
|
-
|
|
35
|
+
const worldLight = this.builder.vars.light;
|
|
36
|
+
const worldAO = this.builder.vars.ao;
|
|
37
|
+
if (shouldCauseFlip(worldAO.vertices[0], worldAO.vertices[1], worldAO.vertices[2], worldAO.vertices[3]))
|
|
39
38
|
return true;
|
|
40
|
-
return (shouldCauseFlip(this.lightData.getS(
|
|
41
|
-
shouldCauseFlip(this.lightData.sumRGB(
|
|
39
|
+
return (shouldCauseFlip(this.lightData.getS(worldLight.vertices[0]), this.lightData.getS(worldLight.vertices[1]), this.lightData.getS(worldLight.vertices[2]), this.lightData.getS(worldLight.vertices[3])) ||
|
|
40
|
+
shouldCauseFlip(this.lightData.sumRGB(worldLight.vertices[0]), this.lightData.sumRGB(worldLight.vertices[1]), this.lightData.sumRGB(worldLight.vertices[2]), this.lightData.sumRGB(worldLight.vertices[3])));
|
|
42
41
|
}
|
|
43
|
-
add(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.worldAO = tool.vars.ao;
|
|
47
|
-
this.worldLight = tool.vars.light;
|
|
42
|
+
add(args) {
|
|
43
|
+
const tool = this.builder;
|
|
44
|
+
let added = false;
|
|
48
45
|
for (let face = 0; face < 6; face++) {
|
|
49
46
|
if (args[face][ArgIndexes.Enabled]) {
|
|
47
|
+
added = true;
|
|
50
48
|
tool.calculateFaceData(face);
|
|
51
49
|
this.determineShading(face);
|
|
52
50
|
const faceArgs = args[face];
|
|
@@ -66,11 +64,12 @@ export class RulelessBoxVoxelGeometryNode extends GeoemtryNode {
|
|
|
66
64
|
//4
|
|
67
65
|
quad.uvs.vertices[3].x = uvs[3][0];
|
|
68
66
|
quad.uvs.vertices[3].y = uvs[3][1];
|
|
69
|
-
VoxelGeometryBuilder.addQuad(tool,
|
|
70
|
-
|
|
67
|
+
VoxelGeometryBuilder.addQuad(tool, tool.position, quad);
|
|
68
|
+
this.builder.updateBounds(this.quadBounds[face]);
|
|
71
69
|
}
|
|
72
70
|
}
|
|
73
|
-
this.
|
|
74
|
-
this.
|
|
71
|
+
this.builder.vars.light.setAll(0);
|
|
72
|
+
this.builder.vars.ao.setAll(0);
|
|
73
|
+
return added;
|
|
75
74
|
}
|
|
76
75
|
}
|