Update.
[flatland.git] / flatland.cc
index 92a5ebb..abfc644 100644 (file)
@@ -222,22 +222,22 @@ extern "C" void fl_generate_sequences(int nb_sequences,
             scalar_t xf = grabbed_polygon->absolute_x(grab_relative_x, grab_relative_y);
             scalar_t yf = grabbed_polygon->absolute_y(grab_relative_x, grab_relative_y);
             grabbed_polygon->apply_force(dt, xf, yf, 0.0, -1.0);
-            universe->update(dt);
+            universe->update(dt, 1.0 / scaling);
           }
         }
       }
 
       for(int t = 0; t < nb_images_per_sequence; t++) {
-        memcpy(output + (n * nb_images_per_sequence + t) * 3 * width * height,
-               canvases[t]->_data,
-               3 * width * height);
+        unsigned char *src = canvases[t]->_data;
+        unsigned char *dst = output + (n * nb_images_per_sequence + t) * width * height * 3;
+        for(int d = 0; d < 3; d++) {
+          for(int y = 0; y < height; y++) {
+            for(int x = 0; x < width; x++) {
+              dst[x + width * (y + height * d)] = src[d + 4 * (x + width * y)];
+            }
+          }
+        }
       }
-
-      // char buffer[1024];
-      // sprintf(buffer, "%s/%03d/dyn_%06d.png", data_dir, n / 1000, n);
-      // FILE *file = safe_fopen(buffer, "w");
-      // main_canvas.write_png(file);
-      // fclose(file);
     }
 
     for(int t = 0; t < 2 * nb_saved_frames; t++) {