@@ -85,6 +85,33 @@ public static List<CellLocation> GetGridPositions(Vector2d linestart, Vector2d l
8585 {
8686 ret = GetGridPositions61 ( linestart , lineend ) ;
8787 }
88+ else if ( gridversion == 60 )
89+ {
90+ Vector2d line_normal_unit = diff . Normalized ( ) . PerpendicularLeft ; // Does not depend on flipped
91+ Vector2d line_halfway = 0.5 * new Vector2d ( Math . Abs ( diff . X ) , Math . Abs ( diff . Y ) ) ;
92+ Vector2d line_midpoint = linestart + diff * 0.5 ;
93+ Vector2d absolute_normal = new Vector2d ( Math . Abs ( line_normal_unit . X ) , Math . Abs ( line_normal_unit . Y ) ) ;
94+
95+ for ( int cell_x = p1X ; cell_x <= p2X ; cell_x ++ )
96+ {
97+ for ( int cell_y = p1Y ; cell_y <= p2Y ; cell_y ++ )
98+ {
99+ Vector2d curr_pos = CellSize * new Vector2d ( cell_x + 0.5 , cell_y + 0.5 ) ;
100+ CellLocation next_cell_pos = CellInfo ( curr_pos . X , curr_pos . Y ) ;
101+ Vector2d dist_between_centers = line_midpoint - curr_pos ;
102+ double dist_from_cell_center = Vector2d . Dot ( absolute_normal , next_cell_pos . Remainder ) ;
103+ double cell_overlap_into_hitbox = Vector2d . Dot ( new Vector2d ( dist_from_cell_center , dist_from_cell_center ) , absolute_normal ) ;
104+ double norm_dist_between_centers = Vector2d . Dot ( line_normal_unit , dist_between_centers ) ;
105+ double dist_from_line = Math . Abs ( norm_dist_between_centers * line_normal_unit . X ) + Math . Abs ( norm_dist_between_centers * line_normal_unit . Y ) ;
106+ if ( line_halfway . X + next_cell_pos . Remainder . X >= Math . Abs ( dist_between_centers . X )
107+ && line_halfway . Y + next_cell_pos . Remainder . Y >= Math . Abs ( dist_between_centers . Y )
108+ && cell_overlap_into_hitbox >= dist_from_line )
109+ {
110+ ret . Add ( next_cell_pos ) ;
111+ }
112+ }
113+ }
114+ }
88115 return ret ;
89116 }
90117 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
0 commit comments