add child helper
| 483 | |
| 484 | // add child helper |
| 485 | void ParticleBatchNode::insertChild(ParticleSystem* system, int index) |
| 486 | { |
| 487 | system->setAtlasIndex(index); |
| 488 | |
| 489 | if (_textureAtlas->getTotalQuads() + system->getTotalParticles() > _textureAtlas->getCapacity()) |
| 490 | { |
| 491 | increaseAtlasCapacityTo(_textureAtlas->getTotalQuads() + system->getTotalParticles()); |
| 492 | |
| 493 | // after a realloc empty quads of textureAtlas can be filled with gibberish (realloc doesn't perform calloc), |
| 494 | // insert empty quads to prevent it |
| 495 | _textureAtlas->fillWithEmptyQuadsFromIndex(_textureAtlas->getCapacity() - system->getTotalParticles(), |
| 496 | system->getTotalParticles()); |
| 497 | } |
| 498 | |
| 499 | // make room for quads, not necessary for last child |
| 500 | if (system->getAtlasIndex() + system->getTotalParticles() != _textureAtlas->getTotalQuads()) |
| 501 | { |
| 502 | _textureAtlas->moveQuadsFromIndex(index, index + system->getTotalParticles()); |
| 503 | } |
| 504 | |
| 505 | // increase totalParticles here for new particles, update method of particle-system will fill the quads |
| 506 | _textureAtlas->increaseTotalQuadsWith(system->getTotalParticles()); |
| 507 | |
| 508 | updateAllAtlasIndexes(); |
| 509 | } |
| 510 | |
| 511 | // rebuild atlas indexes |
| 512 | void ParticleBatchNode::updateAllAtlasIndexes() |
nothing calls this directly
no test coverage detected