@@ -1192,17 +1192,10 @@ float AtomGroup::Travel(Vector &position,
1192
1192
// Special case of being at rest
1193
1193
if (stepCount == 0 && stepsOnSeg == 1 )
1194
1194
{
1195
- segProgress = 0 .0F ;
1196
1195
halted = true ;
1197
1196
// m_pOwnerMO->SetToSettle(true);
1198
- }
1199
- // Normal travel
1200
- else if (stepCount == 0 ) {
1201
- // Hit on first atom, but has farther to go
1202
- segProgress = 0 .75F / static_cast <float >(stepsOnSeg);
1203
- } else {
1204
- segProgress = static_cast <float >(stepCount) / static_cast <float >(stepsOnSeg);
1205
1197
}
1198
+ segProgress = static_cast <float >(stepCount) / static_cast <float >(stepsOnSeg);
1206
1199
1207
1200
// Move position forward to the hit position.
1208
1201
preHitPos = position;
@@ -1291,80 +1284,54 @@ float AtomGroup::Travel(Vector &position,
1291
1284
}
1292
1285
}
1293
1286
// 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 ());
1321
-
1322
- // Calc and store the collision response effects.
1323
- for (Atom *penetratingAtom : penetratingAtoms)
1324
- {
1325
-
1287
+ // Handle terrain penetration effects.
1288
+ if (!penetratingAtoms.empty ()) {
1289
+ hitFactor = 1 .0F / static_cast <float >(penetratingAtoms.size ());
1326
1290
1327
- // This gets re-set later according to the ortho pixel edges hit.
1291
+ // Calc and store the collision response effects.
1292
+ for (Atom *penetratingAtom : penetratingAtoms)
1293
+ {
1294
+ // This gets re-set later according to the ortho pixel edges hit.
1328
1295
// hitData.BitmapNormal = -(hitData.HitVel[HITOR].GetNormalized());
1329
1296
// hitData.SquaredMIHandle[HITOR] = hitData.HitRadius[HITOR].GetPerpendicular()/*.Dot(hitData.BitmapNormal)*/;
1330
1297
// hitData.SquaredMIHandle[HITOR] *= hitData.SquaredMIHandle[HITOR];
1331
1298
// hitData.HitDenominator = (1.0 / distMass) + (hitData.SquaredMIHandle[HITOR] / distMI);
1332
1299
// hitData.PreImpulse[HITOR] = hitData.HitVel[HITOR] / hitData.HitDenominator;
1333
1300
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
- {
1301
+ // Get the hitdata so far gathered for this Atom.
1302
+ hitData = penetratingAtom->GetHitData ();
1345
1303
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
- }
1304
+ if (g_SceneMan.TryPenetrate (penetratingAtom->GetCurrentPos ().GetFloorIntX (),
1305
+ penetratingAtom->GetCurrentPos ().GetFloorIntY (),
1306
+ hitData.PreImpulse [HITOR],
1307
+ hitData.HitVel [HITOR],
1308
+ retardation,
1309
+ 1 .0F ,
1310
+ 1 /* (*penetratingAtom)->GetNumPenetrations()*/ ))
1311
+ {
1312
+
1313
+ // Recalc these here without the distributed mass and MI.
1314
+ radMag = hitData.HitRadius [HITOR].GetMagnitude ();
1315
+ hitData.HitDenominator = (1 .0F / mass) + ((radMag * radMag) / m_MomInertia);
1316
+ hitData.PreImpulse [HITOR] = hitData.HitVel [HITOR] / hitData.HitDenominator ;
1317
+ hitData.TotalMass [HITOR] = mass;
1318
+ hitData.MomInertia [HITOR] = m_MomInertia;
1319
+ hitData.ImpulseFactor [HITOR] = hitFactor;
1320
+ // Finally calculate the hit response impulse.
1321
+ hitData.ResImpulse [HITOR] = ((hitData.HitVel [HITOR] * retardation) /
1322
+ hitData.HitDenominator ) * hitFactor;
1323
+
1324
+ // Call the call-on-sink function, if requested.
1325
+ if (callOnSink)
1326
+ halted = halted || m_pOwnerMO->OnSink (hitData);
1327
+
1328
+ // Copy back the new hit data with all the info we have so far.
1329
+ penetratingAtom->SetHitData (hitData);
1330
+ // Save the atom for later application of its hit data to the body.
1331
+ hitResponseAtoms.push_back (penetratingAtom);
1332
+ }
1333
+ }
1334
+ }
1368
1335
1369
1336
// MOVABLEOBJECT COLLISION RESPONSE ///////////////////////////////////////////////
1370
1337
// /////////////////////////////////////////////////////////////////////////////////
0 commit comments