X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2Fworld.cpp;fp=src%2Fworld%2Fworld.cpp;h=2a3d5fbc12d7c4dd447acd5c71a4d5f4b47044ca;hb=ed3bdc028edc0ecb5835d1c0bf18dbc59b342daf;hp=dfcf7217f99372d1ea4ada491d55ffa409ec2336;hpb=73d4dd2d78eda1e2f8889d1913a97a60cec86876;p=blank.git diff --git a/src/world/world.cpp b/src/world/world.cpp index dfcf721..2a3d5fb 100644 --- a/src/world/world.cpp +++ b/src/world/world.cpp @@ -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) {