3#include <tess/ops/queued.h>
4#include <tess/sim/path_agent_tick.h>
5#include <tess/sim/render_delta.h>
25 bool clear_render_dirty =
false;
30 std::uint64_t tick = 0;
31 bool planned_ops =
false;
32 bool executed_ops =
false;
36 std::size_t render_delta_count = 0;
40template <
typename World, WritePolicy Policy,
typename Fn>
44 stats.op_report = plan_operations(world, ops);
45 stats.planned_ops = !ops.empty();
46 if (!stats.op_report.ok()) {
49 stats.op_execution = execute_plan<Policy>(world, stats.op_report.plan(), fn);
51 stats.op_execution.status == PlannedExecutionStatus::Executed;
62template <
typename World, WritePolicy Policy,
typename Fn,
typename PathTick>
63auto tick_scheduler_core(SimSchedulerState& state, World& world,
64 const OperationBatch& ops,
65 std::vector<RenderTileDelta>& render_deltas, Fn&& fn,
66 const SimSchedulerOptions& options,
67 PathTick&& path_tick) -> SimSchedulerStats {
69 run_queued_operations<World, Policy>(world, ops, std::forward<Fn>(fn));
75 const bool any_op_wrote =
76 stats.executed_ops || stats.op_execution.chunk_count > 0;
77 if (any_op_wrote && options.pathing_dirty_mask) {
78 for (
const auto& report : stats.op_report.operations()) {
79 if (report.status == OperationStatus::Planned &&
80 (report.field_access.dirty_mask & options.pathing_dirty_mask)) {
81 mark_pathing_dirty(state.path_agents);
87 stats.path_agents = path_tick();
88 stats.tick = stats.path_agents.tick;
90 const auto old_size = render_deltas.size();
91 collect_render_tile_deltas(render_deltas, world, options.render_dirty_mask);
92 stats.render_delta_count = render_deltas.size() - old_size;
93 if (options.clear_render_dirty) {
94 clear_render_delta_dirty(world, options.render_dirty_mask);
102template <
typename World,
typename PassableTag, WritePolicy Policy,
typename Fn>
105 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);
137template <
typename World,
typename Class, std::uint32_t MaxCost,
138 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, Class, MaxCost>(
150 state.path_agents, world, agents, runtime,
151 options.path_agent_options);
155template <
typename World,
typename Class, std::uint32_t MaxCost,
156 typename OccupancyTag,
typename ReservationTag, WritePolicy Policy,
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, Class, MaxCost, OccupancyTag, ReservationTag>(
168 state.path_agents, world, agents, runtime,
169 options.path_agent_options);
Definition path_runtime.h:197
Definition metadata_types.h:12
Configures per-tick movement, caching, and blocked-agent retry limits.
Definition path_agent_tick.h:84
Definition path_agent_tick.h:17
Summarizes path planning and movement performed during one tick.
Definition path_agent_tick.h:531
Definition phase_executor.h:65
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:29