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

Method updateThreads

Engine/source/gui/editor/guiShapeEdPreview.cpp:1258–1323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1256}
1257
1258void GuiShapeEdPreview::updateThreads(F32 delta)
1259{
1260 // Advance time on all threads
1261 for ( S32 i = 0; i < mThreads.size(); i++ )
1262 {
1263 Thread& thread = mThreads[i];
1264 if ( !thread.key || !thread.direction )
1265 continue;
1266
1267 // Make sure thread priority matches sequence priority (which may have changed)
1268 mModel->setPriority( thread.key, mModel->getShape()->sequences[mModel->getSequence( thread.key )].priority );
1269
1270 // Handle ping-pong
1271 if ( thread.pingpong && !mModel->isInTransition( thread.key ) )
1272 {
1273 // Determine next position, then adjust if needed
1274 F32 threadPos = mModel->getPos( thread.key );
1275 F32 nextPos = threadPos + ( mModel->getTimeScale( thread.key ) * delta / mModel->getDuration( thread.key ) );
1276
1277 if ( nextPos < 0 )
1278 {
1279 // Reflect position and swap playback direction
1280 nextPos = -nextPos;
1281 mModel->setTimeScale( thread.key, -mModel->getTimeScale( thread.key ) );
1282 mModel->setPos( thread.key, nextPos );
1283 }
1284 else if ( nextPos > 1.0f )
1285 {
1286 // Reflect position and swap playback direction
1287 nextPos = 2.0f - nextPos;
1288 mModel->setTimeScale( thread.key, -mModel->getTimeScale( thread.key ) );
1289 mModel->setPos( thread.key, nextPos );
1290 }
1291 else
1292 {
1293 // Advance time normally
1294 mModel->advanceTime( delta, thread.key );
1295 }
1296 }
1297 else
1298 {
1299 // Advance time normally
1300 mModel->advanceTime( delta, thread.key );
1301 }
1302
1303 // Invoke script callback if active thread position has changed
1304 if ( i == mActiveThread )
1305 {
1306 F32 threadPos = mModel->getPos( thread.key );
1307 bool inTransition = mModel->isInTransition( thread.key );
1308 onThreadPosChanged_callback( threadPos, inTransition );
1309 }
1310 }
1311
1312 // Mark threads as dirty so they will be re-sorted, in case the user changed
1313 // sequence priority or blend flags
1314 mModel->setDirty( TSShapeInstance::ThreadDirty );
1315

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