Fix T43178: BGE has hard-coded 60 Hz as frame rate

Two areas of the BGE use a hard-coded 60 Hz as frame rate. However, this 60 Hz is just a default setting, and can be changed in the Blender interface.
This setting is now used instead of the hard-coded 60 Hz.

CcdPhysicsEnvironment::SetFixedTimeStep() is actually never called, as we don't even support a true fixed-timestep simulation.
This commit is contained in:
Sybren A. Stüvel 2015-03-16 10:12:29 +01:00
parent 6aaedc7cfd
commit 30527e3e55
Notes: blender-bot 2023-02-14 09:38:58 +01:00
Referenced by issue #43178, CcdPhysicsEnvironment::SetFixedTimeStep has hard-coded 60 Hz as frame rate
2 changed files with 5 additions and 4 deletions

View File

@ -752,8 +752,8 @@ public:
void CcdPhysicsEnvironment::ProcessFhSprings(double curTime,float interval)
{
std::set<CcdPhysicsController*>::iterator it;
// dynamic of Fh spring is based on a timestep of 1/60
int numIter = (int)(interval*60.0001f);
// Add epsilon to the tick rate for numerical stability
int numIter = (int)(interval*(KX_KetsjiEngine::GetTicRate() + 0.001f));
for (it=m_controllers.begin(); it!=m_controllers.end(); it++)
{

View File

@ -22,6 +22,8 @@ subject to the following restrictions:
#define __CCDPHYSICSENVIRONMENT_H__
#include "PHY_IPhysicsEnvironment.h"
#include "KX_KetsjiEngine.h"
#include <vector>
#include <set>
#include <map>
@ -131,8 +133,7 @@ protected:
virtual void SetFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)
{
//based on DEFAULT_PHYSICS_TIC_RATE of 60 hertz
SetNumTimeSubSteps((int)(fixedTimeStep / 60.f));
SetNumTimeSubSteps((int)(fixedTimeStep / KX_KetsjiEngine::GetTicRate()));
}
//returns 0.f if no fixed timestep is used