From 28f4e6ec12a168ac260ba1143a31af8116eda43d Mon Sep 17 00:00:00 2001 From: Oliver Schinagl Date: Thu, 10 Jan 2008 21:17:24 +0000 Subject: cleanup of (most) all legacy code --- Smoke/fluids.c | 58 ++-------------------------------------------------- Smoke/gtk_main.c | 12 ----------- Smoke/renderer_gl.c | 37 --------------------------------- Smoke/smoke.bin | Bin 656364 -> 652769 bytes 4 files changed, 2 insertions(+), 105 deletions(-) diff --git a/Smoke/fluids.c b/Smoke/fluids.c index 04d28d8..4a23c85 100644 --- a/Smoke/fluids.c +++ b/Smoke/fluids.c @@ -36,8 +36,6 @@ fftw_real *vx, *vy; //(vx,vy) = velocity field at the current mome fftw_real *vx0, *vy0; //(vx0,vy0) = velocity field at the previous moment fftw_real *fx, *fy; //(fx,fy) = user-controlled simulation forces, steered with the mouse fftw_real *rho, *rho0; //smoke density at the current (rho) and previous (rho0) moment -fftw_real *height_array; //used for height plot -struct point *normal_array; //used for normal vectors rfftwnd_plan plan_rc, plan_cr; //simulation domain discretization int winWidth, winHeight; //size of the graphics window, in pixels @@ -70,9 +68,6 @@ void fluids_init_simulation(int n, struct vis_data_arrays *vis_data) plan_rc = rfftw2d_create_plan(n, n, FFTW_REAL_TO_COMPLEX, FFTW_IN_PLACE); plan_cr = rfftw2d_create_plan(n, n, FFTW_COMPLEX_TO_REAL, FFTW_IN_PLACE); - height_array = (fftw_real*) malloc(dim2); - normal_array = (struct point *)malloc(dim *sizeof(struct point)); - for (i = 0; i < HISTORY_SIZE; i++) { vis_data->history_frame[i] = (fftw_real *)malloc(dim1); @@ -253,45 +248,10 @@ struct point vector_normal(struct point vert1, struct point vert2, struct point } -void calculate_normal_vectors(void) -{ - int i, j, idx; - struct point p1, p2, p3; - float px, py; - - fftw_real wn = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width - fftw_real hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height - - for (j = 0; j < DIM; j++) - { - for (i = 0; i < DIM; i++) - { - idx = (j * DIM) + i; - px = wn + (fftw_real)i * wn; - py = hn + (fftw_real)(j + 1) * hn; - - p1.x = px; - p1.y = py; - p1.z = height_array[idx]; - - p2.x = px; - p2.y = py + hn; - p2.z = height_array[idx + DIM]; - - p3.x = px + wn; - p3.y = py; - p3.z = height_array[idx + 1]; - - normal_array[idx] = vector_normal(p2, p1, p3); - normal_array[idx + 1] = vector_normal(p2, p1, p3); - } - } -} - struct point calculate_normal_vector(fftw_real *height, int index, int i, int j) { float px, py; - struct point p1, p2, p3, rv; + struct point p1, p2, p3; fftw_real wn = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width fftw_real hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height @@ -311,19 +271,7 @@ struct point calculate_normal_vector(fftw_real *height, int index, int i, int j) p3.y = py; p3.z = height[index + 1]; - normal_array[index] = vector_normal(p2, p1, p3); - rv = vector_normal(p2, p1, p3); - - return rv; -} - -void calculate_height_plots(void) -{ - int i; - for (i = 0; i < DIM * DIM; i++) - { - height_array[i] = rho[i] * 16; - } + return vector_normal(p2, p1, p3); } fftw_real calculate_height_plot(int dataset, int index) @@ -498,8 +446,6 @@ void fluids_calculate_one_simulation_step(struct vis_data_arrays *vis_data) set_forces(); solve(DIM, vx, vy, vx0, vy0, visc, dt); diffuse_matter(DIM, vx, vy, rho, rho0, dt); - calculate_height_plots(); - calculate_normal_vectors(); fluids_hisdex = (fluids_hisdex >= HISTORY_SIZE -1) ? 0 : fluids_hisdex +1; } diff --git a/Smoke/gtk_main.c b/Smoke/gtk_main.c index f006c62..80519e8 100644 --- a/Smoke/gtk_main.c +++ b/Smoke/gtk_main.c @@ -69,12 +69,6 @@ static gboolean select_normals(GtkWidget *button, gpointer data) { return TRUE; } -static gboolean select_normals2(GtkWidget *button, gpointer data) { - normals_set_render2(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))); - - return TRUE; -} - static gboolean reset_zoom(GtkWidget *button, gpointer data) { renderer_reset_zoom(); @@ -208,12 +202,6 @@ GtkWidget *create_main_page(void) gtk_box_pack_start (GTK_BOX(box), button, TRUE, TRUE, 0); gtk_widget_show(button); - button = gtk_check_button_new_with_label("Draw normal vectors 2"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), normals_get_render2()); - g_signal_connect (G_OBJECT(button), "clicked", G_CALLBACK(select_normals2), NULL); - gtk_box_pack_start (GTK_BOX(box), button, TRUE, TRUE, 0); - gtk_widget_show(button); - button = gtk_button_new_with_label("Reset simulation"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(reset_simulation), NULL); gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0); diff --git a/Smoke/renderer_gl.c b/Smoke/renderer_gl.c index 0476df1..96c99af 100644 --- a/Smoke/renderer_gl.c +++ b/Smoke/renderer_gl.c @@ -233,39 +233,6 @@ static void render_grid(void) glEnd(); } -static void render_normal(void) -{ - int i, j, idx, DIM; - double px, py; - fftw_real wn, hn; - float normal_scale = 16.0f; - - DIM = fluids_get_dim(); - wn = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width - hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height - - glDisable(GL_LIGHTING); - glBegin(GL_LINES); - glColor3f(1.0f, 0.2f, 0.0f); - - for (j = 0; j < DIM - 1; j++) - { - for (i = 0; i < DIM; i++) - { - idx = (j * DIM) + i; - px = wn + (fftw_real)i * wn; - py = hn + (fftw_real)(j + 1) * hn; - - glVertex3f(px, py, height_array[idx]); - glVertex3f(px + normal_array[idx].x * normal_scale, - py + normal_array[idx].y * normal_scale, - height_array[idx] + normal_array[idx].z * normal_scale); - } - } - glEnable(GL_LIGHTING); - glEnd(); -} - static void render_normals(void) { @@ -1007,10 +974,6 @@ void visualize(struct vis_data_arrays *vis_data) } if (normals_get_render()) { - render_normal(); - } - - if (normals_get_render2()) { render_normals(); } diff --git a/Smoke/smoke.bin b/Smoke/smoke.bin index 0c324d9..1e708e4 100755 Binary files a/Smoke/smoke.bin and b/Smoke/smoke.bin differ -- cgit v0.12