]> git.localhorst.tv Git - blobs.git/commitdiff
split according to parent heading
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 8 Dec 2017 23:00:38 +0000 (00:00 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 8 Dec 2017 23:00:38 +0000 (00:00 +0100)
src/creature/Situation.hpp
src/creature/creature.cpp

index fb26650d3137782c3bbdd83308d86a8f0138e624..8df8a7a4c8867dc07f0743d61a8654fd12285aa0 100644 (file)
@@ -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;
 
index deb5a10e4173376ca27e3e9434459f570350367f..eebd4f6f51313ba0e6a9fd7ac4155be1513f4914 100644 (file)
@@ -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);
 }