Lot of bugfixes

* Adding clipper to generate the terrain's negative powder-contour offset.
* Fixing RDB issues (fracture, active trigger, performances)
* Fixing blood emission
* Fixing the freezing formula on liquids
* Fixing Steve spawning due to a missed test.
* Reaction table properly build
This commit is contained in:
Gaël committed 2026-10-21 20:46:13 +02:00
1 parent a34f42d53e
commit 00a9c1c26c
48 files changed
+5799 -435

No files matched your search

+21
View File
@@ -139,6 +139,26 @@ struct Canvas {
void frame(int x, int y, int rw, int rh, uint32_t c) {
rect(x, y, rw, 1, c); rect(x, y + rh - 1, rw, 1, c); rect(x, y, 1, rh, c); rect(x + rw - 1, y, 1, rh, c);
}
void line(int x0, int y0, int x1, int y1, uint32_t c) {
// Clip first: terrain fixtures may be far outside the camera.
double a = 0, b = 1;
const double dx = double(x1) - x0, dy = double(y1) - y0;
auto clip = [&](double p, double q) { if (p == 0) return q >= 0; const double t = q / p; if (p < 0) a = std::max(a, t); else b = std::min(b, t); return a <= b; };
if (!clip(-dx, x0) || !clip(dx, w - 1 - x0) || !clip(-dy, y0) || !clip(dy, h - 1 - y0)) return;
const int ax = (int)std::lround(x0 + a * dx), ay = (int)std::lround(y0 + a * dy);
const int bx = (int)std::lround(x0 + b * dx), by = (int)std::lround(y0 + b * dy);
// Integer stepping avoids two floating divisions/rounds per debug-line pixel.
int x = ax, y = ay;
const int ix = std::abs(bx - ax), iy = -std::abs(by - ay), sx = ax < bx ? 1 : -1, sy = ay < by ? 1 : -1;
int error = ix + iy;
for (;;) {
put(x, y, c);
if (x == bx && y == by) break;
const int twice = 2 * error;
if (twice >= iy) { error += iy; x += sx; }
if (twice <= ix) { error += ix; y += sy; }
}
}
int text_width(const std::string& s, int scale) const {
if (font && font->ok()) { int w = 0; for (unsigned char ch : s) { const GameFont::Glyph& gl = font->g[ch]; w += (gl.ok ? gl.width : font->word_space) + font->char_space; } return w * scale; }
return (int)s.size() * 6 * scale - scale;
@@ -601,6 +621,7 @@ inline void draw(Canvas& cv, const Assets& as, const State& s) {
cv.text(cv.w - 14 - cv.text_width(t, 2), s.debug ? 90 : 14, t, rgba(255, 220, 120), 2);
}
if (s.debug) {
cv.text(14, cv.h - 30, "F3+C colliders F3+L save physics dump (debug folder)", rgba(160, 255, 160), 1);
const std::string l1 = fmt("%.0f fps", s.fps) + " frame " + std::to_string(s.frame);
const std::string l2 = "player " + fmt("%.0f", s.px) + ", " + fmt("%.0f", s.py) + " view " + std::to_string(s.view_x) + ", " + std::to_string(s.view_y);
const std::string l3 = "entities " + std::to_string(s.entities) + " stored tiles " + std::to_string(s.stored_tiles) + " " + s.seed_text;