| 2543 | } |
| 2544 | |
| 2545 | S32 zNPCCommon::HaveLOSToPos(xVec3* pos, F32 dist, xScene* xscn, xBase* tgt, xCollis* colCallers) |
| 2546 | { |
| 2547 | S32 result; |
| 2548 | xRay3 ray = {}; |
| 2549 | xVec3 mypos = {}; |
| 2550 | |
| 2551 | xCollis* colrec; |
| 2552 | if (colCallers) |
| 2553 | { |
| 2554 | colrec = colCallers; |
| 2555 | } |
| 2556 | else |
| 2557 | { |
| 2558 | static xCollis localCollis = { k_HIT_0xF00 | k_HIT_CALC_HDNG }; |
| 2559 | memset(&localCollis, 0, sizeof(localCollis)); |
| 2560 | localCollis.flags = k_HIT_0xF00 | k_HIT_CALC_HDNG; |
| 2561 | |
| 2562 | colrec = &localCollis; |
| 2563 | } |
| 2564 | |
| 2565 | this->DBG_PStatCont(eNPCPerfEnable); |
| 2566 | this->DBG_PStatOn(eNPCPerfDisable); |
| 2567 | |
| 2568 | if (!this->GetVertPos(NPC_MDLVERT_LOSEYEBALL, &mypos)) |
| 2569 | { |
| 2570 | xVec3Copy(&mypos, xEntGetCenter(this)); |
| 2571 | } |
| 2572 | |
| 2573 | NPCC_xBoundAway(&this->bound); |
| 2574 | |
| 2575 | ray.min_t = 0.0f; |
| 2576 | ray.max_t = dist; |
| 2577 | xVec3Sub(&ray.dir, pos, &mypos); |
| 2578 | xVec3Normalize(&ray.dir, &ray.dir); |
| 2579 | xVec3Copy(&ray.origin, &mypos); |
| 2580 | ray.flags = XRAY3_USE_MIN | XRAY3_USE_MAX; |
| 2581 | xRayHitsScene(xscn, &ray, colrec); |
| 2582 | |
| 2583 | NPCC_xBoundBack(&this->bound); |
| 2584 | |
| 2585 | if (!(colrec->flags & k_HIT_IT)) |
| 2586 | { |
| 2587 | result = 1; |
| 2588 | } |
| 2589 | else if (colrec->dist > dist) |
| 2590 | { |
| 2591 | result = 1; |
| 2592 | } |
| 2593 | else if (tgt && colrec->oid) |
| 2594 | { |
| 2595 | if (tgt->id == colrec->oid) |
| 2596 | { |
| 2597 | result = 1; |
| 2598 | } |
| 2599 | else |
| 2600 | { |
| 2601 | result = 0; |
| 2602 | } |
no test coverage detected