3#include <tess/ops/queued.h>
4#include <tess/sim/path_agent_tick.h>
5#include <tess/sim/render_delta.h>
22 std::uint32_t pathing_dirty_mask = 0;
23 std::uint32_t render_dirty_mask = 0;
25 bool clear_render_dirty =
false;
26 std::uint32_t movement_dirty_mask = 0;
31 std::uint64_t tick = 0;
32 bool planned_ops =
false;
33 bool executed_ops =
false;
37 std::size_t render_delta_count = 0;
41template <
typename World, WritePolicy Policy,
typename Fn>
42auto run_queued_operations(
World& world,
const FrameOps& ops, Fn&& fn)
45 stats.op_report = plan_operations(world, ops);
46 stats.planned_ops = !ops.empty();
47 if (!stats.op_report.ok()) {
50 stats.op_execution = execute_plan<Policy>(world, stats.op_report.plan(), fn);
52 stats.op_execution.status == PlannedExecutionStatus::Executed;
63template <
typename World, WritePolicy Policy,
typename Fn,
typename PathTick>
64auto tick_scheduler_core(SimSchedulerState& state, World& world,
66 std::vector<RenderTileDelta>& render_deltas, Fn&& fn,
67 const SimSchedulerOptions& options,
68 PathTick&& path_tick) -> SimSchedulerStats {
70 run_queued_operations<World, Policy>(world, ops, std::forward<Fn>(fn));
76 const bool any_op_wrote =
77 stats.executed_ops || stats.op_execution.chunk_count > 0;
78 if (any_op_wrote && options.pathing_dirty_mask != 0) {
79 for (
const auto& report : stats.op_report.operations()) {
80 if (report.status == OperationStatus::Planned &&
81 (report.field_access.dirty_mask & options.pathing_dirty_mask) != 0) {
82 mark_pathing_dirty(state.path_agents);
88 stats.path_agents = path_tick();
89 stats.tick = stats.path_agents.tick;
91 const auto old_size = render_deltas.size();
92 collect_render_tile_deltas(world, options.render_dirty_mask, render_deltas);
93 stats.render_delta_count = render_deltas.size() - old_size;
94 if (options.clear_render_dirty) {
95 clear_render_delta_dirty(world, options.render_dirty_mask);
103template <
typename World,
typename PassableTag, WritePolicy Policy,
typename Fn>
105 const FrameOps& ops, std::span<PathAgentState> agents,
107 std::vector<RenderTileDelta>& render_deltas, Fn&& fn,
110 return detail::tick_scheduler_core<World, Policy>(
111 state, world, ops, render_deltas, std::forward<Fn>(fn), options, [&] {
112 return tick_unit_path_agents<World, PassableTag>(
113 state.path_agents, world, agents, runtime,
114 options.path_agent_options);
118template <
typename World,
typename PassableTag,
typename OccupancyTag,
119 typename ReservationTag, WritePolicy Policy,
typename Fn>
123 std::span<PathAgentState> agents,
125 std::vector<RenderTileDelta>& render_deltas,
128 return detail::tick_scheduler_core<World, Policy>(
129 state, world, ops, render_deltas, std::forward<Fn>(fn), options, [&] {
130 return tick_unit_path_agents_with_movement<
131 World, PassableTag, OccupancyTag, ReservationTag>(
132 state.path_agents, world, agents, runtime,
133 options.path_agent_options, options.movement_dirty_mask);
137template <
typename World,
typename PassableTag,
typename CostTag,
138 std::uint32_t MaxCost, WritePolicy Policy,
typename Fn>
142 std::span<PathAgentState> agents,
144 std::vector<RenderTileDelta>& render_deltas,
147 return detail::tick_scheduler_core<World, Policy>(
148 state, world, ops, render_deltas, std::forward<Fn>(fn), options, [&] {
149 return tick_weighted_path_agents<World, PassableTag, CostTag, MaxCost>(
150 state.path_agents, world, agents, runtime,
151 options.path_agent_options);
155template <
typename World,
typename PassableTag,
typename CostTag,
156 std::uint32_t MaxCost,
typename OccupancyTag,
typename ReservationTag,
157 WritePolicy Policy,
typename Fn>
159auto tick_weighted_movement_scheduler(
162 std::vector<RenderTileDelta>& render_deltas, Fn&& fn,
164 return detail::tick_scheduler_core<World, Policy>(
165 state, world, ops, render_deltas, std::forward<Fn>(fn), options, [&] {
166 return tick_weighted_path_agents_with_movement<
167 World, PassableTag, CostTag, MaxCost, OccupancyTag, ReservationTag>(
168 state.path_agents, world, agents, runtime,
169 options.path_agent_options, options.movement_dirty_mask);
Definition path_runtime.h:92
Configures per-tick movement, caching, and blocked-agent retry limits.
Definition path_agent_tick.h:29
Owns the shared clock, world-dirty flag, and retained routes across ticks.
Definition path_agent_tick.h:13
Summarizes path planning and movement performed during one tick.
Definition path_agent_tick.h:46
Definition phase_executor.h:63
Configures dirty propagation, path-agent work, and render-delta clearing.
Definition scheduler.h:21
Owns simulation subsystem state retained across scheduler ticks.
Definition scheduler.h:16
Summarizes queued operations, path agents, and render deltas for one tick.
Definition scheduler.h:30