Merge pull request #780 from eightyeight/fix-shapebase-animation-networking

Fixed ShapeBase animation networking
This commit is contained in:
Daniel Buckmaster 2014-09-16 09:55:50 +10:00
commit 8f5166393b
2 changed files with 9 additions and 16 deletions

View file

@ -2154,13 +2154,13 @@ bool ShapeBase::setThreadSequence(U32 slot, S32 seq, bool reset)
if (reset) {
st.state = Thread::Play;
st.atEnd = false;
st.timescale = 1.f;
st.position = 0.f;
st.timescale = 1.f;
st.position = 0.f;
}
if (mShapeInstance) {
if (!st.thread)
st.thread = mShapeInstance->addThread();
mShapeInstance->setSequence(st.thread,seq,0);
mShapeInstance->setSequence(st.thread,seq,st.position);
updateThread(st);
}
return true;
@ -2175,17 +2175,11 @@ void ShapeBase::updateThread(Thread& st)
case Thread::Stop:
{
mShapeInstance->setTimeScale( st.thread, 1.f );
mShapeInstance->setPos( st.thread, ( st.timescale > 0.f ) ? 0.0f : 1.0f );
mShapeInstance->setPos( st.thread, ( st.timescale > 0.f ) ? 1.0f : 0.0f );
} // Drop through to pause state
case Thread::Pause:
{
if ( st.position != -1.f )
{
mShapeInstance->setTimeScale( st.thread, 1.f );
mShapeInstance->setPos( st.thread, st.position );
}
mShapeInstance->setTimeScale( st.thread, 0.f );
} break;
@ -2339,6 +2333,7 @@ void ShapeBase::advanceThreads(F32 dt)
if(st.thread)
{
mShapeInstance->advanceTime(dt,st.thread);
st.position = mShapeInstance->getPos(st.thread);
}
}
}
@ -3039,9 +3034,9 @@ void ShapeBase::unpackUpdate(NetConnection *con, BitStream *stream)
if (stream->readFlag()) {
Thread& st = mScriptThread[i];
U32 seq = stream->readInt(ThreadSequenceBits);
st.state = stream->readInt(2);
stream->read( &st.timescale );
stream->read( &st.position );
st.state = Thread::State(stream->readInt(2));
stream->read( &st.timescale );
stream->read( &st.position );
st.atEnd = stream->readFlag();
if (st.sequence != seq && st.state != Thread::Destroy)
setThreadSequence(i,seq,false);

View file

@ -729,9 +729,7 @@ protected:
Play, Stop, Pause, Destroy
};
TSThread* thread; ///< Pointer to 3space data.
U32 state; ///< State of the thread
///
/// @see Thread::State
State state; ///< State of the thread
S32 sequence; ///< The animation sequence which is running in this thread.
F32 timescale; ///< Timescale
bool atEnd; ///< Are we at the end of this thread?