[AD] polygon_cull_criterion()

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


Allegro has a function called polygon_z_normal() in "math3d.c". This
function alone is  completely ok, but the docs say you can use it for
backface culling. Sorry, this is downright wrong. You could only use
polygon_z_normal() for backface culling if one of these conditions are met:

   a) you are in homogenous coordinates
   b) you have an orthogonal projection matrix

It is easy to prove that a face could be visible even if the return value
of polygon_z_normal() is negative. "ex3d.c" does a workaround of this error
in that it depth-sorts faces even if they should be culled and a per-face
depth sorting should not be necessary. I have corrected the docs that they
no longer pretend you can use polygon_z_normal() for backface culling + I
have added a function called polygon_cull_criterion() that does this job
correctly and described it in the docs + I have patched ex3d.c to use
polygon_cull_criterion() instead of polygon_z_normal().

I hope I didn't puzzle you. You certainly thought this part of the library
was tried and true.

And this time I didn't leave out allegro.h in the patch :-)







Attachment: polygon_cull.diff
Description: Binary data



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