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

Method update

core/2d/ParticleSystem.cpp:1557–1844  ·  view source on GitHub ↗

ParticleSystem - MainLoop

Source from the content-addressed store, hash-verified

1555
1556// ParticleSystem - MainLoop
1557void ParticleSystem::update(float dt)
1558{
1559 // don't process particles nor update gl buffer when this node is invisible.
1560 if (!_visible)
1561 return;
1562
1563 AX_PROFILER_START_CATEGORY(kProfilerCategoryParticles, "CCParticleSystem - update");
1564
1565 if (_componentContainer && !_componentContainer->isEmpty())
1566 {
1567 _componentContainer->visit(dt);
1568 }
1569
1570 if (_fixedFPS != 0)
1571 {
1572 _fixedFPSDelta += dt;
1573 if (_fixedFPSDelta < 1.0F / _fixedFPS)
1574 {
1575 updateParticleQuads();
1576 _transformSystemDirty = false;
1577 AX_PROFILER_STOP_CATEGORY(kProfilerCategoryParticles, "CCParticleSystem - update");
1578 return;
1579 }
1580 dt = _fixedFPSDelta;
1581 _fixedFPSDelta = 0.0F;
1582 }
1583
1584 float pureDt = dt;
1585 dt *= _timeScale;
1586
1587 if (_isActive && _emissionRate)
1588 {
1589 float rate = 1.0f / _emissionRate;
1590 int totalParticles = static_cast<int>(_totalParticles * __totalParticleCountFactor);
1591
1592 // issue #1201, prevent bursts of particles, due to too high emitCounter
1593 if (_particleCount < totalParticles)
1594 {
1595 _emitCounter += dt;
1596 _emitCounter = MAX(0.0F, _emitCounter);
1597 }
1598
1599 int emitCount = MIN(totalParticles - _particleCount, _emitCounter / rate);
1600 addParticles(emitCount);
1601 _emitCounter -= rate * emitCount;
1602
1603 _elapsed += dt;
1604 if (_elapsed < 0.f)
1605 _elapsed = 0.f;
1606 if (_duration != static_cast<float>(DURATION_INFINITY) && _duration < _elapsed)
1607 {
1608 this->stopSystem();
1609 }
1610 }
1611
1612 // The reason for using for-loops separately for every property is because
1613 // When the processor needs to read from or write to a location in memory,
1614 // it first checks whether a copy of that data is in the cpu's cache.

Callers 2

simulateMethod · 0.95
updateWithNoTimeMethod · 0.95

Calls 12

stopSystemMethod · 0.95
fill_nFunction · 0.85
normalize_pointFunction · 0.85
disableParticleMethod · 0.80
swapFunction · 0.50
isEmptyMethod · 0.45
visitMethod · 0.45
emptyMethod · 0.45
atMethod · 0.45
sizeMethod · 0.45
unscheduleUpdateMethod · 0.45
removeChildMethod · 0.45

Tested by

no test coverage detected