Fix find mode always reporting 0 particles found

Somehow foundElements (now renamed to foundParticles) made it into RendererSettings in 820f44a71690, 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
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
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));
}
}
foundElements = 0;
foundParticles = 0;
for(i = 0; i<=sim->parts_lastActiveIndex; i++) {
if (sim->parts[i].type && sim->parts[i].type >= 0 && sim->parts[i].type < PT_NUM) {
t = sim->parts[i].type;
@ -483,7 +483,7 @@ void Renderer::render_parts()
{
colr = firer = 255;
colg = fireg = colb = fireb = 0;
foundElements++;
foundParticles++;
}
else
{

View File

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

View File

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

View File

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

View File

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