@@ -1291,80 +1291,56 @@ float AtomGroup::Travel(Vector &position,
1291
1291
}
1292
1292
}
1293
1293
// TERRAIN SINK ////////////////////////////////////////////////////////////////
1294
- // Else all Atom:s must have penetrated and therefore the entire group has
1295
- // sunken into the terrain. Get the penetration resistance results and
1296
- // apply them to the owner.
1297
- else if (!penetratingAtoms.empty ())
1298
- {
1299
- // Re-calculate the progress made on this segment before hitting something.
1300
- // We do this because the hitting step made resulted in a terrain sink,
1301
- // which means the segment progressed another step, and the segmentProgress
1302
- // should reflect this.
1303
- segProgress = static_cast <float >(stepCount + 1 ) / static_cast <float >(stepsOnSeg);
1304
-
1305
- // TODO: Wrapping detection here may be screwed up on very special cases.")
1306
- // Move position forward to the sink hit position.
1307
- position = preHitPos + linSegTraj * segProgress;
1308
- // Wrap position, if necessary.
1309
- didWrap = g_SceneMan.WrapPosition (position) || didWrap;
1310
- // Move rotation forward according to the progress made on the segment, incl sink.
1311
- rotation = preHitRot + rotDelta * segProgress;
1312
- /*
1313
- // Adjust the radius etc to account for the sinking into the terrain.
1314
- (*aItr)->SetHitRadius((*aItr)->GetOffset().RadRotate(rotation));
1315
- // Figure out the pre-collision velocity of the
1316
- // hitting atom due to body translation and rotation.
1317
- (*aItr)->SetHitVel(velocity + (*aItr)->GetOffset().RadRotate(rotation + c_HalfPI) *
1318
- c_MPP * angVel);
1319
- */
1320
- hitFactor = 1 .0F / static_cast <float >(penetratingAtoms.size ());
1294
+ // Handle terrain penetration effects.
1295
+ if (!penetratingAtoms.empty ()) {
1296
+ hitFactor = 1 .0F / static_cast <float >(penetratingAtoms.size ());
1321
1297
1322
- // Calc and store the collision response effects.
1323
- for (Atom *penetratingAtom : penetratingAtoms)
1324
- {
1298
+ // Calc and store the collision response effects.
1299
+ for (Atom *penetratingAtom : penetratingAtoms)
1300
+ {
1325
1301
1326
1302
1327
- // This gets re-set later according to the ortho pixel edges hit.
1303
+ // This gets re-set later according to the ortho pixel edges hit.
1328
1304
// hitData.BitmapNormal = -(hitData.HitVel[HITOR].GetNormalized());
1329
1305
// hitData.SquaredMIHandle[HITOR] = hitData.HitRadius[HITOR].GetPerpendicular()/*.Dot(hitData.BitmapNormal)*/;
1330
1306
// hitData.SquaredMIHandle[HITOR] *= hitData.SquaredMIHandle[HITOR];
1331
1307
// hitData.HitDenominator = (1.0 / distMass) + (hitData.SquaredMIHandle[HITOR] / distMI);
1332
1308
// hitData.PreImpulse[HITOR] = hitData.HitVel[HITOR] / hitData.HitDenominator;
1333
1309
1334
- // Get the hitdata so far gathered for this Atom.
1335
- hitData = penetratingAtom->GetHitData ();
1336
-
1337
- if (g_SceneMan.TryPenetrate (penetratingAtom->GetCurrentPos ().GetFloorIntX (),
1338
- penetratingAtom->GetCurrentPos ().GetFloorIntY (),
1339
- hitData.PreImpulse [HITOR],
1340
- hitData.HitVel [HITOR],
1341
- retardation,
1342
- 1 .0F ,
1343
- 1 /* (*penetratingAtom)->GetNumPenetrations()*/ ))
1344
- {
1310
+ // Get the hitdata so far gathered for this Atom.
1311
+ hitData = penetratingAtom->GetHitData ();
1345
1312
1346
- // Recalc these here without the distributed mass and MI.
1347
- radMag = hitData.HitRadius [HITOR].GetMagnitude ();
1348
- hitData.HitDenominator = (1 .0F / mass) + ((radMag * radMag) / m_MomInertia);
1349
- hitData.PreImpulse [HITOR] = hitData.HitVel [HITOR] / hitData.HitDenominator ;
1350
- hitData.TotalMass [HITOR] = mass;
1351
- hitData.MomInertia [HITOR] = m_MomInertia;
1352
- hitData.ImpulseFactor [HITOR] = hitFactor;
1353
- // Finally calculate the hit response impulse.
1354
- hitData.ResImpulse [HITOR] = ((hitData.HitVel [HITOR] * retardation) /
1355
- hitData.HitDenominator ) * hitFactor;
1356
-
1357
- // Call the call-on-sink function, if requested.
1358
- if (callOnSink)
1359
- halted = halted || m_pOwnerMO->OnSink (hitData);
1360
-
1361
- // Copy back the new hit data with all the info we have so far.
1362
- penetratingAtom->SetHitData (hitData);
1363
- // Save the atom for later application of its hit data to the body.
1364
- hitResponseAtoms.push_back (penetratingAtom);
1365
- }
1366
- }
1367
- }
1313
+ if (g_SceneMan.TryPenetrate (penetratingAtom->GetCurrentPos ().GetFloorIntX (),
1314
+ penetratingAtom->GetCurrentPos ().GetFloorIntY (),
1315
+ hitData.PreImpulse [HITOR],
1316
+ hitData.HitVel [HITOR],
1317
+ retardation,
1318
+ 1 .0F ,
1319
+ 1 /* (*penetratingAtom)->GetNumPenetrations()*/ ))
1320
+ {
1321
+
1322
+ // Recalc these here without the distributed mass and MI.
1323
+ radMag = hitData.HitRadius [HITOR].GetMagnitude ();
1324
+ hitData.HitDenominator = (1 .0F / mass) + ((radMag * radMag) / m_MomInertia);
1325
+ hitData.PreImpulse [HITOR] = hitData.HitVel [HITOR] / hitData.HitDenominator ;
1326
+ hitData.TotalMass [HITOR] = mass;
1327
+ hitData.MomInertia [HITOR] = m_MomInertia;
1328
+ hitData.ImpulseFactor [HITOR] = hitFactor;
1329
+ // Finally calculate the hit response impulse.
1330
+ hitData.ResImpulse [HITOR] = ((hitData.HitVel [HITOR] * retardation) /
1331
+ hitData.HitDenominator ) * hitFactor;
1332
+
1333
+ // Call the call-on-sink function, if requested.
1334
+ if (callOnSink)
1335
+ halted = halted || m_pOwnerMO->OnSink (hitData);
1336
+
1337
+ // Copy back the new hit data with all the info we have so far.
1338
+ penetratingAtom->SetHitData (hitData);
1339
+ // Save the atom for later application of its hit data to the body.
1340
+ hitResponseAtoms.push_back (penetratingAtom);
1341
+ }
1342
+ }
1343
+ }
1368
1344
1369
1345
// MOVABLEOBJECT COLLISION RESPONSE ///////////////////////////////////////////////
1370
1346
// /////////////////////////////////////////////////////////////////////////////////
0 commit comments