optimise update of particle system for free mode

This commit is contained in:
Huabing.Xu 2014-09-18 15:24:27 +08:00
parent 35acdc2284
commit cf4d0faad3
1 changed files with 7 additions and 2 deletions

View File

@ -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)
{