Description
Optimizations:
- new float[] done only when needed, i.e. when point in a triangle
- after a triangle is hit, other triangles aren't checked
- keeping some constants for each triangle object
Bugfixes:
- the current code has a possibility that the tinttransform function is called with an array that was transformed before, because the values array is created too early. This resulted in array bounds exceptions for page 20 of ch14.pdf, which in turn resulted in white triangles.
- polygon.contains() doesn't do the job properly, because it uses integers. The triangle corners must be kept as double to be exact. This bug resulted in black artefacts (points that were not in a triangle but were detected as such). The fix is not to use java functions anymore.
- checking the combined area doesn't work either and resulted in white artefacts (points that were not detected as part of a triangle).
It is still very slow. This is "by design", because in that file, the Gouraud mesh is split into so many items instead of being submitted as one.