PlayThread and non cyclic animations
by Jacobin · in Torque Game Engine Advanced · 04/10/2007 (2:02 pm) · 0 replies
While playing around with blending animations on top of action animations using playThread, I noticed the shapebase threads were not resetting themselves properly when st.atend was true. You could only call them once, as the engine apparently thought they were still running. The change below seems to have resolved the matter.
void ShapeBase::advanceThreads(F32 dt)
{
for (U32 i = 0; i < MaxScriptThreads; i++) {
Thread& st = mScriptThread[i];
if (st.thread) {
if (!mShapeInstance->getShape()->sequences[st.sequence].isCyclic() && !st.atEnd &&
(st.forward? mShapeInstance->getPos(st.thread) >= 1.0:
mShapeInstance->getPos(st.thread) <= 0)) {
st.atEnd = true;
updateThread(st);
if (!isGhost()) {
[b]stopThread(i);[/b]
char slot[16];
dSprintf(slot,sizeof(slot),"%d",i);
Con::executef(mDataBlock,3,"onEndSequence",scriptThis(),slot);
}
}
mShapeInstance->advanceTime(dt,st.thread);
}
}
}