Profiling and optimization of tiles rendering done...

This commit is contained in:
Ognjen Milan Robovic 2024-05-27 11:31:03 -04:00
parent 9ef53ed704
commit 7b57ad4bd1
2 changed files with 40 additions and 26 deletions

View File

@ -320,22 +320,22 @@ begin
--
ui.write (core.framerate'image, core.window_width - 5 * core.icon + 3, core.window_height - 27);
--
ui.write ("draw_tiles_timer :" & world.draw_tiles_timer'image, 1400, 700 - 40, size => 15, code => true);
ui.write ("draw_views_timer :" & world.draw_views_timer'image, 1400, 720 - 40, size => 15, code => true);
ui.write ("draw_landmarks_timer :" & world.draw_landmarks_timer'image, 1400, 740 - 40, size => 15, code => true);
ui.write ("draw_locations_timer :" & world.draw_locations_timer'image, 1400, 760 - 40, size => 15, code => true);
ui.write ("draw_constructions_timer :" & world.draw_constructions_timer'image, 1400, 780 - 40, size => 15, code => true);
ui.write ("draw_equipments_timer :" & world.draw_equipments_timer'image, 1400, 800 - 40, size => 15, code => true);
ui.write ("draw_units_timer :" & world.draw_units_timer'image, 1400, 820 - 40, size => 15, code => true);
ui.write ("draw_world_timer :" & world.draw_world_timer'image, 1400, 840 - 40, size => 15, code => true);
ui.write ("draw_tiles_timer :" & world.draw_tiles_timer'image, 1440, 700 - 40, size => 15, code => true);
ui.write ("draw_views_timer :" & world.draw_views_timer'image, 1440, 720 - 40, size => 15, code => true);
ui.write ("draw_landmarks_timer :" & world.draw_landmarks_timer'image, 1440, 740 - 40, size => 15, code => true);
ui.write ("draw_locations_timer :" & world.draw_locations_timer'image, 1440, 760 - 40, size => 15, code => true);
ui.write ("draw_constructions_timer :" & world.draw_constructions_timer'image, 1440, 780 - 40, size => 15, code => true);
ui.write ("draw_equipments_timer :" & world.draw_equipments_timer'image, 1440, 800 - 40, size => 15, code => true);
ui.write ("draw_units_timer :" & world.draw_units_timer'image, 1440, 820 - 40, size => 15, code => true);
ui.write ("draw_world_timer :" & world.draw_world_timer'image, 1440, 840 - 40, size => 15, code => true);
--
ui.write (world.drawn_tiles'image, 1360, 700 - 40, size => 15, code => true, tint => (255, 0, 0, 255));
ui.write (world.drawn_views'image, 1360, 720 - 40, size => 15, code => true, tint => (255, 0, 0, 255));
ui.write (world.drawn_landmarks'image, 1360, 740 - 40, size => 15, code => true, tint => (255, 0, 0, 255));
ui.write (world.drawn_locations'image, 1360, 760 - 40, size => 15, code => true, tint => (255, 0, 0, 255));
ui.write (world.drawn_constructions'image, 1360, 780 - 40, size => 15, code => true, tint => (255, 0, 0, 255));
ui.write (world.drawn_equipments'image, 1360, 800 - 40, size => 15, code => true, tint => (255, 0, 0, 255));
ui.write (world.drawn_units'image, 1360, 820 - 40, size => 15, code => true, tint => (255, 0, 0, 255));
ui.write (world.drawn_tiles'image, 1380, 700 - 40, size => 15, code => true, tint => (255, 0, 0, 255));
ui.write (world.drawn_views'image, 1380, 720 - 40, size => 15, code => true, tint => (255, 0, 0, 255));
ui.write (world.drawn_landmarks'image, 1380, 740 - 40, size => 15, code => true, tint => (255, 0, 0, 255));
ui.write (world.drawn_locations'image, 1380, 760 - 40, size => 15, code => true, tint => (255, 0, 0, 255));
ui.write (world.drawn_constructions'image, 1380, 780 - 40, size => 15, code => true, tint => (255, 0, 0, 255));
ui.write (world.drawn_equipments'image, 1380, 800 - 40, size => 15, code => true, tint => (255, 0, 0, 255));
ui.write (world.drawn_units'image, 1380, 820 - 40, size => 15, code => true, tint => (255, 0, 0, 255));
--
core.camera.x := world.map.chads (1).x;
core.camera.y := world.map.chads (1).y;

View File

@ -355,8 +355,11 @@ package body world is
------------------------------------------------------------------------------------------
procedure draw is
offset : core.vector := ((core.window_width - core.base) / 2,
(core.window_height - core.base) / 2);
offset : core.vector := ((core.window_width - core.base) / 2, (core.window_height - core.base) / 2);
view_from : core.vector := (core.camera.x - core.window_width / core.base / core.zoom / 2, core.camera.y - core.window_height / core.base / core.zoom / 2);
view_to : core.vector := (core.window_width / core.base / core.zoom, core.window_height / core.base / core.zoom);
--
start_x, start_y : integer;
--
time_0 : float := 0.0;
time_1 : float := 0.0;
@ -372,6 +375,11 @@ package body world is
drawn_equipments := 0;
drawn_units := 0;
--
view_from.x := core.clip (view_from.x, 0, map.width - 1);
view_from.y := core.clip (view_from.y, 0, map.height - 1);
view_to.x := core.clip (view_to.x, 0, map.width - 1);
view_to.y := core.clip (view_to.y, 0, map.height - 1);
--
for vertical in 0 .. map.height - 1 loop
exit when offset.y + (vertical - core.camera.y) * core.base * core.zoom > core.window_height;
--
@ -400,11 +408,17 @@ package body world is
core.draw (corner_lower_right, x - core.base * core.zoom + width, y - core.base * core.zoom + height, factor => core.zoom);
end;
--
for vertical in 0 .. map.height - 1 loop
exit when offset.y + (vertical - core.camera.y) * core.base * core.zoom > core.window_height;
start_y := core.camera.y - core.window_height / core.base / core.zoom;
start_y := (if start_y < 0 then 0 else start_y);
--
for vertical in view_from.y .. view_from.y + view_to.y loop
exit when vertical > map.height - 1;
--
for horizontal in 0 .. map.width - 1 loop
exit when offset.x + (horizontal - core.camera.x) * core.base * core.zoom > core.window_width;
start_x := core.camera.x - core.window_width / core.base / core.zoom;
start_x := (if start_x < 0 then 0 else start_x);
--
for horizontal in view_from.x .. view_from.x + view_to.x loop
exit when horizontal > map.width - 1;
--
if map.views (horizontal, vertical) then
core.draw (data => tiles (map.kind),
@ -435,17 +449,17 @@ package body world is
if core.animation_time = 0 then draw_tiles_timer := core.time - time_0; time_0 := core.time; end if;
--
for index in 1 .. landmark_limit loop
if map.views (map.landmarks (index).x, map.landmarks (index).y) then
if map.views (map.landmarks (index).x, map.landmarks (index).y) then
core.draw (data => landmarks (landmark_index'val (map.landmarks (index).index)),
x => offset.x + (map.landmarks (index).x - core.camera.x) * core.base * core.zoom,
y => offset.y + (map.landmarks (index).y - core.camera.y) * core.base * core.zoom);
--
core.increment (drawn_landmarks);
--
if core.cursor_inside (x => offset.x + (map.landmarks (index).x - core.camera.x) * core.base * core.zoom,
y => offset.y + (map.landmarks (index).y - core.camera.y) * core.base * core.zoom,
width => landmarks (landmark_index'val (map.landmarks (index).index)).width,
height => landmarks (landmark_index'val (map.landmarks (index).index)).height)
if core.cursor_inside (x => offset.x + (map.landmarks (index).x - core.camera.x) * core.base * core.zoom,
y => offset.y + (map.landmarks (index).y - core.camera.y) * core.base * core.zoom,
width => landmarks (landmark_index'val (map.landmarks (index).index)).width,
height => landmarks (landmark_index'val (map.landmarks (index).index)).height)
and core.cursor_mode = core.cursor_middle
and not ui.prioritize then
core.write_text_box (landmark_trait (landmark_index'val (map.landmarks (index).index)).name);