projects
/
platform
/
core
/
uifw
/
dali-toolkit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Fix various Klocwork errors" into devel/master
[platform/core/uifw/dali-toolkit.git]
/
dali-toolkit
/
internal
/
controls
/
bubble-effect
/
bubble-emitter-impl.cpp
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
af57a7f
..
8b248ce
100644
(file)
--- a/
dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.cpp
+++ b/
dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.cpp
@@
-32,27
+32,31
@@
namespace
{
struct Vertex
{
{
struct Vertex
{
- float index;
- Dali::Vector2 position;
- Dali::Vector2 textureCoord;
-
Vertex()
Vertex()
- {}
+ : index( 0.0f ), position(), textureCoord()
+ {
+ }
Vertex( float index, const Dali::Vector2& position, const Dali::Vector2& textureCoord )
: index( index ), position( position ), textureCoord( textureCoord )
Vertex( float index, const Dali::Vector2& position, const Dali::Vector2& textureCoord )
: index( index ), position( position ), textureCoord( textureCoord )
- {}
+ {
+ }
+
+ float index;
+ Dali::Vector2 position;
+ Dali::Vector2 textureCoord;
};
/**
* Return a random value between the given interval.
* @param[in] f0 The low bound
* @param[in] f1 The up bound
};
/**
* 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
*/
* @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
+80,7
@@
BubbleEmitter::BubbleEmitter( const Vector2& movementArea,
mDensity( 5 ),
mTotalNumOfBubble( maximumNumberOfBubble ),
mCurrentBubble( 0 ),
mDensity( 5 ),
mTotalNumOfBubble( maximumNumberOfBubble ),
mCurrentBubble( 0 ),
+ mRandomSeed( 0 ),
mRenderTaskRunning(false)
{
// Calculate how many shaders are required
mRenderTaskRunning(false)
{
// Calculate how many shaders are required
@@
-95,6
+100,8
@@
BubbleEmitter::BubbleEmitter( const Vector2& movementArea,
mNumBubblePerActor = mTotalNumOfBubble;
mNumActor = 1;
}
mNumBubblePerActor = mTotalNumOfBubble;
mNumActor = 1;
}
+
+ mRandomSeed = time( NULL );
}
BubbleEmitter::~BubbleEmitter()
}
BubbleEmitter::~BubbleEmitter()
@@
-128,16
+135,14
@@
void BubbleEmitter::OnInitialize()
// Prepare the frame buffer to store the color adjusted background image
mEffectImage = FrameBufferImage::New( mMovementArea.width/4.f, mMovementArea.height/4.f, Pixel::RGBA8888, Dali::Image::UNUSED );
// Prepare the frame buffer to store the color adjusted background image
mEffectImage = FrameBufferImage::New( mMovementArea.width/4.f, mMovementArea.height/4.f, Pixel::RGBA8888, Dali::Image::UNUSED );
- // Generate the samplers and geometry, which is used by all bubbleActors
- mSamplerBackground = Sampler::New( mEffectImage, "sBackground" );
- mSamplerBubbleShape = Sampler::New( mShapeImage, "sBubbleShape" );
+ // Generate the geometry, which is used by all bubbleActors
mMeshGeometry = CreateGeometry( mNumBubblePerActor*mDensity );
Shader bubbleShader = CreateBubbleShader (mNumBubblePerActor );
mMaterial = Material::New( bubbleShader );
mMeshGeometry = CreateGeometry( mNumBubblePerActor*mDensity );
Shader bubbleShader = CreateBubbleShader (mNumBubblePerActor );
mMaterial = Material::New( bubbleShader );
- mMaterial.Add
Sampler( mSamplerBackground
);
- mMaterial.Add
Sampler( mSamplerBubbleShape
);
+ mMaterial.Add
Texture( mEffectImage, "sBackground"
);
+ mMaterial.Add
Texture( mShapeImage, "sBubbleShape"
);
mBubbleActors.resize( mNumActor );
mBubbleActors.resize( mNumActor );
@@
-191,7
+196,7
@@
void BubbleEmitter::SetBackground( Image bgImage, const Vector3& hsvDelta )
void BubbleEmitter::SetShapeImage( Image shapeImage )
{
void BubbleEmitter::SetShapeImage( Image shapeImage )
{
- m
SamplerBubbleShape.SetImage(
shapeImage );
+ m
Material.SetTextureImage( 1,
shapeImage );
}
void BubbleEmitter::SetBubbleScale( float scale )
}
void BubbleEmitter::SetBubbleScale( float scale )
@@
-297,7
+302,7
@@
Geometry BubbleEmitter::CreateGeometry( unsigned int numOfPatch )
for(unsigned int i = 0; i < numOfPatch; i++)
{
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) ) );
float index = static_cast<float>( i );
vertexData.push_back( Vertex( index, Vector2(0.f,0.f), Vector2(0.f,0.f) ) );
@@
-322,7
+327,7
@@
Geometry BubbleEmitter::CreateGeometry( unsigned int numOfPatch )
vertices.SetData( &vertexData[0] );
Property::Map indexFormat;
vertices.SetData( &vertexData[0] );
Property::Map indexFormat;
- indexFormat["indices"] = Property::
UNSIGNED_
INTEGER;
+ indexFormat["indices"] = Property::INTEGER;
PropertyBuffer indices = PropertyBuffer::New( indexFormat, numIndex );
indices.SetData( &indexData[0] );
PropertyBuffer indices = PropertyBuffer::New( indexFormat, numIndex );
indices.SetData( &indexData[0] );
@@
-340,7
+345,7
@@
void BubbleEmitter::SetBubbleParameter( BubbleActorPtr bubbleActor, unsigned int
int halfRange = displacement.x / 2;
// for the y coordinate, always negative, so bubbles always go upwards
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;
dir.Normalize();
randomVec.x -= dir.x*halfRange;
randomVec.y *= 1.0f - fabsf(dir.x)*0.33f;