Only use a deterministic random when network option is enabled. (#7126)
* Only use a deterministic random when network option is enabled. Signed-off-by: rhhong <rhhong@amazon.com> * use actor instance id as the seed of the lcg random in anim graph instance Signed-off-by: rhhong <rhhong@amazon.com> * add const Signed-off-by: rhhong <rhhong@amazon.com>
This commit is contained in:
@@ -71,6 +71,9 @@ namespace EMotionFX
|
||||
// create the parameter value objects
|
||||
CreateParameterValues();
|
||||
|
||||
// Assign a unique seed for the lcg random number. Here we use the actorInstanceId because it guaranteed to be unique and available on actor instances.
|
||||
m_lcgRandom.SetSeed(actorInstance->GetID());
|
||||
|
||||
m_animGraph->Unlock();
|
||||
GetEventManager().OnCreateAnimGraphInstance(this);
|
||||
}
|
||||
|
||||
@@ -90,15 +90,8 @@ namespace EMotionFX
|
||||
if (m_useRandomization)
|
||||
{
|
||||
// create a randomized count down value
|
||||
if (animGraphInstance->IsNetworkEnabled())
|
||||
{
|
||||
// using a seeded random in order to generate predictable result in network.
|
||||
uniqueData->m_countDownTime = MCore::Random::RandF(m_minRandomTime, m_maxRandomTime, animGraphInstance->GetLcgRandom());
|
||||
}
|
||||
else
|
||||
{
|
||||
uniqueData->m_countDownTime = MCore::Random::RandF(m_minRandomTime, m_maxRandomTime);
|
||||
}
|
||||
uniqueData->m_countDownTime =
|
||||
m_minRandomTime + (m_maxRandomTime - m_minRandomTime) * animGraphInstance->GetLcgRandom().GetRandomFloat();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -64,22 +64,6 @@ namespace MCore
|
||||
*/
|
||||
static MCORE_INLINE float RandF(float minVal, float maxVal) { return minVal + (maxVal - minVal) * rand() / (float)RAND_MAX; }
|
||||
|
||||
/**
|
||||
* Generate a uniform random float in a range of a given minimum and maximum.
|
||||
* @param minVal The minimum value of the range.
|
||||
* @param maxVal The maximum value of the range.
|
||||
* @result A uniform random floating point number in range of [min..max].
|
||||
*/
|
||||
static MCORE_INLINE float RandF(float minVal, float maxVal, unsigned int seed) { AZ_UNUSED(seed); return minVal + (maxVal - minVal) * rand() / (float)RAND_MAX; }
|
||||
|
||||
/**
|
||||
* Generate a uniform random float in a range of a given minimum and maximum.
|
||||
* @param minVal The minimum value of the range.
|
||||
* @param maxVal The maximum value of the range.
|
||||
* @result A uniform random floating point number in range of [min..max].
|
||||
*/
|
||||
static MCORE_INLINE float RandF(float minVal, float maxVal, LcgRandom& rand) { return minVal + (maxVal - minVal) * rand.GetRandomFloat(); }
|
||||
|
||||
/**
|
||||
* Generates a uniform random normalized direction vector, using floats.
|
||||
* @result A uniform random direction vector with a length of 1.
|
||||
|
||||
Reference in New Issue
Block a user