@@ -53,20 +53,22 @@ func _draw_cartesian_grid(target_rect: Rect2i) -> void:
53
53
func _draw_isometric_grid (target_rect : Rect2i ) -> void :
54
54
var grid_multiline_points := PackedVector2Array ()
55
55
56
- var cell_size := Global .isometric_grid_size
57
- var max_cell_count := target_rect .size / cell_size
58
- var origin_offset := Vector2 (Global .grid_offset - target_rect .position ).posmodv (cell_size )
56
+ var cell_size : Vector2 = Global .isometric_grid_size
57
+ var max_cell_count : Vector2 = Vector2 (target_rect .size ) / cell_size
58
+ var origin_offset : Vector2 = Vector2 (Global .grid_offset - target_rect .position ).posmodv (
59
+ cell_size
60
+ )
59
61
60
62
# lines ↗↗↗ (from bottom-left to top-right)
61
- var per_cell_offset : = cell_size * Vector2i (1 , - 1 )
63
+ var per_cell_offset : Vector2 = cell_size * Vector2 (1 , - 1 )
62
64
63
65
# lines ↗↗↗ starting from the rect's left side (top to bottom):
64
66
var y : float = fposmod (
65
67
origin_offset .y + cell_size .y * (0.5 + origin_offset .x / cell_size .x ), cell_size .y
66
68
)
67
69
while y < target_rect .size .y :
68
- var start : Vector2 = target_rect .position + Vector2i (0 , y )
69
- var cells_to_rect_bounds : = minf (max_cell_count .x , y / cell_size .y )
70
+ var start : Vector2 = Vector2 ( target_rect .position ) + Vector2 (0 , y )
71
+ var cells_to_rect_bounds : float = minf (max_cell_count .x , y / cell_size .y )
70
72
var end := start + cells_to_rect_bounds * per_cell_offset
71
73
grid_multiline_points .push_back (start )
72
74
grid_multiline_points .push_back (end )
@@ -75,8 +77,8 @@ func _draw_isometric_grid(target_rect: Rect2i) -> void:
75
77
# lines ↗↗↗ starting from the rect's bottom side (left to right):
76
78
var x : float = (y - target_rect .size .y ) / cell_size .y * cell_size .x
77
79
while x < target_rect .size .x :
78
- var start : Vector2 = target_rect .position + Vector2i (x , target_rect .size .y )
79
- var cells_to_rect_bounds : = minf (max_cell_count .y , max_cell_count .x - x / cell_size .x )
80
+ var start : Vector2 = Vector2 ( target_rect .position ) + Vector2 (x , target_rect .size .y )
81
+ var cells_to_rect_bounds : float = minf (max_cell_count .y , max_cell_count .x - x / cell_size .x )
80
82
var end : Vector2 = start + cells_to_rect_bounds * per_cell_offset
81
83
grid_multiline_points .push_back (start )
82
84
grid_multiline_points .push_back (end )
@@ -88,8 +90,8 @@ func _draw_isometric_grid(target_rect: Rect2i) -> void:
88
90
# lines ↘↘↘ starting from the rect's left side (top to bottom):
89
91
y = fposmod (origin_offset .y - cell_size .y * (0.5 + origin_offset .x / cell_size .x ), cell_size .y )
90
92
while y < target_rect .size .y :
91
- var start : Vector2 = target_rect .position + Vector2i (0 , y )
92
- var cells_to_rect_bounds : = minf (max_cell_count .x , max_cell_count .y - y / cell_size .y )
93
+ var start : Vector2 = Vector2 ( target_rect .position ) + Vector2 (0 , y )
94
+ var cells_to_rect_bounds : float = minf (max_cell_count .x , max_cell_count .y - y / cell_size .y )
93
95
var end : Vector2 = start + cells_to_rect_bounds * per_cell_offset
94
96
grid_multiline_points .push_back (start )
95
97
grid_multiline_points .push_back (end )
@@ -98,8 +100,8 @@ func _draw_isometric_grid(target_rect: Rect2i) -> void:
98
100
# lines ↘↘↘ starting from the rect's top side (left to right):
99
101
x = fposmod (origin_offset .x - cell_size .x * (0.5 + origin_offset .y / cell_size .y ), cell_size .x )
100
102
while x < target_rect .size .x :
101
- var start : Vector2 = target_rect .position + Vector2i (x , 0 )
102
- var cells_to_rect_bounds : = minf (max_cell_count .y , max_cell_count .x - x / cell_size .x )
103
+ var start : Vector2 = Vector2 ( target_rect .position ) + Vector2 (x , 0 )
104
+ var cells_to_rect_bounds : float = minf (max_cell_count .y , max_cell_count .x - x / cell_size .x )
103
105
var end : Vector2 = start + cells_to_rect_bounds * per_cell_offset
104
106
grid_multiline_points .push_back (start )
105
107
grid_multiline_points .push_back (end )
0 commit comments