Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 739343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:23:22+00:00 2026-05-14T08:23:22+00:00

I have a system that generates particles from sources and updates their positions. Currently,

  • 0

I have a system that generates particles from sources and updates their positions. Currently, I have written a program in OpenGL which calls my GenerateParticles(...) and UpdateParticles(...) and displays my output. One functionality that I would like my system to have is being able to generate n particles per second. In my GenerateParticles(...) and UpdateParticles(...) functions, I accept 2 important parameters: current_time and delta_time. In UpdateParticles(...), I update the position of my particle according to the following formula: new_pos = curr_pos + delta_time*particle_vector. How can I use these parameters and global variables (or other mechanisms) to produce n particles per second?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T08:23:23+00:00Added an answer on May 14, 2026 at 8:23 am

    You need to be careful, the naive way of creating particles will have you creating fractional particles for low values of n (probably not what you want). Instead create an accumulator variable that gets summed with your delta_time values each frame. Each frame check it to see how many particles you need to create that frame and subtract the appropriate amounts:

    void GenerateParticles(double delta_time) {
      accumulator += delta_time;
      while (accumulator > 1.0 / particles_per_second) {
        CreateParticle(...);
        accumulator -= 1.0 / particles_per_second;
      }  
    }
    

    Make sure you put some limiting in so that if the time delta is large you don’t create a million particles all at once.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written PLSQL program that generates table having usually more than 200 columns.
In our backoffice we have a core-system that generates models from the DB. When
Currently, I have a system that actively generates the pages on my site using
Greetings! Situation: We have a CRM system that generates unique customer IDs. Now we
I have a data processing system that generates very large reports on the data
I am currently modifying an existing system that generates reports with iText and java.
I have the following program that generates a multiplication table. A formatting problem arises
I have a module that generates fill out a System.Drawing.Graphics object. I then try
The scenario: we have a web system that automatically generates office 2003 excel files
I have implemented a simple little DSL that generates classes from input files, by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.