Skip to content

Commit 0658510

Browse files
ugozapadSNMetamorph
authored andcommitted
client: render: fix sway break and missing uniforms in decal render
1 parent 573bc3d commit 0658510

File tree

9 files changed

+52
-39
lines changed

9 files changed

+52
-39
lines changed

client/render/gl_backend.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,18 @@ void GL_ClipPlane( bool enable )
974974
}
975975
}
976976

977+
/*
978+
=================
979+
GL_InitClipPlane
980+
=================
981+
*/
982+
void GL_InitClipPlane( const mplane_t *in, GLdouble *out )
983+
{
984+
out[0] = in->normal[0];
985+
out[1] = in->normal[1];
986+
out[2] = in->normal[2];
987+
out[3] = -in->dist;
988+
}
977989

978990
/*
979991
=================

client/render/gl_cubemap.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -604,14 +604,11 @@ static void GL_FilterCubemapSpecularIBL(mcubemap_t *cubemap)
604604
{
605605
GLdouble clip[4];
606606
mplane_t *p = &RI->clipPlane;
607-
608-
clip[0] = p->normal[0];
609-
clip[1] = p->normal[1];
610-
clip[2] = p->normal[2];
611-
clip[3] = -p->dist;
612-
607+
608+
GL_InitClipPlane(p, clip);
609+
613610
u->SetValue(clip);
614-
611+
615612
break;
616613
}
617614
}

client/render/gl_decals.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,14 +1453,11 @@ void R_SetDecalUniforms( brushdecal_t *decal )
14531453
{
14541454
GLdouble clip[4];
14551455
mplane_t *p = &RI->clipPlane;
1456-
1457-
clip[0] = p->normal[0];
1458-
clip[1] = p->normal[1];
1459-
clip[2] = p->normal[2];
1460-
clip[3] = -p->dist;
1461-
1456+
1457+
GL_InitClipPlane(p, clip);
1458+
14621459
u->SetValue(clip);
1463-
1460+
14641461
break;
14651462
}
14661463
default:

client/render/gl_grass.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -863,14 +863,11 @@ void R_SetGrassUniforms( word hProgram, grass_t *grass )
863863
{
864864
GLdouble clip[4];
865865
mplane_t *p = &RI->clipPlane;
866-
867-
clip[0] = p->normal[0];
868-
clip[1] = p->normal[1];
869-
clip[2] = p->normal[2];
870-
clip[3] = -p->dist;
871-
866+
867+
GL_InitClipPlane(p, clip);
868+
872869
u->SetValue(clip);
873-
870+
874871
break;
875872
}
876873
default:

client/render/gl_local.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,7 @@ void GL_DisableAllTexGens(void);
764764
void GL_DepthMask(GLint enable);
765765
void GL_FrontFace(GLenum front);
766766
void GL_ClipPlane(bool enable);
767+
void GL_InitClipPlane( const mplane_t *in, GLdouble *out );
767768
void GL_BindFBO(GLuint buffer);
768769
void GL_AlphaTest(GLint enable);
769770
void GL_AlphaToCoverage(bool enable);

client/render/gl_sky.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,7 @@ static void GL_DrawSkySide( word hProgram, int skyside )
322322
GLdouble clip[4];
323323
mplane_t *p = &RI->clipPlane;
324324

325-
clip[0] = p->normal[0];
326-
clip[1] = p->normal[1];
327-
clip[2] = p->normal[2];
328-
clip[3] = -p->dist;
325+
GL_InitClipPlane(p, clip);
329326

330327
u->SetValue(clip);
331328

client/render/gl_studio_draw.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3706,6 +3706,7 @@ void CStudioModelRenderer :: DrawSingleMesh( CSolidEntry *entry, bool force, boo
37063706
break;
37073707
case UT_SWAYHEIGHT:
37083708
u->SetValue(mat->swayHeight);
3709+
break;
37093710
case UT_MODELVIEWMATRIX:
37103711
u->SetValue( &RI->view.worldMatrix );
37113712
break;
@@ -3716,14 +3717,11 @@ void CStudioModelRenderer :: DrawSingleMesh( CSolidEntry *entry, bool force, boo
37163717
{
37173718
GLdouble clip[4];
37183719
mplane_t *p = &RI->clipPlane;
3719-
3720-
clip[0] = p->normal[0];
3721-
clip[1] = p->normal[1];
3722-
clip[2] = p->normal[2];
3723-
clip[3] = -p->dist;
3724-
3720+
3721+
GL_InitClipPlane(p, clip);
3722+
37253723
u->SetValue(clip);
3726-
3724+
37273725
break;
37283726
}
37293727
default:

client/render/gl_studiodecal_new.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,23 @@ void CStudioModelRenderer :: SetDecalUniforms( studiodecal_t *pDecal )
17121712
height = pDecal->texinfo->gl_heightmap_id.GetHeight();
17131713
u->SetValue( (float)width, (float)height, pDecal->texinfo->matdesc->reliefScale, cv_shadow_offset->value );
17141714
break;
1715+
case UT_MODELVIEWMATRIX:
1716+
u->SetValue(&RI->view.worldMatrix);
1717+
break;
1718+
case UT_MODELVIEWPROJECTIONMATRIX:
1719+
u->SetValue(&RI->view.worldProjectionMatrix);
1720+
break;
1721+
case UT_CLIPPLANE:
1722+
{
1723+
GLdouble clip[4];
1724+
mplane_t *p = &RI->clipPlane;
1725+
1726+
GL_InitClipPlane(p, clip);
1727+
1728+
u->SetValue(clip);
1729+
1730+
break;
1731+
}
17151732
default:
17161733
ALERT( at_error, "Unhandled uniform %s\n", u->name );
17171734
break;

client/render/gl_world_new.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2878,14 +2878,11 @@ void R_SetSurfaceUniforms( word hProgram, msurface_t *surface, bool force )
28782878
{
28792879
GLdouble clip[4];
28802880
mplane_t *p = &RI->clipPlane;
2881-
2882-
clip[0] = p->normal[0];
2883-
clip[1] = p->normal[1];
2884-
clip[2] = p->normal[2];
2885-
clip[3] = -p->dist;
2886-
2881+
2882+
GL_InitClipPlane(p, clip);
2883+
28872884
u->SetValue(clip);
2888-
2885+
28892886
break;
28902887
}
28912888
default:

0 commit comments

Comments
 (0)