for(int k = 0; k < nb_it; k++) {
manipulator.update(dt, &universe);
task->update(dt, &universe, &manipulator);
+ universe.apply_gravity(dt, 0.0, 2.0);
changed |= universe.update(dt);
}
}
}
+void Universe::apply_gravity(scalar_t dt, scalar_t fx, scalar_t fy) {
+ for(int n = 0; n < _nb_polygons; n++)
+ if(_polygons[n])
+ _polygons[n]->apply_force(dt,
+ _polygons[n]->_center_x, _polygons[n]->_center_y,
+ fx, fy);
+}
+
void Universe::apply_collision_forces(scalar_t dt) {
const int nb_axis = 2;
int nb_collision[_nb_polygons * _nb_polygons];
// Compute collisions between projections of the polygons on a few
// axis to speed up the computation
void compute_pseudo_collisions(int nb_axis, int *nb_colliding_axis);
+ void apply_gravity(scalar_t dt, scalar_t fx, scalar_t fy);
void apply_collision_forces(scalar_t dt);
bool update(scalar_t dt);