Nelarius / imnodes

A small, dependency-free node editor for dear imgui
MIT License
1.94k stars 237 forks source link

Node id's are overlapped when we have many attributes and nodes. #176

Closed yasinxdxd closed 1 year ago

yasinxdxd commented 1 year ago

id is just an 32 bit integer and we have to use different id for every node and attribute. One of the examples:

            ImNodes::BeginNode(id);
            ImNodes::BeginNodeTitleBar();
            ImGui::TextUnformatted("Node");
            ImNodes::EndNodeTitleBar();

            ImNodes::BeginInputAttribute(id << 8);
            ImGui::TextUnformatted("in1");
            ImNodes::EndInputAttribute();

            ImNodes::BeginOutputAttribute(d << 16);
            const float text_width = ImGui::CalcTextSize("out").x;
            ImGui::Indent(120.f + ImGui::CalcTextSize("value").x - text_width);
            ImGui::TextUnformatted("out");
            ImNodes::EndOutputAttribute();

when we have 2^8 (256) node, then our 256th node id and first node's BeginInputAttribute id will be overlapped. If we have more attributes for every node, it causes more problems. Did I understand correct the id system? Or what is the solution to have more attributes?

yasinxdxd commented 1 year ago

I'm sorry for my unnecassary question, the example make me confused, I can handle those id's by just adding 1 to attributes. I don't have to shift id's it was my bad, sorry.