Bicameral Engine
GPU-resident engine for a magic-research open-world game
Loading...
Searching...
No Matches
debug_view_controller.h
Go to the documentation of this file.
1// debug_view_controller.h — デバッグ表示の操作: 窓の入力を、カメラ・表示の切り替え・つつくセルに振り分ける(T-0015)。
2//
3// データの流れ: platform/window の入力のイベント → HandleInput → カメラと表示の設定(View の状態。世界には入らない)
4// + つつくセル(フレームのループがコマンドにする。06 §3)→ Constants() が描画の定数(render/probe_view_constants.h)を作る。
5// 操作: 左クリック = つつく / Shift + 左クリック = 光線の先の物を押す(T-0098)/ 右ドラッグ = 回る / 中ドラッグ = 平行移動 / ホイール = 寄る / 1・2・3 = 表示 / X・Y・Z = 断面の軸 /
6// Q・E = 断面を動かす(Shift で 8) / B = 活性なブロック / L = 対数・線形 / C = 色分けする量(温度・O2 の減り・CO2・炭)/
7// O = 透視・平行 / R = カメラを戻す /
8// T = 連鎖のトレースを頼む(どこを何刻みかはフレームのループが決める。T-0088)/
9// P = カーソルの下の断面のセルを覗く(覗き窓。T-0096)/ Shift + P = やめる / PageDown・PageUp = 潜る・浮かぶ(カメラが点に寄る)。
10// 設定が変わったらログに出す(画面に文字はまだ無い。12 §5)。
11#pragma once
12
13#include <cstdint>
14#include <span>
15#include <string>
16#include <string_view>
17#include <vector>
18
19#include "platform/input.h"
20#include "render/debug_camera.h"
22
23namespace bicameral::render {
24
25 // 覗き窓の段の数(sim/probe_peek.h の PEEK_LEVEL_COUNT。frame_loop.cpp が static_assert で揃える)
26 inline constexpr uint32_t PEEK_MAX_DEPTH = 9;
27
28 // 覗き窓(View の状態。世界には入らない。T-0096)
29 struct PeekView {
30 bool peeking = false;
31 CellCoordinate cell; // 覗いている世界のセル
32 uint32_t depth = 0; // 潜っている段(0〜PEEK_MAX_DEPTH。カメラの寄り方と枠の色だけ)
33
34 bool operator==(const PeekView&) const = default;
35 };
36
39 uint32_t sliceAxis = 2; // 0 = x・1 = y・2 = z
40 uint32_t slicePosition = 32; // 断面のセルの番号(クリックがつつく面)
41 bool showActiveBlocks = true;
42 bool logarithmic = true;
44 };
45
47 public:
48 DebugViewController(uint32_t gridSize, const DebugViewSettings& settings, const OrbitCameraState& camera);
49
50 // 入力を振り分け、つつくセル(左クリックの光線が断面に当たった所。古い順)を返す。width・height は描く大きさ(px)
51 [[nodiscard]] std::vector<CellCoordinate> HandleInput(std::span<const InputEvent> events, uint32_t width,
52 uint32_t height);
53
54 [[nodiscard]] ProbeViewConstants Constants(uint32_t extractionIndex, uint32_t width, uint32_t height) const;
55 [[nodiscard]] const DebugViewSettings& Settings() const { return m_settings; }
56 [[nodiscard]] const OrbitCamera& Camera() const { return m_camera; }
57 [[nodiscard]] std::string Describe() const; // 今の設定を 1 行で(ログ用)
58
59 // 前に呼んでから T が押されたか(押されていたら true を返して忘れる)
60 [[nodiscard]] bool TakeTraceRequest();
61
62 // 前に呼んでから Shift + 左クリックした画素の光線(格子の座標。古い順。取ったら忘れる。T-0098)
63 [[nodiscard]] std::vector<CameraRay> TakePushRays();
64
65 // --- 覗き窓(T-0096)---
66 // cell を覗いて depth まで潜る(--peek。窓では P と PageDown・PageUp)
67 void Peek(CellCoordinate cell, uint32_t depth);
68 [[nodiscard]] const PeekView& Peeking() const { return m_peek; }
69 // 前に呼んでから覗く場所(覗いているか・セル)が変わったか(変わっていたら true を返して忘れる。潜る段だけの変化は入らない)
70 [[nodiscard]] bool TakePeekChange();
71
72 private:
73 void HandlePointer(const InputEvent& event, uint32_t width, uint32_t height,
74 std::vector<CellCoordinate>& pokes);
75 void HandleKey(const InputEvent& event, uint32_t width, uint32_t height);
76 void HandlePeekKey(const InputEvent& event, uint32_t width, uint32_t height);
77 void FocusOnPeek();
78
79 uint32_t m_gridSize; // 格子の 1 辺のセルの数
82
83 // --- ドラッグ中の状態 ---
84 bool m_rotating = false;
85 bool m_panning = false;
86 int32_t m_lastX = 0; // 前のポインタの位置(画素)
87 int32_t m_lastY = 0;
88
89 bool m_traceRequested = false; // T が押された(TakeTraceRequest で取る)
90 std::vector<CameraRay> m_pushRays; // Shift + 左クリックの光線(TakePushRays で取る)
91
93 bool m_peekChanged = false; // 覗く場所が変わった(TakePeekChange で取る)
94 };
95
96 // 表示の名前(--view の値。volume・mip・slice)→ 表示。知らない名前なら false
97 [[nodiscard]] bool ParseDebugViewMode(std::string_view name, DebugViewMode& mode);
98
99} // namespace bicameral::render
std::vector< CellCoordinate > HandleInput(std::span< const InputEvent > events, uint32_t width, uint32_t height)
void HandlePeekKey(const InputEvent &event, uint32_t width, uint32_t height)
const DebugViewSettings & Settings() const
void HandlePointer(const InputEvent &event, uint32_t width, uint32_t height, std::vector< CellCoordinate > &pokes)
void HandleKey(const InputEvent &event, uint32_t width, uint32_t height)
void Peek(CellCoordinate cell, uint32_t depth)
DebugViewController(uint32_t gridSize, const DebugViewSettings &settings, const OrbitCameraState &camera)
ProbeViewConstants Constants(uint32_t extractionIndex, uint32_t width, uint32_t height) const
constexpr uint32_t PEEK_MAX_DEPTH
bool ParseDebugViewMode(std::string_view name, DebugViewMode &mode)
bool operator==(const PeekView &) const =default