Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
BTGraphDocumentConverter.h
Go to the documentation of this file.
1/**
2 * @file BTGraphDocumentConverter.h
3 * @brief Conversion BehaviorTreeAsset -> Olympe::NodeGraph (Blueprint Editor pipeline)
4 *
5 * @details
6 * Bridge between the runtime BT (BehaviorTreeAsset) and the Blueprint Editor
7 * rendering system (Olympe::NodeGraph + Olympe::NodeGraphManager).
8 * Used exclusively by BehaviorTreeDebugWindow (F10) in debug mode.
9 * Conversion READ-ONLY: no writes from the debugger back to the BT runtime.
10 */
11
12#pragma once
13
14#include "../BlueprintEditor/BTNodeGraphManager.h"
15#include "../AI/BehaviorTree.h"
16#include <cstdint>
17
18namespace Olympe {
19namespace NodeGraphShared {
20
21/**
22 * @class BTGraphDocumentConverter
23 * @brief Converts a BehaviorTreeAsset into an Olympe::NodeGraph for display
24 * in the NodeGraphPanel (Blueprint Editor pipeline).
25 *
26 * The resulting NodeGraph preserves the original BT node IDs so that
27 * NodeGraphPanel::SetActiveDebugNode() works directly with BT node indices.
28 */
30{
31public:
32 /**
33 * @brief Converts a BehaviorTreeAsset into a heap-allocated NodeGraph.
34 *
35 * @details Two-priority loading strategy:
36 * 1. **JSON source file** (preferred): queries `BehaviorTreeManager::GetTreePathFromId()`
37 * to obtain the asset path, then calls `NodeGraphManager::LoadGraph()` to parse the
38 * file. This preserves the visual positions saved in the JSON, making the debugger
39 * layout identical to the Blueprint Editor standalone view. `ClearDirty()` is called
40 * on the resulting graph because the debugger is read-only. The temporary graph slot
41 * in `NodeGraphManager` is closed immediately after cloning.
42 * 2. **BFS fallback**: used when the path is unknown (prefixed `"TreeName:"`) or when
43 * `LoadGraph` returns -1. Positions are computed by `BTGraphLayoutEngine`.
44 *
45 * @param tree BehaviorTree asset to convert (non-null).
46 * @return Newly allocated NodeGraph (caller takes ownership).
47 * Returns nullptr if @p tree is null.
48 */
50
51 /**
52 * @brief Synchronises the active-node metadata in an existing NodeGraph.
53 * @details No-op for the NodeGraph model; actual highlight is driven by
54 * NodeGraphPanel::SetActiveDebugNode(). Kept for API symmetry.
55 * @param graph Target graph (may be null — safely ignored).
56 * @param currentNodeId BT node currently executing.
57 */
58 static void SyncActiveNode(NodeGraph* graph, uint32_t currentNodeId);
59
60private:
62};
63
64} // namespace NodeGraphShared
65} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Converts a BehaviorTreeAsset into an Olympe::NodeGraph for display in the NodeGraphPanel (Blueprint E...
static NodeGraph * FromBehaviorTree(const BehaviorTreeAsset *tree)
Converts a BehaviorTreeAsset into a heap-allocated NodeGraph.
static void SyncActiveNode(NodeGraph *graph, uint32_t currentNodeId)
Synchronises the active-node metadata in an existing NodeGraph.
< Provides AssetID and INVALID_ASSET_ID