]> git.localhorst.tv Git - blobs.git/commitdiff
steering tweaks
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 4 Dec 2017 16:06:24 +0000 (17:06 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 4 Dec 2017 16:06:43 +0000 (17:06 +0100)
src/creature/creature.cpp
src/creature/goal.cpp

index 911d9d024f4ce7c58d4b69e4960ec42575e67ba4..d7a9724fbe62474884cf9538165efbac1df73b81 100644 (file)
@@ -950,10 +950,8 @@ glm::dvec3 Steering::Force(const Situation::State &s) const noexcept {
                        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;
        }
index bcb1682be1bca9514d81a2cbb3fdf3f985fa84f1..3f61e2e8b80214571a75753f5581611ffa970d2c 100644 (file)
@@ -384,6 +384,8 @@ void LocateResourceGoal::LocateResource() {
                }
        } else {
                // well, what now?
+               found = false;
+               searching = false;
        }
 }
 
@@ -451,8 +453,8 @@ void LocateResourceGoal::SearchVicinity() {
                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);
        }