NOLINTNEXTLINE(cata-xy)
| 24 | |
| 25 | // NOLINTNEXTLINE(cata-xy) |
| 26 | static void oldCastLight( float ( &output_cache )[MAPSIZE * SEEX][MAPSIZE * SEEY], |
| 27 | const float ( &input_array )[MAPSIZE * SEEX][MAPSIZE * SEEY], |
| 28 | const int xx, const int xy, const int yx, const int yy, |
| 29 | const int offsetX, const int offsetY, const int offsetDistance, |
| 30 | const int row = 1, float start = 1.0f, const float end = 0.0f ) |
| 31 | { |
| 32 | |
| 33 | float newStart = 0.0f; |
| 34 | const float radius = 60.0f - offsetDistance; |
| 35 | if( start < end ) { |
| 36 | return; |
| 37 | } |
| 38 | bool blocked = false; |
| 39 | tripoint delta; |
| 40 | for( int distance = row; distance <= radius && !blocked; distance++ ) { |
| 41 | delta.y = -distance; |
| 42 | for( delta.x = -distance; delta.x <= 0; delta.x++ ) { |
| 43 | const point current( offsetX + delta.x * xx + delta.y * xy, offsetY + delta.x * yx + delta.y * yy ); |
| 44 | const float leftSlope = ( delta.x - 0.5f ) / ( delta.y + 0.5f ); |
| 45 | const float rightSlope = ( delta.x + 0.5f ) / ( delta.y - 0.5f ); |
| 46 | |
| 47 | if( start < rightSlope ) { |
| 48 | continue; |
| 49 | } else if( end > leftSlope ) { |
| 50 | break; |
| 51 | } |
| 52 | |
| 53 | //check if it's within the visible area and mark visible if so |
| 54 | if( rl_dist( tripoint_zero, delta ) <= radius ) { |
| 55 | output_cache[current.x][current.y] = VISIBILITY_FULL; |
| 56 | } |
| 57 | |
| 58 | if( blocked ) { |
| 59 | //previous cell was a blocking one |
| 60 | if( input_array[current.x][current.y] == LIGHT_TRANSPARENCY_SOLID ) { |
| 61 | //hit a wall |
| 62 | newStart = rightSlope; |
| 63 | } else { |
| 64 | blocked = false; |
| 65 | start = newStart; |
| 66 | } |
| 67 | } else { |
| 68 | if( input_array[current.x][current.y] == LIGHT_TRANSPARENCY_SOLID && |
| 69 | distance < radius ) { |
| 70 | //hit a wall within sight line |
| 71 | blocked = true; |
| 72 | oldCastLight( output_cache, input_array, xx, xy, yx, yy, |
| 73 | offsetX, offsetY, offsetDistance, distance + 1, start, leftSlope ); |
| 74 | newStart = rightSlope; |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | /* |
| 82 | * This is checking whether bresenham visibility checks match shadowcasting (they don't). |
no test coverage detected