void DrawParticles(R3Scene *scene) { // Get current time (in seconds) since start of execution double current_time = GetTime(); static double previous_time = 0; static double time_lost_taking_videos = 0; // for switching back and forth // between recording and not // recording smoothly // program just started up? if (previous_time == 0) previous_time = current_time; // time passed since starting double delta_time = current_time - previous_time; if (save_video) { // in video mode, the time that passes only depends on the frame rate ... delta_time = VIDEO_FRAME_DELAY; // ... but we need to keep track how much time we gained and lost so that we can arbitrarily switch back and forth ... time_lost_taking_videos += (current_time - previous_time) - VIDEO_FRAME_DELAY; } else { // real time simulation delta_time = current_time - previous_time; } // Update particles UpdateParticles(scene, current_time - time_lost_taking_videos, delta_time, integration_type); // Generate new particles GenerateParticles(scene, current_time - time_lost_taking_videos, delta_time); // Render particles if (show_particles) RenderParticles(scene, current_time - time_lost_taking_videos, delta_time); // Remember previous time previous_time = current_time; }
void* ParticleGroup::GenerateParticle() { return GenerateParticles(1); }