| 772 | }; |
| 773 | |
| 774 | bool TerrainBlock::castRayBlock( const Point3F &pStart, |
| 775 | const Point3F &pEnd, |
| 776 | const Point2I &aBlockPos, |
| 777 | U32 aLevel, |
| 778 | F32 invDeltaX, |
| 779 | F32 invDeltaY, |
| 780 | F32 aStartT, |
| 781 | F32 aEndT, |
| 782 | RayInfo *info, |
| 783 | bool collideEmpty ) |
| 784 | { |
| 785 | const U32 BlockSquareWidth = mFile->mSize; |
| 786 | const U32 GridLevels = mFile->mGridLevels; |
| 787 | const U32 BlockMask = mFile->mSize - 1; |
| 788 | |
| 789 | F32 invBlockSize = 1 / F32( BlockSquareWidth ); |
| 790 | |
| 791 | static Vector<TerrLOSStackNode> stack; |
| 792 | stack.setSize( GridLevels * 3 + 1 ); |
| 793 | U32 stackSize = 1; |
| 794 | |
| 795 | stack[0].startT = aStartT; |
| 796 | stack[0].endT = aEndT; |
| 797 | stack[0].blockPos = aBlockPos; |
| 798 | stack[0].level = aLevel; |
| 799 | |
| 800 | if( !aBlockPos.isZero() ) |
| 801 | return false; |
| 802 | |
| 803 | while(stackSize--) |
| 804 | { |
| 805 | TerrLOSStackNode *sn = stack.address() + stackSize; |
| 806 | U32 level = sn->level; |
| 807 | F32 startT = sn->startT; |
| 808 | F32 endT = sn->endT; |
| 809 | Point2I blockPos = sn->blockPos; |
| 810 | |
| 811 | const TerrainSquare *sq = mFile->findSquare( level, blockPos.x, blockPos.y ); |
| 812 | |
| 813 | F32 startZ = startT * (pEnd.z - pStart.z) + pStart.z; |
| 814 | F32 endZ = endT * (pEnd.z - pStart.z) + pStart.z; |
| 815 | |
| 816 | F32 minHeight = fixedToFloat(sq->minHeight); |
| 817 | if(startZ <= minHeight && endZ <= minHeight) |
| 818 | continue; |
| 819 | |
| 820 | F32 maxHeight = fixedToFloat(sq->maxHeight); |
| 821 | if(startZ >= maxHeight && endZ >= maxHeight) |
| 822 | continue; |
| 823 | |
| 824 | if ( !collideEmpty && ( sq->flags & TerrainSquare::Empty ) && |
| 825 | blockPos.x == ( blockPos.x & BlockMask ) && blockPos.y == ( blockPos.y & BlockMask )) |
| 826 | continue; |
| 827 | |
| 828 | if(level == 0) |
| 829 | { |
| 830 | F32 xs = blockPos.x * invBlockSize; |
| 831 | F32 ys = blockPos.y * invBlockSize; |
nothing calls this directly
no test coverage detected