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:
+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;
|
||||
|
||||
Reference in New Issue
Block a user