View Full Version : Water simulation. Time or deltatime?

09-12-2015, 02:56 PM

I'm implementing right now http.developer.nvidia.com/GPUGems/gpugems_ch01.html. I have a question regarding the time( t ) variable.
Should it be calculated like this(All the calculations needs to be framerate independent):

Example 1:

GLfloat timeValue = 0.0f;
const GLfloat SPEED_FACTOR = ...;

void updateTime(GLfloat deltaTime)
timeValue += SPEED_FACTOR * deltaTime;

or like this(time is the time elapsed since the application started):

Example 2:

GLfloat currentTimeValue = 0.0f;
const GLfloat SPEED_FACTOR = ...;

void updateTime(GLfloat time)
currentTimeValue = SPEED_FACTOR * time; //Note that the plus sign is not used here.

If I should use example 1, how do I reset the "timeValue" variable in a correct way? A user should NOT notice that the water simulation is being restored!

Thanks in advance!