diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-18 20:18:37 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-18 20:18:37 (GMT) |
| commit | b40f13b66a8661d8698e5fc737c2842dfb73e6f9 (patch) | |
| tree | 1e9fb258cd8bcbba92c14b0ccef4bf6acfd3712a /src/simulation | |
| parent | ff7428fc70385287204832048bcf2f3c72aaabe8 (diff) | |
| download | powder-b40f13b66a8661d8698e5fc737c2842dfb73e6f9.zip powder-b40f13b66a8661d8698e5fc737c2842dfb73e6f9.tar.gz | |
TPT: Added gel - a liquid with variable heat conductivity and viscosity. 8523da398f
Diffstat (limited to 'src/simulation')
| -rw-r--r-- | src/simulation/ElementFunctions.h | 2 | ||||
| -rw-r--r-- | src/simulation/Elements.h | 1 | ||||
| -rw-r--r-- | src/simulation/Simulation.cpp | 34 | ||||
| -rw-r--r-- | src/simulation/SimulationData.cpp | 6 |
4 files changed, 29 insertions, 14 deletions
diff --git a/src/simulation/ElementFunctions.h b/src/simulation/ElementFunctions.h index ad597b7..7f86424 100644 --- a/src/simulation/ElementFunctions.h +++ b/src/simulation/ElementFunctions.h @@ -108,6 +108,7 @@ int update_MISC(UPDATE_FUNC_ARGS); int update_FRAY(UPDATE_FUNC_ARGS); int update_REPL(UPDATE_FUNC_ARGS); int update_NBLE(UPDATE_FUNC_ARGS); +int update_GEL(UPDATE_FUNC_ARGS); int update_legacy_PYRO(UPDATE_FUNC_ARGS); int update_legacy_all(UPDATE_FUNC_ARGS); int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS); @@ -166,6 +167,7 @@ int graphics_ELEC(GRAPHICS_FUNC_ARGS); int graphics_WIRE(GRAPHICS_FUNC_ARGS); int graphics_ACEL(GRAPHICS_FUNC_ARGS); int graphics_DCEL(GRAPHICS_FUNC_ARGS); +int graphics_GEL(GRAPHICS_FUNC_ARGS); int graphics_DEFAULT(GRAPHICS_FUNC_ARGS); #endif /* ELEMENTFUNCTIONS_H_ */ diff --git a/src/simulation/Elements.h b/src/simulation/Elements.h index 7d59dcb..6a62c11 100644 --- a/src/simulation/Elements.h +++ b/src/simulation/Elements.h @@ -262,6 +262,7 @@ #define PT_BANG 139 #define PT_IGNT 140 #define PT_BOYL 141 +#define PT_GEL 142 #define OLD_PT_WIND 147 #define PT_H2 148 diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index fdc94ab..b08398f 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -1175,7 +1175,7 @@ void Simulation::init_can_move() for (rt=1;rt<PT_NUM;rt++) { // weight check, also prevents particles of same type displacing each other - if (ptypes[t].weight <= ptypes[rt].weight) can_move[t][rt] = 0; + if (ptypes[t].weight <= ptypes[rt].weight || rt==PT_GEL) can_move[t][rt] = 0; if (t==PT_NEUT && (ptypes[rt].properties&PROP_NEUTPASS)) can_move[t][rt] = 2; if (t==PT_NEUT && (ptypes[rt].properties&PROP_NEUTABSORB)) @@ -2598,9 +2598,13 @@ void Simulation::update_particles_i(int start, int inc) } } + float gel_scale = 1.0f; + if (t==PT_GEL) + gel_scale = parts[i].tmp*2.55f; + if (!legacy_enable) { - if (y-2 >= 0 && y-2 < YRES && (ptypes[t].properties&TYPE_LIQUID)) {//some heat convection for liquids + if (y-2 >= 0 && y-2 < YRES && (ptypes[t].properties&TYPE_LIQUID) && gel_scale>(rand()%250)) {//some heat convection for liquids r = pmap[y-2][x]; if (!(!r || parts[i].type != (r&0xFF))) { if (parts[i].temp>parts[r>>8].temp) { @@ -2614,19 +2618,19 @@ void Simulation::update_particles_i(int start, int inc) //heat transfer code h_count = 0; #ifdef REALISTIC - if (t&&(t!=PT_HSWC||parts[i].life==10)&&ptypes[t].hconduct) + if (t&&(t!=PT_HSWC||parts[i].life==10)&&(ptypes[t].hconduct*gel_scale)) { float c_Cm = 0.0f; #else - if (t&&(t!=PT_HSWC||parts[i].life==10)&&ptypes[t].hconduct>(rand()%250)) + if (t&&(t!=PT_HSWC||parts[i].life==10)&&(ptypes[t].hconduct*gel_scale)>(rand()%250)) { float c_Cm = 0.0f; #endif if (aheat_enable) { #ifdef REALISTIC - c_heat = parts[i].temp*96.645/ptypes[t].hconduct*fabs(ptypes[t].weight) + hv[y/CELL][x/CELL]*100*(pv[y/CELL][x/CELL]+273.15f)/256; - c_Cm = 96.645/ptypes[t].hconduct*fabs(ptypes[t].weight) + 100*(pv[y/CELL][x/CELL]+273.15f)/256; + c_heat = parts[i].temp*96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight) + hv[y/CELL][x/CELL]*100*(pv[y/CELL][x/CELL]+273.15f)/256; + c_Cm = 96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight) + 100*(pv[y/CELL][x/CELL]+273.15f)/256; pt = c_heat/c_Cm; pt = restrict_flt(pt, -MAX_TEMP+MIN_TEMP, MAX_TEMP-MIN_TEMP); parts[i].temp = pt; @@ -2655,8 +2659,12 @@ void Simulation::update_particles_i(int start, int inc) { surround_hconduct[j] = r>>8; #ifdef REALISTIC - c_heat += parts[r>>8].temp*96.645/ptypes[rt].hconduct*fabs(ptypes[rt].weight); - c_Cm += 96.645/ptypes[rt].hconduct*fabs(ptypes[rt].weight); + if (rt==PT_GEL) + gel_scale = parts[r>>8].tmp*2.55f; + else gel_scale = 1.0f; + + c_heat += parts[r>>8].temp*96.645/ptypes[rt].hconduct*gel_scale*fabs(ptypes[rt].weight); + c_Cm += 96.645/ptypes[rt].hconduct*gel_scale*fabs(ptypes[rt].weight); #else c_heat += parts[r>>8].temp; #endif @@ -2664,13 +2672,17 @@ void Simulation::update_particles_i(int start, int inc) } } #ifdef REALISTIC + if (t==PT_GEL) + gel_scale = parts[i].tmp*2.55f; + else gel_scale = 1.0f; + if (t == PT_PHOT) pt = (c_heat+parts[i].temp*96.645)/(c_Cm+96.645); else - pt = (c_heat+parts[i].temp*96.645/ptypes[t].hconduct*fabs(ptypes[t].weight))/(c_Cm+96.645/ptypes[t].hconduct*fabs(ptypes[t].weight)); + pt = (c_heat+parts[i].temp*96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight))/(c_Cm+96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight)); - c_heat += parts[i].temp*96.645/ptypes[t].hconduct*fabs(ptypes[t].weight); - c_Cm += 96.645/ptypes[t].hconduct*fabs(ptypes[t].weight); + c_heat += parts[i].temp*96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight); + c_Cm += 96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight); parts[i].temp = restrict_flt(pt, MIN_TEMP, MAX_TEMP); #else pt = (c_heat+parts[i].temp)/(h_count+1); diff --git a/src/simulation/SimulationData.cpp b/src/simulation/SimulationData.cpp index 48dfb7c..46f3ee6 100644 --- a/src/simulation/SimulationData.cpp +++ b/src/simulation/SimulationData.cpp @@ -331,7 +331,7 @@ part_type * LoadElements(int & elementCount) {"TNT", PIXPACK(0xC05050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Explosive.", ST_SOLID, TYPE_SOLID | PROP_NEUTPENETRATE, &update_BANG, NULL}, {"IGNC", PIXPACK(0xC0B050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Ignition cord.", ST_SOLID, TYPE_SOLID | PROP_NEUTPENETRATE | PROP_SPARKSETTLE | PROP_LIFE_KILL, &update_IGNT, NULL}, {"BOYL", PIXPACK(0x0A3200), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.18f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 42, "Boyle, variable pressure gas. Expands when heated.", ST_GAS, TYPE_GAS, &update_BOYL, NULL}, - /*FREE*/{"LOTE", PIXPACK(0xFF0000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Behaves kinda like Living on the Edge S3458/B37/4", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, + {"GEL", PIXPACK(0xFF9900), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 1, 35, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Gel. A liquid with variable viscosity and heat conductivity", ST_LIQUID, TYPE_LIQUID|PROP_LIFE_DEC|PROP_NEUTPENETRATE, &update_GEL, &graphics_GEL}, /*FREE*/{"FRG2", PIXPACK(0x00FF00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Like Frogs rule S124/B3/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, /*FREE*/{"STAR", PIXPACK(0x0000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Like Star Wars rule S3456/B278/6", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, /*FREE*/{"FROG", PIXPACK(0x00AA00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Frogs S12/B34/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, @@ -504,7 +504,7 @@ unsigned int * LoadLatent(int & elementCount) /* TNT */ 0, /* IGNP */ 0, /* BOYL */ 0, - /* FREE */ 0, + /* GEL */ 0, /* FREE */ 0, /* FREE */ 0, /* FREE */ 0, @@ -685,7 +685,7 @@ part_transition * LoadTransitions(int & transitionCount) /* TNT */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /* IGNP */ {IPL, NT, IPH, NT, ITL, NT, 673.0f, PT_FIRE}, /* BOYL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, - /*FREE*//* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GEL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /*FREE*//* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /*FREE*//* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /*FREE*//* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, |
