mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-23 21:15:11 +00:00
GUI: possibly fix particles going out of bounds
This commit is contained in:
parent
a8c04e80e3
commit
ff7110cb05
1 changed files with 51 additions and 24 deletions
|
@ -1011,6 +1011,12 @@ void FurnaceGUI::drawPattern() {
|
|||
e->getCommandStream(cmdStream);
|
||||
ImDrawList* dl=ImGui::GetWindowDrawList();
|
||||
ImVec2 off=ImVec2(0.0f,ImGui::GetWindowPos().y);
|
||||
|
||||
ImVec2 winMin=ImGui::GetWindowPos();
|
||||
ImVec2 winMax=ImVec2(
|
||||
winMin.x+ImGui::GetWindowSize().x,
|
||||
winMin.y+ImGui::GetWindowSize().y
|
||||
);
|
||||
|
||||
// commands
|
||||
for (DivCommand& i: cmdStream) {
|
||||
|
@ -1133,11 +1139,18 @@ void FurnaceGUI::drawPattern() {
|
|||
}
|
||||
|
||||
for (int j=0; j<num; j++) {
|
||||
ImVec2 partPos=ImVec2(
|
||||
off.x+patChanX[i.chan]+fmod(rand(),width)-scrollX,
|
||||
off.y+(ImGui::GetWindowHeight()*0.5f)+randRange(0,patFont->FontSize)
|
||||
);
|
||||
|
||||
if (partPos.x<winMin.x || partPos.y<winMin.y || partPos.x>winMax.x || partPos.y>winMax.y) continue;
|
||||
|
||||
particles.push_back(Particle(
|
||||
color,
|
||||
partIcon,
|
||||
off.x+patChanX[i.chan]+fmod(rand(),width)-scrollX,
|
||||
off.y+(ImGui::GetWindowHeight()*0.5f)+randRange(0,patFont->FontSize),
|
||||
partPos.x,
|
||||
partPos.y,
|
||||
(speedX+randRange(-spread,spread))*0.5*dpiScale,
|
||||
(speedY+randRange(-spread,spread))*0.5*dpiScale,
|
||||
grav,
|
||||
|
@ -1160,18 +1173,25 @@ void FurnaceGUI::drawPattern() {
|
|||
col.w*=0.2;
|
||||
float width=patChanX[i+1]-patChanX[i];
|
||||
|
||||
particles.push_back(Particle(
|
||||
pitchGrad,
|
||||
(ch->portaNote<=ch->note)?ICON_FA_CHEVRON_DOWN:ICON_FA_CHEVRON_UP,
|
||||
ImVec2 partPos=ImVec2(
|
||||
off.x+patChanX[i]+fmod(rand(),width)-scrollX,
|
||||
off.y+fmod(rand(),MAX(1,ImGui::GetWindowHeight())),
|
||||
0.0f,
|
||||
(7.0f+(rand()%5)+pow(ch->portaSpeed,0.7f))*((ch->portaNote<=ch->note)?1:-1),
|
||||
0.0f,
|
||||
1.0f,
|
||||
255.0f,
|
||||
15.0f
|
||||
));
|
||||
off.y+fmod(rand(),MAX(1,ImGui::GetWindowHeight()))
|
||||
);
|
||||
|
||||
if (!(partPos.x<winMin.x || partPos.y<winMin.y || partPos.x>winMax.x || partPos.y>winMax.y)) {
|
||||
particles.push_back(Particle(
|
||||
pitchGrad,
|
||||
(ch->portaNote<=ch->note)?ICON_FA_CHEVRON_DOWN:ICON_FA_CHEVRON_UP,
|
||||
partPos.x,
|
||||
partPos.y,
|
||||
0.0f,
|
||||
(7.0f+(rand()%5)+pow(ch->portaSpeed,0.7f))*((ch->portaNote<=ch->note)?1:-1),
|
||||
0.0f,
|
||||
1.0f,
|
||||
255.0f,
|
||||
15.0f
|
||||
));
|
||||
}
|
||||
|
||||
if (width>0.1) for (float j=-patChanSlideY[i]; j<ImGui::GetWindowHeight(); j+=width*0.7) {
|
||||
ImVec2 tMin=ImVec2(off.x+patChanX[i]-scrollX,off.y+j);
|
||||
|
@ -1210,18 +1230,25 @@ void FurnaceGUI::drawPattern() {
|
|||
col.w*=0.2;
|
||||
float width=patChanX[i+1]-patChanX[i];
|
||||
|
||||
particles.push_back(Particle(
|
||||
pitchGrad,
|
||||
ICON_FA_GLASS,
|
||||
ImVec2 partPos=ImVec2(
|
||||
off.x+patChanX[i]+(width*0.5+0.5*sin(M_PI*(float)ch->vibratoPosGiant/64.0f)*width)-scrollX,
|
||||
off.y+(ImGui::GetWindowHeight()*0.5f)+randRange(0,patFont->FontSize),
|
||||
randRange(-4.0f,4.0f),
|
||||
2.0f*(3.0f+(rand()%5)+ch->vibratoRate),
|
||||
0.4f,
|
||||
1.0f,
|
||||
128.0f,
|
||||
4.0f
|
||||
));
|
||||
off.y+(ImGui::GetWindowHeight()*0.5f)+randRange(0,patFont->FontSize)
|
||||
);
|
||||
|
||||
if (!(partPos.x<winMin.x || partPos.y<winMin.y || partPos.x>winMax.x || partPos.y>winMax.y)) {
|
||||
particles.push_back(Particle(
|
||||
pitchGrad,
|
||||
ICON_FA_GLASS,
|
||||
partPos.x,
|
||||
partPos.y,
|
||||
randRange(-4.0f,4.0f),
|
||||
2.0f*(3.0f+(rand()%5)+ch->vibratoRate),
|
||||
0.4f,
|
||||
1.0f,
|
||||
128.0f,
|
||||
4.0f
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue