![]() |
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=180.0f, float nodeSpacingY=120.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. | |
Private Member Functions | |
| void | AssignLayers (const BehaviorTreeAsset *tree) |
| void | InitialOrdering () |
| void | ReduceCrossings (const BehaviorTreeAsset *tree) |
| void | ApplyBuchheimWalkerLayout (const BehaviorTreeAsset *tree) |
| void | ResolveNodeCollisionsForceDirected (float nodePadding, int maxIterations) |
| void | AssignXCoordinates (float nodeSpacingX) |
| void | ResolveCollisions (float nodeSpacingX) |
| std::vector< uint32_t > | GetChildren (const BTNode *node) const |
| void | BuildParentMap (const BehaviorTreeAsset *tree) |
| float | CalculateBarycenter (uint32_t nodeId, const std::vector< BTNodeLayout * > &neighbors) const |
| void | PlaceSubtree (uint32_t nodeId, const BehaviorTreeAsset *tree, int depth, float &nextAvailableX) |
| void | ShiftSubtree (uint32_t nodeId, const BehaviorTreeAsset *tree, float offset) |
| bool | DoNodesOverlap (const BTNodeLayout &a, const BTNodeLayout &b, float padding) const |
| void | PushNodeApart (uint32_t nodeA, uint32_t nodeB, float minDistance) |
| int | CountEdgeCrossings (const BehaviorTreeAsset *tree) const |
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 the Sugiyama algorithm to create readable, professional-looking node graphs without overlaps.
Definition at line 59 of file BTGraphLayoutEngine.h.
| Olympe::BTGraphLayoutEngine::BTGraphLayoutEngine | ( | ) |
Definition at line 14 of file BTGraphLayoutEngine.cpp.
|
default |
|
private |
Definition at line 471 of file BTGraphLayoutEngine.cpp.
References GetComponentTypeID_Static(), m_layers, m_layouts, and PlaceSubtree().
Referenced by ComputeLayout().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 146 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:Definition at line 355 of file BTGraphLayoutEngine.cpp.
References GetComponentTypeID_Static(), m_layers, m_layouts, and m_nodeIdToIndex.
Here is the call graph for this function:
|
private |
Definition at line 443 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 |
Definition at line 457 of file BTGraphLayoutEngine.cpp.
References GetComponentTypeID_Static().
Referenced by ReduceCrossings().
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 = 180.0f, |
||
| float | nodeSpacingY = 120.0f, |
||
| float | zoomFactor = 1.0f |
||
| ) |
Compute layout for a behavior tree.
| tree | The behavior tree asset to layout |
| nodeSpacingX | Horizontal spacing between nodes (default: 180px, reduced from 250px) |
| nodeSpacingY | Vertical spacing between layers (default: 120px, reduced from 180px) |
| zoomFactor | Zoom multiplier applied to final positions (default: 1.0) |
Definition at line 18 of file BTGraphLayoutEngine.cpp.
References ApplyBuchheimWalkerLayout(), AssignLayers(), GetComponentTypeID_Static(), InitialOrdering(), m_layers, m_layoutDirection, m_layouts, m_nodeIdToIndex, m_parentMap, ReduceCrossings(), ResolveNodeCollisionsForceDirected(), and Olympe::TopToBottom.
Referenced by Olympe::BehaviorTreeDebugWindow::RenderInSeparateWindow().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 680 of file BTGraphLayoutEngine.cpp.
References GetChildren(), GetComponentTypeID_Static(), and m_layers.
Referenced by ReduceCrossings().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 612 of file BTGraphLayoutEngine.cpp.
References GetComponentTypeID_Static(), Olympe::BTNodeLayout::position, and Vector::x.
Referenced by ResolveNodeCollisionsForceDirected().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 419 of file BTGraphLayoutEngine.cpp.
References GetComponentTypeID_Static(), Inverter, Repeater, Selector, and Sequence.
Referenced by AssignLayers(), BuildParentMap(), CountEdgeCrossings(), PlaceSubtree(), ReduceCrossings(), and ShiftSubtree().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Get current layout direction.
Definition at line 75 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 136 of file BTGraphLayoutEngine.cpp.
References GetComponentTypeID_Static(), m_layouts, and m_nodeIdToIndex.
Here is the call graph for this function:
|
private |
Definition at line 204 of file BTGraphLayoutEngine.cpp.
References GetComponentTypeID_Static(), m_layers, m_layouts, and m_nodeIdToIndex.
Referenced by ComputeLayout().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 496 of file BTGraphLayoutEngine.cpp.
References GetChildren(), GetComponentTypeID_Static(), m_layouts, m_nodeIdToIndex, PlaceSubtree(), and ShiftSubtree().
Referenced by ApplyBuchheimWalkerLayout(), and PlaceSubtree().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 630 of file BTGraphLayoutEngine.cpp.
References GetComponentTypeID_Static(), m_layouts, m_nodeIdToIndex, Olympe::BTNodeLayout::position, and Vector::x.
Referenced by ResolveNodeCollisionsForceDirected().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 222 of file BTGraphLayoutEngine.cpp.
References CalculateBarycenter(), CountEdgeCrossings(), GetChildren(), GetComponentTypeID_Static(), m_layers, m_layouts, m_nodeIdToIndex, and m_parentMap.
Referenced by ComputeLayout().
Here is the call graph for this function:
Here is the caller graph for this function:Definition at line 375 of file BTGraphLayoutEngine.cpp.
References GetComponentTypeID_Static(), m_layers, m_layouts, m_nodeIdToIndex, Olympe::BTNodeLayout::position, and Vector::x.
Here is the call graph for this function:
|
private |
Definition at line 568 of file BTGraphLayoutEngine.cpp.
References DoNodesOverlap(), GetComponentTypeID_Static(), m_layers, m_layouts, m_nodeIdToIndex, and PushNodeApart().
Referenced by ComputeLayout().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Set layout direction.
| direction | Layout direction (TopToBottom or LeftToRight) |
Definition at line 69 of file BTGraphLayoutEngine.h.
References m_layoutDirection.
|
private |
Definition at line 549 of file BTGraphLayoutEngine.cpp.
References GetChildren(), GetComponentTypeID_Static(), m_layouts, m_nodeIdToIndex, and ShiftSubtree().
Referenced by PlaceSubtree(), and ShiftSubtree().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 147 of file BTGraphLayoutEngine.h.
Referenced by ApplyBuchheimWalkerLayout(), AssignLayers(), AssignXCoordinates(), ComputeLayout(), CountEdgeCrossings(), InitialOrdering(), ReduceCrossings(), ResolveCollisions(), and ResolveNodeCollisionsForceDirected().
|
private |
Default vertical.
Definition at line 140 of file BTGraphLayoutEngine.h.
Referenced by ComputeLayout(), GetLayoutDirection(), and SetLayoutDirection().
|
private |
Definition at line 143 of file BTGraphLayoutEngine.h.
Referenced by ApplyBuchheimWalkerLayout(), AssignLayers(), AssignXCoordinates(), ComputeLayout(), GetNodeLayout(), InitialOrdering(), PlaceSubtree(), PushNodeApart(), ReduceCrossings(), ResolveCollisions(), ResolveNodeCollisionsForceDirected(), and ShiftSubtree().
Definition at line 144 of file BTGraphLayoutEngine.h.
Referenced by AssignLayers(), AssignXCoordinates(), ComputeLayout(), GetNodeLayout(), InitialOrdering(), PlaceSubtree(), PushNodeApart(), ReduceCrossings(), ResolveCollisions(), ResolveNodeCollisionsForceDirected(), and ShiftSubtree().
Definition at line 148 of file BTGraphLayoutEngine.h.
Referenced by BuildParentMap(), ComputeLayout(), and ReduceCrossings().