mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-07 03:13:49 +00:00
Restore wrongly removed triangle clipping.
This commit is contained in:
parent
1b084dfd7b
commit
deed5ecd01
86
gSP.cpp
86
gSP.cpp
|
@ -151,32 +151,19 @@ u32 __indexmap_getnew(u32 index, u32 num)
|
||||||
|
|
||||||
void gSPTriangle(s32 v0, s32 v1, s32 v2)
|
void gSPTriangle(s32 v0, s32 v1, s32 v2)
|
||||||
{
|
{
|
||||||
if ((v0 < INDEXMAP_SIZE) && (v1 < INDEXMAP_SIZE) && (v2 < INDEXMAP_SIZE))
|
if ((v0 < INDEXMAP_SIZE) && (v1 < INDEXMAP_SIZE) && (v2 < INDEXMAP_SIZE)) {
|
||||||
{
|
|
||||||
|
|
||||||
#ifdef __TRIBUFFER_OPT
|
#ifdef __TRIBUFFER_OPT
|
||||||
v0 = OGL.triangles.indexmap[v0];
|
v0 = OGL.triangles.indexmap[v0];
|
||||||
v1 = OGL.triangles.indexmap[v1];
|
v1 = OGL.triangles.indexmap[v1];
|
||||||
v2 = OGL.triangles.indexmap[v2];
|
v2 = OGL.triangles.indexmap[v2];
|
||||||
#endif
|
#endif
|
||||||
|
if (OGL.triangles.vertices[v0].clip & OGL.triangles.vertices[v1].clip & OGL.triangles.vertices[v2].clip)
|
||||||
|
return;
|
||||||
|
OGL_AddTriangle(v0, v1, v2);
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
gDP.colorImage.changed = TRUE;
|
||||||
// Don't bother with triangles completely outside clipping frustrum
|
gDP.colorImage.height = (unsigned int)(max( gDP.colorImage.height, gDP.scissor.lry ));
|
||||||
if (config.enableClipping)
|
|
||||||
{
|
|
||||||
if (OGL.triangles.vertices[v0].clip & OGL.triangles.vertices[v1].clip & OGL.triangles.vertices[v2].clip)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
OGL_AddTriangle(v0, v1, v2);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
gDP.colorImage.changed = TRUE;
|
|
||||||
gDP.colorImage.height = (unsigned int)(max( gDP.colorImage.height, gDP.scissor.lry ));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gSP1Triangle( const s32 v0, const s32 v1, const s32 v2)
|
void gSP1Triangle( const s32 v0, const s32 v1, const s32 v2)
|
||||||
|
@ -316,6 +303,20 @@ static void gSPBillboardVertex4_default(u32 v)
|
||||||
OGL.triangles.vertices[v+3].w += OGL.triangles.vertices[i].w;
|
OGL.triangles.vertices[v+3].w += OGL.triangles.vertices[i].w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gSPClipVertex4(u32 v)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i = 0; i < 4; i++){
|
||||||
|
SPVertex *vtx = &OGL.triangles.vertices[v+i];
|
||||||
|
vtx->clip = 0;
|
||||||
|
if (vtx->x > +vtx->w) vtx->clip |= CLIP_POSX;
|
||||||
|
if (vtx->x < -vtx->w) vtx->clip |= CLIP_NEGX;
|
||||||
|
if (vtx->y > +vtx->w) vtx->clip |= CLIP_POSY;
|
||||||
|
if (vtx->y < -vtx->w) vtx->clip |= CLIP_NEGY;
|
||||||
|
if (vtx->w < 0.01f) vtx->clip |= CLIP_Z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void gSPProcessVertex4(u32 v)
|
void gSPProcessVertex4(u32 v)
|
||||||
{
|
{
|
||||||
if (gSP.changed & CHANGED_MATRIX)
|
if (gSP.changed & CHANGED_MATRIX)
|
||||||
|
@ -374,6 +375,8 @@ void gSPProcessVertex4(u32 v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gSPClipVertex4(v);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -431,6 +434,17 @@ void gSPCombineMatrices()
|
||||||
gSP.changed &= ~CHANGED_MATRIX;
|
gSP.changed &= ~CHANGED_MATRIX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gSPClipVertex(u32 v)
|
||||||
|
{
|
||||||
|
SPVertex *vtx = &OGL.triangles.vertices[v];
|
||||||
|
vtx->clip = 0;
|
||||||
|
if (vtx->x > +vtx->w) vtx->clip |= CLIP_POSX;
|
||||||
|
if (vtx->x < -vtx->w) vtx->clip |= CLIP_NEGX;
|
||||||
|
if (vtx->y > +vtx->w) vtx->clip |= CLIP_POSY;
|
||||||
|
if (vtx->y < -vtx->w) vtx->clip |= CLIP_NEGY;
|
||||||
|
if (vtx->w < 0.01f) vtx->clip |= CLIP_Z;
|
||||||
|
}
|
||||||
|
|
||||||
void gSPProcessVertex( u32 v )
|
void gSPProcessVertex( u32 v )
|
||||||
{
|
{
|
||||||
if (gSP.changed & CHANGED_MATRIX)
|
if (gSP.changed & CHANGED_MATRIX)
|
||||||
|
@ -455,6 +469,8 @@ void gSPProcessVertex( u32 v )
|
||||||
OGL.triangles.vertices[v].z = -OGL.triangles.vertices[v].w;
|
OGL.triangles.vertices[v].z = -OGL.triangles.vertices[v].w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gSPClipVertex(v);
|
||||||
|
|
||||||
OGL.triangles.vertices[v].HWLight = 0;
|
OGL.triangles.vertices[v].HWLight = 0;
|
||||||
if (gSP.geometryMode & G_LIGHTING) {
|
if (gSP.geometryMode & G_LIGHTING) {
|
||||||
gSPLightVertex(v);
|
gSPLightVertex(v);
|
||||||
|
@ -1265,24 +1281,24 @@ void gSP1Quadrangle( s32 v0, s32 v1, s32 v2, s32 v3 )
|
||||||
|
|
||||||
bool gSPCullVertices( u32 v0, u32 vn )
|
bool gSPCullVertices( u32 v0, u32 vn )
|
||||||
{
|
{
|
||||||
s32 v = v0;
|
s32 v = v0;
|
||||||
#ifdef __TRIBUFFER_OPT
|
#ifdef __TRIBUFFER_OPT
|
||||||
v = OGL.triangles.indexmap[v0];
|
v = OGL.triangles.indexmap[v0];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
u32 clip = OGL.triangles.vertices[v].clip;
|
u32 clip = OGL.triangles.vertices[v].clip;
|
||||||
if (clip == 0)
|
if (clip == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
for (unsigned int i = (v0+1); i <= vn; i++)
|
for (unsigned int i = (v0+1); i <= vn; i++)
|
||||||
{
|
{
|
||||||
v = i;
|
v = i;
|
||||||
#ifdef __TRIBUFFER_OPT
|
#ifdef __TRIBUFFER_OPT
|
||||||
v = OGL.triangles.indexmap[i];
|
v = OGL.triangles.indexmap[i];
|
||||||
#endif
|
#endif
|
||||||
if (OGL.triangles.vertices[v].clip != clip) return FALSE;
|
if (OGL.triangles.vertices[v].clip != clip) return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gSPCullDisplayList( u32 v0, u32 vn )
|
void gSPCullDisplayList( u32 v0, u32 vn )
|
||||||
|
|
6
gSP.h
6
gSP.h
|
@ -54,9 +54,9 @@ if \
|
||||||
#define CLIP_NEGY 0x04
|
#define CLIP_NEGY 0x04
|
||||||
#define CLIP_POSY 0x08
|
#define CLIP_POSY 0x08
|
||||||
|
|
||||||
#define CLIP_Z 0x30
|
#define CLIP_Z 0x10
|
||||||
#define CLIP_NEGZ 0x10
|
|
||||||
#define CLIP_POSZ 0x20
|
#define CLIP_ALL 0x1F // CLIP_NEGX|CLIP_POSX|CLIP_NEGY|CLIP_POSY|CLIP_Z
|
||||||
|
|
||||||
#define SC_POSITION 1
|
#define SC_POSITION 1
|
||||||
#define SC_COLOR 2
|
#define SC_COLOR 2
|
||||||
|
|
Loading…
Reference in New Issue
Block a user