From a5351bb4c5bb516ba74598f650a8302e6f9126af Mon Sep 17 00:00:00 2001 From: xolatile Date: Mon, 27 May 2024 11:51:57 -0400 Subject: [PATCH] Finished general world rendering profiling and added rendering caps... --- source/world.adb | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/source/world.adb b/source/world.adb index 85c2440..31e7791 100644 --- a/source/world.adb +++ b/source/world.adb @@ -359,8 +359,6 @@ package body world is 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; begin @@ -408,15 +406,9 @@ 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; -- - 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; -- - 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; -- @@ -449,7 +441,9 @@ 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) + and map.landmarks (index).x > view_from.x and map.landmarks (index).x < view_from.x + view_to.x + and map.landmarks (index).y > view_from.y and map.landmarks (index).y < view_from.y + view_to.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); @@ -470,7 +464,9 @@ package body world is if core.animation_time = 0 then draw_landmarks_timer := core.time - time_0; time_0 := core.time; end if; -- for index in 1 .. location_limit loop - if map.views (map.locations (index).x, map.locations (index).y) then + if map.views (map.locations (index).x, map.locations (index).y) + and map.locations (index).x > view_from.x and map.locations (index).x < view_from.x + view_to.x + and map.locations (index).y > view_from.y and map.locations (index).y < view_from.y + view_to.y then core.draw (data => locations (location_index'val (map.locations (index).index)), x => offset.x + (map.locations (index).x - core.camera.x) * core.base * core.zoom, y => offset.y + (map.locations (index).y - core.camera.y) * core.base * core.zoom, @@ -508,7 +504,9 @@ package body world is if core.animation_time = 0 then draw_locations_timer := core.time - time_0; time_0 := core.time; end if; -- for index in 1 .. construction_limit loop - if map.views (map.constructions (index).x, map.constructions (index).y) then + if map.views (map.constructions (index).x, map.constructions (index).y) + and map.constructions (index).x > view_from.x and map.constructions (index).x < view_from.x + view_to.x + and map.constructions (index).y > view_from.y and map.constructions (index).y < view_from.y + view_to.y then construction.draw_plus (construction.enumeration'val (map.constructions (index).index), offset.x + (map.constructions (index).x - core.camera.x) * core.base * core.zoom, offset.y + (map.constructions (index).y - core.camera.y) * core.base * core.zoom); @@ -520,7 +518,9 @@ package body world is if core.animation_time = 0 then draw_constructions_timer := core.time - time_0; time_0 := core.time; end if; -- for index in 1 .. equipment_limit loop - if map.views (map.equipments (index).x, map.equipments (index).y) then + if map.views (map.equipments (index).x, map.equipments (index).y) + and map.equipments (index).x > view_from.x and map.equipments (index).x < view_from.x + view_to.x + and map.equipments (index).y > view_from.y and map.equipments (index).y < view_from.y + view_to.y then equipment.draw_plus (equipment.enumeration'val (map.equipments (index).index), core.idle, offset.x + (map.equipments (index).x - core.camera.x) * core.base * core.zoom, @@ -541,7 +541,9 @@ package body world is if core.animation_time = 0 then draw_equipments_timer := core.time - time_0; time_0 := core.time; end if; -- for index in 1 .. unit_limit loop - if map.views (map.units (index).x, map.units (index).y) then + if map.views (map.units (index).x, map.units (index).y) + and map.units (index).x > view_from.x and map.units (index).x < view_from.x + view_to.x + and map.units (index).y > view_from.y and map.units (index).y < view_from.y + view_to.y then unit.draw (unit.enumeration'val (map.units (index).index), core.animation'val (map.units (index).state), offset.x + (map.units (index).x - core.camera.x) * core.base * core.zoom, @@ -561,11 +563,16 @@ package body world is end if; end loop; -- - for vertical in 0 .. map.height - 1 loop - exit when offset.y + (vertical - core.camera.y) * core.base * core.zoom > core.window_height; + 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; + for horizontal in view_from.x .. view_from.x + view_to.x loop + exit when horizontal > map.width - 1; + --~for vertical in 0 .. map.height - 1 loop + --~exit when offset.y + (vertical - core.camera.y) * core.base * core.zoom > core.window_height; + --~-- + --~for horizontal in 0 .. map.width - 1 loop + --~exit when offset.x + (horizontal - core.camera.x) * core.base * core.zoom > core.window_width; -- if (horizontal - core.camera.x) ** 2 + (vertical - core.camera.y) ** 2 > view_reach then core.draw (data => dark,