Skip to content

Commit 098bbf4

Browse files
committed
Fixed attachables not inheriting angular velocity and derived rotational velocity when detached
1 parent 1b8c43c commit 098bbf4

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8383

8484
- Almost all ctrl+* special inputs functionality (i.e restarting activity, world dumps, showing performance stats) are now mapped to right alt, to not interfere with default crouching inputs. The only exception is ctrl+arrow keys for changing console size.
8585

86-
- Gibs and Attachables detached due to gibbing now inherit velocity derived from the angular velocity of the parent MO. This only has an effect when the gib/attachable is offset, and gibs are further scaled by `InheritsVel`.
86+
- Gibs and detached Attachables now inherit the parent's angular velocity, as well as velocity derived from the angular velocity of the parent MO and their offset from the parent's centre. On gibs, this is scaled by `InheritsVel`.
8787

8888
</details>
8989

Source/Entities/MOSRotating.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,9 +1041,7 @@ void MOSRotating::RemoveAttachablesWhenGibbing(const Vector& impactImpulse, Mova
10411041
float attachableGibBlastStrength = (attachable->GetParentGibBlastStrengthMultiplier() * m_GibBlastStrength) / (1 + attachable->GetMass());
10421042
attachable->SetAngularVel((attachable->GetAngularVel() * 0.5F) + (attachable->GetAngularVel() * 0.5F * attachableGibBlastStrength * RandomNormalNum()));
10431043
Vector gibBlastVel = Vector(attachable->GetParentOffset()).SetMagnitude(attachableGibBlastStrength * 0.5F + (attachableGibBlastStrength * RandomNum()));
1044-
Vector rotationalVelocity = ((attachable->GetPos() - m_Pos).GetPerpendicular() * m_AngularVel) / c_PPM;
1045-
attachable->SetAngularVel(attachable->GetAngularVel() + m_AngularVel);
1046-
attachable->SetVel(m_Vel + gibBlastVel + rotationalVelocity); // Attachables have already had their velocity updated by ApplyImpulses(), no need to add impactImpulse again
1044+
attachable->SetVel(attachable->GetVel() + gibBlastVel); // Attachables have already had their velocity updated by ApplyImpulses(), no need to add impactImpulse again
10471045
attachable->GibThis();
10481046
continue;
10491047
}
@@ -1052,9 +1050,7 @@ void MOSRotating::RemoveAttachablesWhenGibbing(const Vector& impactImpulse, Mova
10521050
float attachableGibBlastStrength = (attachable->GetParentGibBlastStrengthMultiplier() * m_GibBlastStrength) / (1 + attachable->GetMass());
10531051
attachable->SetAngularVel((attachable->GetAngularVel() * 0.5F) + (attachable->GetAngularVel() * 0.5F * attachableGibBlastStrength * RandomNormalNum()));
10541052
Vector gibBlastVel = Vector(attachable->GetParentOffset()).SetMagnitude(attachableGibBlastStrength * 0.5F + (attachableGibBlastStrength * RandomNum()));
1055-
Vector rotationalVelocity = ((attachable->GetPos() - m_Pos).GetPerpendicular() * m_AngularVel) / c_PPM;
1056-
attachable->SetAngularVel(attachable->GetAngularVel() + m_AngularVel);
1057-
attachable->SetVel(m_Vel + gibBlastVel + rotationalVelocity); // Attachables have already had their velocity updated by ApplyImpulses(), no need to add impactImpulse again
1053+
attachable->SetVel(attachable->GetVel() + gibBlastVel); // Attachables have already had their velocity updated by ApplyImpulses(), no need to add impactImpulse again
10581054

10591055
if (movableObjectToIgnore) {
10601056
attachable->SetWhichMOToNotHit(movableObjectToIgnore);
@@ -1484,6 +1480,10 @@ Attachable* MOSRotating::RemoveAttachable(Attachable* attachable, bool addToMova
14841480
}
14851481
RTEAssert(attachable->IsAttachedTo(this), "Tried to remove Attachable " + attachable->GetPresetNameAndUniqueID() + " from presumed parent " + GetPresetNameAndUniqueID() + ", but it had a different parent (" + (attachable->GetParent() ? attachable->GetParent()->GetPresetNameAndUniqueID() : "ERROR") + "). This should never happen!");
14861482

1483+
Vector rotationalVelocity = ((attachable->GetPos() - m_Pos).GetPerpendicular() * m_AngularVel) / c_PPM;
1484+
attachable->SetAngularVel(attachable->GetAngularVel() + m_AngularVel);
1485+
attachable->SetVel(attachable->GetVel() + rotationalVelocity); // Attachables have already had their velocity updated by ApplyImpulses(), no need to add impactImpulse again
1486+
14871487
if (!m_Attachables.empty()) {
14881488
m_Attachables.remove(attachable);
14891489
}

0 commit comments

Comments
 (0)