X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbubble-effect%2Fbubble-emitter-impl.cpp;h=9fed7cc985cce36685daf4b89c1f295bc35e17ba;hp=a9b9aa94ebc27893e5af46779f127f27125b70c7;hb=2c8390f8447bfe14329222f1bcd6c9ea649254ac;hpb=ae34cf6aef4b3b807bd1e099baa48230b6b32156 diff --git a/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.cpp b/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.cpp index a9b9aa9..9fed7cc 100644 --- a/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.cpp +++ b/dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.cpp @@ -48,11 +48,12 @@ struct Vertex * Return a random value between the given interval. * @param[in] f0 The low bound * @param[in] f1 The up bound + * @param[in] seed The seed to genergate random number * @return A random value between the given interval */ -float RandomRange(float f0, float f1) +float RandomRange(float f0, float f1, unsigned int& seed) { - return f0 + (rand() & 0xfff) * (f1-f0) * (1.0f/4095.0f); + return f0 + (rand_r( &seed ) & 0xfff) * (f1-f0) * (1.0f/4095.0f); } } @@ -76,6 +77,7 @@ BubbleEmitter::BubbleEmitter( const Vector2& movementArea, mDensity( 5 ), mTotalNumOfBubble( maximumNumberOfBubble ), mCurrentBubble( 0 ), + mRandomSeed( 0 ), mRenderTaskRunning(false) { // Calculate how many shaders are required @@ -95,6 +97,8 @@ BubbleEmitter::BubbleEmitter( const Vector2& movementArea, mNumBubblePerActor = mTotalNumOfBubble; mNumActor = 1; } + + mRandomSeed = time( NULL ); } BubbleEmitter::~BubbleEmitter() @@ -297,7 +301,7 @@ Geometry BubbleEmitter::CreateGeometry( unsigned int numOfPatch ) for(unsigned int i = 0; i < numOfPatch; i++) { - float curSize = RandomRange(mBubbleSizeRange.x, mBubbleSizeRange.y); + float curSize = RandomRange(mBubbleSizeRange.x, mBubbleSizeRange.y, mRandomSeed); float index = static_cast( i ); vertexData.push_back( Vertex( index, Vector2(0.f,0.f), Vector2(0.f,0.f) ) ); @@ -340,7 +344,7 @@ void BubbleEmitter::SetBubbleParameter( BubbleActorPtr bubbleActor, unsigned int int halfRange = displacement.x / 2; // for the y coordinate, always negative, so bubbles always go upwards - Vector2 randomVec(rand()%static_cast(displacement.x) - halfRange, -rand()%static_cast(displacement.y)); + Vector2 randomVec( rand_r( &mRandomSeed ) % static_cast(displacement.x) - halfRange, -rand_r( &mRandomSeed ) % static_cast(displacement.y) ); dir.Normalize(); randomVec.x -= dir.x*halfRange; randomVec.y *= 1.0f - fabsf(dir.x)*0.33f;