Same-row belt feed into an uphill low end draws as two capped ends (t67)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,27 +23,13 @@ vec3 slopeShape(vec2 p, vec2 worldOrigin, float grade, int joins) {
|
||||
vec2 axis = vec2(1.0, grade) * 0.70710678;
|
||||
vec3 best = slopeStroke(p, a, b, dot(worldOrigin + a, axis));
|
||||
if ((joins & 1) != 0) {
|
||||
vec3 h;
|
||||
if ((joins & 128) != 0 && grade < 0.0) {
|
||||
h = slopeStroke(p, vec2(-2, 2), vec2(0, 2), worldOrigin.x - 2.0);
|
||||
if (h.x < best.x) best = h;
|
||||
h = slopeStroke(p, vec2(0, 2), vec2(0, a.y), worldOrigin.x);
|
||||
if (h.x < best.x) best = h;
|
||||
h = slopeStroke(p, vec2(0, a.y), a, worldOrigin.x);
|
||||
} else h = slopeStroke(p, vec2(-2.0, a.y), a, worldOrigin.x - 2.0);
|
||||
vec3 h = slopeStroke(p, vec2(-2.0, a.y), a, worldOrigin.x - 2.0);
|
||||
if (h.x < best.x) best = h;
|
||||
h = slopeCorner(p, a, worldOrigin.x + a.x);
|
||||
if (h.x < best.x) best = h;
|
||||
}
|
||||
if ((joins & 2) != 0) {
|
||||
vec3 h;
|
||||
if ((joins & 128) != 0 && grade > 0.0) {
|
||||
h = slopeStroke(p, b, vec2(4, b.y), worldOrigin.x + b.x);
|
||||
if (h.x < best.x) best = h;
|
||||
h = slopeStroke(p, vec2(4, b.y), vec2(4, 2), worldOrigin.x + 4.0);
|
||||
if (h.x < best.x) best = h;
|
||||
h = slopeStroke(p, vec2(4, 2), vec2(6, 2), worldOrigin.x + 4.0);
|
||||
} else h = slopeStroke(p, b, vec2(6, b.y), worldOrigin.x + b.x);
|
||||
vec3 h = slopeStroke(p, b, vec2(6, b.y), worldOrigin.x + b.x);
|
||||
if (h.x < best.x) best = h;
|
||||
h = slopeCorner(p, b, worldOrigin.x + b.x);
|
||||
if (h.x < best.x) best = h;
|
||||
@@ -91,9 +77,8 @@ const SM_SLOPE_DRAW = `
|
||||
float grade = (shape == 0 || shape == 2) ? -1.0 : 1.0;
|
||||
float dir = ((slopeClass - 23) % 2) == 1 ? 1.0 : -1.0;
|
||||
vec4 tag = cellAt(tTree, c);
|
||||
int packedX = int(tag.g * 255.0 + 0.5);
|
||||
int joins = (int(tag.a * 255.0 + 0.5) & 127) | (packedX & 128);
|
||||
vec2 local = vec2(float(packedX & 127), floor(tag.b * 255.0 + 0.5)) - 8.0 + fract(w);
|
||||
int joins = int(tag.a * 255.0 + 0.5);
|
||||
vec2 local = floor(tag.gb * 255.0 + 0.5) - 8.0 + fract(w);
|
||||
vec3 shapePos = slopeShape(local, w - local, grade, joins);
|
||||
float sd = shapePos.x, axis = shapePos.y, depth = shapePos.z;
|
||||
float time = !mesh && (joins & 16) != 0 ? uTime : 0.0;
|
||||
|
||||
+17
-15
@@ -7,16 +7,26 @@ function slopeBeltConnections(bx, by, code, planned = null) {
|
||||
const join = endJoin(bx, by, end, planned);
|
||||
if (join < 0) continue;
|
||||
const nb = join >> 1, next = planned && planned.get(nb);
|
||||
const slope = isSlopeBelt(next ? next[0] : blockP[nb]) &&
|
||||
((nb / BW) | 0) - by === beltGrade(code) * (nb % BW - bx);
|
||||
const pcode = next ? next[0] : blockP[nb];
|
||||
const slope = isSlopeBelt(pcode) && ((nb / BW) | 0) - by === beltGrade(code) * (nb % BW - bx);
|
||||
// A same-row feed into a low end drops onto its face: drawn as two capped ends, still joined.
|
||||
if (!slope && beltDrop(nb, by, beltGrade(code) * (end ? 1 : -1) > 0, pcode, join & 1)) continue;
|
||||
joins |= (slope ? 4 : 1) << end;
|
||||
if (!slope && beltGrade(code) * (end ? 1 : -1) > 0 &&
|
||||
((nb / BW) | 0) === by) joins |= 128; // low-end feed drops from the same-row flat
|
||||
}
|
||||
return joins;
|
||||
}
|
||||
// Does a same-row join between a piece in row `by` and block nb meet a slope's low end?
|
||||
function beltDrop(nb, by, ownLow, pcode, pend) {
|
||||
return ((nb / BW) | 0) === by && (ownLow || beltGrade(pcode) * (pend ? 1 : -1) > 0);
|
||||
}
|
||||
function flatBeltCaps(b, planned = null) {
|
||||
return 3 ^ pieceJoins(b % BW, (b / BW) | 0, planned);
|
||||
const bx = b % BW, by = (b / BW) | 0;
|
||||
let caps = 0;
|
||||
for (let end = 0; end < 2; end++) {
|
||||
const join = endJoin(bx, by, end, planned), nb = join >> 1, next = planned && planned.get(nb);
|
||||
if (join < 0 || beltDrop(nb, by, false, next ? next[0] : blockP[nb], join & 1)) caps |= 1 << end;
|
||||
}
|
||||
return caps;
|
||||
}
|
||||
function prepareSlopeBelts(x0, y0, x1, y1) {
|
||||
if (slopeBeltJoins.length !== NB) { slopeBeltJoins = new Uint8Array(NB); slopeBeltHalo = new Uint8Array(NB); beltCaps = new Uint8Array(NB); }
|
||||
@@ -60,19 +70,11 @@ function slopeBeltShape(x, y, b, joins = slopeBeltJoins[b], code = blockP[b]) {
|
||||
const origin = (ox + grade * oy) * Math.SQRT1_2;
|
||||
slopeBeltSegment(x, y, ax, ay, bx, by, origin + (ax + grade * ay) * Math.SQRT1_2);
|
||||
if (joins & 1) {
|
||||
if ((joins & 128) && grade < 0) {
|
||||
slopeBeltSegment(x, y, -2, 2, 0, 2, ox - 2);
|
||||
slopeBeltSegment(x, y, 0, 2, 0, ay, ox);
|
||||
slopeBeltSegment(x, y, 0, ay, ax, ay, ox);
|
||||
} else slopeBeltSegment(x, y, -2, ay, ax, ay, ox - 2);
|
||||
slopeBeltSegment(x, y, -2, ay, ax, ay, ox - 2);
|
||||
slopeBeltCorner(x, y, ax, ay, ox + ax);
|
||||
}
|
||||
if (joins & 2) {
|
||||
if ((joins & 128) && grade > 0) {
|
||||
slopeBeltSegment(x, y, bx, by, 4, by, ox + bx);
|
||||
slopeBeltSegment(x, y, 4, by, 4, 2, ox + 4);
|
||||
slopeBeltSegment(x, y, 4, 2, 6, 2, ox + 4);
|
||||
} else slopeBeltSegment(x, y, bx, by, 6, by, ox + bx);
|
||||
slopeBeltSegment(x, y, bx, by, 6, by, ox + bx);
|
||||
slopeBeltCorner(x, y, bx, by, ox + bx);
|
||||
}
|
||||
return slopeDistance;
|
||||
|
||||
+1
-2
@@ -279,9 +279,8 @@ function drawWorld() {
|
||||
const slopeClass = 23 + (code - BP_BELT_UP) * 2 + dir;
|
||||
if (slopeArt) cl = slopeClass;
|
||||
const f = isFilter(code) && filterCfg.get(sb), fm = f && f.m.length ? f.m[(Math.floor((x + beltGrade(code) * y) / 2) & 65535) % f.m.length] : 0;
|
||||
// Alpha bit 128 marks slope tags; the spare high bit of local X carries the drop.
|
||||
tpx[row + bx] = ((slopeBeltJoins[sb] | 128) << 24) | slopeClass |
|
||||
((y - ((sb / BW) | 0) * BS + 8) << 16) | (((x - (sb % BW) * BS + 8) | (slopeBeltJoins[sb] & 128)) << 8);
|
||||
((y - ((sb / BW) | 0) * BS + 8) << 16) | ((x - (sb % BW) * BS + 8) << 8);
|
||||
if (slopeArt) { r = fm ? COLR[fm] : 0; g = fm ? COLG[fm] : 0; b = fm ? COLB[fm] : 0; }
|
||||
}
|
||||
if (slopeDetail && slopeWallOwner >= 0) {
|
||||
|
||||
Reference in New Issue
Block a user