Re: [AD] Z-buffer

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Here are some minor modifications to the 3D clipping functions (clip3d
and clip3df) in order to make them compliant with the Z-buffered types.
I have also added a small modification to the polygon3d function : due
to round-off errors on fixed point numbers, some thin polygons were not
drawn whereas they should. The patch fixes that bug.

	Bertrand.
diff -urN allegro.old/src/clip3d.c allegro/src/clip3d.c
--- allegro.old/src/clip3d.c	Sat Jul 29 12:18:44 2000
+++ allegro/src/clip3d.c	Sun Nov 26 18:25:21 2000
@@ -89,6 +89,7 @@
       INT_UV + INT_1COL                     /* ptex mask lit */
    };
 
+   type &= ~POLYTYPE_ZBUF;
    flags = flag_table[type];
 
    if (max_z > min_z) {
diff -urN allegro.old/src/clip3df.c allegro/src/clip3df.c
--- allegro.old/src/clip3df.c	Sat Jul 29 12:18:44 2000
+++ allegro/src/clip3df.c	Sun Nov 26 18:25:29 2000
@@ -95,6 +95,7 @@
       INT_UV + INT_1COL                     /* ptex mask lit */
    };
 
+   type &= ~POLYTYPE_ZBUF;
    flags = flag_table[type];
 
    if (max_z > min_z) {
diff -urN allegro.old/src/poly3d.c allegro/src/poly3d.c
--- allegro.old/src/poly3d.c	Wed Nov 15 19:22:09 2000
+++ allegro/src/poly3d.c	Sun Nov 26 18:25:39 2000
@@ -1102,7 +1102,7 @@
 
    /* determine whether the vertices are given in clockwise order or not */
 
-   test_normal = fixtoi(vtx[2]->y-vtx[1]->y)*fixtoi(vtx[1]->x-vtx[0]->x)-fixtoi(vtx[1]->y-vtx[0]->y)*fixtoi(vtx[2]->x-vtx[1]->x);
+   test_normal = ftofix(fixtof(vtx[2]->y-vtx[1]->y)*fixtof(vtx[1]->x-vtx[0]->x)-fixtof(vtx[1]->y-vtx[0]->y)*fixtof(vtx[2]->x-vtx[1]->x));
 
    if (test_normal < 0) {
       /* vertices are given in counterclockwise order */


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/