![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
Converts BehaviorTree structures to generic TaskGraphTemplate format for simulation. More...
#include <BehaviorTreeGraphAdapter.h>
Static Public Member Functions | |
| static std::unique_ptr< TaskGraphTemplate > | AdaptToTaskGraph (const BehaviorTreeAsset &btAsset) |
| Converts a BehaviorTreeAsset to TaskGraphTemplate format. | |
| static std::string | FormatTraceForBehaviorTree (const GraphExecutionTracer &tracer, const BehaviorTreeAsset &btAsset) |
| Formats generic execution trace back to BehaviorTree-specific context. | |
| static bool | ValidateTreeStructure (const BehaviorTreeAsset &btAsset) |
| Validates BehaviorTree structure before conversion. | |
Static Private Member Functions | |
| static void | AddNodeToGraph (const BTNode &btNode, const BehaviorTreeAsset &btAsset, TaskGraphTemplate &outGraph, std::map< uint32_t, int32_t > &btToGraphIdMap) |
| Helper: Recursively adds a node and its children to the graph. | |
| static int32_t | CalculateNodeDepth (uint32_t nodeId, const BehaviorTreeAsset &btAsset) |
| Helper: Calculates depth of a node in BT hierarchy. | |
| static uint32_t | FindParentNodeId (uint32_t childNodeId, const BehaviorTreeAsset &btAsset) |
| Helper: Finds parent node ID for a given child node. | |
| static std::string | GetBTNodeTypeName (uint8_t type) |
| Helper: Gets BehaviorTree node type name. | |
Converts BehaviorTree structures to generic TaskGraphTemplate format for simulation.
This adapter layer enables the reuse of the generic GraphExecutionSimulator framework for BehaviorTree graphs without code duplication. It performs bidirectional conversion:
Forward (BehaviorTree → Graph):
Reverse (Trace → BehaviorTree Format):
Example Usage:
Definition at line 70 of file BehaviorTreeGraphAdapter.h.
|
static |
Converts a BehaviorTreeAsset to TaskGraphTemplate format.
| btAsset | Source BehaviorTree asset containing hierarchical BTNode structure. |
Performs the following transformations:
Definition at line 23 of file BehaviorTreeGraphAdapter.cpp.
References AddNodeToGraph(), GetComponentTypeID_Static(), and ValidateTreeStructure().
Here is the call graph for this function:
|
staticprivate |
Helper: Recursively adds a node and its children to the graph.
Definition at line 178 of file BehaviorTreeGraphAdapter.cpp.
References Action, AddNodeToGraph(), Olympe::AtomicTask, Condition, Olympe::Decorator, GetComponentTypeID_Static(), Inverter, Olympe::TaskNodeDefinition::NodeID, OnEvent, Repeater, Root, Olympe::Root, Selector, Olympe::Selector, Sequence, Olympe::Sequence, and Olympe::ExecPinConnection::SourceNodeID.
Referenced by AdaptToTaskGraph(), and AddNodeToGraph().
Here is the call graph for this function:
Here is the caller graph for this function:
|
staticprivate |
Helper: Calculates depth of a node in BT hierarchy.
Definition at line 256 of file BehaviorTreeGraphAdapter.cpp.
References CalculateNodeDepth(), FindParentNodeId(), and GetComponentTypeID_Static().
Referenced by CalculateNodeDepth(), and FormatTraceForBehaviorTree().
Here is the call graph for this function:
Here is the caller graph for this function:
|
staticprivate |
Helper: Finds parent node ID for a given child node.
Definition at line 275 of file BehaviorTreeGraphAdapter.cpp.
References GetComponentTypeID_Static().
Referenced by CalculateNodeDepth().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Formats generic execution trace back to BehaviorTree-specific context.
| tracer | GraphExecutionTracer containing generic ExecutionEvent trace. |
| btAsset | Original BehaviorTreeAsset for context and hierarchy information. |
Post-processes the generic execution trace from GraphExecutionSimulator with BehaviorTree-specific enhancements:
Definition at line 59 of file BehaviorTreeGraphAdapter.cpp.
References CalculateNodeDepth(), GetBTNodeTypeName(), and GetComponentTypeID_Static().
Here is the call graph for this function:
|
staticprivate |
|
static |
Validates BehaviorTree structure before conversion.
| btAsset | BehaviorTreeAsset to validate. |
Performs structural validation to catch issues before conversion:
Definition at line 126 of file BehaviorTreeGraphAdapter.cpp.
References GetComponentTypeID_Static().
Referenced by AdaptToTaskGraph().
Here is the call graph for this function:
Here is the caller graph for this function: