+double Creature::PerceptionRange() const noexcept {
+ return 3.0 * (Dexerty() / (Dexerty() + 1)) + Size();
+}
+
+double Creature::PerceptionOmniRange() const noexcept {
+ return 0.5 * (Dexerty() / (Dexerty() + 1)) + Size();
+}
+
+double Creature::PerceptionField() const noexcept {
+ // this is the cosine of half the angle, so 1.0 is none, -1.0 is perfect
+ return 0.8 - (Dexerty() / (Dexerty() + 1));
+}
+
+bool Creature::PerceptionTest(const glm::dvec3 &p) const noexcept {
+ const glm::dvec3 diff(p - situation.Position());
+ double omni_range = PerceptionOmniRange();
+ if (length2(diff) < omni_range * omni_range) return true;
+ double range = PerceptionRange();
+ if (length2(diff) > range * range) return false;
+ return dot(normalize(diff), situation.Heading()) > PerceptionField();
+}
+