Fix geometry collision traps and implement authentic sector morphing
This commit is contained in:
1 parent
cd63921ea4
commit
b9353f552c
16 files changed
+1470
-131
No files matched your search
+14
-9
@@ -38,6 +38,17 @@ CraftInput compute_ai_input(CraftState& ai, const assets::LevelData& level,
|
||||
ai.ai_seeking_pit = false;
|
||||
}
|
||||
|
||||
auto is_ai_blocked = [&](float wx, float wz) -> bool {
|
||||
int ix = static_cast<int>(std::floor(wx));
|
||||
int iz = static_cast<int>(std::floor(wz));
|
||||
float local_floor = 0.0f;
|
||||
float local_ceil = 1e6f;
|
||||
level.sample_surface_and_ceiling(wx, wz, ai.curr_pose.pos.y, local_floor, local_ceil);
|
||||
float probe_y = local_floor + 0.28f;
|
||||
return level.is_cell_solid_at_point(ix, iz, wx, wz, probe_y) ||
|
||||
level.is_cliff_blocking_at_y(ix, iz, ai.curr_pose.pos.y);
|
||||
};
|
||||
|
||||
// Spread AI racing lines gently so racers overtake instead of forming a single line
|
||||
if (!ai.ai_seeking_pit) {
|
||||
const auto& nxt = level.main_waypoints[(wp_idx + 1) % n_wp];
|
||||
@@ -45,9 +56,7 @@ CraftInput compute_ai_input(CraftState& ai, const assets::LevelData& level,
|
||||
Vec2 right(-seg.y, seg.x);
|
||||
float lane = (static_cast<float>((ai.id % 5) - 2)) * 0.55f;
|
||||
Vec2 shifted = tgt_pos + right * lane;
|
||||
if (!level.is_cell_solid_at_y(static_cast<int>(std::floor(shifted.x)),
|
||||
static_cast<int>(std::floor(shifted.y)),
|
||||
ai.curr_pose.pos.y)) {
|
||||
if (!is_ai_blocked(shifted.x, shifted.y)) {
|
||||
tgt_pos = shifted;
|
||||
}
|
||||
}
|
||||
@@ -63,9 +72,7 @@ CraftInput compute_ai_input(CraftState& ai, const assets::LevelData& level,
|
||||
float max_probe = std::min(tgt_dist, 7.5f);
|
||||
for (float d = 1.0f; d <= max_probe; d += 0.75f) {
|
||||
Vec2 p = cur_pos + base_dir * d;
|
||||
if (level.is_cell_solid_at_y(static_cast<int>(std::floor(p.x)),
|
||||
static_cast<int>(std::floor(p.y)),
|
||||
ai.curr_pose.pos.y)) {
|
||||
if (is_ai_blocked(p.x, p.y)) {
|
||||
hit_dist = d;
|
||||
break;
|
||||
}
|
||||
@@ -84,9 +91,7 @@ CraftInput compute_ai_input(CraftState& ai, const assets::LevelData& level,
|
||||
Vec2 p = cur_pos + base_dir * pd + perp * (side * off);
|
||||
if (p.x < 2.0f || p.x > assets::kMapWidth - 3.0f ||
|
||||
p.y < 2.0f || p.y > assets::kMapHeight - 3.0f ||
|
||||
level.is_cell_solid_at_y(static_cast<int>(std::floor(p.x)),
|
||||
static_cast<int>(std::floor(p.y)),
|
||||
ai.curr_pose.pos.y)) {
|
||||
is_ai_blocked(p.x, p.y)) {
|
||||
clear = false;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user