Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
ModernEnvironment.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "ModernGltfMesh.hpp"
5
6#include <array>
7#include <cstdint>
8#include <filesystem>
9#include <functional>
10#include <string_view>
11#include <vector>
12
13namespace monopoly::engine
14{
15 inline constexpr std::size_t ModernEnvironmentCount = 3;
16 inline constexpr std::size_t ModernCityCount = 17;
17 // Logical identities belong only to the optional native modern scene.
18 // They are not retail bank/sequence IDs and never enter retail resolution.
19 inline constexpr std::uint16_t ModernEnvironmentLogicalGroup = 0xFFFB;
20 inline constexpr sequence::SequenceNodeId ModernEnvironmentNodeBase = 0x8000FFFB00000000ULL;
21
23 {
24 std::string_view slug;
25 std::string_view relativeGlbPath;
28 std::array<float, 3> originalYup{};
29 float localYawDegrees{-90.0F};
30 };
31 [[nodiscard]] const std::array<ModernEnvironmentDefinition, ModernEnvironmentCount>&
33
35 {
36 public:
37 using Diagnostic = std::function<void(std::string_view)>;
38 using Loader = std::function<std::expected<std::shared_ptr<const data::MeshRenderData>,
39 data::MeshRuntimeError>(const std::filesystem::path&, data::ModernGltfLoadOptions)>;
40
41 ModernEnvironment() = default;
42 explicit ModernEnvironment(std::filesystem::path modernAssetsRoot,
43 bool enabled = false, Diagnostic diagnostic = {}, Loader loader = {});
44 void setEnabled(bool enabled) noexcept { enabled_ = enabled; }
45 // Production uses half logical CPUs, bounded1..8 (unknown CPU count4).
46 // Explicit override is bounded1..8. An injected
47 // loader stays sequential unless its caller opts in and guarantees safety.
48 void setDecodeWorkers(unsigned workers) noexcept
49 { decodeWorkers_ = workers < 1 ? 1 : workers > 8 ? 8 : workers; }
50 [[nodiscard]] unsigned decodeWorkers() const noexcept { return decodeWorkers_; }
51 [[nodiscard]] bool enabled() const noexcept { return enabled_; }
52 // Renderer rejection permanently drops this owner's optional geometry.
53 // Pointer identity prevents unrelated/native-retail instances being rejected.
54 void rejectGeometry(const data::MeshRenderData* geometry);
55
56 // Caller must qualify the active board as an actual modern board mesh.
57 // The matrix is its real sequencer transform, including the retail .10
58 // scale. Geometry remains immutable; only these scene instances move.
59 [[nodiscard]] std::vector<sequence::SequenceMeshRenderItem> items(
60 const sequence::Matrix3D& boardMatrix, std::uint32_t tick,
61 bool includePresentation = false, bool includeLandmarks = true,
62 bool includeCity = false);
63
64 private:
65 void loadPending(const std::vector<std::size_t>& indices);
66 void report(std::string_view message) const;
67 std::filesystem::path root_;
68 bool enabled_{};
69 unsigned decodeWorkers_{4};
70 bool invalidMatrixReported_{};
71 Diagnostic diagnostic_;
72 Loader loader_;
73 std::array<bool, ModernEnvironmentCount + 2 + ModernCityCount> attempted_{};
74 std::array<std::shared_ptr<const data::MeshRuntimeAsset>, ModernEnvironmentCount + 2 + ModernCityCount> assets_{};
75 };
76}
bool enabled
Definition Engine.cpp:170
unsigned index
unsigned decodeWorkers() const noexcept
std::function< std::expected< std::shared_ptr< const data::MeshRenderData >, data::MeshRuntimeError >(const std::filesystem::path &, data::ModernGltfLoadOptions)> Loader
void setDecodeWorkers(unsigned workers) noexcept
std::function< void(std::string_view)> Diagnostic
void setEnabled(bool enabled) noexcept
std::uint32_t DataId
Definition DataBanks.hpp:10
constexpr std::size_t ModernCityCount
const std::array< ModernEnvironmentDefinition, ModernEnvironmentCount > & modernEnvironmentDefinitions() noexcept
constexpr std::size_t ModernEnvironmentCount
constexpr sequence::SequenceNodeId ModernEnvironmentNodeBase
constexpr std::uint16_t ModernEnvironmentLogicalGroup
std::uint64_t SequenceNodeId