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

Method startSplits

Engine/source/T3D/fx/lightning.cpp:1298–1321  ·  view source on GitHub ↗

---------------------------------------------------------------------------- Start split - kick off the recursive 'createSplit' procedure ----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1296// Start split - kick off the recursive 'createSplit' procedure
1297//----------------------------------------------------------------------------
1298void LightningBolt::startSplits()
1299{
1300
1301 for( U32 i=0; i<mMajorNodes.numNodes-1; i++ )
1302 {
1303 if( gRandGen.randF() > 0.3f )
1304 continue;
1305
1306 Node node = mMajorNodes.nodeList[i];
1307 Node node2 = mMajorNodes.nodeList[i+1];
1308
1309 VectorF segDir = node2.point - node.point;
1310 F32 length = segDir.len();
1311 segDir.normalizeSafe();
1312
1313 VectorF newDir = MathUtils::randomDir( segDir, 20.0f, 40.0f );
1314 Point3F newEndPoint = node.point + newDir * gRandGen.randF( 0.5f, 1.5f ) * length;
1315
1316
1317 createSplit( node.point, newEndPoint, 4, width * 0.30f );
1318 }
1319
1320
1321}
1322
1323//----------------------------------------------------------------------------
1324// Update

Callers 1

processEventMethod · 0.80

Calls 4

randomDirFunction · 0.85
randFMethod · 0.80
lenMethod · 0.45
normalizeSafeMethod · 0.45

Tested by

no test coverage detected