diff --git a/AlembicImporter/Assets/UTJ/Alembic/Editor/Importer/AlembicImporter.cs b/AlembicImporter/Assets/UTJ/Alembic/Editor/Importer/AlembicImporter.cs index 86330daac..3b933a980 100644 --- a/AlembicImporter/Assets/UTJ/Alembic/Editor/Importer/AlembicImporter.cs +++ b/AlembicImporter/Assets/UTJ/Alembic/Editor/Importer/AlembicImporter.cs @@ -105,7 +105,7 @@ public override void OnImportAsset(AssetImportContext ctx) using (var abcStream = new AlembicStream(go, streamDescriptor)) { - abcStream.AbcLoad(true); + abcStream.AbcLoad(); AbcStartTime = abcStream.AbcStartTime; AbcEndTime = abcStream.AbcEndTime; AbcFrameCount = abcStream.AbcFrameCount; diff --git a/AlembicImporter/Assets/UTJ/Alembic/Scripts/Importer/AbcAPI.cs b/AlembicImporter/Assets/UTJ/Alembic/Scripts/Importer/AbcAPI.cs index c003043a2..434824b92 100644 --- a/AlembicImporter/Assets/UTJ/Alembic/Scripts/Importer/AbcAPI.cs +++ b/AlembicImporter/Assets/UTJ/Alembic/Scripts/Importer/AbcAPI.cs @@ -341,12 +341,12 @@ public static float GetAspectRatio(aiAspectRatioMode mode) } } - public static void UpdateAbcTree(aiContext ctx, AlembicTreeNode node, float time, bool createMissingNodes=false) + public static void UpdateAbcTree(aiContext ctx, AlembicTreeNode node, float time, bool createMissingNodes=true) { var ic = new ImportContext { alembicTreeNode = node, - //ss = aiTimeToSampleSelector(time), + ss = aiTimeToSampleSelector(time), createMissingNodes = createMissingNodes, objectsToDelete = new List() }; diff --git a/AlembicImporter/Assets/UTJ/Alembic/Scripts/Importer/AlembicStream.cs b/AlembicImporter/Assets/UTJ/Alembic/Scripts/Importer/AlembicStream.cs index 38cfef40d..6befe99c7 100644 --- a/AlembicImporter/Assets/UTJ/Alembic/Scripts/Importer/AlembicStream.cs +++ b/AlembicImporter/Assets/UTJ/Alembic/Scripts/Importer/AlembicStream.cs @@ -149,36 +149,35 @@ public bool AbcUpdate(float time,float motionScale,bool interpolateSamples) return true; } - public void AbcLoad(bool createMissingNodes=false) + public void AbcLoad() { m_Time = 0.0f; m_Context = AbcAPI.aiCreateContext(alembicTreeRoot.linkedGameObj.GetInstanceID()); - m_Loaded = AbcAPI.aiLoad(m_Context,m_StreamDesc.pathToAbc); - - - if (m_Loaded) - { - var settings = m_StreamDesc.settings; - m_Config.swapHandedness = settings.swapHandedness; - m_Config.shareVertices = settings.shareVertices; - m_Config.swapFaceWinding = settings.swapFaceWinding; - m_Config.normalsMode = settings.normalsMode; - m_Config.tangentsMode = settings.tangentsMode; - m_Config.cacheSamples = settings.cacheSamples; - m_Config.treatVertexExtraDataAsStatics = settings.treatVertexExtraDataAsStatics; - m_Config.turnQuadEdges = settings.turnQuadEdges; - m_Config.aspectRatio = AbcAPI.GetAspectRatio(settings.aspectRatioMode); - m_Config.cacheTangentsSplits = true; + var settings = m_StreamDesc.settings; + m_Config.swapHandedness = settings.swapHandedness; + m_Config.shareVertices = settings.shareVertices; + m_Config.swapFaceWinding = settings.swapFaceWinding; + m_Config.normalsMode = settings.normalsMode; + m_Config.tangentsMode = settings.tangentsMode; + m_Config.cacheSamples = settings.cacheSamples; + m_Config.treatVertexExtraDataAsStatics = settings.treatVertexExtraDataAsStatics; + m_Config.turnQuadEdges = settings.turnQuadEdges; + m_Config.aspectRatio = AbcAPI.GetAspectRatio(settings.aspectRatioMode); + m_Config.cacheTangentsSplits = true; #if !UNITY_2017_3_OR_NEWER - m_Config.use32BitsIndexBuffer = settings.use32BitsIndexBuffer; + m_Config.use32BitsIndexBuffer = settings.use32BitsIndexBuffer; #else - m_Config.use32BitsIndexBuffer = false; + m_Config.use32BitsIndexBuffer = false; #endif AbcAPI.aiSetConfig(m_Context, ref m_Config); - AbcAPI.UpdateAbcTree(m_Context, alembicTreeRoot, m_Time, createMissingNodes); + m_Loaded = AbcAPI.aiLoad(m_Context,m_StreamDesc.pathToAbc); + + if (m_Loaded) + { + AbcAPI.UpdateAbcTree(m_Context, alembicTreeRoot, m_Time); AlembicStream.s_Streams.Add(this); } else diff --git a/AlembicImporter/Assets/UTJ/Alembic/Scripts/Importer/AlembicStreamPlayer.cs b/AlembicImporter/Assets/UTJ/Alembic/Scripts/Importer/AlembicStreamPlayer.cs index 4a3e34d74..19290ab1a 100644 --- a/AlembicImporter/Assets/UTJ/Alembic/Scripts/Importer/AlembicStreamPlayer.cs +++ b/AlembicImporter/Assets/UTJ/Alembic/Scripts/Importer/AlembicStreamPlayer.cs @@ -68,7 +68,7 @@ public void LoadStream() { if (streamDescriptor == null) return; Stream = new AlembicStream(gameObject, streamDescriptor); - Stream.AbcLoad(true); + Stream.AbcLoad(); m_ForceUpdate = true; } diff --git a/Plugin/abci/Importer/aiSchema.h b/Plugin/abci/Importer/aiSchema.h index c38fca592..3bfaf9228 100644 --- a/Plugin/abci/Importer/aiSchema.h +++ b/Plugin/abci/Importer/aiSchema.h @@ -40,7 +40,6 @@ class aiSchemaBase void setSampleCallback(aiSampleCallback cb, void *arg); void invokeConfigCallback(aiConfig *config) const; void invokeSampleCallback(aiSampleBase *sample, bool topologyChanged) const; - virtual void cacheAllSamples() =0; virtual void cacheSamples(int64_t startIndex, int64_t endIndex)=0; virtual int getTimeSamplingIndex() const = 0; virtual int getNumSamples() const = 0; @@ -125,19 +124,6 @@ class aiTSchema : public aiSchemaBase return static_cast(m_numSamples); } - void cacheAllSamples() override - { - if (m_constant) - return; - readConfig(); - for (int64_t i=0; i< m_numSamples ; i++) - { - auto &sp = m_samples[i]; - bool unused = i == 0; - sp.reset(readSample(i, unused)); - } - } - void cacheSamples(int64_t startIndex, int64_t endIndex) override { if (m_constant)