行为树节点编辑器适配修饰节点

This commit is contained in:
codeboss 2025-07-04 23:51:25 +08:00
parent 83842aa439
commit de23ab621a
1 changed files with 10 additions and 7 deletions

View File

@ -50,18 +50,15 @@ AcceptType NodePresent::testAccept(const QPointF& local_pos, const QString& kind
QList<NodeKind> no_child{ NodeKind::ACTIONNODE, NodeKind::COMPARENODE };
auto pnode = this->_node_bind->parent().lock();
decltype(pnode) new_type = nullptr;
if (this->_node_bind->bindMap())
new_type = this->_node_bind->bindMap()->getKernal()->getNode(kind_str);
else
new_type = std::dynamic_pointer_cast<BehaviorMapNode>(this->_node_bind)->getKernal()->getNode(kind_str);
decltype(pnode) new_type = this->_node_bind->getKernal()->getNode(kind_str);
// 当前节点存在父节点且不属于Action和Compare
if (left_rect.contains(local_pos) && pnode && !no_child.contains(new_type->nodeKind()))
return AcceptType::PREV_LEVEL;
QList<NodeKind> single_child{ NodeKind::MAPNODE, NodeKind::MODIFYNODE };
// 当前节点存在父节点且父节点可以存在多个节点
if (pnode && pnode->nodeKind() != NodeKind::MAPNODE) {
if (pnode && !single_child.contains(pnode->nodeKind())) {
if (top_rect.contains(local_pos))
return AcceptType::PREV_SIBLING;
@ -72,10 +69,14 @@ AcceptType NodePresent::testAccept(const QPointF& local_pos, const QString& kind
// 分辨当前节点的是否可以插入新节点
if (right_rect.contains(local_pos))
switch (this->_node_bind->nodeKind()) {
case NodeKind::MAPNODE: // 根节点只能容纳一个节点
case NodeKind::MAPNODE: // 根节点只能容纳一个子节点
if (!this->_node_bind->children().size() && !this->_node_bind->parent().lock())
return AcceptType::NEXT_LEVEL;
break;
case NodeKind::MODIFYNODE: // 修饰节点只能容纳一个子节点
if (!this->_node_bind->children().size())
return AcceptType::NEXT_LEVEL;
break;
case NodeKind::PARALLELNODE:
case NodeKind::SELECTORNODE:
case NodeKind::SEQUENCENODE:
@ -252,6 +253,7 @@ NodePresent* BehaviorsPresent::presentAllocate(std::shared_ptr<LogicalNode> ins)
QList<NodePresent*> _children_set;
switch (ins->nodeKind()) {
case NodeKind::MAPNODE:
case NodeKind::MODIFYNODE:
case NodeKind::PARALLELNODE:
case NodeKind::SEQUENCENODE:
case NodeKind::SELECTORNODE:
@ -340,6 +342,7 @@ QSizeF BehaviorsPresent::outlineMeasure(std::shared_ptr<LogicalNode> ins, QHash<
switch (ins->nodeKind()) {
case NodeKind::MAPNODE:
case NodeKind::MODIFYNODE:
case NodeKind::PARALLELNODE:
case NodeKind::SELECTORNODE:
case NodeKind::SEQUENCENODE: