EntityDerivative f;
constexpr float sixth = 1.0f / 6.0f;
- f.position = sixth * ((a.position + 2.0f * (b.position + c.position)) + d.position);
- f.velocity = sixth * ((a.velocity + 2.0f * (b.velocity + c.velocity)) + d.velocity);
+ f.position = sixth * (a.position + 2.0f * (b.position + c.position) + d.position);
+ f.velocity = sixth * (a.velocity + 2.0f * (b.velocity + c.velocity) + d.velocity);
state.pos.block += f.position * dt;
state.velocity += f.velocity * dt;
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) {