@divinevoxel/vlox 0.0.5 → 0.0.7
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/InitWorldDataSync.js +2 -4
- package/Contexts/Render/DVERenderThreads.d.ts +1 -1
- package/Contexts/Render/DVERenderThreads.js +2 -2
- package/Contexts/Render/DivineVoxelEngineRender.d.ts +5 -5
- package/Contexts/Render/DivineVoxelEngineRender.js +1 -1
- package/Contexts/World/DivineVoxelEngineWorld.d.ts +5 -5
- package/Init/StartRenderer.js +5 -5
- package/Math/Indexing.js +6 -6
- package/Mesher/Functions/CompactVoxelMesh.js +40 -7
- package/Mesher/Functions/MeshSection.js +16 -9
- package/Mesher/Functions/MeshTexture.d.ts +1 -1
- package/Mesher/Functions/MeshVoxel.js +5 -4
- package/Mesher/Geomtry/Buffers.d.ts +19 -0
- package/Mesher/Geomtry/Buffers.js +81 -0
- package/Mesher/Geomtry/Tools/MesherDataTools.d.ts +3 -3
- package/Mesher/Geomtry/Tools/MesherDataTools.js +2 -2
- package/Mesher/Geomtry/VoxelGeometryBuilder.js +3 -3
- package/Mesher/Geomtry/VoxelMesh.d.ts +12 -0
- package/Mesher/Geomtry/VoxelMesh.js +25 -0
- package/Mesher/InitTask.js +1 -2
- package/Mesher/Models/Common/BoxGeometryNode.js +2 -1
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +10 -7
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +7 -7
- package/Mesher/Models/Nodes/VoxelGeometryConstructor.js +1 -1
- package/Mesher/Models/VoxelConstructor.d.ts +0 -2
- package/Mesher/Models/VoxelConstructor.js +9 -15
- package/Mesher/Models/VoxelGeometryLookUp.d.ts +20 -11
- package/Mesher/Models/VoxelGeometryLookUp.js +84 -50
- package/Mesher/Tools/VoxelMeshBVHBuilder.js +20 -25
- package/Mesher/Tools/VoxelMeshVertexStructCursor.d.ts +3 -1
- package/Mesher/Tools/VoxelMesherDataTool.d.ts +3 -2
- package/Mesher/Tools/VoxelMesherDataTool.js +8 -3
- package/Renderer/Classes/DVESectionMeshes.d.ts +1 -0
- package/Renderer/Classes/SectionMesh.d.ts +1 -2
- package/Renderer/Classes/SectionMesh.js +0 -3
- package/Renderer/InitTasks.js +16 -1
- package/Renderer/MeshManager.js +4 -0
- package/Renderer/MeshRegister.d.ts +1 -6
- package/Renderer/index.d.ts +0 -1
- package/Renderer/index.js +0 -1
- package/Settings/EngineSettings.d.ts +5 -5
- package/Settings/EngineSettings.js +15 -15
- package/Settings/EngineSettings.types.d.ts +62 -44
- package/Settings/EngineSettings.types.js +44 -42
- package/Tasks/IWG/IWG.d.ts +3 -0
- package/Tasks/IWG/IWG.js +3 -0
- package/Tasks/IWG/Internal/Functions/cullSectors.js +1 -2
- package/Tasks/IWG/Internal/Functions/getSectorState.js +1 -1
- package/Tasks/IWG/Internal/Functions/runBuildUpdate.js +1 -2
- package/Tasks/IWG/Internal/Functions/runWorldUpdate.js +1 -2
- package/Tasks/IWG/Internal/IWGTasks.js +7 -13
- package/Tasks/Propagation/Explosion/ExplosionManager.js +1 -1
- package/Tasks/Propagation/Flow/WorldFlow.js +6 -8
- package/Tasks/Propagation/Illumanation/RGBUpdate.js +2 -2
- package/Tasks/Propagation/Illumanation/WorldRGB.js +2 -3
- package/Tasks/Propagation/Illumanation/WorldSun.js +11 -5
- package/Tasks/Update/VoxelUpdate.js +21 -26
- package/Tasks/WorldGeneration/WorldGenRegister.js +5 -8
- package/Tasks/WorldGeneration/WorldGeneration.d.ts +0 -2
- package/Tasks/WorldGeneration/WorldGeneration.js +0 -2
- package/Templates/Cursor/TemplateVoxelCursor.d.ts +1 -0
- package/Templates/Cursor/TemplateVoxelCursor.js +1 -0
- package/Textures/TextureBuilder.d.ts +1 -1
- package/Textures/TextureBuilder.js +1 -1
- package/Textures/TextureManager.js +1 -1
- package/Tools/Brush/Brush.d.ts +1 -0
- package/Tools/Brush/Brush.js +8 -11
- package/Voxels/Cursor/VoxelCursor.d.ts +1 -0
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +5 -0
- package/Voxels/Cursor/VoxelCursor.interface.js +5 -5
- package/Voxels/Cursor/VoxelCursor.js +5 -3
- package/Voxels/VoxelLevelReader.d.ts +10 -0
- package/Voxels/VoxelLevelReader.js +20 -0
- package/World/Archive/Functions/ArchiveSector.d.ts +1 -1
- package/World/Archive/Functions/ArchiveSector.js +2 -3
- package/World/Archive/InitTasks.js +2 -3
- package/World/Cursor/SectionCursor.js +1 -2
- package/World/Cursor/SectorCursor.d.ts +1 -0
- package/World/Cursor/SectorCursor.js +8 -3
- package/World/Cursor/WorldCursor.js +1 -2
- package/World/Cursor/WorldVoxelCursor.d.ts +1 -5
- package/World/Cursor/WorldVoxelCursor.js +1 -5
- package/World/InitTasks.js +5 -10
- package/World/Lock/WorldLock.js +4 -5
- package/World/Sector/SectorHeightMap.js +4 -6
- package/World/WorldRegister.d.ts +4 -6
- package/World/WorldRegister.js +24 -20
- package/World/WorldSpaces.d.ts +21 -0
- package/World/WorldSpaces.js +58 -7
- package/package.json +1 -1
- package/Mesher/Geomtry/Mesh.d.ts +0 -11
- package/Mesher/Geomtry/Mesh.js +0 -23
- package/Renderer/Classes/DVESectionMeshInterface.d.ts +0 -3
- package/Renderer/Classes/DVESectionMeshInterface.js +0 -1
- package/Voxels/VoxelStateReader.d.ts +0 -12
- package/Voxels/VoxelStateReader.js +0 -30
- package/World/WorldBounds.d.ts +0 -20
- package/World/WorldBounds.js +0 -53
|
@@ -1,46 +1,64 @@
|
|
|
1
|
+
import { Vector3Like } from "@amodx/math";
|
|
2
|
+
export interface RenderSettingsData {
|
|
3
|
+
}
|
|
4
|
+
export declare class RenderSettingsData {
|
|
5
|
+
mode: "webgl" | "webgpu";
|
|
6
|
+
cpuBound: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface TextureSettings {
|
|
9
|
+
}
|
|
10
|
+
export declare class TextureSettings {
|
|
11
|
+
textureSize: number;
|
|
12
|
+
}
|
|
13
|
+
export interface UpdatingSettings {
|
|
14
|
+
}
|
|
15
|
+
export declare class UpdatingSettings {
|
|
16
|
+
autoRebuild: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface WorldSettings {
|
|
19
|
+
}
|
|
20
|
+
export declare class WorldSettings {
|
|
21
|
+
min: Vector3Like;
|
|
22
|
+
max: Vector3Like;
|
|
23
|
+
}
|
|
24
|
+
export interface SectorSettings {
|
|
25
|
+
}
|
|
26
|
+
export declare class SectorSettings {
|
|
27
|
+
power2Size: Vector3Like;
|
|
28
|
+
}
|
|
29
|
+
export interface SectionSettings {
|
|
30
|
+
}
|
|
31
|
+
export declare class SectionSettings {
|
|
32
|
+
power2Size: Vector3Like;
|
|
33
|
+
}
|
|
34
|
+
export interface VoxelSettings {
|
|
35
|
+
}
|
|
36
|
+
export declare class VoxelSettings {
|
|
37
|
+
doColors: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface FlowSettings {
|
|
40
|
+
}
|
|
41
|
+
export declare class FlowSettings {
|
|
42
|
+
enable: boolean;
|
|
43
|
+
baseFlowLimit: number;
|
|
44
|
+
}
|
|
45
|
+
export interface LightingSettings {
|
|
46
|
+
}
|
|
47
|
+
export declare class LightingSettings {
|
|
48
|
+
doAO: boolean;
|
|
49
|
+
doSunLight: boolean;
|
|
50
|
+
doRGBLight: boolean;
|
|
51
|
+
autoRGBLight: boolean;
|
|
52
|
+
autoSunLight: boolean;
|
|
53
|
+
}
|
|
1
54
|
export declare class EngineSettingsData {
|
|
2
|
-
rendererSettings:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
autoRebuild: boolean;
|
|
12
|
-
};
|
|
13
|
-
world: {
|
|
14
|
-
maxX: number;
|
|
15
|
-
minX: number;
|
|
16
|
-
maxZ: number;
|
|
17
|
-
minZ: number;
|
|
18
|
-
maxY: number;
|
|
19
|
-
minY: number;
|
|
20
|
-
};
|
|
21
|
-
sectors: {
|
|
22
|
-
sectorXPow2: number;
|
|
23
|
-
sectorYPow2: number;
|
|
24
|
-
sectorZPow2: number;
|
|
25
|
-
};
|
|
26
|
-
sections: {
|
|
27
|
-
autoHeightMap: boolean;
|
|
28
|
-
sectionXPow2: number;
|
|
29
|
-
sectionYPow2: number;
|
|
30
|
-
sectionZPow2: number;
|
|
31
|
-
};
|
|
32
|
-
voxels: {
|
|
33
|
-
doColors: boolean;
|
|
34
|
-
};
|
|
35
|
-
flow: {
|
|
36
|
-
enable: boolean;
|
|
37
|
-
baseFlowLimit: number;
|
|
38
|
-
};
|
|
39
|
-
lighting: {
|
|
40
|
-
doAO: boolean;
|
|
41
|
-
doSunLight: boolean;
|
|
42
|
-
doRGBLight: boolean;
|
|
43
|
-
autoRGBLight: boolean;
|
|
44
|
-
autoSunLight: boolean;
|
|
45
|
-
};
|
|
55
|
+
rendererSettings: RenderSettingsData;
|
|
56
|
+
textures: TextureSettings;
|
|
57
|
+
updating: UpdatingSettings;
|
|
58
|
+
world: WorldSettings;
|
|
59
|
+
sectors: SectorSettings;
|
|
60
|
+
sections: SectionSettings;
|
|
61
|
+
voxels: VoxelSettings;
|
|
62
|
+
flow: FlowSettings;
|
|
63
|
+
lighting: LightingSettings;
|
|
46
64
|
}
|
|
@@ -1,44 +1,46 @@
|
|
|
1
|
+
import { Vector3Like } from "@amodx/math";
|
|
2
|
+
export class RenderSettingsData {
|
|
3
|
+
mode = "webgl";
|
|
4
|
+
cpuBound = false;
|
|
5
|
+
}
|
|
6
|
+
export class TextureSettings {
|
|
7
|
+
textureSize = 16;
|
|
8
|
+
}
|
|
9
|
+
export class UpdatingSettings {
|
|
10
|
+
autoRebuild = true;
|
|
11
|
+
}
|
|
12
|
+
export class WorldSettings {
|
|
13
|
+
min = Vector3Like.Create(-Number.MAX_SAFE_INTEGER, 0, -Number.MAX_SAFE_INTEGER);
|
|
14
|
+
max = Vector3Like.Create(Number.MAX_SAFE_INTEGER, 256, Number.MAX_SAFE_INTEGER);
|
|
15
|
+
}
|
|
16
|
+
export class SectorSettings {
|
|
17
|
+
power2Size = Vector3Like.Create(4, 8, 4);
|
|
18
|
+
}
|
|
19
|
+
export class SectionSettings {
|
|
20
|
+
power2Size = Vector3Like.Create(4, 4, 4);
|
|
21
|
+
}
|
|
22
|
+
export class VoxelSettings {
|
|
23
|
+
doColors = true;
|
|
24
|
+
}
|
|
25
|
+
export class FlowSettings {
|
|
26
|
+
enable = true;
|
|
27
|
+
baseFlowLimit = 200;
|
|
28
|
+
}
|
|
29
|
+
export class LightingSettings {
|
|
30
|
+
doAO = true;
|
|
31
|
+
doSunLight = true;
|
|
32
|
+
doRGBLight = true;
|
|
33
|
+
autoRGBLight = true;
|
|
34
|
+
autoSunLight = true;
|
|
35
|
+
}
|
|
1
36
|
export class EngineSettingsData {
|
|
2
|
-
rendererSettings =
|
|
3
|
-
textures =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
world = {
|
|
12
|
-
maxX: Number.MAX_SAFE_INTEGER,
|
|
13
|
-
minX: -Number.MAX_SAFE_INTEGER,
|
|
14
|
-
maxZ: Number.MAX_SAFE_INTEGER,
|
|
15
|
-
minZ: -Number.MAX_SAFE_INTEGER,
|
|
16
|
-
maxY: 256,
|
|
17
|
-
minY: 0,
|
|
18
|
-
};
|
|
19
|
-
sectors = {
|
|
20
|
-
sectorXPow2: 4,
|
|
21
|
-
sectorYPow2: 8,
|
|
22
|
-
sectorZPow2: 4,
|
|
23
|
-
};
|
|
24
|
-
sections = {
|
|
25
|
-
autoHeightMap: true,
|
|
26
|
-
sectionXPow2: 4,
|
|
27
|
-
sectionYPow2: 4,
|
|
28
|
-
sectionZPow2: 4,
|
|
29
|
-
};
|
|
30
|
-
voxels = {
|
|
31
|
-
doColors: true,
|
|
32
|
-
};
|
|
33
|
-
flow = {
|
|
34
|
-
enable: true,
|
|
35
|
-
baseFlowLimit: 200,
|
|
36
|
-
};
|
|
37
|
-
lighting = {
|
|
38
|
-
doAO: true,
|
|
39
|
-
doSunLight: true,
|
|
40
|
-
doRGBLight: true,
|
|
41
|
-
autoRGBLight: true,
|
|
42
|
-
autoSunLight: true,
|
|
43
|
-
};
|
|
37
|
+
rendererSettings = new RenderSettingsData();
|
|
38
|
+
textures = new TextureSettings();
|
|
39
|
+
updating = new UpdatingSettings();
|
|
40
|
+
world = new WorldSettings();
|
|
41
|
+
sectors = new SectorSettings();
|
|
42
|
+
sections = new SectionSettings();
|
|
43
|
+
voxels = new VoxelSettings();
|
|
44
|
+
flow = new FlowSettings();
|
|
45
|
+
lighting = new LightingSettings();
|
|
44
46
|
}
|
package/Tasks/IWG/IWG.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ interface IWGInitData {
|
|
|
8
8
|
threads: Thread | ThreadPool;
|
|
9
9
|
worldStorage?: WorldStorageInterface;
|
|
10
10
|
}
|
|
11
|
+
/**# Infinite World Generation IWG
|
|
12
|
+
* Object to handle the loading and generating the world around a created generator.
|
|
13
|
+
*/
|
|
11
14
|
export declare class IWG {
|
|
12
15
|
private static _cullGenerators;
|
|
13
16
|
static readonly _generators: Generator[];
|
package/Tasks/IWG/IWG.js
CHANGED
|
@@ -10,6 +10,9 @@ import { Vector3Like } from "@amodx/math";
|
|
|
10
10
|
import { InitalLoad } from "./Procedures/InitalLoad";
|
|
11
11
|
import SaveAllSectors from "./Procedures/SaveAllSectors";
|
|
12
12
|
let initalized = false;
|
|
13
|
+
/**# Infinite World Generation IWG
|
|
14
|
+
* Object to handle the loading and generating the world around a created generator.
|
|
15
|
+
*/
|
|
13
16
|
export class IWG {
|
|
14
17
|
static _cullGenerators = [];
|
|
15
18
|
static _generators = [];
|
|
@@ -70,13 +70,12 @@ export function cullSectors(generatos, cullGenerators) {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
else {
|
|
73
|
-
WorldRegister.sectors.remove(cx, cy, cz);
|
|
73
|
+
WorldRegister.sectors.remove(dimension.id, cx, cy, cz);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
if (!cullGenerators.length)
|
|
78
78
|
continue;
|
|
79
|
-
WorldRegister.setDimension(dimension.id);
|
|
80
79
|
const worldDimension = WorldRegister.dimensions.get(dimension.id);
|
|
81
80
|
for (const [, sector] of worldDimension.sectors) {
|
|
82
81
|
const [cx, cy, cz] = sector.position;
|
|
@@ -14,7 +14,7 @@ export function getSectorState(sector, state, segment) {
|
|
|
14
14
|
if (!segment.vistedMap.has(sectorPOS.x, cy, sectorPOS.z)) {
|
|
15
15
|
segment.queue.push(sectorPOS.x, cy, sectorPOS.z);
|
|
16
16
|
}
|
|
17
|
-
const sector = WorldRegister.sectors.get(sectorPOS.x, cy, sectorPOS.z);
|
|
17
|
+
const sector = WorldRegister.sectors.get(segment.id, sectorPOS.x, cy, sectorPOS.z);
|
|
18
18
|
if (!sector) {
|
|
19
19
|
state.genAlldone = false;
|
|
20
20
|
state.nWorldGenAllDone = false;
|
|
@@ -32,8 +32,7 @@ export function runBuildUpdate(generators) {
|
|
|
32
32
|
sectorSquare.center.y = cz + WorldSpaces.sector.bounds.z / 2;
|
|
33
33
|
if (!Circle.IsSquareInsideOrTouchingCircle(sectorSquare, generator._renderCircle))
|
|
34
34
|
continue;
|
|
35
|
-
WorldRegister.
|
|
36
|
-
const sector = WorldRegister.sectors.get(cx, cy, cz);
|
|
35
|
+
const sector = WorldRegister.sectors.get(generator._dimension, cx, cy, cz);
|
|
37
36
|
if (!sector)
|
|
38
37
|
continue;
|
|
39
38
|
const state = getSectorState(sector, stateCursor, segment);
|
|
@@ -35,8 +35,7 @@ export function runWorldUpdate(generators) {
|
|
|
35
35
|
sectorSquare.center.y = cz + WorldSpaces.sector.bounds.z / 2;
|
|
36
36
|
if (!Circle.IsSquareInsideOrTouchingCircle(sectorSquare, generator._genCircle))
|
|
37
37
|
continue;
|
|
38
|
-
WorldRegister.
|
|
39
|
-
const sector = WorldRegister.sectors.get(cx, cy, cz);
|
|
38
|
+
const sector = WorldRegister.sectors.get(generator._dimension, cx, cy, cz);
|
|
40
39
|
if (!sector) {
|
|
41
40
|
IWGTasks.worldLoadTasks.add(generator._dimension, cx, cy, cz);
|
|
42
41
|
continue;
|
|
@@ -12,12 +12,11 @@ export class IWGTasks {
|
|
|
12
12
|
propagationBlocking: true,
|
|
13
13
|
async run(location, onDone) {
|
|
14
14
|
const [dimension, x, y, z] = location;
|
|
15
|
-
WorldRegister.
|
|
16
|
-
const sector = WorldRegister.sectors.get(x, y, z);
|
|
15
|
+
const sector = WorldRegister.sectors.get(location[0], x, y, z);
|
|
17
16
|
if (sector)
|
|
18
17
|
return onDone();
|
|
19
18
|
if (!IWGTools.worldStorage) {
|
|
20
|
-
WorldRegister.sectors.new(x, y, z);
|
|
19
|
+
WorldRegister.sectors.new(location[0], x, y, z);
|
|
21
20
|
return onDone();
|
|
22
21
|
}
|
|
23
22
|
const loaded = await IWGTools.worldStorage.loadSector([
|
|
@@ -27,8 +26,7 @@ export class IWGTasks {
|
|
|
27
26
|
z,
|
|
28
27
|
]);
|
|
29
28
|
if (!loaded) {
|
|
30
|
-
WorldRegister.
|
|
31
|
-
WorldRegister.sectors.new(x, y, z);
|
|
29
|
+
WorldRegister.sectors.new(location[0], x, y, z);
|
|
32
30
|
}
|
|
33
31
|
onDone();
|
|
34
32
|
},
|
|
@@ -40,8 +38,7 @@ export class IWGTasks {
|
|
|
40
38
|
id: "generate",
|
|
41
39
|
propagationBlocking: true,
|
|
42
40
|
async run(location, onDone) {
|
|
43
|
-
WorldRegister.
|
|
44
|
-
const sector = WorldRegister.sectors.get(location[1], location[2], location[3]);
|
|
41
|
+
const sector = WorldRegister.sectors.get(location[0], location[1], location[2], location[3]);
|
|
45
42
|
if (!sector)
|
|
46
43
|
throw new Error(`Sector at ${location.toString()} does not exist when attempting generation.`);
|
|
47
44
|
Sector.StateStruct.setBuffer(sector.buffer);
|
|
@@ -61,8 +58,7 @@ export class IWGTasks {
|
|
|
61
58
|
id: "decorate",
|
|
62
59
|
propagationBlocking: true,
|
|
63
60
|
async run(location, onDone) {
|
|
64
|
-
WorldRegister.
|
|
65
|
-
const sector = WorldRegister.sectors.get(location[1], location[2], location[3]);
|
|
61
|
+
const sector = WorldRegister.sectors.get(location[0], location[1], location[2], location[3]);
|
|
66
62
|
if (!sector)
|
|
67
63
|
throw new Error(`Sector at ${location.toString()} does not exist when attempting decoration.`);
|
|
68
64
|
Sector.StateStruct.setBuffer(sector.buffer);
|
|
@@ -82,8 +78,7 @@ export class IWGTasks {
|
|
|
82
78
|
id: "wolrd_sun",
|
|
83
79
|
propagationBlocking: true,
|
|
84
80
|
async run(location, onDone) {
|
|
85
|
-
WorldRegister.
|
|
86
|
-
const sector = WorldRegister.sectors.get(location[1], location[2], location[3]);
|
|
81
|
+
const sector = WorldRegister.sectors.get(location[0], location[1], location[2], location[3]);
|
|
87
82
|
if (!sector)
|
|
88
83
|
throw new Error(`Sector at ${location.toString()} does not exist when attempting world sun.`);
|
|
89
84
|
Sector.StateStruct.setBuffer(sector.buffer);
|
|
@@ -103,8 +98,7 @@ export class IWGTasks {
|
|
|
103
98
|
id: "propagation",
|
|
104
99
|
propagationBlocking: true,
|
|
105
100
|
async run(location, onDone) {
|
|
106
|
-
WorldRegister.
|
|
107
|
-
const sector = WorldRegister.sectors.get(location[1], location[2], location[3]);
|
|
101
|
+
const sector = WorldRegister.sectors.get(location[0], location[1], location[2], location[3]);
|
|
108
102
|
if (!sector)
|
|
109
103
|
throw new Error(`Sector at ${location.toString()} does not exist when attempting propagation.`);
|
|
110
104
|
Sector.StateStruct.setBuffer(sector.buffer);
|
|
@@ -4,7 +4,6 @@ import { SectionHeightMap } from "../../../World/Section/SectionHeightMap";
|
|
|
4
4
|
import { EngineSettings } from "../../../Settings/EngineSettings";
|
|
5
5
|
import { SunRemove, SunUpdate } from "../Illumanation/SunUpdate";
|
|
6
6
|
import { RGBRemove, RGBUpdate } from "../Illumanation/RGBUpdate";
|
|
7
|
-
import { WorldBounds } from "../../../World/WorldBounds";
|
|
8
7
|
const flowUpdateChecks = [
|
|
9
8
|
[0, -1, 0],
|
|
10
9
|
[1, 0, 0],
|
|
@@ -51,13 +50,13 @@ function Flood(task, voxel) {
|
|
|
51
50
|
nState == 0) {
|
|
52
51
|
if (downAir && !downSameVoxel) {
|
|
53
52
|
nVoxel.setId(voxelId);
|
|
54
|
-
nVoxel.
|
|
53
|
+
nVoxel.updateVoxel(0);
|
|
55
54
|
nVoxel.setLevel(7);
|
|
56
55
|
nVoxel.setLevelState(1);
|
|
57
56
|
}
|
|
58
57
|
else if (!downSameVoxel) {
|
|
59
58
|
nVoxel.setId(voxelId);
|
|
60
|
-
nVoxel.
|
|
59
|
+
nVoxel.updateVoxel(0);
|
|
61
60
|
nVoxel.setLevel(level - 1);
|
|
62
61
|
nVoxel.setLevelState(0);
|
|
63
62
|
}
|
|
@@ -72,7 +71,7 @@ function Flood(task, voxel) {
|
|
|
72
71
|
}
|
|
73
72
|
continue;
|
|
74
73
|
}
|
|
75
|
-
if (!
|
|
74
|
+
if (!WorldSpaces.world.inBounds(x, y - 1, z) && levelState != 1)
|
|
76
75
|
continue;
|
|
77
76
|
let nVoxel = task.nDataCursor.getVoxel(x, y - 1, z);
|
|
78
77
|
const nLevel = nVoxel.isAir()
|
|
@@ -99,17 +98,16 @@ function Flood(task, voxel) {
|
|
|
99
98
|
task.rgb.remove.push(x, y - 1, z);
|
|
100
99
|
}
|
|
101
100
|
nVoxel.setId(voxelId);
|
|
102
|
-
nVoxel.
|
|
101
|
+
nVoxel.updateVoxel(0);
|
|
103
102
|
nVoxel.setLevel(7);
|
|
104
103
|
nVoxel.setLevelState(state);
|
|
105
104
|
queue.push(x, y - 1, z);
|
|
106
105
|
}
|
|
107
106
|
}
|
|
108
107
|
export function WorldFlow(task) {
|
|
109
|
-
if (!EngineSettings.doFlow
|
|
108
|
+
if (!EngineSettings.doFlow)
|
|
110
109
|
return false;
|
|
111
|
-
WorldRegister.
|
|
112
|
-
const sector = WorldRegister.sectors.get(task.origin[1], task.origin[2], task.origin[3]);
|
|
110
|
+
const sector = WorldRegister.sectors.get(task.origin[0], task.origin[1], task.origin[2], task.origin[3]);
|
|
113
111
|
if (!sector) {
|
|
114
112
|
console.error(`Tried running world flow on a sector that does not exist ${task.origin.toString()}`);
|
|
115
113
|
return false;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { $3dCardinalNeighbors } from "../../../Math/CardinalNeighbors";
|
|
2
|
-
import { getMinusOneForRGB, isGreaterOrEqualThanForRGBRemove, isLessThanForRGBAdd, isLessThanForRGBRemove,
|
|
2
|
+
import { getMinusOneForRGB, isGreaterOrEqualThanForRGBRemove, isLessThanForRGBAdd, isLessThanForRGBRemove, removeRGBLight, } from "./CommonFunctions";
|
|
3
3
|
//@todo change array to not use push and shift
|
|
4
4
|
export function RGBUpdate(tasks) {
|
|
5
5
|
const queue = tasks.rgb.update;
|
|
@@ -76,7 +76,7 @@ export function RGBRemove(tasks) {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
tasks.bounds.update(x, y, z);
|
|
79
|
-
voxel.setLight(
|
|
79
|
+
voxel.setLight(removeRGBLight(sl));
|
|
80
80
|
}
|
|
81
81
|
removeMap.clear();
|
|
82
82
|
}
|
|
@@ -6,10 +6,9 @@ import { EngineSettings } from "../../../Settings/EngineSettings";
|
|
|
6
6
|
import { RGBUpdate } from "./RGBUpdate";
|
|
7
7
|
const sectionCursor = new SectionCursor();
|
|
8
8
|
export function WorldRGB(task) {
|
|
9
|
-
if (!EngineSettings.doLight
|
|
9
|
+
if (!EngineSettings.doLight)
|
|
10
10
|
return false;
|
|
11
|
-
WorldRegister.
|
|
12
|
-
const sector = WorldRegister.sectors.get(task.origin[1], task.origin[2], task.origin[3]);
|
|
11
|
+
const sector = WorldRegister.sectors.get(task.origin[0], task.origin[1], task.origin[2], task.origin[3]);
|
|
13
12
|
if (!sector) {
|
|
14
13
|
console.error(`Tried running world rgb on a sector that does not exist ${task.origin.toString()}`);
|
|
15
14
|
return false;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
//types
|
|
2
2
|
//data
|
|
3
|
-
import { WorldBounds } from "../../../World/WorldBounds.js";
|
|
4
|
-
import { WorldRegister } from "../../../World/WorldRegister.js";
|
|
5
3
|
import { $3dCardinalNeighbors } from "../../../Math/CardinalNeighbors.js";
|
|
6
4
|
import { WorldSpaces } from "../../../World/WorldSpaces.js";
|
|
7
5
|
import { SectorHeightMap } from "../../../World/Sector/SectorHeightMap.js";
|
|
@@ -17,12 +15,11 @@ const FloodOutPositions = [
|
|
|
17
15
|
const queue = [];
|
|
18
16
|
const lightData = new VoxelLightData();
|
|
19
17
|
export function RunWorldSun(tasks) {
|
|
20
|
-
WorldRegister.setDimension(tasks.origin[0]);
|
|
21
18
|
const [dimension, cx, cy, cz] = tasks.origin;
|
|
22
19
|
const RmaxY = SectorHeightMap.getRelative(tasks.origin);
|
|
23
20
|
const AmaxY = SectorHeightMap.getAbsolute(tasks.origin);
|
|
24
21
|
const maxX = cx + WorldSpaces.sector.bounds.x;
|
|
25
|
-
const maxY =
|
|
22
|
+
const maxY = WorldSpaces.world.bounds.MaxY;
|
|
26
23
|
const maxZ = cz + WorldSpaces.sector.bounds.z;
|
|
27
24
|
const sectorCursor = tasks.nDataCursor.getSector(tasks.origin[1], tasks.origin[2], tasks.origin[3]);
|
|
28
25
|
if (!sectorCursor) {
|
|
@@ -30,8 +27,10 @@ export function RunWorldSun(tasks) {
|
|
|
30
27
|
return;
|
|
31
28
|
}
|
|
32
29
|
const minY = AmaxY - 1 < 0 ? 0 : AmaxY;
|
|
30
|
+
const section = sectorCursor.getSection(cx, minY, cz);
|
|
31
|
+
const sectionY = section.getPosition()[1] + WorldSpaces.section.bounds.y;
|
|
33
32
|
//fill
|
|
34
|
-
for (let iy = minY; iy <
|
|
33
|
+
for (let iy = minY; iy < sectionY; iy++) {
|
|
35
34
|
for (let ix = cx; ix < maxX; ix++) {
|
|
36
35
|
for (let iz = cz; iz < maxZ; iz++) {
|
|
37
36
|
const voxel = sectorCursor.getVoxel(ix, iy, iz);
|
|
@@ -44,6 +43,13 @@ export function RunWorldSun(tasks) {
|
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
}
|
|
46
|
+
for (let iy = sectionY; iy < maxY; iy += WorldSpaces.section.bounds.y) {
|
|
47
|
+
const section = sectorCursor.getSection(cx, iy, cz);
|
|
48
|
+
const length = section.light.length;
|
|
49
|
+
for (let i = 0; i < length; i++) {
|
|
50
|
+
section.light[i] = lightData.setS(0xf, section.light[i]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
47
53
|
const maxAcculamteY = AmaxY == RmaxY ? RmaxY + 1 : RmaxY;
|
|
48
54
|
let index = queue.length;
|
|
49
55
|
//accumulate
|
|
@@ -9,8 +9,8 @@ import { FlowRemove } from "../Propagation/Flow/FlowRemove.js";
|
|
|
9
9
|
const tasks = new UpdateTask();
|
|
10
10
|
const substanceData = new SubstanceDataTool();
|
|
11
11
|
const updateLightTask = (tasks) => {
|
|
12
|
-
let doRGB = ES.doRGBPropagation
|
|
13
|
-
let doSun = ES.doSunPropagation
|
|
12
|
+
let doRGB = ES.doRGBPropagation;
|
|
13
|
+
let doSun = ES.doSunPropagation;
|
|
14
14
|
const [dimension, x, y, z] = tasks.origin;
|
|
15
15
|
tasks.nDataCursor.setFocalPoint(dimension, x, y, z);
|
|
16
16
|
for (const n of $3dCardinalNeighbors) {
|
|
@@ -39,7 +39,7 @@ export async function EreaseAndUpdate(location) {
|
|
|
39
39
|
if (!voxel)
|
|
40
40
|
return false;
|
|
41
41
|
substanceData.setSubstance(voxel.getSubstance());
|
|
42
|
-
if (!voxel.isAir() && ES.doFlow
|
|
42
|
+
if (!voxel.isAir() && ES.doFlow && voxel.isRenderable()) {
|
|
43
43
|
if (substanceData.isLiquid()) {
|
|
44
44
|
FlowRemove(tasks);
|
|
45
45
|
return tasks;
|
|
@@ -56,17 +56,17 @@ export async function EreaseAndUpdate(location) {
|
|
|
56
56
|
.setLevelState(0)
|
|
57
57
|
.setState(0)
|
|
58
58
|
.setMod(0)
|
|
59
|
-
.
|
|
60
|
-
if (ES.doLight
|
|
61
|
-
if (ES.doRGBPropagation
|
|
59
|
+
.updateVoxel(1);
|
|
60
|
+
if (ES.doLight) {
|
|
61
|
+
if (ES.doRGBPropagation && isLightSource) {
|
|
62
62
|
tasks.rgb.remove.push(x, y, z);
|
|
63
63
|
RGBRemove(tasks);
|
|
64
64
|
}
|
|
65
65
|
updateLightTask(tasks);
|
|
66
|
-
if (ES.doRGBPropagation
|
|
66
|
+
if (ES.doRGBPropagation) {
|
|
67
67
|
RGBUpdate(tasks);
|
|
68
68
|
}
|
|
69
|
-
if (ES.doSunPropagation
|
|
69
|
+
if (ES.doSunPropagation) {
|
|
70
70
|
SunUpdate(tasks);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -80,9 +80,9 @@ export async function PaintAndUpdate(data) {
|
|
|
80
80
|
return false;
|
|
81
81
|
const raw = data[1];
|
|
82
82
|
const isOpaque = voxel.isOpaque();
|
|
83
|
-
let doRGB = ES.doRGBPropagation
|
|
84
|
-
let doSun = ES.doSunPropagation
|
|
85
|
-
lighttest: if (ES.doLight
|
|
83
|
+
let doRGB = ES.doRGBPropagation;
|
|
84
|
+
let doSun = ES.doSunPropagation;
|
|
85
|
+
lighttest: if (ES.doLight) {
|
|
86
86
|
const light = voxel.getLight();
|
|
87
87
|
if (light <= 0)
|
|
88
88
|
break lighttest;
|
|
@@ -104,24 +104,19 @@ export async function PaintAndUpdate(data) {
|
|
|
104
104
|
if (id < 0)
|
|
105
105
|
return false;
|
|
106
106
|
voxel.setId(id);
|
|
107
|
-
voxel.
|
|
108
|
-
|
|
109
|
-
if (substance > -1 && !voxel.isAir()
|
|
110
|
-
? substanceData.setSubstance(voxel.getSubstance()).isLiquid()
|
|
111
|
-
: false) {
|
|
112
|
-
voxel.setLevel(7);
|
|
113
|
-
}
|
|
107
|
+
voxel.setLevel(raw[2]);
|
|
108
|
+
voxel.setState(raw[3]);
|
|
114
109
|
voxel.setMod(raw[4]);
|
|
115
110
|
if (raw[3] > 0 && voxel.canHaveSecondaryVoxel()) {
|
|
116
111
|
voxel.setSecondary(true);
|
|
117
|
-
voxel.setId(raw[
|
|
112
|
+
voxel.setId(raw[5]);
|
|
118
113
|
voxel.setSecondary(false);
|
|
119
114
|
}
|
|
120
115
|
if (voxel.isLightSource() && voxel.getLightSourceValue()) {
|
|
121
116
|
voxel.setLight(voxel.getLightSourceValue());
|
|
122
117
|
}
|
|
123
|
-
voxel.
|
|
124
|
-
if (ES.doLight
|
|
118
|
+
voxel.updateVoxel(0);
|
|
119
|
+
if (ES.doLight) {
|
|
125
120
|
updateLightTask(tasks);
|
|
126
121
|
if (doRGB) {
|
|
127
122
|
tasks.rgb.update.push(x, y, z);
|
|
@@ -132,7 +127,7 @@ export async function PaintAndUpdate(data) {
|
|
|
132
127
|
}
|
|
133
128
|
}
|
|
134
129
|
voxel = tasks.sDataCursor.getVoxel(x, y, z);
|
|
135
|
-
if (ES.doFlow
|
|
130
|
+
if (ES.doFlow) {
|
|
136
131
|
if (!voxel.isAir() &&
|
|
137
132
|
substanceData.setSubstance(voxel.getSubstance()).isLiquid()) {
|
|
138
133
|
FlowUpdate(tasks);
|
|
@@ -146,9 +141,9 @@ export async function VoxelUpdate(data) {
|
|
|
146
141
|
const voxel = tasks.sDataCursor.getVoxel(x, y, z);
|
|
147
142
|
if (!voxel)
|
|
148
143
|
return false;
|
|
149
|
-
let doRGB = ES.doRGBPropagation
|
|
150
|
-
let doSun = ES.doSunPropagation
|
|
151
|
-
if (ES.doLight
|
|
144
|
+
let doRGB = ES.doRGBPropagation;
|
|
145
|
+
let doSun = ES.doSunPropagation;
|
|
146
|
+
if (ES.doLight) {
|
|
152
147
|
updateLightTask(tasks);
|
|
153
148
|
if (doRGB) {
|
|
154
149
|
tasks.rgb.update.push(x, y, z);
|
|
@@ -159,7 +154,7 @@ export async function VoxelUpdate(data) {
|
|
|
159
154
|
SunUpdate(tasks);
|
|
160
155
|
}
|
|
161
156
|
}
|
|
162
|
-
if (ES.doFlow
|
|
157
|
+
if (ES.doFlow) {
|
|
163
158
|
if (substanceData.setSubstance(voxel.getSubstance()).isLiquid()) {
|
|
164
159
|
FlowUpdate(tasks);
|
|
165
160
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { WorldSpaces } from "../../World/WorldSpaces.js";
|
|
2
2
|
import { BrushTool } from "../../Tools/Brush/Brush";
|
|
3
|
-
import { WorldBounds } from "../../World/WorldBounds";
|
|
4
3
|
import { DivineVoxelEngineConstructor } from "../../Contexts/Constructor";
|
|
5
4
|
import { WorldRegister } from "../../World/WorldRegister";
|
|
6
5
|
const brush = new BrushTool();
|
|
@@ -19,14 +18,13 @@ export class WorldGenRegister {
|
|
|
19
18
|
return id;
|
|
20
19
|
}
|
|
21
20
|
static addToRequest(registerId, location, rawData) {
|
|
22
|
-
if (location[2] <
|
|
23
|
-
location[2] >=
|
|
21
|
+
if (location[2] < WorldSpaces.world.bounds.MinY ||
|
|
22
|
+
location[2] >= WorldSpaces.world.bounds.MaxY)
|
|
24
23
|
return false;
|
|
25
24
|
const requests = this._requests.get(registerId);
|
|
26
25
|
if (!requests)
|
|
27
26
|
return;
|
|
28
|
-
WorldRegister.
|
|
29
|
-
const sector = WorldRegister.sectors.get(location[1], location[2], location[3]);
|
|
27
|
+
const sector = WorldRegister.sectors.get(location[0], location[1], location[2], location[3]);
|
|
30
28
|
if (!sector) {
|
|
31
29
|
const sectorPos = WorldSpaces.sector.getPosition(location[1], location[2], location[3]);
|
|
32
30
|
const sectorKey = WorldSpaces.hash.hashVec3(sectorPos);
|
|
@@ -46,12 +44,11 @@ export class WorldGenRegister {
|
|
|
46
44
|
const requests = this._requests.get(registerId);
|
|
47
45
|
if (!requests || !requests.voxels.length)
|
|
48
46
|
return true;
|
|
49
|
-
WorldRegister.setDimension(requests.dimension);
|
|
50
47
|
let done = true;
|
|
51
48
|
for (const [key, pos] of requests.sections) {
|
|
52
|
-
if (!
|
|
49
|
+
if (!WorldSpaces.world.inBounds(pos[0], pos[1], pos[2]))
|
|
53
50
|
continue;
|
|
54
|
-
const sector = WorldRegister.sectors.get(pos[0], pos[1], pos[2]);
|
|
51
|
+
const sector = WorldRegister.sectors.get(requests.dimension, pos[0], pos[1], pos[2]);
|
|
55
52
|
if (!sector) {
|
|
56
53
|
done = false;
|
|
57
54
|
DivineVoxelEngineConstructor.instance.threads.world.runTask("add-sector", [requests.dimension, pos[0], pos[1], pos[2]]);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { WorldBounds } from "../../World/WorldBounds.js";
|
|
2
1
|
import { WorldGenRegister } from "./WorldGenRegister.js";
|
|
3
2
|
import { WorldGenBrush } from "./WorldGenBrush.js";
|
|
4
3
|
import { WorldGenInterface } from "./WorldGen.types.js";
|
|
@@ -6,7 +5,6 @@ import { GenerateTasks } from "../Tasks.types.js";
|
|
|
6
5
|
export declare class WorldGeneration {
|
|
7
6
|
static worldGen: WorldGenInterface | null;
|
|
8
7
|
static register: typeof WorldGenRegister;
|
|
9
|
-
static worldBounds: typeof WorldBounds;
|
|
10
8
|
static _brushes: any[];
|
|
11
9
|
static setWorldGen(worldGen: WorldGenInterface): void;
|
|
12
10
|
static generate(data: GenerateTasks, mode: "generate" | "decorate", onDone: Function): Promise<void>;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
//types
|
|
2
2
|
//objects
|
|
3
|
-
import { WorldBounds } from "../../World/WorldBounds.js";
|
|
4
3
|
import { WorldGenRegister } from "./WorldGenRegister.js";
|
|
5
4
|
//tools
|
|
6
5
|
import { WorldGenBrush } from "./WorldGenBrush.js";
|
|
7
6
|
export class WorldGeneration {
|
|
8
7
|
static worldGen = null;
|
|
9
8
|
static register = WorldGenRegister;
|
|
10
|
-
static worldBounds = WorldBounds;
|
|
11
9
|
static _brushes = [];
|
|
12
10
|
static setWorldGen(worldGen) {
|
|
13
11
|
this.worldGen = worldGen;
|