12#include "../system/system_utils.h"
29 static_cast<void>(nodeSpacingX);
30 static_cast<void>(nodeSpacingY);
31 static_cast<void>(zoomFactor);
59 <<
" nodes positioned" << std::endl;
87 std::queue<std::pair<uint32_t, int>>
queue;
95 while (!
queue.empty())
97 std::pair<uint32_t, int>
front =
queue.front();
99 int layer =
front.second;
126 queue.push({childId, layer + 1});
141 for (
size_t i = 0;
i < layer.size(); ++
i)
146 m_layouts[
it->second].orderInLayer =
static_cast<int>(
i);
160 std::vector<uint32_t> children;
165 children =
node->childIds;
170 if (
node->decoratorChildId != 0)
172 children.push_back(
node->decoratorChildId);
183 for (
const auto&
node :
tree->nodes)
Graph layout engine for behavior tree visualization.
@ Selector
OR node - succeeds if any child succeeds.
@ Sequence
AND node - succeeds if all children succeed.
@ Inverter
Decorator - inverts child result.
@ Repeater
Decorator - repeats child N times.
ComponentTypeID GetComponentTypeID_Static()
bool UpdateNodePosition(uint32_t nodeId, float x, float y)
Update the stored position for a node (e.g.
const BTNodeLayout * GetNodeLayout(uint32_t nodeId) const
Get computed layout for a specific node.
std::vector< BTNodeLayout > m_layouts
std::vector< uint32_t > GetChildren(const BTNode *node) const
void BuildParentMap(const BehaviorTreeAsset *tree)
std::map< uint32_t, size_t > m_nodeIdToIndex
std::map< uint32_t, std::vector< uint32_t > > m_parentMap
void AssignLayers(const BehaviorTreeAsset *tree)
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.
std::vector< std::vector< uint32_t > > m_layers
< Provides AssetID and INVALID_ASSET_ID
Represents a single node in a behavior tree.
Layout information for a single behavior tree node.
Vector position
Final position (x, y)
uint32_t nodeId
BT node ID.