Fix find mode always reporting 0 particles found

Somehow foundElements (now renamed to foundParticles) made it into RendererSettings in 820f44a716, even though it's actually a result of the rendering process. It is now extracted the same way as the resulting frame.
This commit is contained in:
Tamás Bálint Misius
2024-09-07 15:13:24 +02:00
parent 65aa34201b
commit 6da42933c4
5 changed files with 12 additions and 4 deletions

View File

@@ -262,7 +262,7 @@ void Renderer::render_parts()
BlendPixel({ nx, ny }, 0x646464_rgb .WithAlpha(80)); BlendPixel({ nx, ny }, 0x646464_rgb .WithAlpha(80));
} }
} }
foundElements = 0; foundParticles = 0;
for(i = 0; i<=sim->parts_lastActiveIndex; i++) { for(i = 0; i<=sim->parts_lastActiveIndex; i++) {
if (sim->parts[i].type && sim->parts[i].type >= 0 && sim->parts[i].type < PT_NUM) { if (sim->parts[i].type && sim->parts[i].type >= 0 && sim->parts[i].type < PT_NUM) {
t = sim->parts[i].type; t = sim->parts[i].type;
@@ -483,7 +483,7 @@ void Renderer::render_parts()
{ {
colr = firer = 255; colr = firer = 255;
colg = fireg = colb = fireb = 0; colg = fireg = colb = fireb = 0;
foundElements++; foundParticles++;
} }
else else
{ {

View File

@@ -32,6 +32,7 @@ class Renderer : private RendererSettings, public RasterDrawMethods<Renderer>
RendererFrame video; RendererFrame video;
std::array<pixel, WINDOW.X * RES.Y> persistentVideo; std::array<pixel, WINDOW.X * RES.Y> persistentVideo;
RendererFrame warpVideo; RendererFrame warpVideo;
int foundParticles = 0;
Rect<int> GetClipRect() const Rect<int> GetClipRect() const
{ {
@@ -72,6 +73,11 @@ public:
return video; return video;
} }
int GetFoundParticles() const
{
return foundParticles;
}
const RenderableSimulation *sim = nullptr; const RenderableSimulation *sim = nullptr;
struct GradientStop struct GradientStop

View File

@@ -21,7 +21,6 @@ struct RendererSettings
}; };
DecorationLevel decorationLevel = decorationEnabled; DecorationLevel decorationLevel = decorationEnabled;
bool debugLines = false; bool debugLines = false;
int foundElements = 0;
ui::Point mousePos = { 0, 0 }; ui::Point mousePos = { 0, 0 };
int gridSize = 0; int gridSize = 0;
float fireIntensity = 1; float fireIntensity = 1;

View File

@@ -2159,6 +2159,7 @@ void GameView::OnDraw()
{ {
StartRendererThread(); StartRendererThread();
WaitForRendererThread(); WaitForRendererThread();
foundParticles = ren->GetFoundParticles();
*rendererThreadResult = ren->GetVideo(); *rendererThreadResult = ren->GetVideo();
rendererFrame = rendererThreadResult.get(); rendererFrame = rendererThreadResult.get();
DispatchRendererThread(); DispatchRendererThread();
@@ -2168,6 +2169,7 @@ void GameView::OnDraw()
PauseRendererThread(); PauseRendererThread();
ren->ApplySettings(*rendererSettings); ren->ApplySettings(*rendererSettings);
RenderSimulation(*sim, true); RenderSimulation(*sim, true);
foundParticles = ren->GetFoundParticles();
rendererFrame = &ren->GetVideo(); rendererFrame = &ren->GetVideo();
} }
@@ -2514,7 +2516,7 @@ void GameView::OnDraw()
if (showDebug) if (showDebug)
{ {
if (rendererSettings->findingElement) if (rendererSettings->findingElement)
fpsInfo << " Parts: " << rendererSettings->foundElements << "/" << sample.NumParts; fpsInfo << " Parts: " << foundParticles << "/" << sample.NumParts;
else else
fpsInfo << " Parts: " << sample.NumParts; fpsInfo << " Parts: " << sample.NumParts;
} }

View File

@@ -172,6 +172,7 @@ private:
void DispatchRendererThread(); void DispatchRendererThread();
std::unique_ptr<RenderableSimulation> rendererThreadSim; std::unique_ptr<RenderableSimulation> rendererThreadSim;
std::unique_ptr<RendererFrame> rendererThreadResult; std::unique_ptr<RendererFrame> rendererThreadResult;
int foundParticles = 0;
const RendererFrame *rendererFrame = nullptr; const RendererFrame *rendererFrame = nullptr;
public: public: