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