@@ -20,7 +20,7 @@ namespace RTE {
20
20
m_Depth = 0 ;
21
21
m_JointOffset.Reset ();
22
22
m_LimbPos.Reset ();
23
- m_MomInertia = 0 ;
23
+ m_MomentOfInertia = 0 ;
24
24
m_IgnoreMOIDs.clear ();
25
25
}
26
26
@@ -66,12 +66,12 @@ namespace RTE {
66
66
m_Atoms.push_back (atomCopy);
67
67
68
68
// Add to the appropriate spot in the subgroup map
69
- long subID = atomCopy->GetSubID ();
70
- if (subID != 0 ) {
69
+ long subgroupID = atomCopy->GetSubID ();
70
+ if (subgroupID != 0 ) {
71
71
// Make a new list for the subgroup ID if there isn't one already
72
- if (m_SubGroups.find (subID ) == m_SubGroups.end ()) { m_SubGroups.insert ({ subID , std::list<Atom *>() }); }
72
+ if (m_SubGroups.find (subgroupID ) == m_SubGroups.end ()) { m_SubGroups.insert ({ subgroupID , std::list<Atom *>() }); }
73
73
74
- m_SubGroups.find (subID )->second .push_back (atomCopy);
74
+ m_SubGroups.find (subgroupID )->second .push_back (atomCopy);
75
75
}
76
76
}
77
77
}
@@ -202,38 +202,38 @@ namespace RTE {
202
202
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
203
203
204
204
float AtomGroup::GetMomentOfInertia () {
205
- if (m_MomInertia == 0 .0F ) {
205
+ if (m_MomentOfInertia == 0 .0F ) {
206
206
RTEAssert (m_OwnerMO, " Getting AtomGroup stuff without a parent MO!" );
207
207
208
208
float distMass = m_OwnerMO->GetMass () / static_cast <float >(m_Atoms.size ());
209
209
float radius = 0 .0F ;
210
210
for (const Atom *atom : m_Atoms) {
211
211
radius = atom->GetOffset ().GetMagnitude () * c_MPP;
212
- m_MomInertia += distMass * radius * radius;
212
+ m_MomentOfInertia += distMass * radius * radius;
213
213
}
214
214
}
215
215
// Avoid zero (if radius is nonexistent, for example), will cause divide by zero problems otherwise
216
- if (m_MomInertia == 0 .0F ) { m_MomInertia = 0 .000001F ; }
216
+ if (m_MomentOfInertia == 0 .0F ) { m_MomentOfInertia = 0 .000001F ; }
217
217
218
- return m_MomInertia ;
218
+ return m_MomentOfInertia ;
219
219
}
220
220
221
221
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
222
222
223
- void AtomGroup::AddAtoms (const std::list<Atom *> &atomList, long subID , const Vector &offset, const Matrix &offsetRotation) {
224
- if (m_SubGroups.count (subID ) == 0 ) { m_SubGroups.insert ({ subID , std::list<Atom *>() }); }
223
+ void AtomGroup::AddAtoms (const std::list<Atom *> &atomList, long subgroupID , const Vector &offset, const Matrix &offsetRotation) {
224
+ if (m_SubGroups.count (subgroupID ) == 0 ) { m_SubGroups.insert ({ subgroupID , std::list<Atom *>() }); }
225
225
226
226
Atom *atomToAdd;
227
227
for (const Atom * atom : atomList) {
228
228
atomToAdd = new Atom (*atom);
229
- atomToAdd->SetSubID (subID );
229
+ atomToAdd->SetSubID (subgroupID );
230
230
atomToAdd->SetOffset (offset + (atomToAdd->GetOriginalOffset () * offsetRotation));
231
231
atomToAdd->SetOwner (m_OwnerMO);
232
232
// Put ownership here - not sure if this is a TODO or not.
233
233
m_Atoms.push_back (atomToAdd);
234
234
235
235
// Add the Atom to the subgroup in the SubGroups map, not transferring ownership
236
- m_SubGroups.at (subID ).push_back (atomToAdd);
236
+ m_SubGroups.at (subgroupID ).push_back (atomToAdd);
237
237
}
238
238
}
239
239
@@ -262,13 +262,13 @@ namespace RTE {
262
262
263
263
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
264
264
265
- bool AtomGroup::UpdateSubAtoms (long subID , const Vector &newOffset, const Matrix &newOffsetRotation) {
266
- if (m_SubGroups.count (subID ) == 0 ) {
265
+ bool AtomGroup::UpdateSubAtoms (long subgroupID , const Vector &newOffset, const Matrix &newOffsetRotation) {
266
+ if (m_SubGroups.count (subgroupID ) == 0 ) {
267
267
return false ;
268
268
}
269
- RTEAssert (!m_SubGroups.at (subID ).empty (), " Found empty Atom subgroup list!?" );
269
+ RTEAssert (!m_SubGroups.at (subgroupID ).empty (), " Found empty Atom subgroup list!?" );
270
270
271
- for (Atom *subGroupAtom : m_SubGroups.at (subID )) {
271
+ for (Atom *subGroupAtom : m_SubGroups.at (subgroupID )) {
272
272
subGroupAtom->SetOffset (newOffset + (subGroupAtom->GetOriginalOffset () * newOffsetRotation));
273
273
}
274
274
return true ;
@@ -282,10 +282,10 @@ namespace RTE {
282
282
283
283
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
284
284
285
- float AtomGroup::Travel (Vector &position, Vector &velocity, Matrix &rotation, float &angVel , bool &didWrap, Vector &totalImpulse, float mass, float travelTime, bool callOnBounce, bool callOnSink, bool scenePreLocked) {
285
+ float AtomGroup::Travel (Vector &position, Vector &velocity, Matrix &rotation, float &angularVel , bool &didWrap, Vector &totalImpulse, float mass, float travelTime, bool callOnBounce, bool callOnSink, bool scenePreLocked) {
286
286
RTEAssert (m_OwnerMO, " Traveling an AtomGroup without a parent MO!" );
287
287
288
- m_MomInertia = GetMomentOfInertia ();
288
+ m_MomentOfInertia = GetMomentOfInertia ();
289
289
290
290
didWrap = false ;
291
291
@@ -333,7 +333,7 @@ namespace RTE {
333
333
// Calculate and store the accurate hit radius of the Atom in relation to the CoM.
334
334
hitData.HitRadius [HITOR] = startOff * c_MPP;
335
335
// Figure out the pre-collision velocity of the hitting Atom due to body translation and rotation.
336
- hitData.HitVel [HITOR] = velocity + hitData.HitRadius [HITOR].GetPerpendicular () * angVel ;
336
+ hitData.HitVel [HITOR] = velocity + hitData.HitRadius [HITOR].GetPerpendicular () * angularVel ;
337
337
338
338
/*
339
339
radMag = hitData.HitRadius[HITOR].GetMagnitude();
@@ -345,7 +345,7 @@ namespace RTE {
345
345
346
346
hitFactor = 1.0; // / (float)hitTerrAtoms.size();
347
347
atom->GetHitData().mass[HITOR] = mass;
348
- atom->GetHitData().MomInertia[HITOR] = m_MomInertia ;
348
+ atom->GetHitData().MomInertia[HITOR] = m_MomentOfInertia ;
349
349
atom->GetHitData().ImpulseFactor[HITOR] = hitFactor;
350
350
351
351
// Call the call-on-bounce function, if requested.
@@ -363,7 +363,7 @@ namespace RTE {
363
363
364
364
// Apply terrain conflict response
365
365
velocity += hitData.ResImpulse [HITOR] / mass;
366
- angVel += hitData.HitRadius [HITOR].GetPerpendicular ().Dot (hitData.ResImpulse [HITOR]) / m_MomInertia ;
366
+ angularVel += hitData.HitRadius [HITOR].GetPerpendicular ().Dot (hitData.ResImpulse [HITOR]) / m_MomentOfInertia ;
367
367
// Accumulate all the impulse forces so the MO can determine if it took damaged as a result
368
368
totalImpulse += hitData.ResImpulse [HITOR];
369
369
}
@@ -378,7 +378,7 @@ namespace RTE {
378
378
linSegTraj = velocity * timeLeft * c_PPM;
379
379
380
380
// The amount of rotation to be achieved during the time slot, in radians.
381
- float rotDelta = angVel * timeLeft;
381
+ float rotDelta = angularVel * timeLeft;
382
382
383
383
// Cap the segment if the rotation is too severe. This will chunk the segment into several in order to more closely approximate the arc an Atom on a rotating body will trace.
384
384
if (std::fabs (rotDelta) > segRotLimit) {
@@ -499,14 +499,14 @@ namespace RTE {
499
499
somethingPenetrated = false ;
500
500
501
501
const float massDistribution = mass / static_cast <float >(hitTerrAtoms.size () * (m_Resolution ? m_Resolution : 1 ));
502
- const float momentInertiaDistribution = m_MomInertia / static_cast <float >(hitTerrAtoms.size () * (m_Resolution ? m_Resolution : 1 ));
502
+ const float momentInertiaDistribution = m_MomentOfInertia / static_cast <float >(hitTerrAtoms.size () * (m_Resolution ? m_Resolution : 1 ));
503
503
504
504
// Determine which of the colliding Atoms will penetrate the terrain.
505
505
for (std::list<Atom*>::iterator atomItr = hitTerrAtoms.begin (); atomItr != hitTerrAtoms.end (); ) {
506
506
// Calculate and store the accurate hit radius of the Atom in relation to the CoM
507
507
hitData.HitRadius [HITOR] = m_OwnerMO->RotateOffset ((*atomItr)->GetOffset ()) * c_MPP;
508
508
// Figure out the pre-collision velocity of the hitting Atom due to body translation and rotation.
509
- hitData.HitVel [HITOR] = velocity + hitData.HitRadius [HITOR].GetPerpendicular () * angVel ;
509
+ hitData.HitVel [HITOR] = velocity + hitData.HitRadius [HITOR].GetPerpendicular () * angularVel ;
510
510
511
511
const float radMag = hitData.HitRadius [HITOR].GetMagnitude ();
512
512
// These are set temporarily here, will be re-set later when the normal of the hit terrain bitmap (ortho pixel side) is known.
@@ -537,14 +537,14 @@ namespace RTE {
537
537
538
538
// Calculate the distributed mass that each bouncing Atom has.
539
539
// massDistribution = mass /*/ (hitTerrAtoms.size() * (m_Resolution ? m_Resolution : 1))*/;
540
- // momentInertiaDistribution = m_MomInertia /* / (hitTerrAtoms.size() * (m_Resolution ? m_Resolution : 1))*/;
540
+ // momentInertiaDistribution = m_MomentOfInertia /* / (hitTerrAtoms.size() * (m_Resolution ? m_Resolution : 1))*/;
541
541
542
542
const float hitFactor = 1 .0F / static_cast <float >(hitTerrAtoms.size ());
543
543
544
544
// Gather the collision response effects so that the impulse force can be calculated.
545
545
for (Atom *hitTerrAtom : hitTerrAtoms) {
546
546
hitTerrAtom->GetHitData ().TotalMass [HITOR] = mass;
547
- hitTerrAtom->GetHitData ().MomInertia [HITOR] = m_MomInertia ;
547
+ hitTerrAtom->GetHitData ().MomInertia [HITOR] = m_MomentOfInertia ;
548
548
hitTerrAtom->GetHitData ().ImpulseFactor [HITOR] = hitFactor;
549
549
550
550
// Get the HitData so far gathered for this Atom.
@@ -585,10 +585,10 @@ namespace RTE {
585
585
if (g_SceneMan.TryPenetrate (penetratingAtom->GetCurrentPos ().GetFloorIntX (), penetratingAtom->GetCurrentPos ().GetFloorIntY (), hitData.PreImpulse [HITOR], hitData.HitVel [HITOR], retardation, 1 .0F , 1 /* (*penetratingAtom)->GetNumPenetrations()*/ )) {
586
586
// Recalculate these here without the distributed mass and MI.
587
587
const float radMag = hitData.HitRadius [HITOR].GetMagnitude ();
588
- hitData.HitDenominator = (1 .0F / mass) + ((radMag * radMag) / m_MomInertia );
588
+ hitData.HitDenominator = (1 .0F / mass) + ((radMag * radMag) / m_MomentOfInertia );
589
589
hitData.PreImpulse [HITOR] = hitData.HitVel [HITOR] / hitData.HitDenominator ;
590
590
hitData.TotalMass [HITOR] = mass;
591
- hitData.MomInertia [HITOR] = m_MomInertia ;
591
+ hitData.MomInertia [HITOR] = m_MomentOfInertia ;
592
592
hitData.ImpulseFactor [HITOR] = hitFactor;
593
593
// Finally calculate the hit response impulse.
594
594
hitData.ResImpulse [HITOR] = ((hitData.HitVel [HITOR] * retardation) / hitData.HitDenominator ) * hitFactor;
@@ -609,7 +609,7 @@ namespace RTE {
609
609
if (hitsMOs && !hitMOAtoms.empty ()) {
610
610
// Set the mass and other data pertaining to the hitor, aka this AtomGroup's owner MO.
611
611
hitData.TotalMass [HITOR] = mass;
612
- hitData.MomInertia [HITOR] = m_MomInertia ;
612
+ hitData.MomInertia [HITOR] = m_MomentOfInertia ;
613
613
hitData.ImpulseFactor [HITOR] = 1 .0F / static_cast <float >(atomsHitMOsCount);
614
614
615
615
for (const map<MOID, std::list<Atom *>>::value_type &MOAtomMapEntry : hitMOAtoms) {
@@ -624,7 +624,7 @@ namespace RTE {
624
624
// Calculate and store the accurate hit radius of the Atom in relation to the CoM
625
625
hitData.HitRadius [HITOR] = m_OwnerMO->RotateOffset (hitMOAtom->GetOffset ()) * c_MPP;
626
626
// Figure out the pre-collision velocity of the hitting Atom due to body translation and rotation.
627
- hitData.HitVel [HITOR] = velocity + hitData.HitRadius [HITOR].GetPerpendicular () * angVel ;
627
+ hitData.HitVel [HITOR] = velocity + hitData.HitRadius [HITOR].GetPerpendicular () * angularVel ;
628
628
// Set the Atom with the HitData with all the info we have so far.
629
629
hitMOAtom->SetHitData (hitData);
630
630
// Let the Atom calculate the impulse force resulting from the collision, and only add it if collision is valid
@@ -652,7 +652,7 @@ namespace RTE {
652
652
// TODO: Investigate damping!
653
653
hitData = hitResponseAtom->GetHitData ();
654
654
velocity += hitData.ResImpulse [HITOR] / mass;
655
- angVel += hitData.HitRadius [HITOR].GetPerpendicular ().Dot (hitData.ResImpulse [HITOR]) / m_MomInertia ;
655
+ angularVel += hitData.HitRadius [HITOR].GetPerpendicular ().Dot (hitData.ResImpulse [HITOR]) / m_MomentOfInertia ;
656
656
// Accumulate all the impulse forces so the MO can determine if it took damaged as a result
657
657
totalImpulse += hitData.ResImpulse [HITOR];
658
658
}
@@ -718,7 +718,7 @@ namespace RTE {
718
718
719
719
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
720
720
721
- Vector AtomGroup::PushTravel (Vector &position, Vector velocity, float pushForce, bool &didWrap, float travelTime, bool callOnBounce, bool callOnSink, bool scenePreLocked) {
721
+ Vector AtomGroup::PushTravel (Vector &position, const Vector & velocity, float pushForce, bool &didWrap, float travelTime, bool callOnBounce, bool callOnSink, bool scenePreLocked) {
722
722
RTEAssert (m_OwnerMO, " Traveling an AtomGroup without a parent MO!" );
723
723
724
724
didWrap = false ;
@@ -1149,7 +1149,7 @@ namespace RTE {
1149
1149
for (const std::pair<Vector, Vector> &impulseForcesEntry : impulseForces) {
1150
1150
// Cap the impulse to what the max push force is
1151
1151
// impulseForcesEntry.first.CapMagnitude(pushForce * (travelTime/* - timeLeft*/));
1152
- velocity += impulseForcesEntry.first / mass;
1152
+ // velocity += impulseForcesEntry.first / mass;
1153
1153
returnPush += impulseForcesEntry.first ;
1154
1154
}
1155
1155
// Stunt travel time if there is no more velocity
@@ -1216,12 +1216,12 @@ namespace RTE {
1216
1216
1217
1217
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1218
1218
1219
- void AtomGroup::FlailAsLimb (const Vector &ownerPos, const Vector &jointOffset, const float limbRadius, const Vector &velocity, const float angVel , const float mass, const float travelTime) {
1219
+ void AtomGroup::FlailAsLimb (const Vector &ownerPos, const Vector &jointOffset, const float limbRadius, const Vector &velocity, const float angularVel , const float mass, const float travelTime) {
1220
1220
RTEAssert (m_OwnerMO, " Traveling an AtomGroup without a parent MO!" );
1221
1221
1222
1222
bool didWrap = false ;
1223
1223
Vector jointPos = ownerPos + jointOffset;
1224
- Vector centrifugalVel = jointOffset * std::fabs (angVel );
1224
+ Vector centrifugalVel = jointOffset * std::fabs (angularVel );
1225
1225
1226
1226
// Do the push travel calculations and get the resulting push impulse vector back.
1227
1227
Vector pushImpulse = PushTravel (m_LimbPos, velocity + centrifugalVel, 100 , didWrap, travelTime, false , false , false );
0 commit comments