BGE: Random sensor will produce true random sequence of events when seed is set to 0 in the GUI (the actual seed value is stored in the sensor seed attribute). Positive values will use fixed pseudo random sequence.

This commit is contained in:
Benoit Bolsee 2009-05-23 14:40:36 +00:00
parent 4e3248fb91
commit 6d8d7cd768
3 changed files with 11 additions and 0 deletions

@ -682,6 +682,11 @@ void BL_ConvertSensors(struct Object* blenderobject,
if (eventmgr)
{
int randomSeed = blenderrndsensor->seed;
if (randomSeed == 0)
{
randomSeed = (int)(kxengine->GetRealTime()*100000.0);
randomSeed ^= (intptr_t)blenderrndsensor;
}
gamesensor = new SCA_RandomSensor(eventmgr, gameobj, randomSeed);
}
}

@ -1770,6 +1770,11 @@ double KX_KetsjiEngine::GetClockTime(void) const
return m_clockTime;
}
double KX_KetsjiEngine::GetRealTime(void) const
{
return m_kxsystem->GetTimeInSeconds();
}
void KX_KetsjiEngine::SetAnimFrameRate(double framerate)
{
m_anim_framerate = framerate;

@ -271,6 +271,7 @@ public:
*/
double GetClockTime(void) const;
double GetRealTime(void) const;
/**
* Returns the difference between the local time of the scene (when it
* was running and not suspended) and the "curtime"