1
0
Fork 0
mirror of https://git.coom.tech/drummyfish/small3dlib.git synced 2024-11-21 20:39:57 +01:00

Fix disappearing triangles

This commit is contained in:
Miloslav Číž 2019-06-03 18:06:06 +02:00
parent 9d2020b83c
commit 3378325093
2 changed files with 15 additions and 3 deletions

View file

@ -1531,6 +1531,18 @@ void S3L_drawTriangle(
loop */ loop */
#endif #endif
if (rXClipped < lXClipped)
{
/* This can sometimes happen because of numerical errors in sorting
left vs right triangle point, which are compared based on SLOPE, not
x coordinates. Here we swap the values to prevents not drawing the
triagle. */
S3L_ScreenCoord tmp = rXClipped;
rXClipped = lXClipped;
lXClipped = tmp;
}
// draw the row -- inner loop: // draw the row -- inner loop:
for (S3L_ScreenCoord x = lXClipped; x < rXClipped; ++x) for (S3L_ScreenCoord x = lXClipped; x < rXClipped; ++x)

View file

@ -18,8 +18,8 @@
#define S3L_PIXEL_FUNCTION drawPixel #define S3L_PIXEL_FUNCTION drawPixel
#define S3L_RESOLUTION_X 640 #define S3L_RESOLUTION_X 110
#define S3L_RESOLUTION_Y 480 #define S3L_RESOLUTION_Y 88
#include "small3dlib.h" #include "small3dlib.h"
@ -280,7 +280,7 @@ scene.camera.transform.rotation.x = -35;
scene.camera.transform.rotation.y = 128; scene.camera.transform.rotation.y = 128;
scene.camera.transform.rotation.z = 0; scene.camera.transform.rotation.z = 0;
S3L_setTransform3D(-542,-449,3259,39,216,0,512,512,512,&(scene.camera.transform)); S3L_setTransform3D(-542,-449,4000,39,216,0,512,512,512,&(scene.camera.transform));
scene.modelCount = 2; scene.modelCount = 2;
scene.models = models; scene.models = models;