mirror of https://github.com/axmolengine/axmol.git
optimise update of particle system for free mode
This commit is contained in:
parent
35acdc2284
commit
cf4d0faad3
|
@ -694,6 +694,8 @@ void ParticleSystem::update(float dt)
|
|||
}
|
||||
|
||||
{
|
||||
Mat4 worldToNodeTM = getWorldToNodeTransform();
|
||||
|
||||
while (_particleIdx < _particleCount)
|
||||
{
|
||||
tParticle *p = &_particles[_particleIdx];
|
||||
|
@ -769,8 +771,11 @@ void ParticleSystem::update(float dt)
|
|||
|
||||
if (_positionType == PositionType::FREE)
|
||||
{
|
||||
Vec2 diff = convertToNodeSpace(currentPosition) - convertToNodeSpace(p-> startPos);
|
||||
newPos = p->pos - diff;
|
||||
Vec3 p1(currentPosition.x,currentPosition.y,0),p2(p->startPos.x,p->startPos.y,0);
|
||||
worldToNodeTM.transformPoint(&p1);
|
||||
worldToNodeTM.transformPoint(&p2);
|
||||
p1 = p1 - p2;
|
||||
newPos = p->pos - Vec2(p1.x,p1.y);
|
||||
}
|
||||
else if(_positionType == PositionType::RELATIVE)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue