New nodes now spawn at popup start location.
parent
e3baa65c3b
commit
7c7a765455
|
@ -20,6 +20,7 @@ struct EditorState {
|
||||||
size_t hierarchyStackIndex = 0;
|
size_t hierarchyStackIndex = 0;
|
||||||
|
|
||||||
bool isGraphLoadedThisFrame = false;
|
bool isGraphLoadedThisFrame = false;
|
||||||
|
ImVec2 mousePopupStart = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
static EditorState sEditorState;
|
static EditorState sEditorState;
|
||||||
|
@ -520,13 +521,12 @@ void AnimGraphEditorUpdate(ax::NodeEditor::EditorContext* context) {
|
||||||
{
|
{
|
||||||
const bool open_popup = ImGui::IsMouseReleased(ImGuiMouseButton_Right);
|
const bool open_popup = ImGui::IsMouseReleased(ImGuiMouseButton_Right);
|
||||||
|
|
||||||
ImVec2 popup_mouse_position = ImGui::GetMousePos();
|
if (open_popup && ImGui::IsWindowHovered()) {
|
||||||
|
|
||||||
ax::NodeEditor::Suspend();
|
ax::NodeEditor::Suspend();
|
||||||
if (open_popup) {
|
|
||||||
ImGui::OpenPopup("add node");
|
ImGui::OpenPopup("add node");
|
||||||
}
|
|
||||||
ax::NodeEditor::Resume();
|
ax::NodeEditor::Resume();
|
||||||
|
sEditorState.mousePopupStart = ImGui::GetMousePos();
|
||||||
|
}
|
||||||
|
|
||||||
ax::NodeEditor::Suspend();
|
ax::NodeEditor::Suspend();
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8.f, 8.f));
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8.f, 8.f));
|
||||||
|
@ -570,7 +570,7 @@ void AnimGraphEditorUpdate(ax::NodeEditor::EditorContext* context) {
|
||||||
size_t node_id =
|
size_t node_id =
|
||||||
sEditorState.hierarchyStack[sEditorState.hierarchyStackIndex]
|
sEditorState.hierarchyStack[sEditorState.hierarchyStackIndex]
|
||||||
->m_blend_tree_resource.GetNumNodes();
|
->m_blend_tree_resource.GetNumNodes();
|
||||||
ax::NodeEditor::SetNodePosition(node_id, popup_mouse_position);
|
ax::NodeEditor::SetNodePosition(node_id, sEditorState.mousePopupStart);
|
||||||
sEditorState.hierarchyStack[sEditorState.hierarchyStackIndex]
|
sEditorState.hierarchyStack[sEditorState.hierarchyStackIndex]
|
||||||
->m_blend_tree_resource.AddNode(node_resource);
|
->m_blend_tree_resource.AddNode(node_resource);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue