行为树节点编辑器适配修饰节点
This commit is contained in:
parent
83842aa439
commit
de23ab621a
|
@ -50,18 +50,15 @@ AcceptType NodePresent::testAccept(const QPointF& local_pos, const QString& kind
|
||||||
|
|
||||||
QList<NodeKind> no_child{ NodeKind::ACTIONNODE, NodeKind::COMPARENODE };
|
QList<NodeKind> no_child{ NodeKind::ACTIONNODE, NodeKind::COMPARENODE };
|
||||||
auto pnode = this->_node_bind->parent().lock();
|
auto pnode = this->_node_bind->parent().lock();
|
||||||
decltype(pnode) new_type = nullptr;
|
decltype(pnode) new_type = this->_node_bind->getKernal()->getNode(kind_str);
|
||||||
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);
|
|
||||||
|
|
||||||
// 当前节点存在父节点且不属于Action和Compare
|
// 当前节点存在父节点且不属于Action和Compare
|
||||||
if (left_rect.contains(local_pos) && pnode && !no_child.contains(new_type->nodeKind()))
|
if (left_rect.contains(local_pos) && pnode && !no_child.contains(new_type->nodeKind()))
|
||||||
return AcceptType::PREV_LEVEL;
|
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))
|
if (top_rect.contains(local_pos))
|
||||||
return AcceptType::PREV_SIBLING;
|
return AcceptType::PREV_SIBLING;
|
||||||
|
|
||||||
|
@ -72,10 +69,14 @@ AcceptType NodePresent::testAccept(const QPointF& local_pos, const QString& kind
|
||||||
// 分辨当前节点的是否可以插入新节点
|
// 分辨当前节点的是否可以插入新节点
|
||||||
if (right_rect.contains(local_pos))
|
if (right_rect.contains(local_pos))
|
||||||
switch (this->_node_bind->nodeKind()) {
|
switch (this->_node_bind->nodeKind()) {
|
||||||
case NodeKind::MAPNODE: // 根节点只能容纳一个节点
|
case NodeKind::MAPNODE: // 根节点只能容纳一个子节点
|
||||||
if (!this->_node_bind->children().size() && !this->_node_bind->parent().lock())
|
if (!this->_node_bind->children().size() && !this->_node_bind->parent().lock())
|
||||||
return AcceptType::NEXT_LEVEL;
|
return AcceptType::NEXT_LEVEL;
|
||||||
break;
|
break;
|
||||||
|
case NodeKind::MODIFYNODE: // 修饰节点只能容纳一个子节点
|
||||||
|
if (!this->_node_bind->children().size())
|
||||||
|
return AcceptType::NEXT_LEVEL;
|
||||||
|
break;
|
||||||
case NodeKind::PARALLELNODE:
|
case NodeKind::PARALLELNODE:
|
||||||
case NodeKind::SELECTORNODE:
|
case NodeKind::SELECTORNODE:
|
||||||
case NodeKind::SEQUENCENODE:
|
case NodeKind::SEQUENCENODE:
|
||||||
|
@ -252,6 +253,7 @@ NodePresent* BehaviorsPresent::presentAllocate(std::shared_ptr<LogicalNode> ins)
|
||||||
QList<NodePresent*> _children_set;
|
QList<NodePresent*> _children_set;
|
||||||
switch (ins->nodeKind()) {
|
switch (ins->nodeKind()) {
|
||||||
case NodeKind::MAPNODE:
|
case NodeKind::MAPNODE:
|
||||||
|
case NodeKind::MODIFYNODE:
|
||||||
case NodeKind::PARALLELNODE:
|
case NodeKind::PARALLELNODE:
|
||||||
case NodeKind::SEQUENCENODE:
|
case NodeKind::SEQUENCENODE:
|
||||||
case NodeKind::SELECTORNODE:
|
case NodeKind::SELECTORNODE:
|
||||||
|
@ -340,6 +342,7 @@ QSizeF BehaviorsPresent::outlineMeasure(std::shared_ptr<LogicalNode> ins, QHash<
|
||||||
|
|
||||||
switch (ins->nodeKind()) {
|
switch (ins->nodeKind()) {
|
||||||
case NodeKind::MAPNODE:
|
case NodeKind::MAPNODE:
|
||||||
|
case NodeKind::MODIFYNODE:
|
||||||
case NodeKind::PARALLELNODE:
|
case NodeKind::PARALLELNODE:
|
||||||
case NodeKind::SELECTORNODE:
|
case NodeKind::SELECTORNODE:
|
||||||
case NodeKind::SEQUENCENODE:
|
case NodeKind::SEQUENCENODE:
|
||||||
|
|
Loading…
Reference in New Issue