MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / rebuildExplosion

Method rebuildExplosion

src/geometry/TankSceneNode.cpp:434–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

432
433
434void TankSceneNode::rebuildExplosion() {
435 // prepare explosion rotations and translations
436 for (int i = 0; i < LastTankPart; i++) {
437 // pick an unbiased rotation vector
438 float distSq;
439 do {
440 spin[i].x = (float)(bzfrand() - 0.5);
441 spin[i].y = (float)(bzfrand() - 0.5);
442 spin[i].z = (float)(bzfrand() - 0.5);
443 distSq = spin[i].xyz().lengthSq();
444 }
445 while ((distSq < 1.0e-6) || (distSq > 0.25f));
446 spin[i].xyz() *= (1.0f / sqrtf(distSq)); // normalize
447
448 // now an angular velocity -- make sure we get at least 2 complete turns
449 spin[i].w = 360.0f * (5.0f * (float)bzfrand() + 2.0f);
450
451 // different cheezy spheroid explosion pattern
452 const float vhMax = maxExplosionVel;
453 const float vhAngleVert = (float)(0.25 * M_PI * bzfrand());
454 const float vhMag = vhMax * cosf(vhAngleVert);
455 const float vhAngle = (float)(2.0 * M_PI * bzfrand());
456 vel[i].z = vhMax * sinf(vhAngleVert) * vertExplosionRatio;
457 vel[i].y = vhMag * cosf(vhAngle);
458 vel[i].x = vhMag * sinf(vhAngle);
459 }
460 return;
461}
462
463
464void TankSceneNode::renderRadar() {

Callers 1

explodeMethod · 0.80

Calls 1

lengthSqMethod · 0.45

Tested by

no test coverage detected