Skip to content

Commit

Permalink
Merge pull request firemodels#2180 from gforney/master
Browse files Browse the repository at this point in the history
remove alpha_factor code, fix to alpha correction code when skipping smoke planes
  • Loading branch information
gforney authored Jan 31, 2025
2 parents 5b8f50b + 4cf16a7 commit 251aa1f
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 17 deletions.
1 change: 0 additions & 1 deletion Source/shared/shared_structures.h
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,6 @@ typedef struct _smoke3ddata {
unsigned char *alphas_dir[6];
int fire_alpha, co2_alpha;
float fire_alphas[256], co2_alphas[256];
float alpha_factor;
int *timeslist;
int ntimes, ntimes_old, ismoke3d_time, lastiframe, ntimes_full;
int nchars_uncompressed;
Expand Down
14 changes: 6 additions & 8 deletions Source/smokeview/IOsmoke.c
Original file line number Diff line number Diff line change
Expand Up @@ -1521,30 +1521,30 @@ void DrawSmoke3DGPU(smoke3ddata *smoke3di){

/* ------------------ InitAlphas ------------------------ */

void InitAlphas(unsigned char *alphanew, float base_extinct, float alpha_factor, float new_extinct, float base_dx, float new_dx){
void InitAlphas(unsigned char *alphanew, float base_extinct, float new_extinct, float base_dx, float new_dx){
int i;

if(base_extinct<=0.01){
base_extinct = 1.0;
new_extinct = 1.0;
}
if(alpha_factor <= 0.01){
alpha_factor = 0.01;
}
alphanew[0] = 0;
if(force_alpha_opaque==1){
for(i = 1; i<255; i++){
alphanew[i] = (unsigned char)254;
}
}
else{
if(smokeskipm1 != 0){
base_dx /= (float)(smokeskipm1 + 1);
}
for(i = 1; i<255; i++){
float val;
int ival;

val = -log(1.0-(float)i/254.0)/(base_extinct*base_dx);
val = 254.0*(1.0-exp(-val*new_extinct*new_dx))+0.5;
ival = CLAMP(val/alpha_factor, 0, 254);
ival = CLAMP(val, 0, 254);
alphanew[i] = (unsigned char)ival;
}
}
Expand Down Expand Up @@ -1573,9 +1573,7 @@ void UpdateSmokeAlphas(void){
dists[ALPHA_YZ] = smoke_mesh->dyzDdx*dx;
dists[ALPHA_XZ] = smoke_mesh->dxzDdx*dx;
for(j=0;j<6;j++){
InitAlphas(smoke3di->alphas_dir[j],
smoke3di->extinct, smoke3di->alpha_factor, glui_smoke3d_extinct,
smoke_mesh->dxyz_orig[0], dists[j]);
InitAlphas(smoke3di->alphas_dir[j], smoke3di->extinct, glui_smoke3d_extinct, smoke_mesh->dxyz_orig[0], dists[j]);
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion Source/smokeview/glui_smoke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ extern "C" void GLUI3dSmokeSetup(int main_window){
#endif

PANEL_display = glui_3dsmoke->add_panel_to_panel(ROLLOUT_slices, "smoke slice display");
RADIO_skipframes = glui_3dsmoke->add_radiogroup_to_panel(PANEL_display,&smokeskipm1);
RADIO_skipframes = glui_3dsmoke->add_radiogroup_to_panel(PANEL_display,&smokeskipm1, SMOKE_SKIP, GLUISmoke3dCB);
glui_3dsmoke->add_radiobutton_to_group(RADIO_skipframes,_("All"));
glui_3dsmoke->add_radiobutton_to_group(RADIO_skipframes,_("Every 2nd"));
glui_3dsmoke->add_radiobutton_to_group(RADIO_skipframes,_("Every 3rd"));
Expand Down Expand Up @@ -1264,6 +1264,9 @@ extern "C" void GLUISmoke3dCB(int var){
UpdateSmokeColormap(smoke_render_option);
IdleCB();
break;
case SMOKE_SKIP:
global_scase.update_smoke_alphas = 1;
break;
case SMOKE_EXTINCT:
global_scase.update_smoke_alphas = 1;
glui_smoke3d_extinct = MAX(glui_smoke3d_extinct, 0.0);
Expand Down
7 changes: 4 additions & 3 deletions Source/smokeview/glui_smoke.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
#define SMOKE_SKIP_Z 111
#define SMOKE_BLACK 75
#ifdef pp_SMOKE16
#define SMOKE_LOAD16 101
#define SMOKE_SHOW16 102
#define SMOKE_SHOW8 103
#define SMOKE_LOAD16 112
#define SMOKE_SHOW16 113
#define SMOKE_SHOW8 114
#endif
#define SMOKE_DELTA_PAR 76
#define SMOKE_NEW 77
Expand All @@ -87,6 +87,7 @@
#define VOLTEST_UPDATE 103
#define FORCE_ALPHA_OPAQUE 104
#define MERGE_SMOKE 105
#define SMOKE_SKIP 106

//*** glui_smoke.cpp headers

Expand Down
3 changes: 3 additions & 0 deletions Source/smokeview/menus.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include "IOscript.h"
#include "viewports.h"
#include "colorbars.h"
#ifdef pp_SMOKE16
#include "glui_smoke.h"
#endif

void LoadHVACMenu(int value);
void LoadPlot2DMenu(int value);
Expand Down
1 change: 0 additions & 1 deletion Source/smokeview/readsmv.c
Original file line number Diff line number Diff line change
Expand Up @@ -5603,7 +5603,6 @@ int ParseSMOKE3DProcess(smv_case *scase, bufferstreamdata *stream, char *buffer,
#ifndef pp_SMOKEFRAME
smoke3di->smoke_comp_all = NULL;
#endif
smoke3di->alpha_factor = alpha_factor;
smoke3di->smokeview_tmp = NULL;
smoke3di->times = NULL;
smoke3di->times_map = NULL;
Expand Down
2 changes: 1 addition & 1 deletion Source/smokeview/smokeheaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ EXTERNCPP void DrawVolSmokeFrame(void);
EXTERNCPP void GetSmoke3DTimeSteps(int fortran_skip, char *smokefile, int version, int *ntimes_found, int *ntimes_full);
EXTERNCPP int GetSmokeNFrames(int type, float *tmin, float *tmax);
EXTERNCPP void InitAlphas(unsigned char *alphanew,
float base_extinct, float alpha_factor, float new_extinct,
float base_extinct, float new_extinct,
float base_dx, float new_dx);
EXTERNCPP int IsSmokeComponentPresent(smoke3ddata *smoke3di);
EXTERNCPP void MakeIBlankSmoke3D(void);
Expand Down
3 changes: 1 addition & 2 deletions Source/smokeview/viewports.c
Original file line number Diff line number Diff line change
Expand Up @@ -1994,8 +1994,7 @@ void GetSmokeDir(float *mm){
else{
smoke_dist = meshj->smoke_dist[minalphadir];
}
InitAlphas(soot->alphas_dir[minalphadir], soot->extinct, soot->alpha_factor, glui_smoke3d_extinct,
meshj->dxyz_orig[0], smoke_dist);
InitAlphas(soot->alphas_dir[minalphadir], soot->extinct, glui_smoke3d_extinct, meshj->dxyz_orig[0], smoke_dist);
}
if(demo_mode != 0){
meshj->smokedir = 1;
Expand Down

0 comments on commit 251aa1f

Please sign in to comment.