MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / zParPTankSpawnSparkles

Function zParPTankSpawnSparkles

src/SB/Game/zParPTank.cpp:161–225  ·  view source on GitHub ↗

Equivalent: regswaps

Source from the content-addressed store, hash-verified

159
160// Equivalent: regswaps
161void zParPTankSpawnSparkles(xVec3* pos, U32 count)
162{
163 if (zGameIsPaused())
164 {
165 return;
166 }
167 zParPTank* zp = sSparklePTank;
168
169 if (count > zp->max_particles - zp->num_particles)
170 {
171 count = zp->max_particles - zp->num_particles;
172 }
173
174 if (count == 0)
175 {
176 return;
177 }
178
179 RpPTankLockStruct posLock;
180 RpPTankLockStruct vtx2TexCoordsLock;
181
182 RpPTankAtomicLock(zp->ptank, &posLock, rpPTANKLFLAGPOSITION, rpPTANKLOCKWRITE);
183 if (posLock.data == NULL)
184 {
185 return;
186 }
187
188 RpPTankAtomicLock(zp->ptank, &vtx2TexCoordsLock, rpPTANKDFLAGVTX2TEXCOORDS, rpPTANKLOCKWRITE);
189 if (vtx2TexCoordsLock.data == NULL)
190 {
191 return;
192 }
193
194 U32 poslock_base = (U32)posLock.data;
195 U32 uvlock_base = (U32)vtx2TexCoordsLock.data;
196 xVec3* ref_pos = pos;
197 RwCamera* camera = RwCameraGetCurrentCamera();
198 if (gGameState == eGameState_Play && camera)
199 {
200 // TODO: This was probably some Renderware macro
201 ref_pos = (xVec3*)((U8*)camera->object.object.parent + 0x40);
202 }
203
204 xVec3* posit = pos;
205 for (U32 i = 0; i < count; posit++, i++)
206 {
207 if (!sGameScreenTransCam && ref_pos && xVec3Dist2(posit, ref_pos) > 900.0f)
208 {
209 continue;
210 }
211
212 *(xVec3*)(poslock_base + zp->num_particles * posLock.stride) = *posit;
213 RwTexCoords* uv =
214 (RwTexCoords*)(uvlock_base + zp->num_particles * vtx2TexCoordsLock.stride);
215 uv[0].u = 0.0f;
216 uv[0].v = 0.5f;
217 uv[1].u = 0.125f + uv[0].u;
218 uv[1].v = 0.125f + uv[0].v;

Callers

nothing calls this directly

Calls 2

zGameIsPausedFunction · 0.85
xVec3Dist2Function · 0.85

Tested by

no test coverage detected