Update.
[flatland.git] / sequence_generator.cc
index bfba036..cd4d313 100644 (file)
@@ -108,6 +108,9 @@ extern "C" void fl_generate_sequence(int nb_images,
     canvases[s] = new CanvasCairo(scaling, universe->width(), universe->height());
   }
 
+  scalar_t gravity_fx = 0.0;
+  scalar_t gravity_fy = 1.0;
+
   scalar_t grab_start_x, grab_start_y;
 
   int failed;
@@ -214,9 +217,12 @@ extern "C" void fl_generate_sequence(int nb_images,
       }
 
       if(s < nb_simulated_frames - 1) {
+
         // Run the simulation
+
         for(int i = 0; i < nb_iterations_per_steps; i++) {
           if(pulling) {
+            // Pulling the grabbed rectangle
             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);
             if (xf < 0 || xf >= world_width || yf < 0 || yf >= world_height) {
@@ -225,7 +231,9 @@ extern "C" void fl_generate_sequence(int nb_images,
             grabbed_polygon->apply_force(dt, xf, yf, 0.0, -1.0);
           } else {
             // Gravity
+            universe->apply_gravity(dt, gravity_fx, gravity_fy);
           }
+
           universe->update(dt, 1.0 / scaling);
         }
       }
@@ -234,7 +242,9 @@ extern "C" void fl_generate_sequence(int nb_images,
     total_nb_attempts++;
 
     if(total_nb_attempts >= max_total_nb_attempts) {
-      cerr << "There was " << max_total_nb_attempts << " attempts at generating the sequences." << endl;
+      cerr << "There was "
+           << max_total_nb_attempts
+           << " attempts at generating the sequences, aborting." << endl;
       abort();
     }