/// <summary>
        /// Query all the PDG graph context in the current Houdini Engine session.
        /// Handle PDG events, work item status updates.
        /// Forward relevant events to HEU_PDGAssetLink objects.
        /// </summary>
        private void UpdatePDGContext()
        {
#if HOUDINIENGINEUNITY_ENABLED
            HEU_SessionBase session = GetHAPIPDGSession();
            if (session == null || !session.IsSessionValid())
            {
                return;
            }

            // Get current PDG graph contexts
            ReinitializePDGContext();

            // Process next set of events for each graph context
            if (_pdgContextIDs != null)
            {
                foreach (HAPI_PDG_GraphContextId contextID in _pdgContextIDs)
                {
                    int pdgStateInt;
                    if (!session.GetPDGState(contextID, out pdgStateInt))
                    {
                        SetErrorState("Failed to get PDG state", true);
                        continue;
                    }

                    _pdgState = (HAPI_PDG_State)pdgStateInt;

                    // Only initialize event array if not valid, or user resized max size
                    if (_pdgQueryEvents == null || _pdgQueryEvents.Length != _pdgMaxProcessEvents)
                    {
                        _pdgQueryEvents = new HAPI_PDG_EventInfo[_pdgMaxProcessEvents];
                    }

                    for (int i = 0; i < _pdgQueryEvents.Length; ++i)
                    {
                        ResetPDGEventInfo(ref _pdgQueryEvents[i]);
                    }

                    int eventCount     = 0;
                    int remainingCount = 0;
                    if (!session.GetPDGEvents(contextID, _pdgQueryEvents, _pdgMaxProcessEvents, out eventCount, out remainingCount))
                    {
                        SetErrorState("Failed to get PDG events", true);
                        continue;
                    }

                    for (int i = 0; i < eventCount; ++i)
                    {
                        ProcessPDGEvent(session, contextID, ref _pdgQueryEvents[i]);
                    }
                }
            }
#endif
        }
Exemple #2
0
        private void UpdatePDGContext()
        {
            HEU_SessionBase session = GetHAPIPDGSession();

            if (session == null || !session.IsSessionValid())
            {
                return;
            }

            ReinitializePDGContext();

            // Get next set of events for each graph context
            if (_pdgContextIDs != null)
            {
                foreach (HAPI_PDG_GraphContextId contextID in _pdgContextIDs)
                {
                    int pdgStateInt;
                    if (!session.GetPDGState(contextID, out pdgStateInt))
                    {
                        SetErrorState("Failed to get PDG state", true);
                        continue;
                    }

                    _pdgState = (HAPI_PDG_State)pdgStateInt;


                    if (_pdgQueryEvents == null || _pdgQueryEvents.Length != _pdgMaxProcessEvents)
                    {
                        _pdgQueryEvents = new HAPI_PDG_EventInfo[_pdgMaxProcessEvents];
                    }

                    for (int i = 0; i < _pdgQueryEvents.Length; ++i)
                    {
                        ResetPDGEventInfo(ref _pdgQueryEvents[i]);
                    }

                    int eventCount     = 0;
                    int remainingCount = 0;
                    if (!session.GetPDGEvents(contextID, _pdgQueryEvents, _pdgMaxProcessEvents, out eventCount, out remainingCount))
                    {
                        SetErrorState("Failed to get PDG events", true);
                        continue;
                    }

                    for (int i = 0; i < eventCount; ++i)
                    {
                        ProcessPDGEvent(session, contextID, ref _pdgQueryEvents[i]);
                    }
                }
            }
        }