WIP
| 265 | |
| 266 | // WIP |
| 267 | void zLOD_UseCustomTable(xEnt* ent, zLODTable* lod) |
| 268 | { |
| 269 | xModelInstance* model = ent->model; |
| 270 | if (model == NULL || sManagerCount == 0) |
| 271 | { |
| 272 | return; |
| 273 | } |
| 274 | |
| 275 | for (U32 i = 0; i < sManagerCount; i++) |
| 276 | { |
| 277 | zLODManager* mgr = &sManagerList[i]; |
| 278 | |
| 279 | if (mgr->model == model) |
| 280 | { |
| 281 | mgr->lod = lod; |
| 282 | |
| 283 | F32 dist = xsqrt(lod->noRenderDist) + 10.0f; |
| 284 | mgr->adjustNoRenderDist = dist * dist; |
| 285 | |
| 286 | RwMatrix* mat = model->Mat; |
| 287 | F32 distscale = |
| 288 | mat->right.x * mat->right.x + mat->up.x * mat->up.x + mat->at.x * mat->at.x; |
| 289 | if (distscale < 0.0001f) |
| 290 | { |
| 291 | distscale = 1.0f; |
| 292 | } |
| 293 | |
| 294 | xVec3* camPos = &globals.camera.mat.pos; |
| 295 | F32 camdist2 = 0.0f; |
| 296 | if (mat) |
| 297 | { |
| 298 | camdist2 = ((camPos->x - mat->pos.x) * (camPos->x - mat->pos.x) + |
| 299 | (camPos->y - mat->pos.y) * (camPos->y - mat->pos.y) + |
| 300 | (camPos->z - mat->pos.z) * (camPos->z - mat->pos.z)) / |
| 301 | distscale; |
| 302 | } |
| 303 | |
| 304 | if (camdist2 < mgr->adjustNoRenderDist) |
| 305 | { |
| 306 | model->PipeFlags &= ~0x400; |
| 307 | |
| 308 | if (lod->baseBucket) |
| 309 | { |
| 310 | model->Bucket = lod->baseBucket; |
| 311 | model->Data = (*lod->baseBucket)->Data; |
| 312 | } |
| 313 | |
| 314 | S32 lodIndex; |
| 315 | for (lodIndex = 0; |
| 316 | lodIndex < 3 && lod->lodBucket[lodIndex] && lod->lodDist[lodIndex] < camdist2; |
| 317 | lodIndex++) |
| 318 | { |
| 319 | model->Bucket = lod->lodBucket[lodIndex]; |
| 320 | model->Data = (*lod->lodBucket[lodIndex])->Data; |
| 321 | } |
| 322 | |
| 323 | if (mgr->numextra) |
| 324 | { |
no test coverage detected