mirror of
https://git.coom.tech/drummyfish/small3dlib.git
synced 2024-12-23 01:26:19 +01:00
Fix disappearing triangles
This commit is contained in:
parent
9d2020b83c
commit
3378325093
2 changed files with 15 additions and 3 deletions
12
small3dlib.h
12
small3dlib.h
|
@ -1531,6 +1531,18 @@ void S3L_drawTriangle(
|
|||
loop */
|
||||
#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:
|
||||
|
||||
for (S3L_ScreenCoord x = lXClipped; x < rXClipped; ++x)
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
|
||||
#define S3L_PIXEL_FUNCTION drawPixel
|
||||
|
||||
#define S3L_RESOLUTION_X 640
|
||||
#define S3L_RESOLUTION_Y 480
|
||||
#define S3L_RESOLUTION_X 110
|
||||
#define S3L_RESOLUTION_Y 88
|
||||
|
||||
#include "small3dlib.h"
|
||||
|
||||
|
@ -280,7 +280,7 @@ scene.camera.transform.rotation.x = -35;
|
|||
scene.camera.transform.rotation.y = 128;
|
||||
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.models = models;
|
||||
|
|
Loading…
Reference in a new issue