limit particle number and fix particles drawing over everything

This commit is contained in:
Eknous-P 2026-01-08 00:28:29 +04:00
parent 2e9245b043
commit b6c316bb8e
2 changed files with 16 additions and 2 deletions

View file

@ -29,6 +29,8 @@
#include "../utfutils.h"
#include <fmt/printf.h>
#define MAX_PARTICLES 8192
#define SETUP_ORDER_ALPHA \
if (ord==curOrder) { \
ImGui::GetStyle().Alpha=origAlpha; \
@ -1976,6 +1978,7 @@ void FurnaceGUI::drawPatternNew() {
if (partPos.x<winMin.x || partPos.y<winMin.y || partPos.x>winMax.x || partPos.y>winMax.y) continue;
if (particles.size()>MAX_PARTICLES) particles.erase(particles.begin());
particles.push_back(Particle(
color,
partIcon,
@ -2009,6 +2012,7 @@ void FurnaceGUI::drawPatternNew() {
);
if (!(partPos.x<winMin.x || partPos.y<winMin.y || partPos.x>winMax.x || partPos.y>winMax.y)) {
if (particles.size()>MAX_PARTICLES) particles.erase(particles.begin());
particles.push_back(Particle(
pitchGrad,
(ch->portaNote<=ch->note)?ICON_FA_CHEVRON_DOWN:ICON_FA_CHEVRON_UP,
@ -2066,6 +2070,7 @@ void FurnaceGUI::drawPatternNew() {
);
if (!(partPos.x<winMin.x || partPos.y<winMin.y || partPos.x>winMax.x || partPos.y>winMax.y)) {
if (particles.size()>MAX_PARTICLES) particles.erase(particles.begin());
particles.push_back(Particle(
pitchGrad,
ICON_FA_GLASS,
@ -2083,7 +2088,8 @@ void FurnaceGUI::drawPatternNew() {
}
// particle simulation
ImDrawList* fdl=ImGui::GetForegroundDrawList();
ImDrawList* fdl=ImGui::GetWindowDrawList();
fdl->PushClipRectFullScreen();
if (!particles.empty()) WAKE_UP;
fdl->AddCallback(_pushPartBlend,this);
for (size_t i=0; i<particles.size(); i++) {
@ -2103,6 +2109,7 @@ void FurnaceGUI::drawPatternNew() {
}
}
fdl->AddCallback(_popPartBlend,this);
fdl->PopClipRect();
}
ImGui::PopFont();

View file

@ -29,6 +29,8 @@
#include "../utfutils.h"
#include <fmt/printf.h>
#define MAX_PARTICLES 8192
struct DelayedLabel {
float posCenter, posY;
ImVec2 textSize;
@ -1802,6 +1804,7 @@ void FurnaceGUI::drawPattern() {
if (partPos.x<winMin.x || partPos.y<winMin.y || partPos.x>winMax.x || partPos.y>winMax.y) continue;
if (particles.size()>MAX_PARTICLES) particles.erase(particles.begin());
particles.push_back(Particle(
color,
partIcon,
@ -1835,6 +1838,7 @@ void FurnaceGUI::drawPattern() {
);
if (!(partPos.x<winMin.x || partPos.y<winMin.y || partPos.x>winMax.x || partPos.y>winMax.y)) {
if (particles.size()>MAX_PARTICLES) particles.erase(particles.begin());
particles.push_back(Particle(
pitchGrad,
(ch->portaNote<=ch->note)?ICON_FA_CHEVRON_DOWN:ICON_FA_CHEVRON_UP,
@ -1892,6 +1896,7 @@ void FurnaceGUI::drawPattern() {
);
if (!(partPos.x<winMin.x || partPos.y<winMin.y || partPos.x>winMax.x || partPos.y>winMax.y)) {
if (particles.size()>MAX_PARTICLES) particles.erase(particles.begin());
particles.push_back(Particle(
pitchGrad,
ICON_FA_GLASS,
@ -1909,7 +1914,8 @@ void FurnaceGUI::drawPattern() {
}
// particle simulation
ImDrawList* fdl=ImGui::GetForegroundDrawList();
ImDrawList* fdl=ImGui::GetWindowDrawList();
fdl->PushClipRectFullScreen();
if (!particles.empty()) WAKE_UP;
fdl->AddCallback(_pushPartBlend,this);
for (size_t i=0; i<particles.size(); i++) {
@ -1929,6 +1935,7 @@ void FurnaceGUI::drawPattern() {
}
}
fdl->AddCallback(_popPartBlend,this);
fdl->PopClipRect();
}
ImGui::PopStyleColor(3);