glm::dvec3 diff = s.Position() - other->GetSituation().Position();
if (length2(diff) > max_look * max_look) continue;
if (!c.PerceptionTest(other->GetSituation().Position())) continue;
- double sep = length(diff) - other->Size() * 0.707 - c.Size() * 0.707;
- if (sep < min_dist) {
- repulse += normalize(diff) * (1.0 - sep / min_dist);
- }
+ double sep = glm::clamp(length(diff) - other->Size() * 0.707 - c.Size() * 0.707, 0.0, min_dist);
+ repulse += normalize(diff) * (1.0 - sep / min_dist) * force;
}
result += repulse;
}
}
} else {
// well, what now?
+ found = false;
+ searching = false;
}
}
target_pos = GetSituation().Position();
target_pos[(srf + 0) % 3] += Assets().random.SNorm();
target_pos[(srf + 1) % 3] += Assets().random.SNorm();
- // bias towards current direction
- target_pos += glm::normalize(GetSituation().Velocity()) * 0.5;
+ // bias towards current heading
+ target_pos += GetSituation().Heading() * 0.5;
target_pos = clamp(target_pos, -planet.Radius(), planet.Radius());
GetSteering().GoTo(target_pos);
}