Spaces:
Running
Running
1.33.23 true road-end dissolve
Browse files- src/engine/gl.js +25 -2
src/engine/gl.js
CHANGED
|
@@ -2417,6 +2417,28 @@ function refreshResourceTerrainNode(N,kind,before,after){
|
|
| 2417 |
const k=TS/MAP,r=(kind==='mass'?125:112)*k,sx=clamp(Math.floor(N.x*k-r),0,TS-1),sy=clamp(Math.floor(N.y*k-r),0,TS-1);
|
| 2418 |
uploadTerrainTexRegion(sx,sy,Math.min(TS-sx,r*2),Math.min(TS-sy,r*2),true);
|
| 2419 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2420 |
function buildRoads(c,def){
|
| 2421 |
ROADG=new Uint8Array(PGS*PGS);
|
| 2422 |
if(!def.roads) return;
|
|
@@ -2425,7 +2447,8 @@ function buildRoads(c,def){
|
|
| 2425 |
const drawPath=(path,width)=>{
|
| 2426 |
for(let i=1;i<path.length;i++){
|
| 2427 |
const p=path[i-1],q=path[i];
|
| 2428 |
-
|
|
|
|
| 2429 |
markRoad(p[0],p[1],q[0],q[1],width);
|
| 2430 |
}
|
| 2431 |
};
|
|
@@ -2606,7 +2629,7 @@ function buildTerrain(themeKey){
|
|
| 2606 |
buildNavalMask();
|
| 2607 |
paintCityGround(c); // connected subgrade + authored plots under the streets
|
| 2608 |
for(const S of cityStreets){
|
| 2609 |
-
|
| 2610 |
markRoad(S[0],S[1],S[2],S[3],S[4]);
|
| 2611 |
}
|
| 2612 |
paintResourceGround(c); // mass corruption and geothermal scars live in the terrain
|
|
|
|
| 2417 |
const k=TS/MAP,r=(kind==='mass'?125:112)*k,sx=clamp(Math.floor(N.x*k-r),0,TS-1),sy=clamp(Math.floor(N.y*k-r),0,TS-1);
|
| 2418 |
uploadTerrainTexRegion(sx,sy,Math.min(TS-sx,r*2),Math.min(TS-sy,r*2),true);
|
| 2419 |
}
|
| 2420 |
+
/* Paint a road whose ENDS dissolve: the body at full strength, then the
|
| 2421 |
+
final stretch in alpha-stepped slices. The macro tint fades with the
|
| 2422 |
+
material mask instead of running grey to a hard cap — the missing half of
|
| 2423 |
+
"road ends must blend". Slice steps vanish under the texture noise. */
|
| 2424 |
+
function paintFadingRoad(c,x0,y0,x1,y1,W,fadeA,fadeB){
|
| 2425 |
+
const dx=x1-x0,dy=y1-y0,L=Math.hypot(dx,dy)||1,ux=dx/L,uy=dy/L;
|
| 2426 |
+
const F=Math.min(L*0.42, W*2.6+18);
|
| 2427 |
+
const a0=fadeA?F:0, b0=fadeB?F:0;
|
| 2428 |
+
const bx0=x0+ux*a0, by0=y0+uy*a0, bx1=x1-ux*b0, by1=y1-uy*b0;
|
| 2429 |
+
if(Math.hypot(bx1-bx0,by1-by0)>2) paintRoadLand(c,bx0,by0,bx1,by1,W);
|
| 2430 |
+
const slice=(sx,sy,dirx,diry,len)=>{
|
| 2431 |
+
const N=6;
|
| 2432 |
+
for(let k2=0;k2<N;k2++){
|
| 2433 |
+
const t0=k2/N,t1=(k2+1)/N;
|
| 2434 |
+
c.globalAlpha=1-(k2+0.5)/N;
|
| 2435 |
+
paintRoadLand(c,sx+dirx*len*t0,sy+diry*len*t0,sx+dirx*len*t1,sy+diry*len*t1,W*(1-0.25*t1));
|
| 2436 |
+
}
|
| 2437 |
+
c.globalAlpha=1;
|
| 2438 |
+
};
|
| 2439 |
+
if(fadeA) slice(bx0,by0,-ux,-uy,a0);
|
| 2440 |
+
if(fadeB) slice(bx1,by1,ux,uy,b0);
|
| 2441 |
+
}
|
| 2442 |
function buildRoads(c,def){
|
| 2443 |
ROADG=new Uint8Array(PGS*PGS);
|
| 2444 |
if(!def.roads) return;
|
|
|
|
| 2447 |
const drawPath=(path,width)=>{
|
| 2448 |
for(let i=1;i<path.length;i++){
|
| 2449 |
const p=path[i-1],q=path[i];
|
| 2450 |
+
const first=i===1, last=i===path.length-1;
|
| 2451 |
+
paintFadingRoad(c,p[0],p[1],q[0],q[1],width,first,last);
|
| 2452 |
markRoad(p[0],p[1],q[0],q[1],width);
|
| 2453 |
}
|
| 2454 |
};
|
|
|
|
| 2629 |
buildNavalMask();
|
| 2630 |
paintCityGround(c); // connected subgrade + authored plots under the streets
|
| 2631 |
for(const S of cityStreets){
|
| 2632 |
+
paintFadingRoad(c,S[0],S[1],S[2],S[3],S[4],true,true);
|
| 2633 |
markRoad(S[0],S[1],S[2],S[3],S[4]);
|
| 2634 |
}
|
| 2635 |
paintResourceGround(c); // mass corruption and geothermal scars live in the terrain
|