From d05324febdb9f67d66a03a2f716c406289a047e1 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Sat, 9 Dec 2017 00:00:38 +0100 Subject: [PATCH] split according to parent heading --- src/creature/Situation.hpp | 1 + src/creature/creature.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/creature/Situation.hpp b/src/creature/Situation.hpp index fb26650..8df8a7a 100644 --- a/src/creature/Situation.hpp +++ b/src/creature/Situation.hpp @@ -54,6 +54,7 @@ public: world::Planet &GetPlanet() const noexcept { return *planet; } bool OnSurface() const noexcept; const glm::dvec3 &Position() const noexcept { return state.pos; } + glm::dvec3 SurfaceNormal() const noexcept; world::Tile &GetTile() const noexcept; const world::TileType &GetTileType() const noexcept; diff --git a/src/creature/creature.cpp b/src/creature/creature.cpp index deb5a10..eebd4f6 100644 --- a/src/creature/creature.cpp +++ b/src/creature/creature.cpp @@ -756,7 +756,7 @@ void Split(Creature &c) { // TODO: duplicate situation somehow a->GetSituation().SetPlanetSurface( s.GetPlanet(), - s.Position() + glm::dvec3(0.0, 0.55 * a->Size(), 0.0)); + s.Position() + glm::rotate(s.Heading() * a->Size() * 0.6, PI * 0.5, s.SurfaceNormal())); a->BuildVAO(); c.GetSimulation().Log() << a->Name() << " was born" << std::endl; @@ -770,7 +770,7 @@ void Split(Creature &c) { s.GetPlanet().AddCreature(b); b->GetSituation().SetPlanetSurface( s.GetPlanet(), - s.Position() - glm::dvec3(0.0, 0.55 * b->Size(), 0.0)); + s.Position() + glm::rotate(s.Heading() * b->Size() * 0.6, PI * -0.5, s.SurfaceNormal())); b->BuildVAO(); c.GetSimulation().Log() << b->Name() << " was born" << std::endl; @@ -891,6 +891,10 @@ bool Situation::OnSurface() const noexcept { return type == PLANET_SURFACE; } +glm::dvec3 Situation::SurfaceNormal() const noexcept { + return planet->NormalAt(state.pos); +} + world::Tile &Situation::GetTile() const noexcept { return planet->TileAt(state.pos); } -- 2.39.2