From 0e34b2c52c93fe1507d65e634aab683e500eee1e Mon Sep 17 00:00:00 2001 From: Miloslav Ciz Date: Mon, 12 May 2025 20:24:27 +0200 Subject: [PATCH] Handle buddy tris --- TODO.txt | 3 +++ renderer.h | 1 - small3dlib.h | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/TODO.txt b/TODO.txt index 49437bc..0e8bc0b 100644 --- a/TODO.txt +++ b/TODO.txt @@ -4,6 +4,7 @@ fuck issue trackers :D - hitting ramps at higher speed still often bugs, try to fiddle with physics again (reshape iterations, tension, ...) +- make car turned on its back behave nicer - press forward map??? :-D only when physics is frozen - make some kinda repo for world record runs? - Try doing the bouncy car body? Just keep a point and its velocity, change @@ -34,6 +35,8 @@ fuck issue trackers :D =========== BUGS ================= +- at high resolution (like 1920) buggy triangles sometimes appeard, tried to + fix this in S3L now but needs to be tested - immediately after starting the map countdown seems to be lower (seems to perhaps be caused by nextPhysicsFrameTime, look into it) diff --git a/renderer.h b/renderer.h index 31e3fa8..b47e8dd 100644 --- a/renderer.h +++ b/renderer.h @@ -361,7 +361,6 @@ void _LCR_pixelFunc3D(S3L_PixelInfo *pixel) if (pixel->modelIndex == 8) { - // car model LCR_loadImage(LCR_IMAGE_CAR); diff --git a/small3dlib.h b/small3dlib.h index 4b77365..0d8b89b 100644 --- a/small3dlib.h +++ b/small3dlib.h @@ -2,6 +2,9 @@ #define SMALL3DLIB_H /* + NOTE: This is a Licar specific fork of the library. Changes made can be + found e.g. with diff. + Simple realtime 3D software rasterization renderer. It is fast, focused on resource-limited computers, located in a single C header file, with no dependencies, using only 32bit integer arithmetics. @@ -2016,6 +2019,25 @@ void S3L_drawTriangle( p.triangleSize[1] = (rPointSS->y > lPointSS->y ? rPointSS->y : lPointSS->y) - tPointSS->y; + // Licar modifications below: handle buggy triangles (still imperfect) + if (S3L_abs(p.triangleSize[0]) > (5 * S3L_RESOLUTION_X / 2) || + S3L_abs(p.triangleSize[1]) > (5 * S3L_RESOLUTION_Y / 2)) + return; + + lPointSS->x = S3L_clamp(lPointSS->x, + -1 * S3L_RESOLUTION_X,2 * S3L_RESOLUTION_X); + rPointSS->x = S3L_clamp(rPointSS->x, + -1 * S3L_RESOLUTION_X,2 * S3L_RESOLUTION_X); + tPointSS->x = S3L_clamp(tPointSS->x, + -1 * S3L_RESOLUTION_X,2 * S3L_RESOLUTION_X); + + lPointSS->y = S3L_clamp(lPointSS->y, + -1 * S3L_RESOLUTION_Y,2 * S3L_RESOLUTION_Y); + rPointSS->y = S3L_clamp(rPointSS->y, + -1 * S3L_RESOLUTION_Y,2 * S3L_RESOLUTION_Y); + tPointSS->y = S3L_clamp(tPointSS->y, + -1 * S3L_RESOLUTION_Y,2 * S3L_RESOLUTION_Y); + // now draw the triangle line by line: S3L_ScreenCoord splitY; // Y of the vertically middle point of the triangle