• Create Account

### #ActualN01

Posted 09 September 2013 - 11:32 PM

Do you mean that in 2.5 seconds (that is: 2.5 seconds of simulation time), your sphere, starting at rest, has fallen 132m? If so, that's much further than expected - you'd expect 0.5 * 9.81 * 2.5 * 2.5 which is about 30.7m. That would suggest your simulation is running faster than normal... so I'm not sure I've interpreted your numbers right.

In post 13 your loop multiplies by mStepSize, which is definitely wrong - but then you correct it in post 15. But it's still not quite clear what your latest version looks like.

In any case I'd expect this to work:

...


I've replaced two calls to clock with one. I wonder - with your current code, assuming your scene is really simple, that update loop may spend a lot of time just spinning round, whilst it waits for the accumulator to accumulate, in which case each time it will lose a little bit of time - maybe that's where your slowdown is coming from?

resulting numbers also confused me. to clarify, ~2.5 seconds is 149frames/60 FPS in PVD. according to formula, it should've fallen 30 units in 2.5 seconds. but in my scene it's less, than human height. rigid objects shouldn't fall from that height for 2.5 seconds. even what i consider as "slow mo" runs faster. but you measure it in meters, and i do in units and i'm not sure, how do you convert arbitrary scene into metrical system. ...so i guess, scale somehow matters. and also, even when i multiply deltaTime by 5, so in-game physics are close to speed i expect, PVD's recodred clip is still in slow-mo.

scene is not super basic, but it's not a full scale level. it's just some part of the level done, with some additional testing objects.

running simulation looks like that in semi-pseudocode:

physicsManager::update() {
float currentTime = clock();
float deltaTime = (currentTime - mLastTime)/CLOCKS_PER_SEC;
mAccumulator  += deltaTime;
mLastTime = currentTime;

while(mAccumulator > mStepSize) {
mAccumulator -= mStepSize;
mScene->simulate(mStepSize);
mScene->fetchResults(true);
}

//update objects
...
}

//do stuff
...
physicsManager.update();
Sleep(30 - timeTookProcessing); //running at 30FPS
}

//render stuff
...
Sleep(16 - timeTookRendering); //running at 60 FPS
}

### #7N01

Posted 09 September 2013 - 11:32 PM

Do you mean that in 2.5 seconds (that is: 2.5 seconds of simulation time), your sphere, starting at rest, has fallen 132m? If so, that's much further than expected - you'd expect 0.5 * 9.81 * 2.5 * 2.5 which is about 30.7m. That would suggest your simulation is running faster than normal... so I'm not sure I've interpreted your numbers right.

In post 13 your loop multiplies by mStepSize, which is definitely wrong - but then you correct it in post 15. But it's still not quite clear what your latest version looks like.

In any case I'd expect this to work:

void update() {
clock_t c = clock();
float deltaTime = (c - mLastTime) / CLOCKS_PER_SEC;
mAccumulator  += deltaTime;
mLastTime = c;

while(mAccumulator > mStepSize) {
mAccumulator -= mStepSize;
mScene->simulate(mStepSize);
mScene->fetchResults(true);
}
// Ideally call something like sleepInSeconds(mAccumulator) here
}


I've replaced two calls to clock with one. I wonder - with your current code, assuming your scene is really simple, that update loop may spend a lot of time just spinning round, whilst it waits for the accumulator to accumulate, in which case each time it will lose a little bit of time - maybe that's where your slowdown is coming from?

resulting numbers also confused me. to clarify, ~2.5 seconds is 149frames/60 FPS in PVD. according to formula, it should've fallen 30 units in 2.5 seconds. but in my scene it's less, than human height. rigid objects shouldn't fall from that height for 2.5 seconds. even what i consider as "slow mo" runs faster. but you measure it in meters, and i do in units and i'm not sure, how do you convert arbitrary scene into metrical system. ...so i guess, scale somehow matters. and also, even when i multiply deltaTime by 5, so in-game physics are close to speed i expect, PVD's recodred clip is still in slow-mo.

scene is not super basic, but it's not a full scale level. it's just some part of the level done, with some additional testing objects.

running simulation looks like that in semi-pseudocode:

physicsManager::update() {
float currentTime = clock();
float deltaTime = (currentTime - mLastTime)/CLOCKS_PER_SEC;
mAccumulator  += deltaTime;
mLastTime = currentTime;

while(mAccumulator > mStepSize) {
mAccumulator -= mStepSize;
mScene->simulate(mStepSize);
mScene->fetchResults(true);
}

//update objects
...
}

//do stuff
...
physicsManager.update();
Sleep(30 - timeTookProcessing); //running at 30FPS
}

//render stuff
...
Sleep(16 - timeTookRendering); //running at 60 FPS
}

### #6N01

Posted 09 September 2013 - 11:03 PM

Do you mean that in 2.5 seconds (that is: 2.5 seconds of simulation time), your sphere, starting at rest, has fallen 132m? If so, that's much further than expected - you'd expect 0.5 * 9.81 * 2.5 * 2.5 which is about 30.7m. That would suggest your simulation is running faster than normal... so I'm not sure I've interpreted your numbers right.

In post 13 your loop multiplies by mStepSize, which is definitely wrong - but then you correct it in post 15. But it's still not quite clear what your latest version looks like.

In any case I'd expect this to work:

void update() {
clock_t c = clock();
float deltaTime = (c - mLastTime) / CLOCKS_PER_SEC;
mAccumulator  += deltaTime;
mLastTime = c;

while(mAccumulator > mStepSize) {
mAccumulator -= mStepSize;
mScene->simulate(mStepSize);
mScene->fetchResults(true);
}
// Ideally call something like sleepInSeconds(mAccumulator) here
}


I've replaced two calls to clock with one. I wonder - with your current code, assuming your scene is really simple, that update loop may spend a lot of time just spinning round, whilst it waits for the accumulator to accumulate, in which case each time it will lose a little bit of time - maybe that's where your slowdown is coming from?

resulting numbers also confused me. to clarify, ~2.5 seconds is 149frames/60 FPS in PVD. according to formula, it should've fallen 30 units in 2.5 seconds. but in my scene it's less, than human height. rigid objects shouldn't fall from that height for 2.5 seconds. even what i consider as "slow mo" runs faster. but you measure it in meters, and i do in units and i'm not sure, how do you convert arbitrary scene into metrical system. ...so i guess, scale somehow matters. and also, even when i multiply deltaTime by 5, so in-game physics are close to speed i expect, PVD's recodred clip is still slow-mo.

scene is not super basic, but it's not a full scale level. it's just some part of the level done and with some additional testing objects.

running simulation it looks like that in semi-pseudocode:

physicsManager::update() {
float currentTime = clock();
float deltaTime = (currentTime - mLastTime)/CLOCKS_PER_SEC;
mAccumulator  += deltaTime;
mLastTime = currentTime;

while(mAccumulator > mStepSize) {
mAccumulator -= mStepSize;
mScene->simulate(mStepSize);
mScene->fetchResults(true);
}

//update objects
...
}

//do stuff
...
physicsManager.update();
Sleep(30 - timeTookProcessing); //running at 30FPS
}

//render stuff
...
Sleep(16 - timeTookRendering); //running at 60 FPS
}

### #5N01

Posted 09 September 2013 - 11:02 PM

Do you mean that in 2.5 seconds (that is: 2.5 seconds of simulation time), your sphere, starting at rest, has fallen 132m? If so, that's much further than expected - you'd expect 0.5 * 9.81 * 2.5 * 2.5 which is about 30.7m. That would suggest your simulation is running faster than normal... so I'm not sure I've interpreted your numbers right.

In post 13 your loop multiplies by mStepSize, which is definitely wrong - but then you correct it in post 15. But it's still not quite clear what your latest version looks like.

In any case I'd expect this to work:

void update() {
clock_t c = clock();
float deltaTime = (c - mLastTime) / CLOCKS_PER_SEC;
mAccumulator  += deltaTime;
mLastTime = c;

while(mAccumulator > mStepSize) {
mAccumulator -= mStepSize;
mScene->simulate(mStepSize);
mScene->fetchResults(true);
}
// Ideally call something like sleepInSeconds(mAccumulator) here
}


I've replaced two calls to clock with one. I wonder - with your current code, assuming your scene is really simple, that update loop may spend a lot of time just spinning round, whilst it waits for the accumulator to accumulate, in which case each time it will lose a little bit of time - maybe that's where your slowdown is coming from?

resulting numbers also confused me. to clarify, ~2.5 seconds is 149frames/60 FPS in PVD. according to formula, it should've fallen 30 units in 2.5 seconds. but in my scene it's less, than human height. rigid objects shouldn't fall from that height for 2.5 seconds. even what i consider as "slow mo" runs faster. but you measure it in meters, and i do in units and i'm not sure, how do you convert arbitrary scene into metrical system. ...so i guess, scale somehow matters. and also, even when i multiply deltaTime by 5, so in-game physics are close to speed i expect, PVD output is still slowed down.

scene is not super basic, but it's not a full scale level. it's just some part of the level done and with some additional testing objects.

running simulation it looks like that in semi-pseudocode:

physicsManager::update() {
float currentTime = clock();
float deltaTime = (currentTime - mLastTime)/CLOCKS_PER_SEC;
mAccumulator  += deltaTime;
mLastTime = currentTime;

while(mAccumulator > mStepSize) {
mAccumulator -= mStepSize;
mScene->simulate(mStepSize);
mScene->fetchResults(true);
}

//update objects
...
}

//do stuff
...
physicsManager.update();
Sleep(30 - timeTookProcessing); //running at 30FPS
}

//render stuff
...
Sleep(16 - timeTookRendering); //running at 60 FPS
}

### #4N01

Posted 09 September 2013 - 11:00 PM

Do you mean that in 2.5 seconds (that is: 2.5 seconds of simulation time), your sphere, starting at rest, has fallen 132m? If so, that's much further than expected - you'd expect 0.5 * 9.81 * 2.5 * 2.5 which is about 30.7m. That would suggest your simulation is running faster than normal... so I'm not sure I've interpreted your numbers right.

In post 13 your loop multiplies by mStepSize, which is definitely wrong - but then you correct it in post 15. But it's still not quite clear what your latest version looks like.

In any case I'd expect this to work:

void update() {
clock_t c = clock();
float deltaTime = (c - mLastTime) / CLOCKS_PER_SEC;
mAccumulator  += deltaTime;
mLastTime = c;

while(mAccumulator > mStepSize) {
mAccumulator -= mStepSize;
mScene->simulate(mStepSize);
mScene->fetchResults(true);
}
// Ideally call something like sleepInSeconds(mAccumulator) here
}


I've replaced two calls to clock with one. I wonder - with your current code, assuming your scene is really simple, that update loop may spend a lot of time just spinning round, whilst it waits for the accumulator to accumulate, in which case each time it will lose a little bit of time - maybe that's where your slowdown is coming from?

resulting numbers also confused me. to clarify, ~2.5 seconds is 149frames/60 FPS in PVD. according to formula, it should've fallen 30 units in 2.5 seconds. but in my scene it's less, than human height. rigid objects shouldn't fall from that height for 2.5 seconds. even what i consider as "slow mo" runs faster. but you measure it in meters, and i do in units and i'm not sure, how do you convert arbitrary scene into metrical system. ...so i guess, scale somehow matters. and also, even when i multiply deltaTime by 5, so in-game physics are close to speed i expect, PVD output is still slowed down.

scene is not super basic, but it's not a full scale level. it's just some part of the level done and with some additional testing objects.

running simulation it looks like that:

physicsManager::update() {
float deltaTime = (clock() - mLastTime)/CLOCKS_PER_SEC;
mAccumulator  += deltaTime;
mLastTime = clock();

while(mAccumulator > mStepSize) {
mAccumulator -= mStepSize;
mScene->simulate(mStepSize);
mScene->fetchResults(true);
}

//update objects
...
}

//do stuff
...
physicsManager.update();
Sleep(30 - timeTookProcessing); //running at 30FPS
}

//render stuff
...
Sleep(16 - timeTookRendering); //running at 60 FPS
}

### #3N01

Posted 09 September 2013 - 10:59 PM

Do you mean that in 2.5 seconds (that is: 2.5 seconds of simulation time), your sphere, starting at rest, has fallen 132m? If so, that's much further than expected - you'd expect 0.5 * 9.81 * 2.5 * 2.5 which is about 30.7m. That would suggest your simulation is running faster than normal... so I'm not sure I've interpreted your numbers right.

In post 13 your loop multiplies by mStepSize, which is definitely wrong - but then you correct it in post 15. But it's still not quite clear what your latest version looks like.

In any case I'd expect this to work:

void update() {
clock_t c = clock();
float deltaTime = (c - mLastTime) / CLOCKS_PER_SEC;
mAccumulator  += deltaTime;
mLastTime = c;

while(mAccumulator > mStepSize) {
mAccumulator -= mStepSize;
mScene->simulate(mStepSize);
mScene->fetchResults(true);
}
// Ideally call something like sleepInSeconds(mAccumulator) here
}


I've replaced two calls to clock with one. I wonder - with your current code, assuming your scene is really simple, that update loop may spend a lot of time just spinning round, whilst it waits for the accumulator to accumulate, in which case each time it will lose a little bit of time - maybe that's where your slowdown is coming from?

resulting numbers also confused me. to clarify, ~2.5 seconds is 149frames/60 FPS in PVD. according to formula, it should've fallen 30 units in 2.5 seconds. but in my scene it's less, than human height. rigid objects don't fall from that height for 2.5 seconds. even what i consider as "slow mo" runs faster. but you measure it in meters, and i do in units and i'm not sure, how do you convert arbitrary scene into metrical system. so i guess, scale somehow matters. and also, even when i multiply deltaTime by 5, so in-game physics are closer to speed i expect, PVD output is still slowed down.

scene is not super basic, but it's not a full scale level. it's just some part of the level done and with some additional testing objects.

running simulation it looks like that:

physicsManager::update() {
float deltaTime = (clock() - mLastTime)/CLOCKS_PER_SEC;
mAccumulator  += deltaTime;
mLastTime = clock();

while(mAccumulator > mStepSize) {
mAccumulator -= mStepSize;
mScene->simulate(mStepSize);
mScene->fetchResults(true);
}

//update objects
...
}

}