![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
Computes clean hierarchical layouts for behavior trees. More...
#include <BTGraphLayoutEngine.h>
Public Member Functions | |
| BTGraphLayoutEngine () | |
| ~BTGraphLayoutEngine ()=default | |
| void | SetLayoutDirection (BTLayoutDirection direction) |
| Set layout direction. | |
| BTLayoutDirection | GetLayoutDirection () const |
| Get current layout direction. | |
| std::vector< BTNodeLayout > | ComputeLayout (const BehaviorTreeAsset *tree, float nodeSpacingX=320.0f, float nodeSpacingY=180.0f, float zoomFactor=1.0f) |
| Compute layout for a behavior tree. | |
| const BTNodeLayout * | GetNodeLayout (uint32_t nodeId) const |
| Get computed layout for a specific node. | |
| bool | UpdateNodePosition (uint32_t nodeId, float x, float y) |
| Update the stored position for a node (e.g. | |
| BTGraphLayoutEngine () | |
| ~BTGraphLayoutEngine ()=default | |
| void | SetLayoutDirection (BTLayoutDirection direction) |
| Set layout direction. | |
| BTLayoutDirection | GetLayoutDirection () const |
| Get current layout direction. | |
| std::vector< BTNodeLayout > | ComputeLayout (const BehaviorTreeAsset *tree, float nodeSpacingX=320.0f, float nodeSpacingY=180.0f, float zoomFactor=1.0f) |
| Compute layout for a behavior tree. | |
| const BTNodeLayout * | GetNodeLayout (uint32_t nodeId) const |
| Get computed layout for a specific node. | |
| bool | UpdateNodePosition (uint32_t nodeId, float x, float y) |
| Update the stored position for a node (e.g. | |
Private Member Functions | |
| void | AssignLayers (const BehaviorTreeAsset *tree) |
| std::vector< uint32_t > | GetChildren (const BTNode *node) const |
| void | BuildParentMap (const BehaviorTreeAsset *tree) |
| void | AssignLayers (const BehaviorTreeAsset *tree) |
| std::vector< uint32_t > | GetChildren (const BTNode *node) const |
| void | BuildParentMap (const BehaviorTreeAsset *tree) |
Private Attributes | |
| BTLayoutDirection | m_layoutDirection = BTLayoutDirection::TopToBottom |
| Default vertical. | |
| std::vector< BTNodeLayout > | m_layouts |
| std::map< uint32_t, size_t > | m_nodeIdToIndex |
| std::vector< std::vector< uint32_t > > | m_layers |
| std::map< uint32_t, std::vector< uint32_t > > | m_parentMap |
Computes clean hierarchical layouts for behavior trees.
Uses BFS layering followed by a fixed 400x200 grid to produce a horizontal layout with no overlaps.
Definition at line 60 of file BTGraphLayoutEngine.h.
| Olympe::BTGraphLayoutEngine::BTGraphLayoutEngine | ( | ) |
Definition at line 18 of file BTGraphLayoutEngine.cpp.
|
default |
| Olympe::BTGraphLayoutEngine::BTGraphLayoutEngine | ( | ) |
|
default |
|
private |
Definition at line 84 of file BTGraphLayoutEngine.cpp.
References BuildParentMap(), GetChildren(), GetComponentTypeID_Static(), m_layers, m_layouts, m_nodeIdToIndex, and Olympe::BTNodeLayout::nodeId.
Referenced by ComputeLayout().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
|
private |
Definition at line 179 of file BTGraphLayoutEngine.cpp.
References GetChildren(), GetComponentTypeID_Static(), and m_parentMap.
Referenced by AssignLayers().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
| std::vector< BTNodeLayout > Olympe::BTGraphLayoutEngine::ComputeLayout | ( | const BehaviorTreeAsset * | tree, |
| float | nodeSpacingX = 320.0f, |
||
| float | nodeSpacingY = 180.0f, |
||
| float | zoomFactor = 1.0f |
||
| ) |
Compute layout for a behavior tree.
| tree | The behavior tree asset to layout |
| nodeSpacingX | Horizontal spacing between nodes (unused, fixed grid used) |
| nodeSpacingY | Vertical spacing between layers (unused, fixed grid used) |
| zoomFactor | Zoom multiplier (unused, fixed grid used) |
Definition at line 22 of file BTGraphLayoutEngine.cpp.
References AssignLayers(), GetComponentTypeID_Static(), m_layers, m_layouts, m_nodeIdToIndex, m_parentMap, and SYSTEM_LOG.
Referenced by Olympe::NodeGraphShared::BehaviorTreeAdapter::ComputeLayout(), and Olympe::NodeGraphShared::BTGraphDocumentConverter::FromBehaviorTree().
Here is the call graph for this function:
Here is the caller graph for this function:| std::vector< BTNodeLayout > Olympe::BTGraphLayoutEngine::ComputeLayout | ( | const BehaviorTreeAsset * | tree, |
| float | nodeSpacingX = 320.0f, |
||
| float | nodeSpacingY = 180.0f, |
||
| float | zoomFactor = 1.0f |
||
| ) |
Compute layout for a behavior tree.
| tree | The behavior tree asset to layout |
| nodeSpacingX | Horizontal spacing between nodes (unused, fixed grid used) |
| nodeSpacingY | Vertical spacing between layers (unused, fixed grid used) |
| zoomFactor | Zoom multiplier (unused, fixed grid used) |
|
private |
Definition at line 155 of file BTGraphLayoutEngine.cpp.
References GetComponentTypeID_Static(), Inverter, Repeater, Selector, and Sequence.
Referenced by AssignLayers(), and BuildParentMap().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
|
inline |
Get current layout direction.
Definition at line 76 of file BTGraphLayoutEngine.h.
References m_layoutDirection.
|
inline |
Get current layout direction.
Definition at line 71 of file BTGraphLayoutEngine.h.
References m_layoutDirection.
| const BTNodeLayout * Olympe::BTGraphLayoutEngine::GetNodeLayout | ( | uint32_t | nodeId | ) | const |
Get computed layout for a specific node.
| nodeId | The BT node ID |
Definition at line 64 of file BTGraphLayoutEngine.cpp.
References GetComponentTypeID_Static(), m_layouts, and m_nodeIdToIndex.
Referenced by Olympe::NodeGraphShared::BehaviorTreeAdapter::GetNodeLayout().
Here is the call graph for this function:
Here is the caller graph for this function:| const BTNodeLayout * Olympe::BTGraphLayoutEngine::GetNodeLayout | ( | uint32_t | nodeId | ) | const |
Get computed layout for a specific node.
| nodeId | The BT node ID |
|
inline |
Set layout direction.
| direction | Layout direction (TopToBottom or LeftToRight) |
Definition at line 70 of file BTGraphLayoutEngine.h.
References m_layoutDirection.
|
inline |
Set layout direction.
| direction | Layout direction (TopToBottom or LeftToRight) |
Definition at line 65 of file BTGraphLayoutEngine.h.
References m_layoutDirection.
Update the stored position for a node (e.g.
after user drag).
| nodeId | The BT node ID. |
| x | New X position in canvas (grid) units. |
| y | New Y position in canvas (grid) units. |
Definition at line 74 of file BTGraphLayoutEngine.cpp.
References GetComponentTypeID_Static(), m_layouts, m_nodeIdToIndex, Olympe::BTNodeLayout::position, and Vector::x.
Referenced by Olympe::NodeGraphShared::BehaviorTreeAdapter::UpdateNodePosition().
Here is the call graph for this function:
Here is the caller graph for this function:Update the stored position for a node (e.g.
after user drag).
| nodeId | The BT node ID. |
| x | New X position in canvas (grid) units. |
| y | New Y position in canvas (grid) units. |
|
private |
Definition at line 127 of file BTGraphLayoutEngine.h.
Referenced by AssignLayers(), and ComputeLayout().
|
private |
Default vertical.
Definition at line 120 of file BTGraphLayoutEngine.h.
Referenced by GetLayoutDirection(), and SetLayoutDirection().
|
private |
Definition at line 123 of file BTGraphLayoutEngine.h.
Referenced by AssignLayers(), ComputeLayout(), GetNodeLayout(), and UpdateNodePosition().
Definition at line 124 of file BTGraphLayoutEngine.h.
Referenced by AssignLayers(), ComputeLayout(), GetNodeLayout(), and UpdateNodePosition().
Definition at line 128 of file BTGraphLayoutEngine.h.
Referenced by BuildParentMap(), and ComputeLayout().