| 240 | } |
| 241 | |
| 242 | void 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; |
no test coverage detected