Some progress with new graph editor.
This commit is contained in:
		
							parent
							
								
									e61180c4a7
								
							
						
					
					
						commit
						fdb2b6ffc5
					
				@ -14,6 +14,7 @@
 | 
			
		||||
#include "misc/cpp/imgui_stdlib.h"
 | 
			
		||||
 | 
			
		||||
static AnimGraphResource sGraphGresource = AnimGraphResource();
 | 
			
		||||
static bool sGraphLoadedThisFrame = false;
 | 
			
		||||
 | 
			
		||||
ImNodesPinShape sGetSocketShapeFromSocketType(const SocketType& socket_type) {
 | 
			
		||||
  switch (socket_type) {
 | 
			
		||||
@ -261,6 +262,7 @@ void AnimGraphEditorUpdate(ax::NodeEditor::EditorContext* context) {
 | 
			
		||||
//          i,
 | 
			
		||||
//          ImVec2(node_resource.m_position[0], node_resource.m_position[1]));
 | 
			
		||||
//    }
 | 
			
		||||
    sGraphLoadedThisFrame = true;
 | 
			
		||||
  }
 | 
			
		||||
  if (ImGui::Button("Clear")) {
 | 
			
		||||
    sGraphGresource.clear();
 | 
			
		||||
@ -283,6 +285,8 @@ void AnimGraphEditorUpdate(ax::NodeEditor::EditorContext* context) {
 | 
			
		||||
  ax::NodeEditor::SetCurrentEditor(context);
 | 
			
		||||
  ax::NodeEditor::Begin("Graph Editor");
 | 
			
		||||
 | 
			
		||||
  int node_editor_id = 0;
 | 
			
		||||
 | 
			
		||||
  for (size_t node_id = 0, n = sGraphGresource.m_nodes.size(); node_id < n;
 | 
			
		||||
       node_id++) {
 | 
			
		||||
    AnimNodeResource& node_resource = sGraphGresource.m_nodes[node_id];
 | 
			
		||||
@ -291,31 +295,35 @@ void AnimGraphEditorUpdate(ax::NodeEditor::EditorContext* context) {
 | 
			
		||||
      // continue;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    node_editor_id++;
 | 
			
		||||
 | 
			
		||||
    ax::NodeEditor::BeginNode(node_id);
 | 
			
		||||
    if (sGraphLoadedThisFrame) {
 | 
			
		||||
      ax::NodeEditor::SetNodePosition(node_editor_id, ImVec2(node_resource.m_position[0], node_resource.m_position[1]));
 | 
			
		||||
    }
 | 
			
		||||
    ax::NodeEditor::BeginNode(node_editor_id);
 | 
			
		||||
    ImGui::Text("%s", node_resource.m_type_name.c_str());
 | 
			
		||||
 | 
			
		||||
    // Inputs
 | 
			
		||||
    std::vector<Socket>& node_inputs =
 | 
			
		||||
        node_resource.m_socket_accessor->m_inputs;
 | 
			
		||||
    for (size_t j = 0, ni = node_inputs.size(); j < ni; j++) {
 | 
			
		||||
      Socket& socket = node_inputs[j];
 | 
			
		||||
      int pin_id = static_cast<int>(node_id) + j * 1000;
 | 
			
		||||
      ax::NodeEditor::BeginPin(pin_id, ax::NodeEditor::PinKind::Input);
 | 
			
		||||
      ImGui::Text("%s", socket.m_name.c_str());
 | 
			
		||||
      ax::NodeEditor::EndPin();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Outputs
 | 
			
		||||
    const std::vector<Socket>& node_outputs =
 | 
			
		||||
        node_resource.m_socket_accessor->m_outputs;
 | 
			
		||||
    for (size_t j = 0, ni = node_outputs.size(); j < ni; j++) {
 | 
			
		||||
      const Socket& socket = node_outputs[j];
 | 
			
		||||
      int pin_id = static_cast<int>(node_id) + j * 1000 * 1000;
 | 
			
		||||
      ax::NodeEditor::BeginPin(pin_id, ax::NodeEditor::PinKind::Output);
 | 
			
		||||
      ImGui::Text("%s", socket.m_name.c_str());
 | 
			
		||||
      ax::NodeEditor::EndPin();
 | 
			
		||||
    }
 | 
			
		||||
//    // Inputs
 | 
			
		||||
//    std::vector<Socket>& node_inputs =
 | 
			
		||||
//        node_resource.m_socket_accessor->m_inputs;
 | 
			
		||||
//    for (size_t j = 0, ni = node_inputs.size(); j < ni; j++) {
 | 
			
		||||
//      Socket& socket = node_inputs[j];
 | 
			
		||||
//      int pin_id = static_cast<int>(node_id) + j * 1000;
 | 
			
		||||
//      ax::NodeEditor::BeginPin(pin_id, ax::NodeEditor::PinKind::Input);
 | 
			
		||||
//      ImGui::Text("%s", socket.m_name.c_str());
 | 
			
		||||
//      ax::NodeEditor::EndPin();
 | 
			
		||||
//    }
 | 
			
		||||
//
 | 
			
		||||
//    // Outputs
 | 
			
		||||
//    const std::vector<Socket>& node_outputs =
 | 
			
		||||
//        node_resource.m_socket_accessor->m_outputs;
 | 
			
		||||
//    for (size_t j = 0, ni = node_outputs.size(); j < ni; j++) {
 | 
			
		||||
//      const Socket& socket = node_outputs[j];
 | 
			
		||||
//      int pin_id = static_cast<int>(node_id) + j * 1000 * 1000;
 | 
			
		||||
//      ax::NodeEditor::BeginPin(pin_id, ax::NodeEditor::PinKind::Output);
 | 
			
		||||
//      ImGui::Text("%s", socket.m_name.c_str());
 | 
			
		||||
//      ax::NodeEditor::EndPin();
 | 
			
		||||
//    }
 | 
			
		||||
 | 
			
		||||
    ax::NodeEditor::EndNode();
 | 
			
		||||
  }
 | 
			
		||||
@ -366,6 +374,12 @@ void AnimGraphEditorUpdate(ax::NodeEditor::EditorContext* context) {
 | 
			
		||||
  ax::NodeEditor::End();
 | 
			
		||||
 | 
			
		||||
  ax::NodeEditor::SetCurrentEditor(nullptr);
 | 
			
		||||
 | 
			
		||||
  if (sGraphLoadedThisFrame) {
 | 
			
		||||
    ax::NodeEditor::NavigateToContent();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  sGraphLoadedThisFrame = false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void LegacyAnimGraphEditorUpdate() {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user