Skip to content

Commit

Permalink
fixed 1frame lag when playing alembic from timeline/playable
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonm-unity committed Aug 22, 2017
1 parent cfb73c4 commit b9e3b48
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace UTJ.Alembic
public class AlembicStreamPlayer : MonoBehaviour
{
private AlembicStream _stream = null;
public bool m_ManualUpdateMode = false;

[HideInInspector]
public AlembicStream Stream
Expand Down Expand Up @@ -49,9 +50,15 @@ void OnEnable()

}

public void ManualUpdate()
{
if (Stream != null && m_ManualUpdateMode == true)
Stream.ProcessUpdateEvent();
}

public void Update()
{
if (Stream != null)
if (Stream != null && m_ManualUpdateMode == false)
Stream.ProcessUpdateEvent();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@ namespace UTJ.Alembic
{
public class AlembicShotPlayable : PlayableBehaviour
{
public AlembicStreamPlayer streamPlayer { get; set; }

public float m_StartTimeOffsetsdfs;
AlembicStreamPlayer m_StreamPlayer;
public AlembicStreamPlayer streamPlayer
{
get
{
return m_StreamPlayer;
}
set
{
m_StreamPlayer = value;
m_StreamPlayer.m_ManualUpdateMode = true;
}
}

public float m_StartTimeOffset;
public float m_EndTimeClipOff;
Expand All @@ -22,7 +32,6 @@ public override void ProcessFrame(Playable playable, FrameData info, object play

if (streamPlayer == null)
return;

streamPlayer.m_PlaybackSettings.m_startTime = 0f;
streamPlayer.m_PlaybackSettings.m_cycle = m_Cycle;
streamPlayer.m_PlaybackSettings.m_timeOffset = (float)m_StartTimeOffset;
Expand All @@ -31,6 +40,8 @@ public override void ProcessFrame(Playable playable, FrameData info, object play
streamPlayer.m_PlaybackSettings.m_Time = (float)playable.GetTime();
streamPlayer.m_PlaybackSettings.m_OverrideTime = true;
streamPlayer.m_PlaybackSettings.m_preserveStartTime = true;

streamPlayer.ManualUpdate();
}
}
}
Expand Down

0 comments on commit b9e3b48

Please sign in to comment.