X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=src%2Fworld%2Fworld.cpp;h=08ee294fca5e5a8b72351be8bb3ff3e3e40abdd2;hb=be06fbd6c75dabf411f33ebdeed29e60fb639694;hp=3f5740e21f75d8755d84003ef8882874c642828c;hpb=52154f309e569c913520dd004e9fafcbc4671e6f;p=blank.git diff --git a/src/world/world.cpp b/src/world/world.cpp index 3f5740e..08ee294 100644 --- a/src/world/world.cpp +++ b/src/world/world.cpp @@ -128,15 +128,9 @@ Ray Entity::Aim(const Chunk::Pos &chunk_offset) const noexcept { 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)); } } @@ -666,7 +660,27 @@ void World::Render(Viewport &viewport) { 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(); } }