private void DisconnectAndDestroyInputAssets(HEU_SessionBase session) { DisconnectInputAssetActor(session); _inputAsset = null; if (session != null) { foreach (HAPI_NodeId nodeID in _inputObjectsConnectedAssetIDs) { session.DeleteNode(nodeID); } if (_connectedNodeID != HEU_Defines.HEU_INVALID_NODE_ID && HEU_HAPIUtility.IsAssetValidInHoudini(session, _connectedNodeID)) { // We'll delete the parent Object because we presume to have created the SOP/merge ourselves. // If the parent Object doesn't get deleted, it sticks around unused. HAPI_NodeInfo parentNodeInfo = new HAPI_NodeInfo(); if(session.GetNodeInfo(_connectedNodeID, ref parentNodeInfo)) { if (parentNodeInfo.parentId != HEU_Defines.HEU_INVALID_NODE_ID) { session.DeleteNode(parentNodeInfo.parentId); } } } } _inputObjectsConnectedAssetIDs.Clear(); _connectedNodeID = HEU_Defines.HEU_INVALID_NODE_ID; }
/// <summary> /// Create input node for the given inputObject, and upload its mesh data (along with LOD meshes). /// Outputs the inputNodeID if successfully uploaded mesh data and returns true. /// </summary> /// <param name="session">Session to create input node</param> /// <param name="assetID">The parent asset ID</param> /// <param name="inputObject">The input GameObject to query mesh data from</param> /// <param name="inputNodeID">Output of input node ID if successfully created</param> /// <returns>True if successfully created and uploaded mesh data</returns> public static bool CreateInputNodeWithGeoData(HEU_SessionBase session, HAPI_NodeId assetID, GameObject inputObject, out HAPI_NodeId inputNodeID) { inputNodeID = HEU_Defines.HEU_INVALID_NODE_ID; if (!HEU_HAPIUtility.IsAssetValidInHoudini(session, assetID)) { return false; } bool bHasLODGroup = false; List<HEU_UploadMeshData> uploadMeshDatas = GenerateMeshDatasFromInputObject(inputObject, out bHasLODGroup); if (uploadMeshDatas == null || uploadMeshDatas.Count == 0) { return false; } // If connected asset is not valid, then need to create an input asset if (inputNodeID == HEU_Defines.HEU_INVALID_NODE_ID) { string inputName = null; HAPI_NodeId newNodeID = HEU_Defines.HEU_INVALID_NODE_ID; session.CreateInputNode(out newNodeID, inputName); if (newNodeID == HEU_Defines.HEU_INVALID_NODE_ID || !HEU_HAPIUtility.IsAssetValidInHoudini(session, newNodeID)) { Debug.LogErrorFormat("Failed to create new input node in Houdini session!"); return false; } inputNodeID = newNodeID; if (!session.CookNode(inputNodeID, false)) { Debug.LogErrorFormat("New input node failed to cook!"); return false; } } return UploadInputMeshData(session, inputNodeID, uploadMeshDatas, bHasLODGroup); }