Slight speed improvement for liquids and powders
This commit is contained in:
parent
7543a3d05e
commit
ddaed2ad69
64
src/powder.c
64
src/powder.c
@ -1935,38 +1935,48 @@ killed:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
s = 1;
|
||||||
r = (rand()%2)*2-1;
|
r = (rand()%2)*2-1;
|
||||||
if (fin_y!=clear_y && try_move(i, x, y, clear_x+r, fin_y))
|
if (clear_x!=x || clear_y!=y || nt || surround_space)
|
||||||
{
|
{
|
||||||
parts[i].x = clear_xf+r;
|
// allow diagonal movement if target position is blocked
|
||||||
parts[i].y = fin_yf;
|
// but no point trying this if particle is stuck in a block of identical particles
|
||||||
parts[i].vx *= ptypes[t].collision;
|
if (fin_y!=clear_y && try_move(i, x, y, clear_x+r, fin_y))
|
||||||
parts[i].vy *= ptypes[t].collision;
|
{
|
||||||
|
parts[i].x = clear_xf+r;
|
||||||
|
parts[i].y = fin_yf;
|
||||||
|
parts[i].vx *= ptypes[t].collision;
|
||||||
|
parts[i].vy *= ptypes[t].collision;
|
||||||
|
}
|
||||||
|
else if (fin_y!=clear_y && try_move(i, x, y, clear_x-r, fin_y))
|
||||||
|
{
|
||||||
|
parts[i].x = clear_xf-r;
|
||||||
|
parts[i].y = fin_yf;
|
||||||
|
parts[i].vx *= ptypes[t].collision;
|
||||||
|
parts[i].vy *= ptypes[t].collision;
|
||||||
|
}
|
||||||
|
else if (fin_x!=clear_x && try_move(i, x, y, fin_x, clear_y+r))
|
||||||
|
{
|
||||||
|
parts[i].x = fin_xf;
|
||||||
|
parts[i].y = clear_yf+r;
|
||||||
|
parts[i].vx *= ptypes[t].collision;
|
||||||
|
parts[i].vy *= ptypes[t].collision;
|
||||||
|
}
|
||||||
|
else if (fin_x!=clear_x && try_move(i, x, y, fin_x, clear_y-r))
|
||||||
|
{
|
||||||
|
parts[i].x = fin_xf;
|
||||||
|
parts[i].y = clear_yf-r;
|
||||||
|
parts[i].vx *= ptypes[t].collision;
|
||||||
|
parts[i].vy *= ptypes[t].collision;
|
||||||
|
}
|
||||||
|
else s = 0;
|
||||||
}
|
}
|
||||||
else if (fin_y!=clear_y && try_move(i, x, y, clear_x-r, fin_y))
|
else s = 0;
|
||||||
{
|
// s==0 means particle has not yet moved, allow liquids code to run
|
||||||
parts[i].x = clear_xf-r;
|
if (s==0 && ptypes[t].falldown>1 && (parts[i].vy>fabs(parts[i].vx) || gravityMode==2))
|
||||||
parts[i].y = fin_yf;
|
|
||||||
parts[i].vx *= ptypes[t].collision;
|
|
||||||
parts[i].vy *= ptypes[t].collision;
|
|
||||||
}
|
|
||||||
else if (fin_x!=clear_x && try_move(i, x, y, fin_x, clear_y+r))
|
|
||||||
{
|
|
||||||
parts[i].x = fin_xf;
|
|
||||||
parts[i].y = clear_yf+r;
|
|
||||||
parts[i].vx *= ptypes[t].collision;
|
|
||||||
parts[i].vy *= ptypes[t].collision;
|
|
||||||
}
|
|
||||||
else if (fin_x!=clear_x && try_move(i, x, y, fin_x, clear_y-r))
|
|
||||||
{
|
|
||||||
parts[i].x = fin_xf;
|
|
||||||
parts[i].y = clear_yf-r;
|
|
||||||
parts[i].vx *= ptypes[t].collision;
|
|
||||||
parts[i].vy *= ptypes[t].collision;
|
|
||||||
}
|
|
||||||
else if (ptypes[t].falldown>1 && (parts[i].vy>fabs(parts[i].vx) || gravityMode==2))
|
|
||||||
{
|
{
|
||||||
s = 0;
|
s = 0;
|
||||||
|
// rt is true if FLAG_STAGNANT was set for this particle in previous frame
|
||||||
if (!rt || nt) //nt is if there is an something else besides the current particle type, around the particle
|
if (!rt || nt) //nt is if there is an something else besides the current particle type, around the particle
|
||||||
rt = 30;//slight less water lag, although it changes how it moves a lot
|
rt = 30;//slight less water lag, although it changes how it moves a lot
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user