diff --git a/includes/air.h b/includes/air.h index d9e04f631..eda397640 100644 --- a/includes/air.h +++ b/includes/air.h @@ -2,6 +2,11 @@ #define AIR_H #include "defines.h" +extern float ogravmap[YRES/CELL][XRES/CELL]; +extern float gravmap[YRES/CELL][XRES/CELL]; +extern float gravx[YRES/CELL][XRES/CELL]; +extern float gravy[YRES/CELL][XRES/CELL]; + extern float vx[YRES/CELL][XRES/CELL], ovx[YRES/CELL][XRES/CELL]; extern float vy[YRES/CELL][XRES/CELL], ovy[YRES/CELL][XRES/CELL]; extern float pv[YRES/CELL][XRES/CELL], opv[YRES/CELL][XRES/CELL]; @@ -16,6 +21,8 @@ extern float kernel[9]; void make_kernel(void); +void update_grav(void); + void update_air(void); #endif \ No newline at end of file diff --git a/includes/graphics.h b/includes/graphics.h index 31f8c57d4..f17e3f3d3 100644 --- a/includes/graphics.h +++ b/includes/graphics.h @@ -100,6 +100,8 @@ void draw_icon(pixel *vid_buf, int x, int y, char ch, int flag); void draw_air(pixel *vid); +void draw_grav(pixel *vid); + void draw_line(pixel *vid, int x1, int y1, int x2, int y2, int r, int g, int b, int a); void addpixel(pixel *vid, int x, int y, int r, int g, int b, int a); diff --git a/src/air.c b/src/air.c index 8c11f30a9..2947d935c 100644 --- a/src/air.c +++ b/src/air.c @@ -4,6 +4,11 @@ #include float kernel[9]; +float ogravmap[YRES/CELL][XRES/CELL]; +float gravmap[YRES/CELL][XRES/CELL]; +float gravx[YRES/CELL][XRES/CELL]; +float gravy[YRES/CELL][XRES/CELL]; + float vx[YRES/CELL][XRES/CELL], ovx[YRES/CELL][XRES/CELL]; float vy[YRES/CELL][XRES/CELL], ovy[YRES/CELL][XRES/CELL]; float pv[YRES/CELL][XRES/CELL], opv[YRES/CELL][XRES/CELL]; @@ -29,6 +34,48 @@ void make_kernel(void) //used for velocity for (i=-1; i<2; i++) kernel[(i+1)+3*(j+1)] *= s; } +void update_grav(void) +{ + int x, y, i, j, changed = 0; + //Find any changed cells + for (i=0; i0.0f) //Only calculate with populated or changed cells. + for (y=0; y1180) bsx = 1180; if (bsx<0) @@ -2881,6 +2882,7 @@ int main(int argc, char *argv[]) bsy = 0; update_particles(vid_buf); //update everything + update_grav(); draw_parts(vid_buf); //draw particles if (cmode==CM_PERS) @@ -3577,7 +3579,7 @@ int main(int argc, char *argv[]) sprintf(heattext, "Empty, Pressure: %3.2f", pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL]); if (DEBUG_MODE) { - sprintf(coordtext, "X:%d Y:%d", x/sdl_scale, y/sdl_scale); + sprintf(coordtext, "X:%d Y:%d. GX: %.2f GY: %.2f", x/sdl_scale, y/sdl_scale, gravx[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], gravy[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL]); } } } diff --git a/src/powder.c b/src/powder.c index 7dd1ad8aa..e697f2444 100644 --- a/src/powder.c +++ b/src/powder.c @@ -1463,6 +1463,12 @@ void update_particles_i(pixel *vid, int start, int inc) pGravX = ptypes[t].gravity * ((float)(x - XCNTR) / pGravD); pGravY = ptypes[t].gravity * ((float)(y - YCNTR) / pGravD); } + //Get some gravity from the gravity map + if(!(ptypes[t].properties & TYPE_SOLID)) + { + pGravX += gravx[y/CELL][x/CELL]; + pGravY += gravy[y/CELL][x/CELL]; + } //velocity updates for the particle parts[i].vx *= ptypes[t].loss; parts[i].vy *= ptypes[t].loss;