MCPcopy Create free account
hub / github.com/axmolengine/axmol / insertChild

Method insertChild

core/2d/ParticleBatchNode.cpp:485–509  ·  view source on GitHub ↗

add child helper

Source from the content-addressed store, hash-verified

483
484// add child helper
485void 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
512void ParticleBatchNode::updateAllAtlasIndexes()

Callers

nothing calls this directly

Calls 6

getTotalQuadsMethod · 0.80
getTotalParticlesMethod · 0.80
moveQuadsFromIndexMethod · 0.80
getCapacityMethod · 0.45

Tested by

no test coverage detected