Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 9124cef

Browse files
committed
Review changes
1 parent 9bcb79d commit 9124cef

File tree

2 files changed

+98
-93
lines changed

2 files changed

+98
-93
lines changed

Entities/AtomGroup.cpp

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace RTE {
2020
m_Depth = 0;
2121
m_JointOffset.Reset();
2222
m_LimbPos.Reset();
23-
m_MomInertia = 0;
23+
m_MomentOfInertia = 0;
2424
m_IgnoreMOIDs.clear();
2525
}
2626

@@ -66,12 +66,12 @@ namespace RTE {
6666
m_Atoms.push_back(atomCopy);
6767

6868
// 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) {
7171
// 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 *>() }); }
7373

74-
m_SubGroups.find(subID)->second.push_back(atomCopy);
74+
m_SubGroups.find(subgroupID)->second.push_back(atomCopy);
7575
}
7676
}
7777
}
@@ -202,38 +202,38 @@ namespace RTE {
202202
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
203203

204204
float AtomGroup::GetMomentOfInertia() {
205-
if (m_MomInertia == 0.0F) {
205+
if (m_MomentOfInertia == 0.0F) {
206206
RTEAssert(m_OwnerMO, "Getting AtomGroup stuff without a parent MO!");
207207

208208
float distMass = m_OwnerMO->GetMass() / static_cast<float>(m_Atoms.size());
209209
float radius = 0.0F;
210210
for (const Atom *atom : m_Atoms) {
211211
radius = atom->GetOffset().GetMagnitude() * c_MPP;
212-
m_MomInertia += distMass * radius * radius;
212+
m_MomentOfInertia += distMass * radius * radius;
213213
}
214214
}
215215
// 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; }
217217

218-
return m_MomInertia;
218+
return m_MomentOfInertia;
219219
}
220220

221221
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
222222

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 *>() }); }
225225

226226
Atom *atomToAdd;
227227
for (const Atom * atom : atomList) {
228228
atomToAdd = new Atom(*atom);
229-
atomToAdd->SetSubID(subID);
229+
atomToAdd->SetSubID(subgroupID);
230230
atomToAdd->SetOffset(offset + (atomToAdd->GetOriginalOffset() * offsetRotation));
231231
atomToAdd->SetOwner(m_OwnerMO);
232232
// Put ownership here - not sure if this is a TODO or not.
233233
m_Atoms.push_back(atomToAdd);
234234

235235
// 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);
237237
}
238238
}
239239

@@ -262,13 +262,13 @@ namespace RTE {
262262

263263
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
264264

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) {
267267
return false;
268268
}
269-
RTEAssert(!m_SubGroups.at(subID).empty(), "Found empty Atom subgroup list!?");
269+
RTEAssert(!m_SubGroups.at(subgroupID).empty(), "Found empty Atom subgroup list!?");
270270

271-
for (Atom *subGroupAtom : m_SubGroups.at(subID)) {
271+
for (Atom *subGroupAtom : m_SubGroups.at(subgroupID)) {
272272
subGroupAtom->SetOffset(newOffset + (subGroupAtom->GetOriginalOffset() * newOffsetRotation));
273273
}
274274
return true;
@@ -282,10 +282,10 @@ namespace RTE {
282282

283283
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
284284

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) {
286286
RTEAssert(m_OwnerMO, "Traveling an AtomGroup without a parent MO!");
287287

288-
m_MomInertia = GetMomentOfInertia();
288+
m_MomentOfInertia = GetMomentOfInertia();
289289

290290
didWrap = false;
291291

@@ -333,7 +333,7 @@ namespace RTE {
333333
// Calculate and store the accurate hit radius of the Atom in relation to the CoM.
334334
hitData.HitRadius[HITOR] = startOff * c_MPP;
335335
// 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;
337337

338338
/*
339339
radMag = hitData.HitRadius[HITOR].GetMagnitude();
@@ -345,7 +345,7 @@ namespace RTE {
345345
346346
hitFactor = 1.0; // / (float)hitTerrAtoms.size();
347347
atom->GetHitData().mass[HITOR] = mass;
348-
atom->GetHitData().MomInertia[HITOR] = m_MomInertia;
348+
atom->GetHitData().MomInertia[HITOR] = m_MomentOfInertia;
349349
atom->GetHitData().ImpulseFactor[HITOR] = hitFactor;
350350
351351
// Call the call-on-bounce function, if requested.
@@ -363,7 +363,7 @@ namespace RTE {
363363

364364
// Apply terrain conflict response
365365
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;
367367
// Accumulate all the impulse forces so the MO can determine if it took damaged as a result
368368
totalImpulse += hitData.ResImpulse[HITOR];
369369
}
@@ -378,7 +378,7 @@ namespace RTE {
378378
linSegTraj = velocity * timeLeft * c_PPM;
379379

380380
// The amount of rotation to be achieved during the time slot, in radians.
381-
float rotDelta = angVel * timeLeft;
381+
float rotDelta = angularVel * timeLeft;
382382

383383
// 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.
384384
if (std::fabs(rotDelta) > segRotLimit) {
@@ -499,14 +499,14 @@ namespace RTE {
499499
somethingPenetrated = false;
500500

501501
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));
503503

504504
// Determine which of the colliding Atoms will penetrate the terrain.
505505
for (std::list<Atom*>::iterator atomItr = hitTerrAtoms.begin(); atomItr != hitTerrAtoms.end(); ) {
506506
// Calculate and store the accurate hit radius of the Atom in relation to the CoM
507507
hitData.HitRadius[HITOR] = m_OwnerMO->RotateOffset((*atomItr)->GetOffset()) * c_MPP;
508508
// 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;
510510

511511
const float radMag = hitData.HitRadius[HITOR].GetMagnitude();
512512
// 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 {
537537

538538
// Calculate the distributed mass that each bouncing Atom has.
539539
//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))*/;
541541

542542
const float hitFactor = 1.0F / static_cast<float>(hitTerrAtoms.size());
543543

544544
// Gather the collision response effects so that the impulse force can be calculated.
545545
for (Atom *hitTerrAtom : hitTerrAtoms) {
546546
hitTerrAtom->GetHitData().TotalMass[HITOR] = mass;
547-
hitTerrAtom->GetHitData().MomInertia[HITOR] = m_MomInertia;
547+
hitTerrAtom->GetHitData().MomInertia[HITOR] = m_MomentOfInertia;
548548
hitTerrAtom->GetHitData().ImpulseFactor[HITOR] = hitFactor;
549549

550550
// Get the HitData so far gathered for this Atom.
@@ -585,10 +585,10 @@ namespace RTE {
585585
if (g_SceneMan.TryPenetrate(penetratingAtom->GetCurrentPos().GetFloorIntX(), penetratingAtom->GetCurrentPos().GetFloorIntY(), hitData.PreImpulse[HITOR], hitData.HitVel[HITOR], retardation, 1.0F, 1/*(*penetratingAtom)->GetNumPenetrations()*/)) {
586586
// Recalculate these here without the distributed mass and MI.
587587
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);
589589
hitData.PreImpulse[HITOR] = hitData.HitVel[HITOR] / hitData.HitDenominator;
590590
hitData.TotalMass[HITOR] = mass;
591-
hitData.MomInertia[HITOR] = m_MomInertia;
591+
hitData.MomInertia[HITOR] = m_MomentOfInertia;
592592
hitData.ImpulseFactor[HITOR] = hitFactor;
593593
// Finally calculate the hit response impulse.
594594
hitData.ResImpulse[HITOR] = ((hitData.HitVel[HITOR] * retardation) / hitData.HitDenominator) * hitFactor;
@@ -609,7 +609,7 @@ namespace RTE {
609609
if (hitsMOs && !hitMOAtoms.empty()) {
610610
// Set the mass and other data pertaining to the hitor, aka this AtomGroup's owner MO.
611611
hitData.TotalMass[HITOR] = mass;
612-
hitData.MomInertia[HITOR] = m_MomInertia;
612+
hitData.MomInertia[HITOR] = m_MomentOfInertia;
613613
hitData.ImpulseFactor[HITOR] = 1.0F / static_cast<float>(atomsHitMOsCount);
614614

615615
for (const map<MOID, std::list<Atom *>>::value_type &MOAtomMapEntry : hitMOAtoms) {
@@ -624,7 +624,7 @@ namespace RTE {
624624
// Calculate and store the accurate hit radius of the Atom in relation to the CoM
625625
hitData.HitRadius[HITOR] = m_OwnerMO->RotateOffset(hitMOAtom->GetOffset()) * c_MPP;
626626
// 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;
628628
// Set the Atom with the HitData with all the info we have so far.
629629
hitMOAtom->SetHitData(hitData);
630630
// 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 {
652652
// TODO: Investigate damping!
653653
hitData = hitResponseAtom->GetHitData();
654654
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;
656656
// Accumulate all the impulse forces so the MO can determine if it took damaged as a result
657657
totalImpulse += hitData.ResImpulse[HITOR];
658658
}
@@ -718,7 +718,7 @@ namespace RTE {
718718

719719
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
720720

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) {
722722
RTEAssert(m_OwnerMO, "Traveling an AtomGroup without a parent MO!");
723723

724724
didWrap = false;
@@ -1149,7 +1149,7 @@ namespace RTE {
11491149
for (const std::pair<Vector, Vector> &impulseForcesEntry : impulseForces) {
11501150
// Cap the impulse to what the max push force is
11511151
//impulseForcesEntry.first.CapMagnitude(pushForce * (travelTime/* - timeLeft*/));
1152-
velocity += impulseForcesEntry.first / mass;
1152+
//velocity += impulseForcesEntry.first / mass;
11531153
returnPush += impulseForcesEntry.first;
11541154
}
11551155
// Stunt travel time if there is no more velocity
@@ -1216,12 +1216,12 @@ namespace RTE {
12161216

12171217
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
12181218

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) {
12201220
RTEAssert(m_OwnerMO, "Traveling an AtomGroup without a parent MO!");
12211221

12221222
bool didWrap = false;
12231223
Vector jointPos = ownerPos + jointOffset;
1224-
Vector centrifugalVel = jointOffset * std::fabs(angVel);
1224+
Vector centrifugalVel = jointOffset * std::fabs(angularVel);
12251225

12261226
// Do the push travel calculations and get the resulting push impulse vector back.
12271227
Vector pushImpulse = PushTravel(m_LimbPos, velocity + centrifugalVel, 100, didWrap, travelTime, false, false, false);

0 commit comments

Comments
 (0)