Exemplo n.º 1
0
        void OnDestroy()
        {
            if (!AbcIsValid())
            {
                return;
            }

            if (!Application.isPlaying)
            {
    #if UNITY_EDITOR
                if (!EditorApplication.isPlayingOrWillChangePlaymode)
                {
                    AbcDetachElements();
                    AbcAPI.aiDestroyContext(m_abc);
                    m_abc = default(AbcAPI.aiContext);
                }
    #else
                AbcDetachElements();
                AbcAPI.aiDestroyContext(m_abc);
                m_abc = default(AbcAPI.aiContext);
    #endif
            }
        }
Exemplo n.º 2
0
        void AbcUpdateBegin(float time)
        {
            if (m_lastLogToFile != m_logToFile ||
                m_lastLogPath != m_logPath)
            {
                AbcAPI.aiEnableFileLog(m_logToFile, m_logPath);

                m_lastLogToFile = m_logToFile;
                m_lastLogPath   = m_logPath;
            }

            if (!m_loaded && m_pathToAbc != null)
            {
                // We have lost the alembic context, try to recover it
                m_loaded = AbcRecoverContext();
            }

            if (m_loaded)
            {
                if (!AbcIsValid())
                {
                    // We have lost the alembic context, try to recover
                    m_loaded = AbcRecoverContext();
                    if (!m_loaded)
                    {
                        Debug.LogWarning("AlembicStream.AbcUpdate: Lost alembic context");

                        return;
                    }
                }

                m_time = time;

                float abcTime     = AbcTime(m_time);
                float aspectRatio = AbcAPI.GetAspectRatio(m_aspectRatioMode);

                if (AbcUpdateRequired(abcTime, aspectRatio))
                {
                    if (m_verbose)
                    {
                        Debug.Log("AlembicStream.AbcUpdate: t=" + m_time + " (t'=" + abcTime + ")");
                    }

                    if (m_pathToAbc != m_lastPathToAbc)
                    {
                        if (m_verbose)
                        {
                            Debug.Log("AlembicStream.AbcUpdate: Path to alembic file changed");
                        }

                        AbcDetachElements();

                        AbcAPI.aiDestroyContext(m_abc);

                        m_elements.Clear();

                        AbcLoad(true);

                        AbcCleanupTree();
                    }
                    else
                    {
                        AbcSyncConfig();

                        if (m_useThreads)
                        {
                            AbcAPI.aiUpdateSamplesBegin(m_abc, abcTime);
                            m_updateBegan = true;
                        }
                        else
                        {
                            AbcAPI.aiUpdateSamples(m_abc, abcTime);
                            AbcUpdateElements();
                        }
                    }

                    AbcSetLastUpdateState(abcTime, aspectRatio);
                }
            }
        }