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

Commit 769e9d7

Browse files
committed
Improve crawl path jerkiness by starting them once fully prone
1 parent 2ff228d commit 769e9d7

File tree

1 file changed

+34
-42
lines changed

1 file changed

+34
-42
lines changed

Entities/AHuman.cpp

Lines changed: 34 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3686,52 +3686,44 @@ void AHuman::Update()
36863686
m_Paths[FGROUND][WALK].Terminate();
36873687
m_Paths[BGROUND][WALK].Terminate();
36883688
}
3689-
}
3690-
// CRAWLING
3691-
else if (m_MoveState == CRAWL)
3692-
{
3693-
// LEG Crawls
3694-
float FGLegProg = m_Paths[FGROUND][CRAWL].GetRegularProgress();
3695-
float BGLegProg = m_Paths[BGROUND][CRAWL].GetRegularProgress();
3689+
} else if (m_MoveState == CRAWL) {
3690+
// Start crawling only once we are fully prone.
3691+
if (m_ProneState == PRONE) {
36963692

3697-
// FG Leg crawl
3698-
if (m_pFGLeg && (!m_pBGLeg || (!(m_Paths[FGROUND][CRAWL].PathEnded() && BGLegProg < 0.5) || m_StrideStart)))
3699-
{
3700-
// m_StrideStart = false;
3701-
// Reset the stride timer if the path is about to restart
3702-
if (m_Paths[FGROUND][CRAWL].PathEnded() || m_Paths[FGROUND][CRAWL].PathIsAtStart()) { m_StrideTimer.Reset(); }
3703-
m_pFGFootGroup->PushAsLimb(m_Pos + RotateOffset(m_pFGLeg->GetParentOffset()), m_Vel, m_Rotation, m_Paths[FGROUND][CRAWL], deltaTime);
3704-
}
3705-
else
3706-
m_Paths[FGROUND][CRAWL].Terminate();
3693+
float FGLegProg = m_Paths[FGROUND][CRAWL].GetRegularProgress();
3694+
float BGLegProg = m_Paths[BGROUND][CRAWL].GetRegularProgress();
37073695

3708-
// BG Leg crawl
3709-
if (m_pBGLeg && (!m_pFGLeg || !(m_Paths[BGROUND][CRAWL].PathEnded() && FGLegProg < 0.5)))
3710-
{
3711-
m_StrideStart = false;
3712-
// Reset the stride timer if the path is about to restart
3713-
if (m_Paths[BGROUND][CRAWL].PathEnded() || m_Paths[BGROUND][CRAWL].PathIsAtStart()) { m_StrideTimer.Reset(); }
3714-
m_pBGFootGroup->PushAsLimb(m_Pos + RotateOffset(m_pBGLeg->GetParentOffset()), m_Vel, m_Rotation, m_Paths[BGROUND][CRAWL], deltaTime);
3715-
}
3716-
else
3717-
m_Paths[BGROUND][CRAWL].Terminate();
3696+
if (m_pFGLeg && (!m_pBGLeg || (!(m_Paths[FGROUND][CRAWL].PathEnded() && BGLegProg < 0.5F) || m_StrideStart))) {
3697+
if (m_Paths[FGROUND][CRAWL].PathEnded() || m_Paths[FGROUND][CRAWL].PathIsAtStart()) { m_StrideTimer.Reset(); }
3698+
m_pFGFootGroup->PushAsLimb(m_Pos + RotateOffset(m_pFGLeg->GetParentOffset()), m_Vel, m_Rotation, m_Paths[FGROUND][CRAWL], deltaTime);
3699+
} else {
3700+
m_Paths[FGROUND][CRAWL].Terminate();
3701+
}
3702+
if (m_pBGLeg && (!m_pFGLeg || !(m_Paths[BGROUND][CRAWL].PathEnded() && FGLegProg < 0.5F))) {
3703+
m_StrideStart = false;
3704+
if (m_Paths[BGROUND][CRAWL].PathEnded() || m_Paths[BGROUND][CRAWL].PathIsAtStart()) { m_StrideTimer.Reset(); }
3705+
m_pBGFootGroup->PushAsLimb(m_Pos + RotateOffset(m_pBGLeg->GetParentOffset()), m_Vel, m_Rotation, m_Paths[BGROUND][CRAWL], deltaTime);
3706+
} else {
3707+
m_Paths[BGROUND][CRAWL].Terminate();
3708+
}
3709+
if (m_pBGArm) {
3710+
m_ArmClimbing[BGROUND] = true;
3711+
m_pBGHandGroup->PushAsLimb(m_Pos + RotateOffset(Vector(0, m_pBGArm->GetParentOffset().m_Y)), m_Vel, m_Rotation, m_Paths[BGROUND][ARMCRAWL], deltaTime);
3712+
} else if (m_pFGArm && !m_pFGArm->HoldsSomething()) {
3713+
m_ArmClimbing[FGROUND] = true;
3714+
m_pFGHandGroup->PushAsLimb(m_Pos + RotateOffset(Vector(0, m_pFGArm->GetParentOffset().m_Y)), m_Vel, m_Rotation, m_Paths[FGROUND][ARMCRAWL], deltaTime);
3715+
}
3716+
// Restart the stride if the current one seems to be taking too long.
3717+
if (m_StrideTimer.IsPastSimMS(m_Paths[FGROUND][CRAWL].GetTotalPathTime())) {
3718+
m_StrideStart = true;
3719+
m_Paths[FGROUND][CRAWL].Terminate();
3720+
m_Paths[BGROUND][CRAWL].Terminate();
3721+
}
3722+
} else {
3723+
if (m_pFGLeg) { m_pFGFootGroup->FlailAsLimb(m_Pos, RotateOffset(m_pFGLeg->GetParentOffset()), m_pFGLeg->GetMaxLength(), m_PrevVel, m_AngularVel, m_pFGLeg->GetMass(), deltaTime); }
37183724

3719-
// ARMS using rotated path to help crawl
3720-
if (m_pBGArm) {
3721-
m_ArmClimbing[BGROUND] = true;
3722-
m_pBGHandGroup->PushAsLimb(m_Pos + RotateOffset(Vector(0, m_pBGArm->GetParentOffset().m_Y)), m_Vel, m_Rotation, m_Paths[BGROUND][ARMCRAWL], deltaTime);
3723-
} else if (m_pFGArm && !m_pFGArm->HoldsSomething()) {
3724-
m_ArmClimbing[FGROUND] = true;
3725-
m_pFGHandGroup->PushAsLimb(m_Pos + RotateOffset(Vector(0, m_pFGArm->GetParentOffset().m_Y)), m_Vel, m_Rotation, m_Paths[FGROUND][ARMCRAWL], deltaTime);
3725+
if (m_pBGLeg) { m_pBGFootGroup->FlailAsLimb(m_Pos, RotateOffset(m_pBGLeg->GetParentOffset()), m_pBGLeg->GetMaxLength(), m_PrevVel, m_AngularVel, m_pBGLeg->GetMass(), deltaTime); }
37263726
}
3727-
3728-
// Restart the stride if the current one seems to be taking too long
3729-
if (m_StrideTimer.IsPastSimMS(m_Paths[FGROUND][CRAWL].GetTotalPathTime()))
3730-
{
3731-
m_StrideStart = true;
3732-
m_Paths[FGROUND][CRAWL].Terminate();
3733-
m_Paths[BGROUND][CRAWL].Terminate();
3734-
}
37353727
} else if (m_pFGLeg || m_pBGLeg) {
37363728
if (m_MoveState == JUMP) {
37373729
// TODO: Utilize jump paths in an intuitive way!

0 commit comments

Comments
 (0)