MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / Update

Method Update

LuaSTGPlus/ResourceMgr.cpp:84–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82 : m_pInstance(ref), m_fEmission((float)ref->GetParticleInfo().nEmission) {}
83
84void ResParticle::ParticlePool::Update(float delta)
85{
86 static fcyRandomWELL512 s_ParticleRandomizer;
87
88 const ParticleInfo& pInfo = m_pInstance->GetParticleInfo();
89
90 if (m_iStatus == Status::Alive)
91 {
92 m_fAge += delta;
93 if (m_fAge >= pInfo.fLifetime && pInfo.fLifetime >= 0.f)
94 m_iStatus = Status::Sleep;
95 }
96
97 // ������������
98 size_t i = 0;
99 while (i < m_iAlive)
100 {
101 ParticleInstance& tInst = m_ParticlePool[i];
102 tInst.fAge += delta;
103 if (tInst.fAge >= tInst.fTerminalAge)
104 {
105 --m_iAlive;
106 if (m_iAlive > i + 1)
107 memcpy(&tInst, &m_ParticlePool[m_iAlive], sizeof(ParticleInstance));
108 continue;
109 }
110
111 // �����߼��ٶȺ�������ٶ�
112 fcyVec2 vecAccel = (tInst.vecLocation - m_vCenter).GetNormalize();
113 fcyVec2 vecAccel2 = vecAccel;
114 vecAccel *= tInst.fRadialAccel;
115 // vecAccel2.Rotate(M_PI_2);
116 std::swap(vecAccel2.x, vecAccel2.y);
117 vecAccel2.x = -vecAccel2.x;
118 vecAccel2 *= tInst.fTangentialAccel;
119
120 // �����ٶ�
121 tInst.vecVelocity += (vecAccel + vecAccel2) * delta;
122 tInst.vecVelocity.y += tInst.fGravity * delta;
123
124 // �����
125 tInst.vecLocation += tInst.vecVelocity * delta;
126
127 // ���������ʹ�С
128 tInst.fSpin += tInst.fSpinDelta * delta;
129 tInst.fSize += tInst.fSizeDelta * delta;
130 tInst.colColor[0] += tInst.colColorDelta[0] * delta;
131 tInst.colColor[1] += tInst.colColorDelta[1] * delta;
132 tInst.colColor[2] += tInst.colColorDelta[2] * delta;
133 tInst.colColor[3] += tInst.colColorDelta[3] * delta;
134
135 ++i;
136 }
137
138 // �����µ�����
139 if (m_iStatus == Status::Alive)
140 {
141 float fParticlesNeeded = m_fEmission * delta + m_fEmissionResidue;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected