Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
ModernTokenVariants.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "ModernGltfMesh.hpp"
4
5#include <array>
6#include <expected>
7#include <filesystem>
8#include <memory>
9#include <map>
10#include <optional>
11#include <span>
12#include <string_view>
13#include <vector>
14
15namespace monopoly::data
16{
18 {
20 // Relative to the runtime assets/modern directory.
21 std::string_view relativeGlbPath;
22 };
23
24 [[nodiscard]] const std::array<ModernTokenVariantDefinition, 2>&
37 [[nodiscard]] std::span<const ModernTokenVariantRootDefinition>
40 std::optional<DataId> rootSequenceDataId, std::uint16_t priority) noexcept;
41
42 // Immutable, transactionally loaded complete pack for one reviewed root. A
43 // malformed or missing state publishes no pack, including its good state.
44 // CNK remains the owner of mesh selection, clocks, transforms and visibility.
46 {
47 public:
48 [[nodiscard]] static std::expected<std::shared_ptr<const ModernTokenVariantPack>, MeshRuntimeError>
49 load(const std::filesystem::path& modernAssetsRoot,
51 [[nodiscard]] std::shared_ptr<const MeshRenderData> resolve(DataId meshId) const noexcept;
52 private:
54 std::vector<ModernTokenVariantDefinition> definitions_;
55 std::vector<std::shared_ptr<const MeshRenderData>> meshes_;
56 };
57
58 // Owner-thread cache. Root subsets publish transactionally, sharing lazy
59 // immutable HMD geometry. Root and geometry failures are remembered until
60 // owner reset; a failed root never publishes a partial modern subset.
62 {
63 public:
64 explicit ModernTokenVariantCache(std::filesystem::path modernAssetsRoot);
65 [[nodiscard]] std::shared_ptr<const MeshRenderData> resolve(DataId meshId,
66 std::optional<DataId> rootSequenceDataId, std::uint16_t priority);
67 [[nodiscard]] bool attempted() const noexcept;
68 [[nodiscard]] bool attempted(DataId rootSequenceDataId) const noexcept;
69 [[nodiscard]] const std::optional<MeshRuntimeError>& loadError() const noexcept;
70 [[nodiscard]] const std::optional<MeshRuntimeError>& loadError(DataId rootSequenceDataId) const noexcept;
71 // Presentation failure invalidates all roots requiring the shared state,
72 // including future roots, before retail views are republished.
73 // Disjoint root subsets remain available.
75 private:
76 std::filesystem::path root_;
78 struct Entry
79 {
80 bool attempted{};
81 std::shared_ptr<const ModernTokenVariantPack> pack;
82 std::optional<MeshRuntimeError> error;
83 };
84 struct GeometryEntry
85 {
86 bool attempted{};
87 // Retain rejected ownership so an address cannot be reused.
88 std::shared_ptr<const MeshRenderData> mesh;
89 std::optional<MeshRuntimeError> error;
90 };
91 [[nodiscard]] std::expected<std::shared_ptr<const ModernTokenVariantPack>, MeshRuntimeError>
92 loadRoot(DataId rootSequenceDataId);
93 [[nodiscard]] std::expected<std::shared_ptr<const MeshRenderData>, MeshRuntimeError>
94 loadGeometry(DataId meshId);
95 std::map<DataId, Entry> packs_;
96 std::map<DataId, GeometryEntry> geometry_;
97 std::optional<float> shipGroundBaseline_;
98 };
99}
std::uint16_t priority
unsigned index
Kind kind
std::string error
std::shared_ptr< const MeshRenderData > resolve(DataId meshId, std::optional< DataId > rootSequenceDataId, std::uint16_t priority)
bool rejectPack(const MeshRenderData *failedState)
const std::optional< MeshRuntimeError > & loadError() const noexcept
std::uint32_t DataId
Definition DataBanks.hpp:10
const std::array< ModernTokenVariantDefinition, 4 > & dogIdleVariantDefinitions() noexcept
std::span< const ModernTokenVariantRootDefinition > modernTokenVariantRootDefinitions() noexcept
const std::array< ModernTokenVariantDefinition, 6 > & horseIdleVariantDefinitions() noexcept
bool qualifiedModernTokenVariantSequence(DataId meshId, std::optional< DataId > rootSequenceDataId, std::uint16_t priority) noexcept
const std::array< ModernTokenVariantDefinition, 2 > & shipMovementVariantDefinitions() noexcept