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

Commit 80468eb

Browse files
authored
Merge pull request #509 from cortex-command-community/4zk-content-source
Fix bug where multiple gib particles would be offset by gib velocity
2 parents 26250fc + 93d09f4 commit 80468eb

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Entities/MOSRotating.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,11 +1146,18 @@ void MOSRotating::CreateGibsWhenGibbing(const Vector &impactImpulse, MovableObje
11461146

11471147
gibParticleClone->SetPos(m_Pos + rotatedGibOffset);
11481148
gibParticleClone->SetHFlipped(m_HFlipped);
1149-
Vector gibVelocity = rotatedGibOffset.IsZero() ? Vector(minVelocity + RandomNum(0.0F, velocityRange), 0.0F) : rotatedGibOffset.SetMagnitude(minVelocity + RandomNum(0.0F, velocityRange));
1149+
Vector gibVelocity = Vector(minVelocity + RandomNum(0.0F, velocityRange), 0.0F);
1150+
11501151
// TODO: Figure out how much the magnitude of an offset should affect spread
11511152
float gibSpread = (rotatedGibOffset.IsZero() && spread == 0.1F) ? c_PI : spread;
1152-
1153-
gibVelocity.RadRotate(gibSettingsObject.InheritsVelocity() > 0 ? impactImpulse.GetAbsRadAngle() : m_Rotation.GetRadAngle() + (m_HFlipped ? c_PI : 0));
1153+
// Determine the primary direction of the gib particles.
1154+
if (gibSettingsObject.InheritsVelocity() > 0 && !impactImpulse.IsZero()) {
1155+
gibVelocity.RadRotate(impactImpulse.GetAbsRadAngle());
1156+
} else if (!rotatedGibOffset.IsZero()) {
1157+
gibVelocity.RadRotate(rotatedGibOffset.GetAbsRadAngle());
1158+
} else {
1159+
gibVelocity.RadRotate(m_Rotation.GetRadAngle() + (m_HFlipped ? c_PI : 0));
1160+
}
11541161
// The "Even" spread will spread all gib particles evenly in an arc, while maintaining a randomized velocity magnitude.
11551162
if (gibSettingsObject.GetSpreadMode() == Gib::SpreadMode::SpreadEven) {
11561163
gibVelocity.RadRotate(gibSpread - (gibSpread * 2.0F * static_cast<float>(i) / static_cast<float>(count)));

0 commit comments

Comments
 (0)