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

Method InitBounds

src/SB/Game/zNPCTypeCommon.cpp:242–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240}
241
242void zNPCCommon::InitBounds()
243{
244 NPCConfig* cfg = this->cfg_npc;
245 xVec3 half = {};
246 xSphere* sph = &this->bound.sph;
247 xBBox* box = &this->bound.box;
248
249 if (cfg->useBoxBound)
250 {
251 this->bound.type = XBOUND_TYPE_BOX;
252 }
253 else
254 {
255 this->bound.type = XBOUND_TYPE_SPHERE;
256 }
257
258 S32 r28;
259 if (xVec3Length2(&cfg->off_bound) > 0.0f)
260 {
261 r28 = 1;
262 }
263 else
264 {
265 r28 = 0;
266 }
267
268 if (xVec3Length2(&cfg->dim_bound) > 0.0f)
269 {
270 xSceneID2Name(globals.sceneCur, this->id);
271 this->DBG_Name();
272
273 if (this->bound.type == XBOUND_TYPE_SPHERE)
274 {
275 sph->r = cfg->dim_bound.x;
276 xVec3Copy(&sph->center, xEntGetPos(this));
277 xVec3AddTo(&sph->center, &cfg->off_bound);
278 }
279 else
280 {
281 xVec3SMul(&half, &cfg->dim_bound, 0.5f);
282 xVec3Copy(&box->center, xEntGetPos(this));
283 xVec3AddTo(&box->center, &cfg->off_bound);
284 xVec3Add(&box->box.upper, &box->center, &half);
285 xVec3Sub(&box->box.lower, &box->center, &half);
286 }
287 }
288 else
289 {
290 xSceneID2Name(globals.sceneCur, this->id);
291 this->DBG_Name();
292
293 switch (this->bound.type)
294 {
295 case XBOUND_TYPE_SPHERE:
296 iSphereForModel(sph, this->model);
297 cfg->dim_bound.x = sph->r;
298 cfg->dim_bound.y = 0.0f;
299 cfg->dim_bound.z = 0.0f;

Callers 1

InitMethod · 0.95

Calls 11

DBG_NameMethod · 0.95
xVec3Length2Function · 0.85
xSceneID2NameFunction · 0.85
xVec3CopyFunction · 0.85
xEntGetPosFunction · 0.85
xVec3AddToFunction · 0.85
xVec3SMulFunction · 0.85
xVec3AddFunction · 0.85
xVec3SubFunction · 0.85
iBoxForModelFunction · 0.85
iSphereForModelFunction · 0.50

Tested by

no test coverage detected