MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / advancePos

Method advancePos

Engine/source/ts/tsThread.cpp:353–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351}
352
353void TSThread::advancePos(F32 delta)
354{
355 if (mFabs(delta)>0.00001f)
356 {
357 // make dirty what this thread changes
358 U32 dirtyFlags = getSequence()->dirtyFlags | (transitionData.inTransition ? TSShapeInstance::TransformDirty : 0);
359 for (S32 i=0; i<mShapeInstance->getShape()->subShapeFirstNode.size(); i++)
360 mShapeInstance->mDirtyFlags[i] |= dirtyFlags;
361 }
362
363 if (transitionData.inTransition)
364 {
365 transitionData.pos += transitionData.direction * delta;
366 if (transitionData.pos<0 || transitionData.pos>=1.0f)
367 {
368 mShapeInstance->clearTransition(this);
369 if (transitionData.pos<0.0f)
370 // return to old sequence
371 mShapeInstance->setSequence(this,transitionData.oldSequence,transitionData.oldPos);
372 }
373 // re-adjust delta to be correct time-wise
374 delta *= transitionData.targetScale * transitionData.duration / getSequence()->duration;
375 }
376
377 // even if we are in a transition, keep playing the sequence
378
379 if (makePath)
380 {
381 path.start = mSeqPos;
382 mSeqPos += delta;
383 if (!getSequence()->isCyclic())
384 {
385 mSeqPos = mClampF(mSeqPos, 0.0f, 1.0f);
386 path.loop = 0;
387 }
388 else
389 {
390 path.loop = (S32)mSeqPos;
391 if (mSeqPos < 0.0f)
392 path.loop--;
393 mSeqPos -= path.loop;
394 // following necessary because of floating point roundoff errors
395 if (mSeqPos < 0.0f) mSeqPos += 1.0f;
396 if (mSeqPos >= 1.0f) mSeqPos -= 1.0f;
397 }
398 path.end = mSeqPos;
399
400 animateTriggers(); // do this automatically...no need for user to call it
401
402 AssertFatal(mSeqPos >=0.0f && mSeqPos <=1.0f,"TSThread::advancePos (1)");
403 AssertFatal(!getSequence()->isCyclic() || mSeqPos<1.0f,"TSThread::advancePos (2)");
404 }
405 else
406 {
407 mSeqPos += delta;
408 if (!getSequence()->isCyclic())
409 mSeqPos = mClampF(mSeqPos, 0.0f, 1.0f);
410 else

Callers 1

advanceTimeMethod · 0.80

Calls 7

mFabsFunction · 0.85
mClampFFunction · 0.85
clearTransitionMethod · 0.80
sizeMethod · 0.45
getShapeMethod · 0.45
setSequenceMethod · 0.45
isCyclicMethod · 0.45

Tested by

no test coverage detected