X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2Fworld.cpp;h=2a3d5fbc12d7c4dd447acd5c71a4d5f4b47044ca;hb=ed3bdc028edc0ecb5835d1c0bf18dbc59b342daf;hp=4d01af394a6d37e386cec343449d1f03ae3e0d82;hpb=5c0d6397cfdec3a284a6560c3c6b3acbcd9f9331;p=blank.git diff --git a/src/world/world.cpp b/src/world/world.cpp index 4d01af3..2a3d5fb 100644 --- a/src/world/world.cpp +++ b/src/world/world.cpp @@ -220,8 +220,8 @@ void Entity::OrientBody(float dt) noexcept { } void Entity::OrientHead(float dt) noexcept { - // maximum yaw of head (90°) - constexpr float max_head_yaw = PI_0p5; + // maximum yaw of head (60°) + constexpr float max_head_yaw = PI / 3.0f; // use local Y as up const glm::vec3 up(model_transform[1]); // if yaw is bigger than max, rotate the body to accomodate @@ -725,7 +725,22 @@ glm::vec3 World::Gravity( const Entity &entity, const EntityState &state ) { - return glm::vec3(0.0f); + glm::vec3 force(0.0f); + ExactLocation::Coarse begin(state.pos.chunk - 1); + ExactLocation::Coarse end(state.pos.chunk + 2); + + for (ExactLocation::Coarse pos(begin); pos.z < end.z; ++pos.z) { + for (pos.y = begin.y; pos.y < end.y; ++pos.y) { + for (pos.x = begin.x; pos.x < end.x; ++pos.x) { + Chunk *chunk = chunks.Get(pos); + if (chunk) { + force += chunk->GravityAt(state.pos); + } + } + } + } + + return force; } World::EntityHandle World::RemoveEntity(EntityHandle &eh) {