}
void Entity::UpdateHeading() noexcept {
- if (Moving()) {
- heading = normalize(Velocity());
+ speed = length(Velocity());
+ if (speed > std::numeric_limits<float>::epsilon()) {
+ heading = Velocity() / speed;
} else {
+ speed = 0.0f;
// use -Z (forward axis) of local view transform
heading = -glm::vec3(view_local[2]);
}
AABB box = e.Bounds();
Chunk::Pos reference = s.chunk_pos;
glm::mat4 M = s.Transform(reference);
+ return Intersection(box, M, reference, col);
+}
+
+bool World::Intersection(
+ const AABB &box,
+ const glm::mat4 &M,
+ const glm::ivec3 &reference,
+ std::vector<WorldCollision> &col
+) {
bool any = false;
for (Chunk &cur_chunk : chunks) {
if (manhattan_radius(cur_chunk.Position() - reference) > 1) {
return any;
}
-
void World::Update(int dt) {
float fdt(dt * 0.001f);
for (Entity &entity : entities) {