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
|
@ -1012,6 +1012,12 @@ void FurnaceGUI::drawPattern() {
|
||||||
ImDrawList* dl=ImGui::GetWindowDrawList();
|
ImDrawList* dl=ImGui::GetWindowDrawList();
|
||||||
ImVec2 off=ImVec2(0.0f,ImGui::GetWindowPos().y);
|
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
|
// commands
|
||||||
for (DivCommand& i: cmdStream) {
|
for (DivCommand& i: cmdStream) {
|
||||||
if (i.cmd==DIV_CMD_PITCH) continue;
|
if (i.cmd==DIV_CMD_PITCH) continue;
|
||||||
|
@ -1133,11 +1139,18 @@ void FurnaceGUI::drawPattern() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j=0; j<num; j++) {
|
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(
|
particles.push_back(Particle(
|
||||||
color,
|
color,
|
||||||
partIcon,
|
partIcon,
|
||||||
off.x+patChanX[i.chan]+fmod(rand(),width)-scrollX,
|
partPos.x,
|
||||||
off.y+(ImGui::GetWindowHeight()*0.5f)+randRange(0,patFont->FontSize),
|
partPos.y,
|
||||||
(speedX+randRange(-spread,spread))*0.5*dpiScale,
|
(speedX+randRange(-spread,spread))*0.5*dpiScale,
|
||||||
(speedY+randRange(-spread,spread))*0.5*dpiScale,
|
(speedY+randRange(-spread,spread))*0.5*dpiScale,
|
||||||
grav,
|
grav,
|
||||||
|
@ -1160,11 +1173,17 @@ void FurnaceGUI::drawPattern() {
|
||||||
col.w*=0.2;
|
col.w*=0.2;
|
||||||
float width=patChanX[i+1]-patChanX[i];
|
float width=patChanX[i+1]-patChanX[i];
|
||||||
|
|
||||||
|
ImVec2 partPos=ImVec2(
|
||||||
|
off.x+patChanX[i]+fmod(rand(),width)-scrollX,
|
||||||
|
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(
|
particles.push_back(Particle(
|
||||||
pitchGrad,
|
pitchGrad,
|
||||||
(ch->portaNote<=ch->note)?ICON_FA_CHEVRON_DOWN:ICON_FA_CHEVRON_UP,
|
(ch->portaNote<=ch->note)?ICON_FA_CHEVRON_DOWN:ICON_FA_CHEVRON_UP,
|
||||||
off.x+patChanX[i]+fmod(rand(),width)-scrollX,
|
partPos.x,
|
||||||
off.y+fmod(rand(),MAX(1,ImGui::GetWindowHeight())),
|
partPos.y,
|
||||||
0.0f,
|
0.0f,
|
||||||
(7.0f+(rand()%5)+pow(ch->portaSpeed,0.7f))*((ch->portaNote<=ch->note)?1:-1),
|
(7.0f+(rand()%5)+pow(ch->portaSpeed,0.7f))*((ch->portaNote<=ch->note)?1:-1),
|
||||||
0.0f,
|
0.0f,
|
||||||
|
@ -1172,6 +1191,7 @@ void FurnaceGUI::drawPattern() {
|
||||||
255.0f,
|
255.0f,
|
||||||
15.0f
|
15.0f
|
||||||
));
|
));
|
||||||
|
}
|
||||||
|
|
||||||
if (width>0.1) for (float j=-patChanSlideY[i]; j<ImGui::GetWindowHeight(); j+=width*0.7) {
|
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);
|
ImVec2 tMin=ImVec2(off.x+patChanX[i]-scrollX,off.y+j);
|
||||||
|
@ -1210,11 +1230,17 @@ void FurnaceGUI::drawPattern() {
|
||||||
col.w*=0.2;
|
col.w*=0.2;
|
||||||
float width=patChanX[i+1]-patChanX[i];
|
float width=patChanX[i+1]-patChanX[i];
|
||||||
|
|
||||||
|
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)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!(partPos.x<winMin.x || partPos.y<winMin.y || partPos.x>winMax.x || partPos.y>winMax.y)) {
|
||||||
particles.push_back(Particle(
|
particles.push_back(Particle(
|
||||||
pitchGrad,
|
pitchGrad,
|
||||||
ICON_FA_GLASS,
|
ICON_FA_GLASS,
|
||||||
off.x+patChanX[i]+(width*0.5+0.5*sin(M_PI*(float)ch->vibratoPosGiant/64.0f)*width)-scrollX,
|
partPos.x,
|
||||||
off.y+(ImGui::GetWindowHeight()*0.5f)+randRange(0,patFont->FontSize),
|
partPos.y,
|
||||||
randRange(-4.0f,4.0f),
|
randRange(-4.0f,4.0f),
|
||||||
2.0f*(3.0f+(rand()%5)+ch->vibratoRate),
|
2.0f*(3.0f+(rand()%5)+ch->vibratoRate),
|
||||||
0.4f,
|
0.4f,
|
||||||
|
@ -1224,6 +1250,7 @@ void FurnaceGUI::drawPattern() {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// particle simulation
|
// particle simulation
|
||||||
ImDrawList* fdl=ImGui::GetForegroundDrawList();
|
ImDrawList* fdl=ImGui::GetForegroundDrawList();
|
||||||
|
|
Loading…
Reference in a new issue