7#include "../system/system_utils.h"
24 static_cast<void>(nodeSpacingX);
25 static_cast<void>(nodeSpacingY);
26 static_cast<void>(zoomFactor);
54 <<
" nodes positioned" << std::endl;
82 std::queue<std::pair<uint32_t, int>>
queue;
90 while (!
queue.empty())
92 std::pair<uint32_t, int>
front =
queue.front();
94 int layer =
front.second;
121 queue.push({childId, layer + 1});
136 for (
size_t i = 0;
i < layer.size(); ++
i)
141 m_layouts[
it->second].orderInLayer =
static_cast<int>(
i);
155 std::vector<uint32_t> children;
160 children =
node->childIds;
165 if (
node->decoratorChildId != 0)
167 children.push_back(
node->decoratorChildId);
178 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.
Vector position
Final position (x, y)