Revert "- no, we do not want to use global variables to pass parameters around..."

This reverts commit 26a782031c.

Not applicable and caused lighting problems with models.
This commit is contained in:
drfrag 2019-11-16 13:35:23 +01:00
parent 787f06d7f3
commit 74aa1763e6
6 changed files with 17 additions and 14 deletions

View file

@ -54,6 +54,8 @@
CVAR(Bool, gl_light_models, true, CVAR_ARCHIVE)
extern int modellightindex;
VSMatrix FGLModelRenderer::GetViewToWorldMatrix()
{
VSMatrix objectToWorldMatrix;
@ -352,9 +354,9 @@ void FModelVertexBuffer::SetupFrame(FModelRenderer *renderer, unsigned int frame
//
//===========================================================================
void gl_RenderModel(GLSprite * spr, int mli)
void gl_RenderModel(GLSprite * spr)
{
FGLModelRenderer renderer(mli);
FGLModelRenderer renderer;
renderer.RenderModel(spr->x, spr->y, spr->z, spr->modelframe, spr->actor);
}
@ -364,8 +366,8 @@ void gl_RenderModel(GLSprite * spr, int mli)
//
//===========================================================================
void gl_RenderHUDModel(DPSprite *psp, float ofsX, float ofsY, int mli)
void gl_RenderHUDModel(DPSprite *psp, float ofsX, float ofsY)
{
FGLModelRenderer renderer(mli);
FGLModelRenderer renderer;
renderer.RenderHUDModel(psp, ofsX, ofsY);
}

View file

@ -32,10 +32,7 @@ class GLSprite;
class FGLModelRenderer : public FModelRenderer
{
int modellightindex = -1;
public:
FGLModelRenderer(int mli) : modellightindex(mli)
{}
ModelRendererType GetType() const override { return GLModelRendererType; }
void BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix, bool mirrored) override;
void EndDrawModel(AActor *actor, FSpriteModelFrame *smf) override;
@ -51,5 +48,5 @@ public:
void DrawElements(int numIndices, size_t offset) override;
};
void gl_RenderModel(GLSprite * spr, int mli);
void gl_RenderHUDModel(DPSprite *psp, float ofsx, float ofsy, int mli);
void gl_RenderModel(GLSprite * spr);
void gl_RenderHUDModel(DPSprite *psp, float ofsx, float ofsy);

View file

@ -81,6 +81,7 @@ EXTERN_CVAR (Bool, r_debug_disable_vis_filter)
extern TArray<spritedef_t> sprites;
extern TArray<spriteframe_t> SpriteFrames;
extern uint32_t r_renderercaps;
extern int modellightindex;
enum HWRenderStyle
{
@ -474,7 +475,7 @@ void GLSprite::Draw(int pass)
}
else
{
gl_RenderModel(this, dynlightindex);
gl_RenderModel(this);
}
}

View file

@ -47,6 +47,8 @@
#include "gl/textures/gl_material.h"
#include "gl/dynlights/gl_lightbuffer.h"
FDynLightData modellightdata;
int modellightindex = -1;
template<class T>
T smoothstep(const T edge0, const T edge1, const T x)
@ -140,6 +142,7 @@ void gl_SetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t *
node = node->nextLight;
}
gl_RenderState.SetDynLight(out[0], out[1], out[2]);
modellightindex = -1;
}
void gl_SetDynSpriteLight(AActor *thing, particle_t *particle)
@ -156,12 +159,11 @@ void gl_SetDynSpriteLight(AActor *thing, particle_t *particle)
int gl_SetDynModelLight(AActor *self, int dynlightindex)
{
static FDynLightData modellightdata; // If this ever gets multithreaded, this variable must either be made non-static or thread_local.
// For deferred light mode this function gets called twice. First time for list upload, and second for draw.
if (gl.lightmethod == LM_DEFERRED && dynlightindex != -1)
{
gl_RenderState.SetDynLight(0, 0, 0);
modellightindex = dynlightindex;
return dynlightindex;
}
@ -220,6 +222,7 @@ int gl_SetDynModelLight(AActor *self, int dynlightindex)
if (gl.lightmethod != LM_DEFERRED)
{
gl_RenderState.SetDynLight(0, 0, 0);
modellightindex = dynlightindex;
}
return dynlightindex;
}

View file

@ -75,7 +75,7 @@ void GLSceneDrawer::DrawPSprite (player_t * player,DPSprite *psp, float sx, floa
// [BB] In the HUD model step we just render the model and break out.
if ( hudModelStep )
{
gl_RenderHUDModel(psp, sx, sy, weapondynlightindex[psp]);
gl_RenderHUDModel(psp, sx, sy);
return;
}

View file

@ -762,7 +762,7 @@ void gl_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitl
}
// cache all used models
FGLModelRenderer renderer(-1);
FGLModelRenderer renderer;
for (unsigned i = 0; i < Models.Size(); i++)
{
if (modellist[i])