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

Method updateThreads

Engine/source/gui/editor/guiShapeEdPreview.cpp:1329–1394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1327}
1328
1329void GuiShapeEdPreview::updateThreads(F32 delta)
1330{
1331 // Advance time on all threads
1332 for ( S32 i = 0; i < mThreads.size(); i++ )
1333 {
1334 Thread& thread = mThreads[i];
1335 if ( !thread.key || !thread.direction )
1336 continue;
1337
1338 // Make sure thread priority matches sequence priority (which may have changed)
1339 mModel->setPriority( thread.key, mModel->getShape()->sequences[mModel->getSequence( thread.key )].priority );
1340
1341 // Handle ping-pong
1342 if ( thread.pingpong && !mModel->isInTransition( thread.key ) )
1343 {
1344 // Determine next position, then adjust if needed
1345 F32 threadPos = mModel->getPos( thread.key );
1346 F32 nextPos = threadPos + ( mModel->getTimeScale( thread.key ) * delta / mModel->getDuration( thread.key ) );
1347
1348 if ( nextPos < 0 )
1349 {
1350 // Reflect position and swap playback direction
1351 nextPos = -nextPos;
1352 mModel->setTimeScale( thread.key, -mModel->getTimeScale( thread.key ) );
1353 mModel->setPos( thread.key, nextPos );
1354 }
1355 else if ( nextPos > 1.0f )
1356 {
1357 // Reflect position and swap playback direction
1358 nextPos = 2.0f - nextPos;
1359 mModel->setTimeScale( thread.key, -mModel->getTimeScale( thread.key ) );
1360 mModel->setPos( thread.key, nextPos );
1361 }
1362 else
1363 {
1364 // Advance time normally
1365 mModel->advanceTime( delta, thread.key );
1366 }
1367 }
1368 else
1369 {
1370 // Advance time normally
1371 mModel->advanceTime( delta, thread.key );
1372 }
1373
1374 // Invoke script callback if active thread position has changed
1375 if ( i == mActiveThread )
1376 {
1377 F32 threadPos = mModel->getPos( thread.key );
1378 bool inTransition = mModel->isInTransition( thread.key );
1379 onThreadPosChanged_callback( threadPos, inTransition );
1380 }
1381 }
1382
1383 // Mark threads as dirty so they will be re-sorted, in case the user changed
1384 // sequence priority or blend flags
1385 mModel->setDirty( TSShapeInstance::ThreadDirty );
1386

Callers

nothing calls this directly

Calls 12

isInTransitionMethod · 0.80
setPosMethod · 0.80
sizeMethod · 0.45
setPriorityMethod · 0.45
getShapeMethod · 0.45
getSequenceMethod · 0.45
getPosMethod · 0.45
getTimeScaleMethod · 0.45
getDurationMethod · 0.45
setTimeScaleMethod · 0.45
advanceTimeMethod · 0.45
setDirtyMethod · 0.45

Tested by

no test coverage detected