Joins follow the travel direction: the next piece goes right after the end (t67 phase 2b)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-27 14:09:28 -04:00
co-authored by Claude Opus 5.5
parent fd35bf334f
commit 45538cc18e
16 changed files with 363 additions and 236 deletions
+2 -1
View File
@@ -14,7 +14,8 @@ function diagonalScrewJoins(bx, by, v, planned = null) {
const code = next ? next[0] : blockP[nb], nv = next ? next[1] : blockV[nb];
if (pieceEnds(code, nv)[join & 1].diagonal) continue;
const horizontal = code !== BP_SCREW || (nv & 1);
const kind = ((nb / BW) | 0) === by ? (end ? 2 : 4) : horizontal ? 5 : 6;
const ny = (nb / BW) | 0, nx = nb % BW;
const kind = ny === by ? (nx > bx ? 2 : 4) : nx === bx ? (ny < by ? 1 : 3) : horizontal ? 5 : 6;
joins |= kind << (end * 3);
}
return joins;
+19 -4
View File
@@ -23,13 +23,27 @@ 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 = slopeStroke(p, vec2(-2.0, a.y), a, worldOrigin.x - 2.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);
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 = slopeStroke(p, b, vec2(6, b.y), worldOrigin.x + b.x);
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);
if (h.x < best.x) best = h;
h = slopeCorner(p, b, worldOrigin.x + b.x);
if (h.x < best.x) best = h;
@@ -77,8 +91,9 @@ 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 joins = int(tag.a * 255.0 + 0.5);
vec2 local = floor(tag.gb * 255.0 + 0.5) - 8.0 + fract(w);
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);
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;
+15 -3
View File
@@ -7,7 +7,11 @@ 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);
joins |= (isSlopeBelt(next ? next[0] : blockP[nb]) ? 4 : 1) << end;
const slope = isSlopeBelt(next ? next[0] : blockP[nb]) &&
((nb / BW) | 0) - by === beltGrade(code) * (nb % BW - bx);
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;
}
@@ -56,11 +60,19 @@ 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) {
slopeBeltSegment(x, y, -2, ay, ax, ay, ox - 2);
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);
slopeBeltCorner(x, y, ax, ay, ox + ax);
}
if (joins & 2) {
slopeBeltSegment(x, y, bx, by, 6, by, ox + bx);
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);
slopeBeltCorner(x, y, bx, by, ox + bx);
}
return slopeDistance;
+2 -1
View File
@@ -279,8 +279,9 @@ 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) << 8);
((y - ((sb / BW) | 0) * BS + 8) << 16) | (((x - (sb % BW) * BS + 8) | (slopeBeltJoins[sb] & 128)) << 8);
if (slopeArt) { r = fm ? COLR[fm] : 0; g = fm ? COLG[fm] : 0; b = fm ? COLB[fm] : 0; }
}
if (slopeDetail && slopeWallOwner >= 0) {