Replace max/min pressure with constants (#870)
This commit is contained in:
parent
b393050e55
commit
510424363b
@ -455,10 +455,10 @@ int luatpt_set_pressure(lua_State* l)
|
||||
width = abs(luaL_optint(l, 3, XRES/CELL));
|
||||
height = abs(luaL_optint(l, 4, YRES/CELL));
|
||||
value = luaL_optnumber(l, 5, 0.0f);
|
||||
if(value > 256.0f)
|
||||
value = 256.0f;
|
||||
else if(value < -256.0f)
|
||||
value = -256.0f;
|
||||
if(value > MAX_PRESSURE)
|
||||
value = MAX_PRESSURE;
|
||||
else if(value < MIN_PRESSURE)
|
||||
value = MIN_PRESSURE;
|
||||
|
||||
if(x1 > (XRES/CELL)-1)
|
||||
x1 = (XRES/CELL)-1;
|
||||
@ -486,10 +486,10 @@ int luatpt_set_gravity(lua_State* l)
|
||||
width = abs(luaL_optint(l, 3, XRES/CELL));
|
||||
height = abs(luaL_optint(l, 4, YRES/CELL));
|
||||
value = luaL_optnumber(l, 5, 0.0f);
|
||||
if(value > 256.0f)
|
||||
value = 256.0f;
|
||||
else if(value < -256.0f)
|
||||
value = -256.0f;
|
||||
if(value > MAX_PRESSURE)
|
||||
value = MAX_PRESSURE;
|
||||
else if(value < MIN_PRESSURE)
|
||||
value = MIN_PRESSURE;
|
||||
|
||||
if(x1 > (XRES/CELL)-1)
|
||||
x1 = (XRES/CELL)-1;
|
||||
|
@ -897,6 +897,8 @@ void LuaScriptInterface::initSimulationAPI()
|
||||
SETCONST(l, R_TEMP);
|
||||
SETCONST(l, MAX_TEMP);
|
||||
SETCONST(l, MIN_TEMP);
|
||||
SETCONSTF(l, MAX_PRESSURE);
|
||||
SETCONSTF(l, MIN_PRESSURE);
|
||||
|
||||
SETCONST(l, TOOL_HEAT);
|
||||
SETCONST(l, TOOL_COOL);
|
||||
@ -1235,10 +1237,10 @@ int LuaScriptInterface::simulation_pressure(lua_State* l)
|
||||
height = lua_tointeger(l, 4);
|
||||
value = (float)lua_tonumber(l, 5);
|
||||
}
|
||||
if(value > 256.0f)
|
||||
value = 256.0f;
|
||||
else if(value < -256.0f)
|
||||
value = -256.0f;
|
||||
if(value > MAX_PRESSURE)
|
||||
value = MAX_PRESSURE;
|
||||
else if(value < MIN_PRESSURE)
|
||||
value = MIN_PRESSURE;
|
||||
|
||||
set_map(x, y, width, height, value, 1);
|
||||
return 0;
|
||||
@ -1309,10 +1311,10 @@ int LuaScriptInterface::simulation_velocityX(lua_State* l)
|
||||
height = lua_tointeger(l, 4);
|
||||
value = (float)lua_tonumber(l, 5);
|
||||
}
|
||||
if(value > 256.0f)
|
||||
value = 256.0f;
|
||||
else if(value < -256.0f)
|
||||
value = -256.0f;
|
||||
if(value > MAX_PRESSURE)
|
||||
value = MAX_PRESSURE;
|
||||
else if(value < MIN_PRESSURE)
|
||||
value = MIN_PRESSURE;
|
||||
|
||||
set_map(x, y, width, height, value, 3);
|
||||
return 0;
|
||||
@ -1346,10 +1348,10 @@ int LuaScriptInterface::simulation_velocityY(lua_State* l)
|
||||
height = lua_tointeger(l, 4);
|
||||
value = (float)lua_tonumber(l, 5);
|
||||
}
|
||||
if(value > 256.0f)
|
||||
value = 256.0f;
|
||||
else if(value < -256.0f)
|
||||
value = -256.0f;
|
||||
if(value > MAX_PRESSURE)
|
||||
value = MAX_PRESSURE;
|
||||
else if(value < MIN_PRESSURE)
|
||||
value = MIN_PRESSURE;
|
||||
|
||||
set_map(x, y, width, height, value, 4);
|
||||
return 0;
|
||||
|
@ -306,12 +306,12 @@ void Air::update_air(void)
|
||||
dy += fvy[y][x];
|
||||
}
|
||||
// pressure/velocity caps
|
||||
if (dp > 256.0f) dp = 256.0f;
|
||||
if (dp < -256.0f) dp = -256.0f;
|
||||
if (dx > 256.0f) dx = 256.0f;
|
||||
if (dx < -256.0f) dx = -256.0f;
|
||||
if (dy > 256.0f) dy = 256.0f;
|
||||
if (dy < -256.0f) dy = -256.0f;
|
||||
if (dp > MAX_PRESSURE) dp = MAX_PRESSURE;
|
||||
if (dp < MIN_PRESSURE) dp = MIN_PRESSURE;
|
||||
if (dx > MAX_PRESSURE) dx = MAX_PRESSURE;
|
||||
if (dx < MIN_PRESSURE) dx = MIN_PRESSURE;
|
||||
if (dy > MAX_PRESSURE) dy = MAX_PRESSURE;
|
||||
if (dy < MIN_PRESSURE) dy = MIN_PRESSURE;
|
||||
|
||||
|
||||
switch (airMode)
|
||||
|
@ -9,6 +9,9 @@
|
||||
#define O_MAX_TEMP 3500
|
||||
#define O_MIN_TEMP -273
|
||||
|
||||
#define MAX_PRESSURE 256.0f
|
||||
#define MIN_PRESSURE -256.0f
|
||||
|
||||
#define TYPE_PART 0x00001 //1 Powders
|
||||
#define TYPE_LIQUID 0x00002 //2 Liquids
|
||||
#define TYPE_SOLID 0x00004 //4 Solids
|
||||
|
@ -3625,8 +3625,8 @@ void Simulation::UpdateParticles(int start, int end)
|
||||
if (aheat_enable && !(elements[t].Properties&PROP_NOAMBHEAT))
|
||||
{
|
||||
#ifdef REALISTIC
|
||||
c_heat = parts[i].temp*96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight) + hv[y/CELL][x/CELL]*100*(pv[y/CELL][x/CELL]+273.15f)/256;
|
||||
float c_Cm = 96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight) + 100*(pv[y/CELL][x/CELL]+273.15f)/256;
|
||||
c_heat = parts[i].temp*96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight) + hv[y/CELL][x/CELL]*100*(pv[y/CELL][x/CELL]-MIN_PRESSURE)/(MAX_PRESSURE-MIN_PRESSURE)*2;
|
||||
float c_Cm = 96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight) + 100*(pv[y/CELL][x/CELL]-MIN_PRESSURE)/(MAX_PRESSURE-MIN_PRESSURE)*2;
|
||||
pt = c_heat/c_Cm;
|
||||
pt = restrict_flt(pt, -MAX_TEMP+MIN_TEMP, MAX_TEMP-MIN_TEMP);
|
||||
parts[i].temp = pt;
|
||||
|
@ -109,7 +109,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
if (j != -1)
|
||||
parts[j].temp = MAX_TEMP;
|
||||
parts[i].temp = MAX_TEMP;
|
||||
sim->pv[y/CELL][x/CELL] = 256;
|
||||
sim->pv[y/CELL][x/CELL] = MAX_PRESSURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
ny = y + ry;
|
||||
while (TYP(r) == PT_FILT)
|
||||
{
|
||||
parts[ID(r)].ctype = 0x10000000 + int(round(photonWl)) + 256;
|
||||
parts[ID(r)].ctype = 0x10000000 + int(round(photonWl) - MIN_PRESSURE);
|
||||
nx += rx;
|
||||
ny += ry;
|
||||
if (nx < 0 || ny < 0 || nx >= XRES || ny >= YRES)
|
||||
|
@ -60,10 +60,10 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parts[i].temp >= 256.0f+273.15f)
|
||||
parts[i].temp = 256.0f+273.15f;
|
||||
if (parts[i].temp <= -256.0f+273.15f)
|
||||
parts[i].temp = -256.0f+273.15f;
|
||||
if (parts[i].temp >= MAX_PRESSURE+273.15f)
|
||||
parts[i].temp = MAX_PRESSURE+273.15f;
|
||||
if (parts[i].temp <= MIN_PRESSURE+273.15f)
|
||||
parts[i].temp = MIN_PRESSURE+273.15f;
|
||||
|
||||
for (rx = -1; rx <= 1; rx++)
|
||||
for (ry = -1; ry <= 1; ry++)
|
||||
@ -79,9 +79,9 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
if (TYP(r) == PT_FILT)
|
||||
{
|
||||
int newPressure = parts[ID(r)].ctype - 0x10000000;
|
||||
if (newPressure >= 0 && newPressure <= 512)
|
||||
if (newPressure >= 0 && newPressure <= MAX_PRESSURE - MIN_PRESSURE)
|
||||
{
|
||||
sim->pv[(y + ry) / CELL][(x + rx) / CELL] = float(newPressure - 256);
|
||||
sim->pv[(y + ry) / CELL][(x + rx) / CELL] = float(newPressure) + MIN_PRESSURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX,
|
||||
{
|
||||
sim->air->pv[y/CELL][x/CELL] += strength*0.05f;
|
||||
|
||||
if (sim->air->pv[y/CELL][x/CELL] > 256.0f)
|
||||
sim->air->pv[y/CELL][x/CELL] = 256.0f;
|
||||
else if (sim->air->pv[y/CELL][x/CELL] < -256.0f)
|
||||
sim->air->pv[y/CELL][x/CELL] = -256.0f;
|
||||
if (sim->air->pv[y/CELL][x/CELL] > MAX_PRESSURE)
|
||||
sim->air->pv[y/CELL][x/CELL] = MAX_PRESSURE;
|
||||
else if (sim->air->pv[y/CELL][x/CELL] < MIN_PRESSURE)
|
||||
sim->air->pv[y/CELL][x/CELL] = MIN_PRESSURE;
|
||||
return 1;
|
||||
}
|
||||
|
@ -37,14 +37,14 @@ static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX,
|
||||
*vy -= (strength / 16) * dvx*invsqr;
|
||||
|
||||
// Clamp velocities
|
||||
if (*vx > 256.0f)
|
||||
*vx = 256.0f;
|
||||
else if (*vx < -256.0f)
|
||||
*vx = -256.0f;
|
||||
if (*vy > 256.0f)
|
||||
*vy = 256.0f;
|
||||
else if (*vy < -256.0f)
|
||||
*vy = -256.0f;
|
||||
if (*vx > MAX_PRESSURE)
|
||||
*vx = MAX_PRESSURE;
|
||||
else if (*vx < MIN_PRESSURE)
|
||||
*vx = MIN_PRESSURE;
|
||||
if (*vy > MAX_PRESSURE)
|
||||
*vy = MAX_PRESSURE;
|
||||
else if (*vy < MIN_PRESSURE)
|
||||
*vy = MIN_PRESSURE;
|
||||
|
||||
}
|
||||
|
||||
|
@ -16,9 +16,9 @@ static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX,
|
||||
{
|
||||
sim->air->pv[y/CELL][x/CELL] -= strength*0.05f;
|
||||
|
||||
if (sim->air->pv[y/CELL][x/CELL] > 256.0f)
|
||||
sim->air->pv[y/CELL][x/CELL] = 256.0f;
|
||||
else if (sim->air->pv[y/CELL][x/CELL] < -256.0f)
|
||||
sim->air->pv[y/CELL][x/CELL] = -256.0f;
|
||||
if (sim->air->pv[y/CELL][x/CELL] > MAX_PRESSURE)
|
||||
sim->air->pv[y/CELL][x/CELL] = MAX_PRESSURE;
|
||||
else if (sim->air->pv[y/CELL][x/CELL] < MIN_PRESSURE)
|
||||
sim->air->pv[y/CELL][x/CELL] = MIN_PRESSURE;
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user