Tweaks to clipping

This commit is contained in:
Luke Benstead 2018-07-15 21:27:15 +01:00
parent 8ef63c75af
commit 0d921c3504
2 changed files with 8 additions and 8 deletions

View File

@ -96,13 +96,6 @@ void clipTriangleStrip(AlignedVector* vertices, AlignedVector* outBuffer) {
* difficult to even write them down!
*/
/* FIXME: Why this value? This was copied from libGL because using zero wasn't working right.
*
* I think this is a hack. We should really be clipping against the W coordinate of each vertex... but I'm not sure
* how yet..
*/
const float CLIP_DISTANCE = -0.2;
uint32_t i;
for(i = 2; i < vertices->size; ++i) {
@ -119,7 +112,7 @@ void clipTriangleStrip(AlignedVector* vertices, AlignedVector* outBuffer) {
ClipVertex* v2 = even ? sourceTriangle[1] : sourceTriangle[0];
ClipVertex* v3 = sourceTriangle[2];
uint8_t visible = ((v1->w > 0) ? 4 : 0) | ((v2->w > 0) ? 2 : 0) | ((v3->w > 0) ? 1 : 0);
uint8_t visible = ((v1->xyz[2] < CLIP_DISTANCE) ? 4 : 0) | ((v2->xyz[2] < CLIP_DISTANCE) ? 2 : 0) | ((v3->xyz[2] < CLIP_DISTANCE) ? 1 : 0);
uint8_t startOfStrip = (i == 2) || (outBuffer->size > 2 && ((ClipVertex*) aligned_vector_back(outBuffer))->flags == VERTEX_CMD_EOL);
/* All visible, we're fine! */

View File

@ -45,6 +45,13 @@ ClipResult clipLineToNearZ(const float* v1, const float* v2, const float dist, f
void clipTriangleStrip(AlignedVector* vertices, AlignedVector* outBuffer);
/* FIXME: Why this value? This was copied from libGL because using zero wasn't working right.
*
* I think this is a hack. We should really be clipping against the W coordinate of each vertex... but I'm not sure
* how yet.. this is probably related to the way the z coordinate is mapped to window coordinates or something
*/
#define CLIP_DISTANCE -0.2
#ifdef __cplusplus
}
#endif