Trace bounded settler paths and their consulted voxel revisions
This commit is contained in:
1 parent
6d1123e172
commit
ee1eca7571
4 files changed
+401
No files matched your search
@@ -0,0 +1,84 @@
|
||||
#pragma once
|
||||
|
||||
#include "settlement/core/voxel_region.hpp"
|
||||
#include <Void/Core/Uuid.hpp>
|
||||
#include <cstddef>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <stop_token>
|
||||
#include <vector>
|
||||
|
||||
namespace settlement {
|
||||
|
||||
enum class VoxelNavigationStatus {
|
||||
Reachable, Unreachable, Unavailable, SearchBoundary, LimitExceeded,
|
||||
Cancelled, InvalidInput, AllocationFailed
|
||||
};
|
||||
|
||||
struct VoxelNavigationLimits {
|
||||
std::size_t max_vertices = 65'536;
|
||||
std::size_t max_steps = 1'000'000;
|
||||
std::size_t max_samples = 4'000'000;
|
||||
std::size_t max_scratch_bytes = 8 * 1024 * 1024;
|
||||
std::size_t max_goals = 64;
|
||||
std::size_t max_dependencies = 4096;
|
||||
};
|
||||
|
||||
struct VoxelReadSet {
|
||||
RegionId region = 0;
|
||||
Void::Uuid::Uuid session;
|
||||
// Sorted unique chunk coordinates, including blocked and unavailable reads.
|
||||
std::vector<ChunkStamp> chunks;
|
||||
[[nodiscard]] bool current(const VoxelRegion& world, const Void::Uuid::Uuid& epoch) const noexcept;
|
||||
};
|
||||
|
||||
struct VoxelTraversalResult {
|
||||
VoxelNavigationStatus status = VoxelNavigationStatus::InvalidInput;
|
||||
VoxelReadSet consulted;
|
||||
};
|
||||
|
||||
struct VoxelPathRequest {
|
||||
RegionId region = 0;
|
||||
Void::Uuid::Uuid session;
|
||||
VoxelPosition start;
|
||||
// The caller chooses a finite search window contained in the region.
|
||||
VoxelBounds search_bounds;
|
||||
std::vector<VoxelPosition> goals;
|
||||
VoxelNavigationLimits limits;
|
||||
};
|
||||
|
||||
struct VoxelPathResult {
|
||||
VoxelNavigationStatus status = VoxelNavigationStatus::InvalidInput;
|
||||
std::optional<VoxelPosition> goal;
|
||||
// Excludes start, includes goal. An already satisfied goal has an empty route.
|
||||
std::vector<VoxelPosition> route;
|
||||
std::size_t cost = 0;
|
||||
std::size_t visited = 0;
|
||||
VoxelReadSet consulted;
|
||||
};
|
||||
|
||||
// Ordinary settlers occupy the foot cell and the cell above, with solid support
|
||||
// below. A transition is one cardinal horizontal move and at most one step.
|
||||
[[nodiscard]] VoxelTraversalResult voxel_standing(
|
||||
const VoxelRegion& world, const Void::Uuid::Uuid& session, VoxelPosition foot,
|
||||
VoxelNavigationLimits limits = {}, std::stop_token stop = {});
|
||||
[[nodiscard]] VoxelTraversalResult voxel_transition(
|
||||
const VoxelRegion& world, const Void::Uuid::Uuid& session,
|
||||
VoxelPosition from, VoxelPosition to, VoxelNavigationLimits limits = {},
|
||||
std::stop_token stop = {});
|
||||
|
||||
// Finds a shortest known route within the requested window. Equal costs choose
|
||||
// the lexicographically first goal; each vertex's neighbors use coordinate order.
|
||||
// A negative result distinguishes missing chunks and an escapable window edge.
|
||||
[[nodiscard]] VoxelPathResult find_voxel_path(
|
||||
const VoxelRegion& world, const VoxelPathRequest& request, std::stop_token stop = {});
|
||||
|
||||
// Candidate feet touch the target by a face of either body cell, or stand one
|
||||
// cell above / two below it. The target must be loaded. Work policy stays with
|
||||
// the owner; navigation only proves contact and a supported clear body volume.
|
||||
// request.goals is ignored; the same bounds, identity and limits apply.
|
||||
[[nodiscard]] VoxelPathResult find_voxel_interaction_path(
|
||||
const VoxelRegion& world, const VoxelPathRequest& request,
|
||||
VoxelPosition target, std::stop_token stop = {});
|
||||
|
||||
} // namespace settlement
|
||||
Reference in new issue
Block a user