#include <dali/public-api/images/resource-image.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/shader-effects/bubble-effect/color-adjuster.h>
#include <dali-toolkit/internal/controls/bubble-effect/bubble-actor.h>
#include <dali-toolkit/internal/controls/bubble-effect/color-adjuster.h>
#include <dali-toolkit/internal/controls/bubble-effect/bubble-effect.h>
* 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);
}
}
mDensity( 5 ),
mTotalNumOfBubble( maximumNumberOfBubble ),
mCurrentBubble( 0 ),
+ mRandomSeed( 0 ),
mRenderTaskRunning(false)
{
// Calculate how many shaders are required
mNumBubblePerActor = mTotalNumOfBubble;
mNumActor = 1;
}
+
+ mRandomSeed = time( NULL );
}
BubbleEmitter::~BubbleEmitter()
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<float>( i );
vertexData.push_back( Vertex( index, Vector2(0.f,0.f), Vector2(0.f,0.f) ) );
vertexFormat["aIndex"] = Property::FLOAT;
vertexFormat["aPosition"] = Property::VECTOR2;
vertexFormat["aTexCoord"] = Property::VECTOR2;
- PropertyBuffer vertices = PropertyBuffer::New( PropertyBuffer::STATIC, vertexFormat, numVertex );
+ PropertyBuffer vertices = PropertyBuffer::New( vertexFormat, numVertex );
vertices.SetData( &vertexData[0] );
Property::Map indexFormat;
- indexFormat["indices"] = Property::UNSIGNED_INTEGER;
- PropertyBuffer indices = PropertyBuffer::New( PropertyBuffer::STATIC, indexFormat, numIndex );
+ indexFormat["indices"] = Property::INTEGER;
+ PropertyBuffer indices = PropertyBuffer::New( indexFormat, numIndex );
indices.SetData( &indexData[0] );
Geometry geometry = Geometry::New();
int halfRange = displacement.x / 2;
// for the y coordinate, always negative, so bubbles always go upwards
- Vector2 randomVec(rand()%static_cast<int>(displacement.x) - halfRange, -rand()%static_cast<int>(displacement.y));
+ Vector2 randomVec( rand_r( &mRandomSeed ) % static_cast<int>(displacement.x) - halfRange, -rand_r( &mRandomSeed ) % static_cast<int>(displacement.y) );
dir.Normalize();
randomVec.x -= dir.x*halfRange;
randomVec.y *= 1.0f - fabsf(dir.x)*0.33f;