void Entity::UpdateModel() noexcept {
state.AdjustHeading();
+ state.orient = glm::quat(glm::vec3(0.0f, state.yaw, 0.0f));
if (model) {
- Part::State &body_state = model.BodyState();
- Part::State &eyes_state = model.EyesState();
- if (&body_state != &eyes_state) {
- body_state.orientation = glm::quat(glm::vec3(0.0f, state.yaw, 0.0f));
- eyes_state.orientation = glm::quat(glm::vec3(state.pitch, 0.0f, 0.0f));
- } else {
- eyes_state.orientation = glm::quat(glm::vec3(state.pitch, state.yaw, 0.0f));
- }
+ model.EyesState().orientation = glm::quat(glm::vec3(state.pitch, 0.0f, 0.0f));
}
}
entity_prog.SetFogDensity(fog_density);
for (Entity &entity : entities) {
- entity.Render(entity.Transform(players.front().GetEntity().ChunkCoords()), entity_prog);
+ glm::mat4 M(entity.Transform(players.front().GetEntity().ChunkCoords()));
+ if (!CullTest(entity.Bounds(), entity_prog.GetVP() * M)) {
+ entity.Render(M, entity_prog);
+ }
+ }
+}
+
+namespace {
+
+PrimitiveMesh::Buffer debug_buf;
+
+}
+
+void World::RenderDebug(Viewport &viewport) {
+ PrimitiveMesh debug_mesh;
+ PlainColor &prog = viewport.WorldColorProgram();
+ for (const Entity &entity : entities) {
+ debug_buf.OutlineBox(entity.Bounds(), glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));
+ debug_mesh.Update(debug_buf);
+ prog.SetM(entity.Transform(players.front().GetEntity().ChunkCoords()));
+ debug_mesh.DrawLines();
}
}