Skip to content

Commit 80009fa

Browse files
committed
Make item avoidance points account better for the new 2.0 item collisions
1 parent 2f7cd4f commit 80009fa

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/items/item.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,12 @@ void Item::initItem(ItemType type, const Vec3 &xyz, const Vec3&normal,
468468
m_distance_from_center = distances.getX();
469469
const DriveNode* dn = DriveGraph::get()->getNode(m_graph_node);
470470
const Vec3& right = dn->getRightUnitVector();
471-
// Give it 10% more space, since the kart will not always come
472-
// parallel to the drive line.
473-
Vec3 delta = right * sqrt(m_distance_2) * 1.3f;
471+
// Give it 120% more space, because
472+
// this piece of code was written back when
473+
// the kart hitbox wasn't used in collision
474+
// calculations.
475+
// For almost all karts, 120% is a good enough value.
476+
Vec3 delta = right * sqrt(m_distance_2) * 2.2f;
474477
m_avoidance_points[0] = new Vec3(getXYZ() + delta);
475478
m_avoidance_points[1] = new Vec3(getXYZ() - delta);
476479
}

src/karts/controller/skidding_ai.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -964,13 +964,16 @@ bool SkiddingAI::steerToAvoid(const std::vector<const ItemState *> &items_to_avo
964964
if( !hit_left && !hit_right)
965965
return false;
966966

967-
// If we hit the left item, aim at the right avoidance point
968-
// of the left item. We might still hit the right item ... this might
969-
// still be better than going too far off track
967+
// TME EDIT: SOMEONE WROTE
968+
// If we hit the left item, aim at the right avoidance point
969+
// of the left item. We might still hit the right item ... this might
970+
// still be better than going too far off track
971+
// THIS IS NONSENSE.
972+
// WE ARE PICKING THE LEFT OF THE LEFTMOST, EVIDENTLY.
970973
if(hit_left)
971974
{
972975
*aim_point =
973-
*(items_to_avoid[index[0]]->getAvoidancePoint(/*left*/false));
976+
*(items_to_avoid[index[0]]->getAvoidancePoint(/*left*/true));
974977
return true;
975978
}
976979

0 commit comments

Comments
 (0)