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

Commit ff9b2d0

Browse files
authored
Merge pull request #196 from cortex-command-community/penetrating-list
Missing atoms penetrating list
2 parents 5a2a72c + c48b0f8 commit ff9b2d0

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Entities/AtomGroup.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,9 +1215,10 @@ float AtomGroup::Travel(Vector &position,
12151215

12161216
// TERRAIN COLLISION RESPONSE /////////////////////////////////////////////////////
12171217
// Determine which of the colliding Atom:s will penetrate the terrain.
1218-
do
1218+
bool somethingPenetrated = false;
1219+
do
12191220
{
1220-
penetratingAtoms.clear();
1221+
somethingPenetrated = false;
12211222

12221223
distMass = mass / static_cast<float>(hitTerrAtoms.size() * (m_Resolution ? m_Resolution : 1));
12231224
distMI = m_MomInertia / static_cast<float>(hitTerrAtoms.size() * (m_Resolution ? m_Resolution : 1));
@@ -1242,11 +1243,12 @@ float AtomGroup::Travel(Vector &position,
12421243
// Move the penetrating atom to the pen. list from the coll. list.
12431244
penetratingAtoms.push_back(*aItr);
12441245
aItr = hitTerrAtoms.erase(aItr);
1246+
somethingPenetrated = true;
12451247
} else
12461248
++aItr;
12471249
}
12481250
}
1249-
while (!hitTerrAtoms.empty() && !penetratingAtoms.empty());
1251+
while (!hitTerrAtoms.empty() && somethingPenetrated);
12501252

12511253
// TERRAIN BOUNCE //////////////////////////////////////////////////////////////////
12521254
// If some Atoms could not penetrate even though all the impulse was on them,
@@ -1937,8 +1939,9 @@ before adding them to the MovableMan.
19371939

19381940
// TERRAIN COLLISION RESPONSE /////////////////////////////////////////////////////
19391941
// Determine which of the colliding Atom:s will penetrate the terrain.
1942+
bool somethingPenetrated = false;
19401943
do {
1941-
penetratingAtoms.clear();
1944+
somethingPenetrated = false;
19421945

19431946
massDist = mass / static_cast<float>(hitTerrAtoms.size() * (m_Resolution ? m_Resolution : 1));
19441947

@@ -1952,11 +1955,12 @@ before adding them to the MovableMan.
19521955
// Move the penetrating atom to the pen. list from the coll. list.
19531956
penetratingAtoms.push_back(pair<Atom *, Vector>((*aoItr).first, (*aoItr).second));
19541957
aoItr = hitTerrAtoms.erase(aoItr);
1958+
somethingPenetrated = true;
19551959
}
19561960
else
19571961
++aoItr;
19581962
}
1959-
} while (!hitTerrAtoms.empty() && !penetratingAtoms.empty());
1963+
} while (!hitTerrAtoms.empty() && somethingPenetrated);
19601964

19611965
// TERRAIN BOUNCE //////////////////////////////////////////////////////////////////
19621966
// If some Atom:s could not penetrate even though all the mass was on them,

0 commit comments

Comments
 (0)