Skip to content

Commit 1e4655d

Browse files
committed
Theoretical fixes to limbpath
1 parent 7bf8805 commit 1e4655d

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

Source/Entities/AHuman.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2585,10 +2585,7 @@ void AHuman::Draw(BITMAP* pTargetBitmap, const Vector& targetPos, DrawMode mode,
25852585
}
25862586

25872587
if (mode == g_DrawColor && !onlyPhysical && g_SettingsMan.DrawLimbPathVisualizations()) {
2588-
m_Paths[m_HFlipped][WALK].Draw(pTargetBitmap, targetPos, 122);
2589-
m_Paths[m_HFlipped][CRAWL].Draw(pTargetBitmap, targetPos, 122);
2590-
m_Paths[m_HFlipped][ARMCRAWL].Draw(pTargetBitmap, targetPos, 13);
2591-
m_Paths[m_HFlipped][CLIMB].Draw(pTargetBitmap, targetPos, 165);
2588+
m_Paths[m_HFlipped][m_MovementState].Draw(pTargetBitmap, targetPos, 122);
25922589
}
25932590
}
25942591

Source/Entities/LimbPath.cpp

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ void LimbPath::Destroy(bool notInherited) {
202202
Vector LimbPath::GetProgressPos() {
203203
Vector returnVec(m_Start);
204204
if (IsStaticPoint()) {
205-
return m_JointPos + RotatePoint(returnVec);
205+
return m_JointPos + (RotatePoint(returnVec) * GetTotalScaleMultiplier());
206206
}
207207

208208
// Add all the segments before the current one
@@ -216,7 +216,7 @@ Vector LimbPath::GetProgressPos() {
216216
returnVec += *m_CurrentSegment * m_SegProgress;
217217
}
218218

219-
return m_JointPos + RotatePoint(returnVec);
219+
return m_JointPos + (RotatePoint(returnVec) * GetTotalScaleMultiplier());
220220
}
221221

222222
Vector LimbPath::GetCurrentSegTarget() {
@@ -296,7 +296,7 @@ void LimbPath::ReportProgress(const Vector& limbPos) {
296296
// Check if we are sufficiently close to the target to start going after the next one.
297297
Vector distVec = g_SceneMan.ShortestDistance(limbPos, GetCurrentSegTarget());
298298
float distance = distVec.GetMagnitude();
299-
float segMag = (*(m_CurrentSegment)).GetMagnitude();
299+
float segMag = (*m_CurrentSegment * GetTotalScaleMultiplier()).GetMagnitude();
300300

301301
if (distance < m_SegmentEndedThreshold) {
302302
if (++(m_CurrentSegment) == m_Segments.end()) {
@@ -398,8 +398,8 @@ bool LimbPath::RestartFree(Vector& limbPos, MOID MOIDToIgnore, int ignoreTeam) {
398398
// Find the first start segment that has an obstacle on it
399399
int i = 0;
400400
for (; i < m_StartSegCount; ++i) {
401-
Vector offsetSegment = (*m_CurrentSegment);
402-
result = g_SceneMan.CastObstacleRay(GetProgressPos(), RotatePoint(offsetSegment), notUsed, limbPos, MOIDToIgnore, ignoreTeam, g_MaterialGrass);
401+
Vector offsetSegment = (*m_CurrentSegment) * GetTotalScaleMultiplier();
402+
result = g_SceneMan.CastObstacleRay(GetProgressPos(), offsetSegment, notUsed, limbPos, MOIDToIgnore, ignoreTeam, g_MaterialGrass);
403403

404404
// If we found an obstacle after the first pixel, report the current segment as the starting one and that there is free space here
405405
if (result > 0) {
@@ -477,6 +477,29 @@ float LimbPath::GetMiddleX() const {
477477
return m_HFlipped ? -result : result;
478478
}
479479

480+
// TODO - these implementations should be more accurate (segments are additive), but they don't seem to work as well
481+
// Investigate!
482+
/*float LimbPath::GetLowestY() const {
483+
float lowestY = m_Start.GetY();
484+
for (auto itr = m_Segments.begin() + m_StartSegCount; itr != m_Segments.end(); ++itr) {
485+
lowestY += itr->GetY() > 0 ? itr->GetY() : 0;
486+
}
487+
return lowestY * GetTotalScaleMultiplier().GetY();
488+
}
489+
490+
float LimbPath::GetMiddleX() const {
491+
float lowestX = m_Start.GetX();
492+
float highestX = m_Start.GetX();
493+
for (auto itr = m_Segments.begin() + m_StartSegCount; itr != m_Segments.end(); ++itr) {
494+
lowestX += itr->GetX() < 0 ? itr->GetX() : 0;
495+
highestX += itr->GetX() > 0 ? itr->GetX() : 0;
496+
}
497+
lowestX *= GetTotalScaleMultiplier().GetX();
498+
highestX *= GetTotalScaleMultiplier().GetX();
499+
float result = (lowestX + highestX) * 0.5F;
500+
return m_HFlipped ? -result : result;
501+
}*/
502+
480503
void LimbPath::Draw(BITMAP* pTargetBitmap,
481504
const Vector& targetPos,
482505
unsigned char color) const {
@@ -485,8 +508,8 @@ void LimbPath::Draw(BITMAP* pTargetBitmap,
485508
for (std::deque<Vector>::const_iterator itr = m_Segments.begin(); itr != m_Segments.end(); ++itr) {
486509
nextPoint += *itr;
487510

488-
Vector prevWorldPosition = m_JointPos + RotatePoint(prevPoint);
489-
Vector nextWorldPosition = m_JointPos + RotatePoint(nextPoint);
511+
Vector prevWorldPosition = m_JointPos + (RotatePoint(prevPoint) * GetTotalScaleMultiplier());
512+
Vector nextWorldPosition = m_JointPos + (RotatePoint(nextPoint) * GetTotalScaleMultiplier());
490513
line(pTargetBitmap, prevWorldPosition.m_X, prevWorldPosition.m_Y, nextWorldPosition.m_X, nextWorldPosition.m_Y, color);
491514

492515
Vector min(std::min(prevWorldPosition.m_X, nextWorldPosition.m_X), std::min(prevWorldPosition.m_Y, nextWorldPosition.m_Y));

0 commit comments

Comments
 (0)