Пример #1
0
	/// <summary>
	/// Displays global PDG status
	/// </summary>
	private void DrawPDGStatus()
	{
	    string pdgState = "PDG is NOT READY";
	    Color stateColor = Color.red;

	    HEU_PDGSession pdgSession = HEU_PDGSession.GetPDGSession();
	    if (pdgSession != null)
	    {
		if (pdgSession._pdgState == HAPI_PDG_State.HAPI_PDG_STATE_COOKING)
		{
		    pdgState = "PDG is COOKING";
		    stateColor = Color.yellow;
		}
		else if (pdgSession._pdgState == HAPI_PDG_State.HAPI_PDG_STATE_READY)
		{
		    pdgState = "PDG is READY";
		    stateColor = Color.green;
		}
	    }

	    EditorGUILayout.Space();

	    _boxStyleStatus.normal.textColor = stateColor;
	    GUILayout.Box(pdgState, _boxStyleStatus);
	}
		private void DrawPDGStatus()
		{
			string pdgState = "PDG is NOT READY";
			Color stateColor = Color.red;

			HEU_PDGSession pdgSession = HEU_PDGSession.GetPDGSession();
			if (pdgSession != null)
			{
				if (pdgSession._pdgState == HAPI_PDG_State.HAPI_PDG_STATE_COOKING)
				{
					pdgState = "PDG is COOKING";
					stateColor = Color.yellow;

					//if (_assetLink != null)
					{
						//pdgState = string.Format("{0} ({1})", pdgState, _assetLink._workItemTally.ProgressRatio());
					}
				}
				else if (pdgSession._pdgState == HAPI_PDG_State.HAPI_PDG_STATE_READY)
				{
					pdgState = "PDG is READY";
					stateColor = Color.green;
				}
			}

			EditorGUILayout.Space();

			_boxStyleStatus.normal.textColor = stateColor;
			GUILayout.Box(pdgState, _boxStyleStatus);
		}
Пример #3
0
	/// <summary>
	/// Cook the specified TOP node.
	/// </summary>
	/// <param name="topNode"></param>
	public void CookTOPNode(HEU_TOPNodeData topNode)
	{
	    HEU_PDGSession pdgSession = HEU_PDGSession.GetPDGSession();
	    if (pdgSession != null)
	    {
		pdgSession.CookTOPNode(topNode._nodeID);
	    }
	}
Пример #4
0
	/// <summary>
	/// Dirty the specified TOP node and clear its work item results.
	/// </summary>
	/// <param name="topNode"></param>
	public void DirtyTOPNode(HEU_TOPNodeData topNode)
	{
	    HEU_PDGSession pdgSession = HEU_PDGSession.GetPDGSession();
	    if (pdgSession != null && pdgSession.DirtyTOPNode(topNode._nodeID))
	    {
		ClearTOPNodeWorkItemResults(topNode);
	    }
	}
Пример #5
0
 public static HEU_PDGSession GetPDGSession()
 {
     if (_pdgSession == null)
     {
         _pdgSession = new HEU_PDGSession();
     }
     return(_pdgSession);
 }
		private void OnDestroy()
		{
			HEU_PDGSession pdgSession = HEU_PDGSession.GetPDGSession();
			if (pdgSession != null)
			{
				pdgSession.RemoveAsset(this);
			}
		}
Пример #7
0
	private void OnDestroy()
	{
	    HEU_PDGSession pdgSession = HEU_PDGSession.GetPDGSession();
	    if (pdgSession != null)
	    {
		// Unregister on clean up
		pdgSession.RemoveAsset(this);
	    }
	}
Пример #8
0
	/// <summary>
	/// Dirty the currently selected TOP network and clear all work item results.
	/// </summary>
	public void DirtyAll()
	{
	    HEU_TOPNetworkData topNetwork = GetSelectedTOPNetwork();
	    if (topNetwork != null)
	    {
		HEU_PDGSession pdgSession = HEU_PDGSession.GetPDGSession();
		if (pdgSession != null && pdgSession.DirtyAll(topNetwork._nodeID))
		{
		    ClearTOPNetworkWorkItemResults(topNetwork);
		}
	    }
	}
Пример #9
0
	/// <summary>
	/// Register self with the global HEU_PDGAssetLink list.
	/// </summary>
	private void HandleInitialLoad()
	{
#if HOUDINIENGINEUNITY_ENABLED
	    HEU_PDGSession pdgSession = HEU_PDGSession.GetPDGSession();
	    if (pdgSession != null)
	    {
		pdgSession.AddAsset(this);
	    }

	    if (_linkState != LinkState.INACTIVE)
	    {
		// On load this, need to relink
		_assetID = HEU_Defines.HEU_INVALID_NODE_ID;
		_linkState = LinkState.INACTIVE;

		// UI will take care of refreshing
		//Refresh();
	    }
#endif
	}
Пример #10
0
	/// <summary>
	/// Cancel the PDG cook of the currently selected TOP network
	/// </summary>
	public void CancelCook()
	{
	    HEU_SessionBase session = GetHAPISession();
	    if (session == null || !session.IsSessionValid())
	    {
		return;
	    }

	    HEU_TOPNetworkData topNetwork = GetSelectedTOPNetwork();
	    if (topNetwork != null)
	    {
		//Debug.Log("Cooking output!");

		_workItemTally.ZeroAll();
		ResetTOPNetworkWorkItemTally(topNetwork);

		HEU_PDGSession pdgSession = HEU_PDGSession.GetPDGSession();
		if (pdgSession != null)
		{
		    pdgSession.CancelCook(topNetwork);
		}
	    }
	}
	/// <summary>
	/// Cook the output TOP node of the currently selected TOP network.
	/// </summary>
	public void CookOutput()
	{
	    HEU_SessionBase session = GetHAPISession();
	    if (session == null || !session.IsSessionValid())
	    {
		return;
	    }

	    HEU_TOPNetworkData topNetwork = GetSelectedTOPNetwork();
	    if (topNetwork != null)
	    {
		//HEU_Logger.Log("Cooking output!");

		_workItemTally.ZeroAll();
		ResetTOPNetworkWorkItemTally(topNetwork);

		HEU_PDGSession pdgSession = HEU_PDGSession.GetPDGSession();
		if (pdgSession != null)
		{
		    pdgSession.CookTOPNetworkOutputNode(topNetwork, OnSyncComplete);
		}
	    }
	}
Пример #12
0
	/// <summary>
	/// Main function to display linked asset's info, and functions.
	/// </summary>
	private void DrawAssetLink()
	{
	    HEU_PDGAssetLink.LinkState validState = _assetLink.AssetLinkState;

	    using (new EditorGUILayout.VerticalScope(_backgroundStyle))
	    {
		EditorGUILayout.Space();

		// Linked asset
		SerializedProperty assetGOProp = HEU_EditorUtility.GetSerializedProperty(serializedObject, "_assetGO");
		if (assetGOProp != null)
		{
		    EditorGUILayout.PropertyField(assetGOProp, _assetGOLabel, false);
		}

		EditorGUILayout.Space();

		using (new EditorGUILayout.HorizontalScope())
		{
		    // Refresh button re-poplates the UI data from linked asset
		    if (GUILayout.Button(_refreshContent, GUILayout.MaxHeight(_largButtonHeight)))
		    {
			_assetLink.Refresh();
		    }

		    // Reset button resets and recreates the HEU_PDGAssetLink
		    if (GUILayout.Button(_resetContent, GUILayout.MaxHeight(_largButtonHeight)))
		    {
			_assetLink.Reset();
		    }
		}

		// Autocook allows to automatically cook the TOP network when input assets are cooked
		_assetLink._autoCook = EditorGUILayout.Toggle(_autocookContent, _assetLink._autoCook);

		// Whether to use HEngine meta data to filter TOP networks and nodes
		_assetLink._useHEngineData = EditorGUILayout.Toggle(_useHEngineDataContent, _assetLink._useHEngineData);

		EditorGUILayout.Space();

		// Asset status
		using (new EditorGUILayout.VerticalScope(HEU_EditorUI.GetSectionStyle()))
		{
		    EditorGUILayout.LabelField("Asset is " + validState);

		    if (validState == HEU_PDGAssetLink.LinkState.ERROR_NOT_LINKED)
		    {
			EditorGUILayout.LabelField("Failed to link with HDA. Unable to proceed. Try rebuilding asset.");
		    }
		    else if (validState == HEU_PDGAssetLink.LinkState.LINKED)
		    {
			EditorGUILayout.Space();

			EditorGUILayout.LabelField(_assetStatusLabel);

			DrawWorkItemTally(_assetLink._workItemTally);

			EditorGUILayout.Space();
		    }
		}
	    }

	    if (validState == HEU_PDGAssetLink.LinkState.INACTIVE)
	    {
		_assetLink.Refresh();
	    }
	    else if (validState == HEU_PDGAssetLink.LinkState.LINKED)
	    {
		using (new EditorGUILayout.VerticalScope(_backgroundStyle))
		{
		    EditorGUILayout.Space();

		    DrawSelectedTOPNetwork();

		    EditorGUILayout.Space();

		    DrawSelectedTOPNode();
		}
	    }

	    // Display cook event messages
	    string eventMsgs = "<color=#c0c0c0ff>Cook event messages and errors will be displayed here...</color>";
	    HEU_PDGSession pdgSession = HEU_PDGSession.GetPDGSession();
	    if (pdgSession != null)
	    {
		string actualMsgs = pdgSession.GetEventMessages();
		if (!string.IsNullOrEmpty(actualMsgs))
		{
		    eventMsgs = string.Format("{0}", actualMsgs);
		}
	    }

	    using (new EditorGUILayout.VerticalScope(_backgroundStyle))
	    {
		EditorGUILayout.Space();

		_eventMessageScrollPos = EditorGUILayout.BeginScrollView(_eventMessageScrollPos, false, false);
		Vector2 textSize = _eventMessageStyle.CalcSize(new GUIContent(eventMsgs));
		EditorGUILayout.PrefixLabel(_eventMessageContent);
		EditorGUILayout.SelectableLabel(eventMsgs, _eventMessageStyle, GUILayout.ExpandHeight(true),
			GUILayout.ExpandWidth(true), GUILayout.MinWidth(textSize.x), GUILayout.MinHeight(textSize.y));
		EditorGUILayout.EndScrollView();
	    }
	}
	/// <summary>
	/// Find all TOP networks from linked HDA, as well as the TOP nodes within, and populate internal state.
	/// </summary>
	/// <returns>True if successfully populated data</returns>
	public bool PopulateTOPNetworks()
	{
	    HEU_SessionBase session = GetHAPISession();

	    HAPI_NodeId[] allNetworkNodeIds = HEU_PDGSession.GetNonBypassedNetworkIds(session, _assetID);
	    if (allNetworkNodeIds == null || allNetworkNodeIds.Length == 0)
	    {
		return false;
	    }

	    // Holds TOP networks in use
	    List<HEU_TOPNetworkData> newNetworks = new List<HEU_TOPNetworkData>();

	    // Find nodes with TOP child nodes
	    foreach (HAPI_NodeId currentNodeId in allNetworkNodeIds)
	    {
		HAPI_NodeInfo topNodeInfo = new HAPI_NodeInfo();
		if (!session.GetNodeInfo(currentNodeId, ref topNodeInfo))
		{
		    return false;
		}

		string nodeName = HEU_SessionManager.GetString(topNodeInfo.nameSH, session);
		//HEU_Logger.LogFormat("Top node: {0} - {1}", nodeName, topNodeInfo.type);

		// Skip any non TOP or SOP networks
		if (topNodeInfo.type != HAPI_NodeType.HAPI_NODETYPE_TOP && topNodeInfo.type != HAPI_NodeType.HAPI_NODETYPE_SOP)
		{
		    continue;
		}

		// Get list of all TOP nodes within this network.
		HAPI_NodeId[] topNodeIDs = null;
		if (!HEU_SessionManager.GetComposedChildNodeList(session, currentNodeId, (int)(HAPI_NodeType.HAPI_NODETYPE_TOP), (int)HAPI_NodeFlags.HAPI_NODEFLAGS_TOP_NONSCHEDULER, true, out topNodeIDs))
		{
		    continue;
		}

		// Skip networks without TOP nodes
		if (topNodeIDs == null || topNodeIDs.Length == 0)
		{
		    continue;
		}

		// Get any filter tags from spare parms on TOP nodes
		TOPNodeTags tags = new TOPNodeTags();
		if (_useHEngineData)
		{
		    ParseHEngineData(session, currentNodeId, ref topNodeInfo, ref tags);

		    if (!tags._showHEngineData)
		    {
			continue;
		    }
		}
		else
		{
		    tags._show = true;
		    tags._showHEngineData = true;
		}

		HEU_TOPNetworkData topNetworkData = GetTOPNetworkByName(nodeName, _topNetworks);
		if (topNetworkData == null)
		{
		    topNetworkData = new HEU_TOPNetworkData();
		}
		else
		{
		    // Found previous TOP network, so remove it from old list. This makes
		    // sure to not remove it when cleaning up old nodes.
		    _topNetworks.Remove(topNetworkData);
		}

		newNetworks.Add(topNetworkData);

		topNetworkData._nodeID = currentNodeId;
		topNetworkData._nodeName = nodeName;
		topNetworkData._parentName = _assetName;
		topNetworkData._tags = tags;

		if (PopulateTOPNodes(session, topNetworkData, topNodeIDs, _useHEngineData))
		{
		    for (int i = 0; i < topNetworkData._topNodes.Count; i++)
		    {
			if (topNetworkData._topNodes[i]._tags._show)
			{
			    topNetworkData._selectedTOPIndex = i;
			    break;
			}
		    }
		}
	    }

	    // Clear old TOP networks and nodes
	    ClearAllTOPData();
	    _topNetworks = newNetworks;

	    // Update latest TOP network names
	    _topNetworkNames = new string[_topNetworks.Count];
	    for (int i = 0; i < _topNetworks.Count; ++i)
	    {
		_topNetworkNames[i] = _topNetworks[i]._nodeName;
	    }

	    return true;
	}