2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "image-effect-modifier.h"
19 #include "image-effect-source.h"
20 namespace Dali::ParticleEffect
23 #define RAD(x) (float(x)*M_PI/180.0f)
25 ImageExplodeEffectModifier::ImageExplodeEffectModifier(ParticleEmitter& emitter)
31 bool ImageExplodeEffectModifier::IsMultiThreaded()
36 void ImageExplodeEffectModifier::Update(ParticleList& particleList, uint32_t first, uint32_t count)
38 // If no acive particles return
39 if(!particleList.GetActiveParticleCount())
44 // Retrieve the Source and get the stream
47 mStreamBasePos = static_cast<ImageExplodeEffectSource*>(&mEmitter.GetSource().GetSourceCallback())->mStreamBasePos;
50 // Missing stream, return!
56 auto& activeParticles = particleList.GetActiveParticles();
58 auto it = activeParticles.begin();
59 std::advance(it, first);
63 for(; count; ++it, count--)
65 // Acquire stream data
67 auto& position = particle.Get<Vector3>(ParticleStream::POSITION_STREAM_BIT);
68 auto& color = particle.Get<Vector4>(ParticleStream::COLOR_STREAM_BIT);
71 auto& basePos = particle.GetByIndex<Vector3>(mStreamBasePos);
72 position.z = 200.f * sin(RAD(mAngle+basePos.x));
73 color.a = position.z < 0.0f ? 1.0f : 1.0f - position.z/500.0f;
74 position.z = 500 + position.z;