Sfoglia il codice sorgente

Fixed ShapeBase animation networking.

We essentially just need to remember to Update ShapeBase::Thread::position
every time we advance the thread in the shape. With a little bit of
supporting code these changes will be passed to the client's shape.
Daniel Buckmaster 11 anni fa
parent
commit
439dc9c56d
2 ha cambiato i file con 9 aggiunte e 16 eliminazioni
  1. 8 13
      Engine/source/T3D/shapeBase.cpp
  2. 1 3
      Engine/source/T3D/shapeBase.h

+ 8 - 13
Engine/source/T3D/shapeBase.cpp

@@ -2154,13 +2154,13 @@ bool ShapeBase::setThreadSequence(U32 slot, S32 seq, bool reset)
       if (reset) {
       if (reset) {
          st.state = Thread::Play;
          st.state = Thread::Play;
          st.atEnd = false;
          st.atEnd = false;
-		 st.timescale = 1.f;
-		 st.position = 0.f;
+         st.timescale = 1.f;
+         st.position = 0.f;
       }
       }
       if (mShapeInstance) {
       if (mShapeInstance) {
          if (!st.thread)
          if (!st.thread)
             st.thread = mShapeInstance->addThread();
             st.thread = mShapeInstance->addThread();
-         mShapeInstance->setSequence(st.thread,seq,0);
+         mShapeInstance->setSequence(st.thread,seq,st.position);
          updateThread(st);
          updateThread(st);
       }
       }
       return true;
       return true;
@@ -2175,17 +2175,11 @@ void ShapeBase::updateThread(Thread& st)
 		case Thread::Stop:
 		case Thread::Stop:
 			{
 			{
 				mShapeInstance->setTimeScale( st.thread, 1.f );
 				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
 			} // Drop through to pause state
 
 
 		case Thread::Pause:
 		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 );
 				mShapeInstance->setTimeScale( st.thread, 0.f );
 			} break;
 			} break;
 
 
@@ -2339,6 +2333,7 @@ void ShapeBase::advanceThreads(F32 dt)
          if(st.thread)
          if(st.thread)
          {
          {
             mShapeInstance->advanceTime(dt,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()) {
          if (stream->readFlag()) {
             Thread& st = mScriptThread[i];
             Thread& st = mScriptThread[i];
             U32 seq = stream->readInt(ThreadSequenceBits);
             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();
             st.atEnd = stream->readFlag();
             if (st.sequence != seq && st.state != Thread::Destroy)
             if (st.sequence != seq && st.state != Thread::Destroy)
                setThreadSequence(i,seq,false);
                setThreadSequence(i,seq,false);

+ 1 - 3
Engine/source/T3D/shapeBase.h

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