Skip to content

Commit

Permalink
Fixed water culling issue #498
Browse files Browse the repository at this point in the history
  • Loading branch information
hzqst committed Oct 11, 2024
1 parent c556897 commit 479a6c9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Plugins/Renderer/gl_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ void R_DrawWorld(void);
void R_DrawSkyBox(void);
void R_CheckVariables(void);
void R_AnimateLight(void);
void R_SetupFrame(void);
void R_SetFrustum(void);
void R_SetupSceneUBO(void);
void R_RenderPreFrame();
void R_RenderStartFrame();
Expand Down
5 changes: 3 additions & 2 deletions Plugins/Renderer/gl_rmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3186,9 +3186,10 @@ void R_SetupFrame(void)
//R_CheckVariables();
//R_AnimateLight();

VectorCopy((*r_refdef.vieworg), r_origin);
R_UpdateRefDef();
//VectorCopy((*r_refdef.vieworg), r_origin);

gEngfuncs.pfnAngleVectors((*r_refdef.viewangles), vpn, vright, vup);
//gEngfuncs.pfnAngleVectors((*r_refdef.viewangles), vpn, vright, vup);

(*r_oldviewleaf) = (*r_viewleaf);

Expand Down
4 changes: 4 additions & 0 deletions Plugins/Renderer/gl_rmisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ void R_PushRefDef(void)
++save_refdef_stack;
}

/*
Purpose: Update r_origin, vpn, vright and vup according to r_refdef stuffs
*/

void R_UpdateRefDef(void)
{
VectorCopy((*r_refdef.vieworg), r_origin);
Expand Down
7 changes: 6 additions & 1 deletion Plugins/Renderer/gl_water.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,9 @@ void R_RenderWaterPass(void)
g_VisibleWaterEntity.clear();
R_ClearWaterReflectCaches();

//Mainly for updating frustrum
R_UpdateRefDef();

mleaf_t *viewleaf = NULL;

if (r_refdef_SvEngine && r_refdef_SvEngine->useCamera)
Expand All @@ -875,6 +878,8 @@ void R_RenderWaterPass(void)
{
viewleaf = Mod_PointInLeaf(r_origin, r_worldmodel);
}
R_SetupGL();
R_SetFrustum();

auto pModel = R_GetWorldSurfaceModel(r_worldmodel);

Expand All @@ -893,7 +898,7 @@ void R_RenderWaterPass(void)
g_VisibleWaterSurfaceModels.emplace_back(pWaterModel);
}
}

for (int i = 0; i < (*cl_numvisedicts); ++i)
{
auto e = cl_visedicts[i];
Expand Down
2 changes: 1 addition & 1 deletion Plugins/Renderer/gl_wsurf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3527,7 +3527,7 @@ void R_ParseBSPEntity_Env_Water_Control(bspentity_t *ent)
}
else
{
int lv;
int lv = 0;
if (sscanf(level_string, "%d", &lv) == 1)
{
pWaterControl->level = math_clamp(lv, WATER_LEVEL_LEGACY, WATER_LEVEL_MAX - 1);
Expand Down

0 comments on commit 479a6c9

Please sign in to comment.