Skip to content

Commit

Permalink
Remove Renderer field from GraphicsFunContext
Browse files Browse the repository at this point in the history
 - Only decorationsEnable & blackDecorations were ever read, graphics update functions shouldn't really be aware of the renderer.
 - `sim` should ideally not be there either, but `luaGraphicsWrapper` has more going on to sort out
  • Loading branch information
simtr committed Apr 6, 2024
1 parent 1a0eb73 commit 2c55a8a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/graphics/Renderer.cpp
Expand Up @@ -176,9 +176,10 @@ void Renderer::render_parts()
auto &elements = sd.elements;
auto &graphicscache = sd.graphicscache;
GraphicsFuncContext gfctx;
gfctx.ren = this;
gfctx.sim = sim;
gfctx.rng.seed(rng());
gfctx.decorationsEnable = decorations_enable;
gfctx.blackDecorations = blackDecorations;
gfctx.pipeSubcallCpart = nullptr;
gfctx.pipeSubcallTpart = nullptr;
int deca, decr, decg, decb, cola, colr, colg, colb, firea, firer, fireg, fireb, pixel_mode, q, i, t, nx, ny, x, y;
Expand Down
3 changes: 2 additions & 1 deletion src/graphics/Renderer.h
Expand Up @@ -18,8 +18,9 @@ struct Particle;

struct GraphicsFuncContext
{
const Renderer *ren;
const Simulation *sim;
bool decorationsEnable;
bool blackDecorations;
RNG rng;
const Particle *pipeSubcallCpart;
Particle *pipeSubcallTpart;
Expand Down
4 changes: 2 additions & 2 deletions src/simulation/elements/EMBR.cpp
Expand Up @@ -100,9 +100,9 @@ static int graphics(GRAPHICS_FUNC_ARGS)
}

bool deco = false;
if (gfctx.ren->decorations_enable && cpart->dcolour && (cpart->dcolour&0xFF000000))
if (gfctx.decorationsEnable && cpart->dcolour && (cpart->dcolour&0xFF000000))
{
if (!gfctx.ren->blackDecorations) // if blackDecorations is off, always show deco
if (!gfctx.blackDecorations) // if blackDecorations is off, always show deco
deco = true;
else if (((cpart->dcolour>>24)&0xFF) >= 250 && ((cpart->dcolour>>16)&0xFF) <= 5 && ((cpart->dcolour>>8)&0xFF) <= 5 && ((cpart->dcolour)&0xFF) <= 5) // else only render black deco
deco = true;
Expand Down
4 changes: 2 additions & 2 deletions src/simulation/elements/LCRY.cpp
Expand Up @@ -107,9 +107,9 @@ static int update(UPDATE_FUNC_ARGS)
static int graphics(GRAPHICS_FUNC_ARGS)
{
bool deco = false;
if (gfctx.ren->decorations_enable && cpart->dcolour && (cpart->dcolour&0xFF000000))
if (gfctx.decorationsEnable && cpart->dcolour && (cpart->dcolour&0xFF000000))
{
if (!gfctx.ren->blackDecorations) // if blackDecorations is off, always show deco
if (!gfctx.blackDecorations) // if blackDecorations is off, always show deco
deco = true;
else if(((cpart->dcolour>>24)&0xFF) >= 250 && ((cpart->dcolour>>16)&0xFF) <= 5 && ((cpart->dcolour>>8)&0xFF) <= 5 && ((cpart->dcolour)&0xFF) <= 5) // else only render black deco
deco = true;
Expand Down
4 changes: 2 additions & 2 deletions src/simulation/elements/LIFE.cpp
Expand Up @@ -58,10 +58,10 @@ static int graphics(GRAPHICS_FUNC_ARGS)
colour1 = 0xFFFFFF_rgb;
}
auto ruleset = cpart->ctype;
bool renderDeco = !gfctx.ren->blackDecorations;
bool renderDeco = !gfctx.blackDecorations;
if (ruleset >= 0 && ruleset < NGOL)
{
if (!renderDeco || !gfctx.ren->decorations_enable)
if (!renderDeco || !gfctx.decorationsEnable)
{
colour1 = builtinGol[ruleset].colour;
colour2 = builtinGol[ruleset].colour2;
Expand Down

0 comments on commit 2c55a8a

Please sign in to comment.