diff options
| author | jacob1 <jfu614@gmail.com> | 2013-02-08 16:39:14 (GMT) |
|---|---|---|
| committer | jacob1 <jfu614@gmail.com> | 2013-02-08 16:39:14 (GMT) |
| commit | cd0af92fb316a3e3dc2de7082512ff2d650e7a70 (patch) | |
| tree | dfb7b0dc5f12df7145ec84eea6efe2417c16748c /src/simulation | |
| parent | 8e02443f0a294fcec9bcc8678dcf8b61f0d56f99 (diff) | |
| download | powder-cd0af92fb316a3e3dc2de7082512ff2d650e7a70.zip powder-cd0af92fb316a3e3dc2de7082512ff2d650e7a70.tar.gz | |
minor fixes to color picker / small speed improvement
Diffstat (limited to 'src/simulation')
| -rw-r--r-- | src/simulation/Simulation.cpp | 101 |
1 files changed, 54 insertions, 47 deletions
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 8eb3094..1a090f7 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -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; 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) - 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 (t==PT_GAS||t==PT_NBLE) { - 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]); + if (pv[y/CELL][x/CELL]<3.5f) + 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) + 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. - { - 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) + else//add the hotair variable to the pressure map, like black hole, or white hole. { - pv[y/CELL][x/CELL+1] += elements[t].HotAir; + pv[y/CELL][x/CELL] += elements[t].HotAir; 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; + } } } - - //Gravity mode by Moach - switch (gravityMode) - { - default: - case 0: - pGravX = 0.0f; - pGravY = elements[t].Gravity; - break; - case 1: - pGravX = pGravY = 0.0f; - break; - case 2: - pGravD = 0.01f - hypotf((x - XCNTR), (y - YCNTR)); - pGravX = elements[t].Gravity * ((float)(x - XCNTR) / pGravD); - pGravY = elements[t].Gravity * ((float)(y - YCNTR) / pGravD); - break; - } - //Get some gravity from the gravity map - if (t==PT_ANAR) + if (elements[t].Gravity || !(elements[t].Properties & TYPE_SOLID)) { - // perhaps we should have a ptypes variable for this - 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)]; + //Gravity mode by Moach + switch (gravityMode) + { + default: + case 0: + pGravX = 0.0f; + pGravY = elements[t].Gravity; + break; + case 1: + pGravX = pGravY = 0.0f; + break; + case 2: + pGravD = 0.01f - hypotf((x - XCNTR), (y - YCNTR)); + pGravX = elements[t].Gravity * ((float)(x - XCNTR) / pGravD); + pGravY = elements[t].Gravity * ((float)(y - YCNTR) / pGravD); + break; + } + //Get some gravity from the gravity map + if (t==PT_ANAR) + { + // perhaps we should have a ptypes variable for this + 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 if (t != PT_SPNG || !(parts[i].flags&FLAG_MOVABLE)) { |
