Skip to content

Commit

Permalink
fixed issue with cacheSamples not having any effect.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomasch-unity3d committed Dec 7, 2017
1 parent fee0a5f commit 7fb21f0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions AlembicImporter/Assets/UTJ/Alembic/Scripts/Importer/AbcAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<aiObject>()
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void LoadStream()
{
if (streamDescriptor == null) return;
Stream = new AlembicStream(gameObject, streamDescriptor);
Stream.AbcLoad(true);
Stream.AbcLoad();
m_ForceUpdate = true;
}

Expand Down
14 changes: 0 additions & 14 deletions Plugin/abci/Importer/aiSchema.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -125,19 +124,6 @@ class aiTSchema : public aiSchemaBase
return static_cast<int>(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)
Expand Down

0 comments on commit 7fb21f0

Please sign in to comment.