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

Function sphereHitsEnvCB

src/SB/Core/gc/iCollide.cpp:206–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204}
205
206RpCollisionTriangle* sphereHitsEnvCB(RpIntersection* isx, RpWorldSector* sector,
207 RpCollisionTriangle* tri, F32 dist, void* data)
208{
209 xCollis* coll = (xCollis*)data;
210 F32 radius = isx->t.line.end.x;
211 xVec3* center;
212 xVec3 tohit;
213 F32 scale;
214
215 if (coll->flags == 0)
216 {
217 coll->flags |= 1;
218 return NULL;
219 }
220
221 dist = FLOAT_MAX;
222 properSphereIsectTri((xVec3*)&isx->t.line.start, radius, &tohit, &dist, tri);
223
224 if (dist < 0.0f)
225 {
226 return tri;
227 }
228 if (0.0f == dist)
229 {
230 return tri;
231 }
232 if (dist >= radius)
233 {
234 return tri;
235 }
236 if (dist >= coll->dist)
237 {
238 return tri;
239 }
240
241 coll->dist = dist;
242 if (coll->flags & 0x200)
243 {
244 xVec3Copy(&coll->norm, (xVec3*)&tri->normal);
245 }
246 if (coll->flags & 0x400)
247 {
248 xVec3Copy(&coll->tohit, &tohit);
249 }
250 if (coll->flags & 0x800)
251 {
252 scale = 1.0f - (radius / coll->dist);
253 scale -= 1e-5f;
254 xVec3Copy(&coll->depen, &tohit);
255 xVec3SMulBy(&coll->depen, scale);
256 }
257 if (coll->flags & 0x1000)
258 {
259 xVec3Normalize(&coll->hdng, &tohit);
260 }
261 coll->flags |= 1;
262 return tri;
263}

Callers 1

sphereHitsModelCBFunction · 0.50

Calls 4

xVec3CopyFunction · 0.85
xVec3SMulByFunction · 0.85
properSphereIsectTriFunction · 0.70
xVec3NormalizeFunction · 0.50

Tested by

no test coverage detected