mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-03-27 01:27:23 +01:00
Added tectonic painter editor
This commit is contained in:
parent
18bddd0cec
commit
2a341346ab
3 changed files with 185 additions and 33 deletions
|
|
@ -4108,10 +4108,17 @@
|
|||
<div id="tectonicEditor" class="dialog stable" style="display: none">
|
||||
<p style="font-size:11px;margin:0 0 6px">Click a plate to edit. Drag arrows to set velocity.</p>
|
||||
<div style="margin-top: 4px">
|
||||
<button id="tectonicPaintToggle" data-tip="Toggle paint mode to reshape plates with a brush">Paint</button>
|
||||
<button id="tectonicRegenerate" data-tip="Regenerate terrain preview from edited plates">Regenerate Preview</button>
|
||||
<button id="tectonicApplyMap" data-tip="Apply changes and regenerate the full map">Apply to Map</button>
|
||||
</div>
|
||||
<div id="tectonicBrushControls" style="display:none;margin-top:4px;font-size:11px">
|
||||
<label>Brush size: </label>
|
||||
<input id="tectonicBrushSize" type="range" min="3" max="40" step="1" value="10"
|
||||
style="width:80px;vertical-align:middle">
|
||||
<span id="tectonicBrushSizeLabel">10</span>
|
||||
</div>
|
||||
<div style="margin-top: 4px">
|
||||
<button id="tectonicApplyMap" data-tip="Apply changes and regenerate the full map">Apply to Map</button>
|
||||
<button id="tectonicToggleOverlay" data-tip="Switch between plate view and height view">Toggle View</button>
|
||||
<button id="tectonicClose" data-tip="Close editor and remove overlay">Close</button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -221,6 +221,9 @@ export class TectonicPlateGenerator {
|
|||
private plates: TectonicPlate[] = [];
|
||||
private boundaries: PlateBoundary[] = [];
|
||||
|
||||
// Grid→sphere mapping for editor cell reassignment
|
||||
private gridToSphere!: Int32Array;
|
||||
|
||||
// Seeded PRNG for deterministic elevation pipeline
|
||||
private elevationSeed: number = 0;
|
||||
private rng: () => number = Math.random;
|
||||
|
|
@ -291,6 +294,27 @@ export class TectonicPlateGenerator {
|
|||
return this.projectAndFinalize();
|
||||
}
|
||||
|
||||
// Reassign grid cells to a different plate, propagating to sphere faces
|
||||
reassignCells(gridCells: number[], newPlateId: number): void {
|
||||
if (newPlateId < 0 || newPlateId >= this.plates.length) return;
|
||||
|
||||
for (const gc of gridCells) {
|
||||
if (gc < 0 || gc >= this.numGridCells) continue;
|
||||
|
||||
// Find current plate and remove from it
|
||||
const sphereFace = this.gridToSphere[gc];
|
||||
if (sphereFace >= 0) {
|
||||
const oldPlateId = this.plateAssignment[sphereFace];
|
||||
if (oldPlateId >= 0 && oldPlateId < this.plates.length) {
|
||||
this.plates[oldPlateId].cells.delete(sphereFace);
|
||||
}
|
||||
// Assign to new plate on sphere
|
||||
this.plateAssignment[sphereFace] = newPlateId;
|
||||
this.plates[newPlateId].cells.add(sphereFace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get current plates for editor access
|
||||
getPlates(): TectonicPlate[] {
|
||||
return this.plates;
|
||||
|
|
@ -1053,6 +1077,7 @@ export class TectonicPlateGenerator {
|
|||
// y: 0..gridHeight → lat: π/2..-π/2 (top = north pole, bottom = south pole)
|
||||
const gridElevations = new Float32Array(this.numGridCells);
|
||||
const gridPlateIds = new Int8Array(this.numGridCells).fill(-1);
|
||||
this.gridToSphere = new Int32Array(this.numGridCells).fill(-1);
|
||||
|
||||
// Build a bucketed spatial index for fast nearest-face lookup
|
||||
const lonBuckets = 72; // 5° per bucket
|
||||
|
|
@ -1122,6 +1147,7 @@ export class TectonicPlateGenerator {
|
|||
|
||||
gridElevations[gi] = this.elevations[bestFace];
|
||||
gridPlateIds[gi] = this.plateAssignment[bestFace];
|
||||
this.gridToSphere[gi] = bestFace;
|
||||
}
|
||||
|
||||
// Light smoothing to remove pixelation from sphere→grid sampling
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue