diff options
author | Oliver Schinagl <oliver@schinagl.nl> | 2008-01-09 16:22:34 (GMT) |
---|---|---|
committer | Oliver Schinagl <oliver@schinagl.nl> | 2008-01-09 16:22:34 (GMT) |
commit | 4b45e834c8a243d299f7b09960dc43db58cb7910 (patch) | |
tree | 81f58e6af8c70b1695ff374d085cacd15edd0d13 /Smoke/fluids.c | |
parent | 19104903490d2c67f9b385804a7f89df8f6fc48c (diff) | |
download | 2iv35-4b45e834c8a243d299f7b09960dc43db58cb7910.zip 2iv35-4b45e834c8a243d299f7b09960dc43db58cb7910.tar.gz 2iv35-4b45e834c8a243d299f7b09960dc43db58cb7910.tar.bz2 |
fix frame history!
Diffstat (limited to 'Smoke/fluids.c')
-rw-r--r-- | Smoke/fluids.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/Smoke/fluids.c b/Smoke/fluids.c index 2ab0e81..2a59ef1 100644 --- a/Smoke/fluids.c +++ b/Smoke/fluids.c @@ -77,11 +77,10 @@ void fluids_init_simulation(int n, struct vis_data_arrays *vis_data) height_array = (fftw_real*) malloc(dim2); normal_array = (struct point*) malloc(dim2); - frame_hist = (fftw_real*) malloc(dim2 * n); - for (i = 0; i <= n; i++) + for (i = 0; i < HISTORY_SIZE; i++) { - frame_hist[i] = (fftw_real*) malloc(dim1); + vis_data->history[i] = (fftw_real*)malloc(dim1); } fluids_reset_simulation(); @@ -398,14 +397,36 @@ fftw_real *get_frame(struct vis_data_arrays *vis_data, int dataset) return_value = vis_data->div_force; break; case DATASET_HIST: - return_value = vis_data->history[0]; +// return_value = vis_data->history; + break; } return return_value; } -void populate_arrays(struct vis_data_arrays *vis_data) +void add_history_frame(int dataset, struct vis_data_arrays *vis_data) +{ + static int hisdex = 0; + fftw_real *frame; + + + if (dataset != DATASET_HIST) { + frame = get_frame(vis_data, dataset); +// printf("hisdex: %d\n", hisdex); + + // if (hisdex) { + memcpy(vis_data->history[hisdex], frame, DIM * 2 * (DIM / 2) * sizeof(fftw_real)); + // } else { + // memcpy(vis_data->history[0], frame, DIM * 2 * (DIM / 2) * sizeof(fftw_real)); + // memcpy(vis_data->history[hisdex], vis_data->history[0], DIM * 2 * (DIM / 2) * sizeof(fftw_real)); + // } + hisdex = (hisdex >= HISTORY_SIZE -1) ? 0 : hisdex +1; + } +} + + +void setup_arrays(struct vis_data_arrays *vis_data) { int idx, i, j; float scale_min, scale_max; @@ -441,7 +462,6 @@ void populate_arrays(struct vis_data_arrays *vis_data) // } - get_frame(vis_data, streamlines_get_dataset()); if (colormap_get_autoscaling()) { if (scale_min > frame[idx]) { colormap_set_scale_min(frame[idx]); } @@ -469,8 +489,9 @@ void fluids_calculate_one_simulation_step(struct vis_data_arrays *vis_data) diffuse_matter(DIM, vx, vy, rho, rho0, dt); calculate_height_plots(); calculate_normal_vectors(); + add_history_frame(streamlines_get_dataset(), vis_data); } - populate_arrays(vis_data); + setup_arrays(vis_data); dataset = smoke_get_dataset(); frame = get_frame(vis_data, dataset); @@ -482,7 +503,7 @@ void fluids_calculate_one_simulation_step(struct vis_data_arrays *vis_data) heightplots_set_frame(vis_data->height); normals_set_frame(vis_data->normals); -// streamlines_set_frame(vis_data->history); + streamlines_set_history(vis_data->history); } //------ VISUALIZATION CODE STARTS HERE ----------------------------------------------------------------- |