@@ -202,7 +202,7 @@ void LimbPath::Destroy(bool notInherited) {
202
202
Vector LimbPath::GetProgressPos () {
203
203
Vector returnVec (m_Start);
204
204
if (IsStaticPoint ()) {
205
- return m_JointPos + RotatePoint (returnVec);
205
+ return m_JointPos + ( RotatePoint (returnVec) * GetTotalScaleMultiplier () );
206
206
}
207
207
208
208
// Add all the segments before the current one
@@ -216,7 +216,7 @@ Vector LimbPath::GetProgressPos() {
216
216
returnVec += *m_CurrentSegment * m_SegProgress;
217
217
}
218
218
219
- return m_JointPos + RotatePoint (returnVec);
219
+ return m_JointPos + ( RotatePoint (returnVec) * GetTotalScaleMultiplier () );
220
220
}
221
221
222
222
Vector LimbPath::GetCurrentSegTarget () {
@@ -296,7 +296,7 @@ void LimbPath::ReportProgress(const Vector& limbPos) {
296
296
// Check if we are sufficiently close to the target to start going after the next one.
297
297
Vector distVec = g_SceneMan.ShortestDistance (limbPos, GetCurrentSegTarget ());
298
298
float distance = distVec.GetMagnitude ();
299
- float segMag = (*( m_CurrentSegment)).GetMagnitude ();
299
+ float segMag = (*m_CurrentSegment * GetTotalScaleMultiplier ( )).GetMagnitude ();
300
300
301
301
if (distance < m_SegmentEndedThreshold) {
302
302
if (++(m_CurrentSegment) == m_Segments.end ()) {
@@ -398,8 +398,8 @@ bool LimbPath::RestartFree(Vector& limbPos, MOID MOIDToIgnore, int ignoreTeam) {
398
398
// Find the first start segment that has an obstacle on it
399
399
int i = 0 ;
400
400
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);
403
403
404
404
// If we found an obstacle after the first pixel, report the current segment as the starting one and that there is free space here
405
405
if (result > 0 ) {
@@ -477,6 +477,29 @@ float LimbPath::GetMiddleX() const {
477
477
return m_HFlipped ? -result : result;
478
478
}
479
479
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
+
480
503
void LimbPath::Draw (BITMAP* pTargetBitmap,
481
504
const Vector& targetPos,
482
505
unsigned char color) const {
@@ -485,8 +508,8 @@ void LimbPath::Draw(BITMAP* pTargetBitmap,
485
508
for (std::deque<Vector>::const_iterator itr = m_Segments.begin (); itr != m_Segments.end (); ++itr) {
486
509
nextPoint += *itr;
487
510
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 () );
490
513
line (pTargetBitmap, prevWorldPosition.m_X , prevWorldPosition.m_Y , nextWorldPosition.m_X , nextWorldPosition.m_Y , color);
491
514
492
515
Vector min (std::min (prevWorldPosition.m_X , nextWorldPosition.m_X ), std::min (prevWorldPosition.m_Y , nextWorldPosition.m_Y ));
0 commit comments