minor fixes to color picker / small speed improvement

This commit is contained in:
jacob1 2013-02-08 11:39:14 -05:00
parent 8e02443f0a
commit cd0af92fb3
4 changed files with 66 additions and 56 deletions

View File

@ -169,7 +169,7 @@ void ColourPickerActivity::OnMouseDown(int x, int y, unsigned button)
{ {
x -= Position.X+5; x -= Position.X+5;
y -= Position.Y+5; y -= Position.Y+5;
if(x >= 0 && x <= 256 && y >= 0 && y < 127) if(x >= 0 && x < 256 && y >= 0 && y <= 128)
{ {
mouseDown = true; mouseDown = true;
currentHue = (float(x)/float(255))*359.0f; currentHue = (float(x)/float(255))*359.0f;
@ -185,7 +185,7 @@ void ColourPickerActivity::OnMouseDown(int x, int y, unsigned button)
currentHue = 0; currentHue = 0;
} }
if(x >= 0 && x <= 256 && y >= 131 && y < 142) if(x >= 0 && x < 256 && y >= 132 && y <= 142)
{ {
valueMouseDown = true; valueMouseDown = true;
currentValue = x; currentValue = x;
@ -295,13 +295,18 @@ void ColourPickerActivity::OnDraw()
g->blendpixel(value+offsetX, i+offsetY+127+5, cr, cg, cb, currentAlpha); g->blendpixel(value+offsetX, i+offsetY+127+5, cr, cg, cb, currentAlpha);
} }
//draw color square pointer
int currentHueX = clamp_flt(currentHue, 0, 359); int currentHueX = clamp_flt(currentHue, 0, 359);
int currentSaturationY = ((255-currentSaturation)/2); int currentSaturationY = ((255-currentSaturation)/2);
g->xor_line(offsetX+currentHueX, offsetY+currentSaturationY-5, offsetX+currentHueX, offsetY+currentSaturationY+5); g->xor_line(offsetX+currentHueX, offsetY+currentSaturationY-5, offsetX+currentHueX, offsetY+currentSaturationY-1);
g->xor_line(offsetX+currentHueX-5, offsetY+currentSaturationY, offsetX+currentHueX+5, offsetY+currentSaturationY); g->xor_line(offsetX+currentHueX, offsetY+currentSaturationY+1, offsetX+currentHueX, offsetY+currentSaturationY+5);
g->xor_line(offsetX+currentHueX-5, offsetY+currentSaturationY, offsetX+currentHueX-1, offsetY+currentSaturationY);
g->xor_line(offsetX+currentHueX+1, offsetY+currentSaturationY, offsetX+currentHueX+5, offsetY+currentSaturationY);
g->xor_line(offsetX+currentValue, offsetY+4+128, offsetX+currentValue, offsetY+13+128); //draw brightness bar pointer
g->xor_line(offsetX+currentValue+1, offsetY+4+128, offsetX+currentValue+1, offsetY+13+128); int currentValueX = restrict_flt(currentValue, 0, 254);
g->xor_line(offsetX+currentValueX, offsetY+4+128, offsetX+currentValueX, offsetY+13+128);
g->xor_line(offsetX+currentValueX+1, offsetY+4+128, offsetX+currentValueX+1, offsetY+13+128);
} }
ColourPickerActivity::~ColourPickerActivity() { ColourPickerActivity::~ColourPickerActivity() {

View File

@ -843,13 +843,11 @@ void GameModel::FrameStep(int frames)
void GameModel::ClearSimulation() void GameModel::ClearSimulation()
{ {
//Load defaults //Load defaults
sim->gravityMode = 0; sim->gravityMode = 0;
sim->air->airMode = 0; sim->air->airMode = 0;
sim->legacy_enable = false; sim->legacy_enable = false;
sim->water_equal_test = false; sim->water_equal_test = false;
sim->grav->stop_grav_async();
sim->SetEdgeMode(edgeMode); sim->SetEdgeMode(edgeMode);
sim->clear_sim(); sim->clear_sim();

View File

@ -86,7 +86,7 @@ void LocalBrowserController::removeSelectedC()
}; };
std::vector<std::string> selected = browserModel->GetSelected(); std::vector<std::string> selected = browserModel->GetSelected();
new TaskWindow("Removing saves", new RemoveSavesTask(this, selected)); new TaskWindow("Removing stamps", new RemoveSavesTask(this, selected));
} }
void LocalBrowserController::RescanStamps() void LocalBrowserController::RescanStamps()

View File

@ -3663,62 +3663,69 @@ void Simulation::update_particles_i(int start, int inc)
vx[y/CELL][x/CELL] = vx[y/CELL][x/CELL]*elements[t].AirLoss + elements[t].AirDrag*parts[i].vx; vx[y/CELL][x/CELL] = vx[y/CELL][x/CELL]*elements[t].AirLoss + elements[t].AirDrag*parts[i].vx;
vy[y/CELL][x/CELL] = vy[y/CELL][x/CELL]*elements[t].AirLoss + elements[t].AirDrag*parts[i].vy; vy[y/CELL][x/CELL] = vy[y/CELL][x/CELL]*elements[t].AirLoss + elements[t].AirDrag*parts[i].vy;
if (t==PT_GAS||t==PT_NBLE) if (elements[t].HotAir)
{ {
if (pv[y/CELL][x/CELL]<3.5f) if (t==PT_GAS||t==PT_NBLE)
pv[y/CELL][x/CELL] += elements[t].HotAir*(3.5f-pv[y/CELL][x/CELL]);
if (y+CELL<YRES && pv[y/CELL+1][x/CELL]<3.5f)
pv[y/CELL+1][x/CELL] += elements[t].HotAir*(3.5f-pv[y/CELL+1][x/CELL]);
if (x+CELL<XRES)
{ {
if (pv[y/CELL][x/CELL+1]<3.5f) if (pv[y/CELL][x/CELL]<3.5f)
pv[y/CELL][x/CELL+1] += elements[t].HotAir*(3.5f-pv[y/CELL][x/CELL+1]); pv[y/CELL][x/CELL] += elements[t].HotAir*(3.5f-pv[y/CELL][x/CELL]);
if (y+CELL<YRES && pv[y/CELL+1][x/CELL+1]<3.5f) if (y+CELL<YRES && pv[y/CELL+1][x/CELL]<3.5f)
pv[y/CELL+1][x/CELL+1] += elements[t].HotAir*(3.5f-pv[y/CELL+1][x/CELL+1]); pv[y/CELL+1][x/CELL] += elements[t].HotAir*(3.5f-pv[y/CELL+1][x/CELL]);
if (x+CELL<XRES)
{
if (pv[y/CELL][x/CELL+1]<3.5f)
pv[y/CELL][x/CELL+1] += elements[t].HotAir*(3.5f-pv[y/CELL][x/CELL+1]);
if (y+CELL<YRES && pv[y/CELL+1][x/CELL+1]<3.5f)
pv[y/CELL+1][x/CELL+1] += elements[t].HotAir*(3.5f-pv[y/CELL+1][x/CELL+1]);
}
} }
} else//add the hotair variable to the pressure map, like black hole, or white hole.
else//add the hotair variable to the pressure map, like black hole, or white hole.
{
pv[y/CELL][x/CELL] += elements[t].HotAir;
if (y+CELL<YRES)
pv[y/CELL+1][x/CELL] += elements[t].HotAir;
if (x+CELL<XRES)
{ {
pv[y/CELL][x/CELL+1] += elements[t].HotAir; pv[y/CELL][x/CELL] += elements[t].HotAir;
if (y+CELL<YRES) if (y+CELL<YRES)
pv[y/CELL+1][x/CELL+1] += elements[t].HotAir; pv[y/CELL+1][x/CELL] += elements[t].HotAir;
if (x+CELL<XRES)
{
pv[y/CELL][x/CELL+1] += elements[t].HotAir;
if (y+CELL<YRES)
pv[y/CELL+1][x/CELL+1] += elements[t].HotAir;
}
} }
} }
if (elements[t].Gravity || !(elements[t].Properties & TYPE_SOLID))
//Gravity mode by Moach
switch (gravityMode)
{ {
default: //Gravity mode by Moach
case 0: switch (gravityMode)
pGravX = 0.0f; {
pGravY = elements[t].Gravity; default:
break; case 0:
case 1: pGravX = 0.0f;
pGravX = pGravY = 0.0f; pGravY = elements[t].Gravity;
break; break;
case 2: case 1:
pGravD = 0.01f - hypotf((x - XCNTR), (y - YCNTR)); pGravX = pGravY = 0.0f;
pGravX = elements[t].Gravity * ((float)(x - XCNTR) / pGravD); break;
pGravY = elements[t].Gravity * ((float)(y - YCNTR) / pGravD); case 2:
break; pGravD = 0.01f - hypotf((x - XCNTR), (y - YCNTR));
} pGravX = elements[t].Gravity * ((float)(x - XCNTR) / pGravD);
//Get some gravity from the gravity map pGravY = elements[t].Gravity * ((float)(y - YCNTR) / pGravD);
if (t==PT_ANAR) break;
{ }
// perhaps we should have a ptypes variable for this //Get some gravity from the gravity map
pGravX -= gravx[(y/CELL)*(XRES/CELL)+(x/CELL)]; if (t==PT_ANAR)
pGravY -= gravy[(y/CELL)*(XRES/CELL)+(x/CELL)]; {
} // perhaps we should have a ptypes variable for this
else if(t!=PT_STKM && t!=PT_STKM2 && t!=PT_FIGH && !(elements[t].Properties & TYPE_SOLID)) pGravX -= gravx[(y/CELL)*(XRES/CELL)+(x/CELL)];
{ pGravY -= gravy[(y/CELL)*(XRES/CELL)+(x/CELL)];
pGravX += gravx[(y/CELL)*(XRES/CELL)+(x/CELL)]; }
pGravY += gravy[(y/CELL)*(XRES/CELL)+(x/CELL)]; else if(t!=PT_STKM && t!=PT_STKM2 && t!=PT_FIGH && !(elements[t].Properties & TYPE_SOLID))
{
pGravX += gravx[(y/CELL)*(XRES/CELL)+(x/CELL)];
pGravY += gravy[(y/CELL)*(XRES/CELL)+(x/CELL)];
}
} }
else
pGravX = pGravY = 0;
//velocity updates for the particle //velocity updates for the particle
if (t != PT_SPNG || !(parts[i].flags&FLAG_MOVABLE)) if (t != PT_SPNG || !(parts[i].flags&FLAG_MOVABLE))
{ {