From 36619df4f430622d878bf8089629543b654349da Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Sun, 7 Apr 2024 16:31:10 +0100 Subject: [PATCH] Revert "Remove `Renderer` field from GraphicsFunContext" This reverts commit 9f02999947f5067535abad3fc2c2b016549c30da & 2c55a8a9d92fc8742c864b43dd919db6882e96fa --- src/graphics/Renderer.cpp | 3 +-- src/graphics/Renderer.h | 3 +-- src/simulation/elements/EMBR.cpp | 4 ++-- src/simulation/elements/LCRY.cpp | 4 ++-- src/simulation/elements/LIFE.cpp | 4 ++-- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp index d97fc0b7a..7b52489ee 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -176,10 +176,9 @@ 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; diff --git a/src/graphics/Renderer.h b/src/graphics/Renderer.h index c0c2d91ca..452a9dd63 100644 --- a/src/graphics/Renderer.h +++ b/src/graphics/Renderer.h @@ -18,9 +18,8 @@ struct Particle; struct GraphicsFuncContext { + const Renderer *ren; const Simulation *sim; - bool decorationsEnable; - bool blackDecorations; RNG rng; const Particle *pipeSubcallCpart; Particle *pipeSubcallTpart; diff --git a/src/simulation/elements/EMBR.cpp b/src/simulation/elements/EMBR.cpp index 95f80b8e2..4edaa1ddd 100644 --- a/src/simulation/elements/EMBR.cpp +++ b/src/simulation/elements/EMBR.cpp @@ -100,9 +100,9 @@ static int graphics(GRAPHICS_FUNC_ARGS) } bool deco = false; - if (gfctx.decorationsEnable && cpart->dcolour && (cpart->dcolour&0xFF000000)) + if (gfctx.ren->decorations_enable && cpart->dcolour && (cpart->dcolour&0xFF000000)) { - if (!gfctx.blackDecorations) // if blackDecorations is off, always show deco + if (!gfctx.ren->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; diff --git a/src/simulation/elements/LCRY.cpp b/src/simulation/elements/LCRY.cpp index df1de32bb..08336aa95 100644 --- a/src/simulation/elements/LCRY.cpp +++ b/src/simulation/elements/LCRY.cpp @@ -107,9 +107,9 @@ static int update(UPDATE_FUNC_ARGS) static int graphics(GRAPHICS_FUNC_ARGS) { bool deco = false; - if (gfctx.decorationsEnable && cpart->dcolour && (cpart->dcolour&0xFF000000)) + if (gfctx.ren->decorations_enable && cpart->dcolour && (cpart->dcolour&0xFF000000)) { - if (!gfctx.blackDecorations) // if blackDecorations is off, always show deco + if (!gfctx.ren->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; diff --git a/src/simulation/elements/LIFE.cpp b/src/simulation/elements/LIFE.cpp index a1a23cbbe..411f4096e 100644 --- a/src/simulation/elements/LIFE.cpp +++ b/src/simulation/elements/LIFE.cpp @@ -58,10 +58,10 @@ static int graphics(GRAPHICS_FUNC_ARGS) colour1 = 0xFFFFFF_rgb; } auto ruleset = cpart->ctype; - bool renderDeco = !gfctx.blackDecorations; + bool renderDeco = !gfctx.ren->blackDecorations; if (ruleset >= 0 && ruleset < NGOL) { - if (!renderDeco || !gfctx.decorationsEnable) + if (!renderDeco || !gfctx.ren->decorations_enable) { colour1 = builtinGol[ruleset].colour; colour2 = builtinGol[ruleset].colour2;