bool OnPlanet() const noexcept;
world::Planet &GetPlanet() const noexcept { return *planet; }
bool OnSurface() const noexcept;
+ bool OnGround() const noexcept;
const glm::dvec3 &Position() const noexcept { return state.pos; }
glm::dvec3 SurfaceNormal() const noexcept;
world::Tile &GetTile() const noexcept;
void Move(const glm::dvec3 &dp) noexcept;
void Accelerate(const glm::dvec3 &dv) noexcept;
void EnforceConstraints(State &) noexcept;
- void CheckWrap() noexcept;
void Heading(const glm::dvec3 &h) noexcept { state.dir = h; }
const glm::dvec3 &Heading() const noexcept { return state.dir; }
return type == PLANET_SURFACE;
}
+bool Situation::OnGround() const noexcept {
+ return OnSurface() && glm::length2(state.pos) < (planet->Radius() + 0.05) * (planet->Radius() + 0.05);
+}
+
glm::dvec3 Situation::SurfaceNormal() const noexcept {
return planet->NormalAt(state.pos);
}
result += TargetVelocity(s, diff * std::min(dist * force, speed) / dist, force);
}
}
+ // remove vertical component, if any
+ const glm::dvec3 normal(c.GetSituation().GetPlanet().NormalAt(s.pos));
+ result += normal * glm::dot(normal, result);
+ // clamp to max
if (glm::length2(result) > max_force * max_force) {
result = glm::normalize(result) * max_force;
}
}
bool IngestGoal::OnSuitableTile() {
- if (!GetSituation().OnSurface()) {
+ if (!GetSituation().OnGround()) {
return false;
}
const world::TileType &t = GetSituation().GetTileType();
}
pos->Text(VectorString(c->GetSituation().Position(), 2));
- tile->Text(c->GetSituation().GetTileType().label);
+ tile->Text(c->GetSituation().GetTileType().label + (
+ c->GetSituation().OnGround()
+ ? (c->GetSituation().Moving() ? " (moving)" : " (standing)")
+ : (c->GetSituation().Moving() ? " (flying)" : " (hovering)")
+ ));
head->Text(VectorString(c->GetSituation().Heading(), 2));
const creature::Composition &comp = c->GetComposition();