Closed Bingdom closed 3 years ago
Hi @Bingdom !
The assertion you're getting actually happens because of this line at the bottom of the file:
void NodeEditorInitialize() { imnodes::SetNodeGridSpacePos(1, ImVec2(200.0f, 200.0f)); }
What happens under the hood when calling SetNodeGridSpacePos
is that we create a node, and then it is also expected to render the node. If you call SetNodeGridSpacePos
with an id of 1, then call BeginNode
only with an id of 0 you get the assert, because there's a mismatch between the submitted nodes and the rendered nodes.
Any chance you could paste the modified code you which caused the flickering? Here's what I tried:
void show()
{
ImGui::Begin("simple node editor");
imnodes::BeginNodeEditor();
imnodes::BeginNode(1);
imnodes::BeginNodeTitleBar();
ImGui::TextUnformatted("simple node :)");
imnodes::EndNodeTitleBar();
imnodes::BeginInputAttribute(2);
ImGui::Text("input");
imnodes::EndInputAttribute();
imnodes::BeginOutputAttribute(3);
ImGui::Indent(40);
ImGui::Text("output");
imnodes::EndOutputAttribute();
imnodes::EndNode();
imnodes::BeginNode(0);
imnodes::BeginNodeTitleBar();
ImGui::TextUnformatted("simple node 2 :)");
imnodes::EndNodeTitleBar();
imnodes::BeginInputAttribute(1);
ImGui::Text("input");
imnodes::EndInputAttribute();
imnodes::BeginOutputAttribute(2);
ImGui::Indent(40);
ImGui::Text("output");
imnodes::EndOutputAttribute();
imnodes::EndNode();
imnodes::EndNodeEditor();
ImGui::End();
}
I'm on my macOS with clang, but I'm not seeing any flickering on my end. The node ids are fine, and I wouldn't expect there to be a problem. The attribute id of 2 repeats itself, and will cause issues if you would try to create links, however.
That makes much more sense! I was able to fix the issues I had earlier.
Here's the code that I used that created the flickering;
void show()
{
imnodes::Begin("simple node editor");
imnodes::BeginNodeEditor();
imnodes::BeginNode(0);
imnodes::BeginNodeTitleBar();
ImGui::TextUnformatted("simple node :)");
imnodes::EndNodeTitleBar();
imnodes::BeginInputAttribute(1);
ImGui::Text("input");
imnodes::EndInputAttribute();
imnodes::BeginOutputAttribute(2);
ImGui::Indent(40);
ImGui::Text("output");
imnodes::EndOutputAttribute();
imnodes::EndNode();
imnodes::BeginNode(3);
imnodes::BeginNodeTitleBar();
ImGui::TextUnformatted("simple node 2 :)");
imnodes::EndNodeTitleBar();
imnodes::BeginInputAttribute(4);
ImGui::Text("input");
imnodes::EndInputAttribute();
imnodes::BeginOutputAttribute(5);
ImGui::Indent(40);
ImGui::Text("output");
imnodes::EndOutputAttribute();
imnodes::EndNode();
imnodes::EndNodeEditor();
ImGui::End();
}
The flickering is remedied when I removed SetNodeGridSpacePos
@Bingdom Thanks a lot for the code listing! I was able to reproduce the problem on Windows, and I actually found a problem in the code which resulted in the unused node (created by SetNodeGridSpacePos
) and an actual node trading places every other frame.
Perhaps I might be doing something very wrong.
Using visual studio 2019.
In the hello.cpp example project;
Create a second node (by copy-pasting the first node). Starting from 0, id the node and attributes in ascending order.
You'll get this odd effect:
Start from 1, and things will work as expected.
If I make the first node's ID larger than the attribute ID (similar way to colornode), I get this assertion error:
assert(node_idx_depth_order.Size == g.node_idx_submission_order.Size);
in imnodes.cppIt also appears that I get this assertion error again with arbitrary values, so it's probably not tied with the attribute id values.
I've had to go into the graph.h file and make the return values start from 1 and adjust when the node id is determined to get my node editor to create new nodes.