diff options
author | Wilrik de Loose <wilrik@wilrik.nl> | 2008-01-03 15:03:55 (GMT) |
---|---|---|
committer | Wilrik de Loose <wilrik@wilrik.nl> | 2008-01-03 15:03:55 (GMT) |
commit | 8addeabeb2498955ebb7b62f810fbf2781bcae59 (patch) | |
tree | 65b770f5f7c86936e7c58b25fd2d6c56ee305986 /Smoke/fluids.c | |
parent | 747c680560744a021f1b99455db33f906970c3fe (diff) | |
download | 2iv35-8addeabeb2498955ebb7b62f810fbf2781bcae59.zip 2iv35-8addeabeb2498955ebb7b62f810fbf2781bcae59.tar.gz 2iv35-8addeabeb2498955ebb7b62f810fbf2781bcae59.tar.bz2 |
betere belichting
Diffstat (limited to 'Smoke/fluids.c')
-rw-r--r-- | Smoke/fluids.c | 87 |
1 files changed, 24 insertions, 63 deletions
diff --git a/Smoke/fluids.c b/Smoke/fluids.c index 2223bde..c3c776a 100644 --- a/Smoke/fluids.c +++ b/Smoke/fluids.c @@ -237,79 +237,40 @@ void vector_normal(struct point vert1, struct point vert2, struct point vert3, s normal->x /= length; normal->y /= length; normal->z /= length; - - if (normal->x == normal->y == normal->z == 0.0f) - { - normal->z = 1.0f; - } } void calculate_normal_vectors(void) { - int i; + 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 + 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 (i = 0; i < DIM * DIM; i++) + for (j = 0; j < DIM; j++) { - switch (vis_dataset) - { - case DATASET_FORCE: - p1.x = fx[i]; - p1.y = fy[i]; - p1.z = height_array[i]; - - p2.x = fx[i + 1]; - p2.y = fy[i + 1]; - p2.z = height_array[i + 1]; - - p3.x = fx[i + DIM]; - p3.y = fy[i + DIM]; - p3.z = height_array[i + DIM]; - break; - - case DATASET_VEL: - p1.x = vx[i]; - p1.y = vy[i]; - p1.z = height_array[i]; - - p3.x = vx[i + 1]; - p3.y = vy[i + 1]; - p3.z = height_array[i + 1]; - - p2.x = vx[i + DIM]; - p2.y = vy[i + DIM]; - p2.z = height_array[i + DIM]; - break; - - case DATASET_RHO: - p1.x = rho[i]; - p1.y = rho[i]; - p1.z = height_array[i]; - - p2.x = rho[i + 1]; - p2.y = rho[i + 1]; - p2.z = height_array[i + 1]; - - p3.x = rho[i + DIM]; - p3.y = rho[i + DIM]; - p3.z = height_array[i + DIM]; - break; - - default: - case DATASET_DIVV: - case DATASET_DIVF: - p1.x = 0.0f; p1.y = 0.0f; p1.z = 0.0f; - p2.x = 0.0f; p2.y = 0.0f; p2.z = 0.0f; - p3.x = 0.0f; p3.y = 0.0f; p3.z = 0.0f; - break; - } - - vector_normal(p1, p2, p3, &normal_array[i]); + 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]; + + vector_normal(p2, p1, p3, &normal_array[idx]); + } } } |