Hi,
I have implemented a polygon renderer that works only if it can be
entirely sure which way round the points of a polygon are in terms of
clockwise or anti-clockwise (it is always one or the other).
Now, I have implemented this into my code such that the regular reverse
face polygon test is used - that is it does the 'd' part of the plane
equation and compares it to 0. However, this is very occasionally
incorrect.
What happens is this, the points, when projected are effectively
collinear. However, accuracy being what it is and so on, they actually
end up being projected to be anti-clockwise when the plane test implied
they would project to be clockwise. This really breaks my polygon
routines, like you wouldn't otherwise believe!
So, I am wondering the way around this. Is there a quick check for
collinearity, or near collinearity? (possibly quicker than one compare
per scanline to check x1 really is < x2 at resolutions from 320x200 up
to 1024x768). Or maybe some sort of check on the projected points for
clockwise / anti-clockwise? Or maybe something more devious I did not
think of?
collinearness shouldn't actually mess up the polygon rendering by the
way . . . but in polygons that are almost horizontal, this can be a real
problem.
-Thomas