summaryrefslogtreecommitdiffstats
path: root/src/game/client/world
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/client/world')
-rw-r--r--src/game/client/world/chunk_mesher.cc125
-rw-r--r--src/game/client/world/chunk_mesher.hh7
-rw-r--r--src/game/client/world/chunk_quad.hh6
-rw-r--r--src/game/client/world/chunk_renderer.cc32
-rw-r--r--src/game/client/world/chunk_renderer.hh4
-rw-r--r--src/game/client/world/chunk_vbo.hh3
-rw-r--r--src/game/client/world/chunk_visibility.cc14
-rw-r--r--src/game/client/world/chunk_visibility.hh4
-rw-r--r--src/game/client/world/outline.cc18
-rw-r--r--src/game/client/world/outline.hh8
-rw-r--r--src/game/client/world/player_target.cc48
-rw-r--r--src/game/client/world/player_target.hh8
-rw-r--r--src/game/client/world/skybox.cc6
-rw-r--r--src/game/client/world/skybox.hh8
-rw-r--r--src/game/client/world/voxel_anims.cc19
-rw-r--r--src/game/client/world/voxel_anims.hh8
-rw-r--r--src/game/client/world/voxel_atlas.cc22
-rw-r--r--src/game/client/world/voxel_atlas.hh15
-rw-r--r--src/game/client/world/voxel_sounds.cc18
-rw-r--r--src/game/client/world/voxel_sounds.hh8
20 files changed, 182 insertions, 199 deletions
diff --git a/src/game/client/world/chunk_mesher.cc b/src/game/client/world/chunk_mesher.cc
index 5e58760..47ef4cb 100644
--- a/src/game/client/world/chunk_mesher.cc
+++ b/src/game/client/world/chunk_mesher.cc
@@ -19,7 +19,7 @@
#include "client/globals.hh"
#include "client/session.hh"
-using QuadBuilder = std::vector<world::ChunkQuad>;
+using QuadBuilder = std::vector<ChunkQuad>;
using CachedChunkCoord = unsigned short;
constexpr static CachedChunkCoord CPOS_ITSELF = 0x0000;
@@ -65,14 +65,14 @@ public:
virtual void finalize(void) override;
private:
- bool vis_test(const world::Voxel* voxel, const local_pos& lpos) const;
- void push_quad_a(const world::Voxel* voxel, const glm::fvec3& pos, const glm::fvec2& size, world::VoxelFace face);
- void push_quad_v(const world::Voxel* voxel, const glm::fvec3& pos, const glm::fvec2& size, world::VoxelFace face, std::size_t entropy);
- void make_cube(const world::Voxel* voxel, const local_pos& lpos, world::VoxelVisBits vis, std::size_t entropy);
+ bool vis_test(const Voxel* voxel, const local_pos& lpos) const;
+ void push_quad_a(const Voxel* voxel, const glm::fvec3& pos, const glm::fvec2& size, VoxelFace face);
+ void push_quad_v(const Voxel* voxel, const glm::fvec3& pos, const glm::fvec2& size, VoxelFace face, std::size_t entropy);
+ void make_cube(const Voxel* voxel, const local_pos& lpos, VoxelVisBits vis, std::size_t entropy);
void cache_chunk(const chunk_pos& cpos);
private:
- std::array<world::VoxelStorage, NUM_CACHED_CPOS> m_cache;
+ std::array<VoxelStorage, NUM_CACHED_CPOS> m_cache;
std::vector<QuadBuilder> m_quads_b; // blending
std::vector<QuadBuilder> m_quads_s; // solid
entt::entity m_entity;
@@ -95,8 +95,8 @@ GL_MeshingTask::GL_MeshingTask(entt::entity entity, const chunk_pos& cpos)
void GL_MeshingTask::process(void)
{
- m_quads_b.resize(world::voxel_atlas::plane_count());
- m_quads_s.resize(world::voxel_atlas::plane_count());
+ m_quads_b.resize(voxel_atlas::plane_count());
+ m_quads_s.resize(voxel_atlas::plane_count());
const auto& voxels = m_cache.at(CPOS_ITSELF);
@@ -108,7 +108,7 @@ void GL_MeshingTask::process(void)
}
const auto lpos = coord::to_local(i);
- const auto voxel = world::voxel_registry::find(voxels[i]);
+ const auto voxel = voxel_registry::find(voxels[i]);
if(voxel == nullptr) {
// Either a NULL_VOXEL_ID or something went
@@ -119,27 +119,27 @@ void GL_MeshingTask::process(void)
unsigned int vis = 0U;
if(vis_test(voxel, lpos + DIR_NORTH<local_pos::value_type>)) {
- vis |= world::VVIS_NORTH;
+ vis |= VVIS_NORTH;
}
if(vis_test(voxel, lpos + DIR_SOUTH<local_pos::value_type>)) {
- vis |= world::VVIS_SOUTH;
+ vis |= VVIS_SOUTH;
}
if(vis_test(voxel, lpos + DIR_EAST<local_pos::value_type>)) {
- vis |= world::VVIS_EAST;
+ vis |= VVIS_EAST;
}
if(vis_test(voxel, lpos + DIR_WEST<local_pos::value_type>)) {
- vis |= world::VVIS_WEST;
+ vis |= VVIS_WEST;
}
if(vis_test(voxel, lpos + DIR_UP<local_pos::value_type>)) {
- vis |= world::VVIS_UP;
+ vis |= VVIS_UP;
}
if(vis_test(voxel, lpos + DIR_DOWN<local_pos::value_type>)) {
- vis |= world::VVIS_DOWN;
+ vis |= VVIS_DOWN;
}
const auto vpos = coord::to_voxel(m_cpos, lpos);
@@ -147,7 +147,7 @@ void GL_MeshingTask::process(void)
const auto entropy = math::crc64(&entropy_src, sizeof(entropy_src));
// FIXME: handle different voxel types
- make_cube(voxel, lpos, world::VoxelVisBits(vis), entropy);
+ make_cube(voxel, lpos, VoxelVisBits(vis), entropy);
}
}
@@ -159,7 +159,7 @@ void GL_MeshingTask::finalize(void)
return;
}
- auto& component = globals::dimension->chunks.emplace_or_replace<world::ChunkMesh>(m_entity);
+ auto& component = globals::dimension->chunks.emplace_or_replace<ChunkMesh>(m_entity);
const std::size_t plane_count_nb = m_quads_s.size();
const std::size_t plane_count_b = m_quads_b.size();
@@ -187,7 +187,7 @@ void GL_MeshingTask::finalize(void)
}
glBindBuffer(GL_ARRAY_BUFFER, buffer.handle);
- glBufferData(GL_ARRAY_BUFFER, sizeof(world::ChunkQuad) * builder.size(), builder.data(), GL_STATIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(ChunkQuad) * builder.size(), builder.data(), GL_STATIC_DRAW);
buffer.size = builder.size();
has_no_submeshes_nb = false;
}
@@ -210,18 +210,18 @@ void GL_MeshingTask::finalize(void)
}
glBindBuffer(GL_ARRAY_BUFFER, buffer.handle);
- glBufferData(GL_ARRAY_BUFFER, sizeof(world::ChunkQuad) * builder.size(), builder.data(), GL_STATIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(ChunkQuad) * builder.size(), builder.data(), GL_STATIC_DRAW);
buffer.size = builder.size();
has_no_submeshes_b = false;
}
}
if(has_no_submeshes_b && has_no_submeshes_nb) {
- globals::dimension->chunks.remove<world::ChunkMesh>(m_entity);
+ globals::dimension->chunks.remove<ChunkMesh>(m_entity);
}
}
-bool GL_MeshingTask::vis_test(const world::Voxel* voxel, const local_pos& lpos) const
+bool GL_MeshingTask::vis_test(const Voxel* voxel, const local_pos& lpos) const
{
const auto pvpos = coord::to_voxel(m_cpos, lpos);
const auto pcpos = coord::to_chunk(pvpos);
@@ -230,7 +230,7 @@ bool GL_MeshingTask::vis_test(const world::Voxel* voxel, const local_pos& lpos)
const auto cached_cpos = get_cached_cpos(m_cpos, pcpos);
const auto& voxels = m_cache.at(cached_cpos);
- const auto neighbour = world::voxel_registry::find(voxels[index]);
+ const auto neighbour = voxel_registry::find(voxels[index]);
bool result;
@@ -250,25 +250,24 @@ bool GL_MeshingTask::vis_test(const world::Voxel* voxel, const local_pos& lpos)
return result;
}
-void GL_MeshingTask::push_quad_a(const world::Voxel* voxel, const glm::fvec3& pos, const glm::fvec2& size, world::VoxelFace face)
+void GL_MeshingTask::push_quad_a(const Voxel* voxel, const glm::fvec3& pos, const glm::fvec2& size, VoxelFace face)
{
auto cached_offset = voxel->get_cached_face_offset(face);
auto cached_plane = voxel->get_cached_face_plane(face);
auto& textures = voxel->get_face_textures(face);
switch(voxel->get_render_mode()) {
- case world::VRENDER_OPAQUE:
+ case VRENDER_OPAQUE:
m_quads_s[cached_plane].push_back(make_chunk_quad(pos, size, face, cached_offset, textures.size()));
break;
- case world::VRENDER_BLEND:
+ case VRENDER_BLEND:
m_quads_b[cached_plane].push_back(make_chunk_quad(pos, size, face, cached_offset, textures.size()));
break;
}
}
-void GL_MeshingTask::push_quad_v(const world::Voxel* voxel, const glm::fvec3& pos, const glm::fvec2& size, world::VoxelFace face,
- std::size_t entropy)
+void GL_MeshingTask::push_quad_v(const Voxel* voxel, const glm::fvec3& pos, const glm::fvec2& size, VoxelFace face, std::size_t entropy)
{
auto cached_offset = voxel->get_cached_face_offset(face);
auto cached_plane = voxel->get_cached_face_plane(face);
@@ -276,69 +275,69 @@ void GL_MeshingTask::push_quad_v(const world::Voxel* voxel, const glm::fvec3& po
auto index = entropy % textures.size();
switch(voxel->get_render_mode()) {
- case world::VRENDER_OPAQUE:
+ case VRENDER_OPAQUE:
m_quads_s[cached_plane].push_back(make_chunk_quad(pos, size, face, cached_offset + index, 0));
break;
- case world::VRENDER_BLEND:
+ case VRENDER_BLEND:
m_quads_b[cached_plane].push_back(make_chunk_quad(pos, size, face, cached_offset + index, 0));
break;
}
}
-void GL_MeshingTask::make_cube(const world::Voxel* voxel, const local_pos& lpos, world::VoxelVisBits vis, std::size_t entropy)
+void GL_MeshingTask::make_cube(const Voxel* voxel, const local_pos& lpos, VoxelVisBits vis, std::size_t entropy)
{
const glm::fvec3 fpos = glm::fvec3(lpos);
const glm::fvec2 fsize = glm::fvec2(1.0f, 1.0f);
if(voxel->is_animated()) {
- if(vis & world::VVIS_NORTH) {
- push_quad_a(voxel, fpos, fsize, world::VFACE_NORTH);
+ if(vis & VVIS_NORTH) {
+ push_quad_a(voxel, fpos, fsize, VFACE_NORTH);
}
- if(vis & world::VVIS_SOUTH) {
- push_quad_a(voxel, fpos, fsize, world::VFACE_SOUTH);
+ if(vis & VVIS_SOUTH) {
+ push_quad_a(voxel, fpos, fsize, VFACE_SOUTH);
}
- if(vis & world::VVIS_EAST) {
- push_quad_a(voxel, fpos, fsize, world::VFACE_EAST);
+ if(vis & VVIS_EAST) {
+ push_quad_a(voxel, fpos, fsize, VFACE_EAST);
}
- if(vis & world::VVIS_WEST) {
- push_quad_a(voxel, fpos, fsize, world::VFACE_WEST);
+ if(vis & VVIS_WEST) {
+ push_quad_a(voxel, fpos, fsize, VFACE_WEST);
}
- if(vis & world::VVIS_UP) {
- push_quad_a(voxel, fpos, fsize, world::VFACE_TOP);
+ if(vis & VVIS_UP) {
+ push_quad_a(voxel, fpos, fsize, VFACE_TOP);
}
- if(vis & world::VVIS_DOWN) {
- push_quad_a(voxel, fpos, fsize, world::VFACE_BOTTOM);
+ if(vis & VVIS_DOWN) {
+ push_quad_a(voxel, fpos, fsize, VFACE_BOTTOM);
}
}
else {
- if(vis & world::VVIS_NORTH) {
- push_quad_v(voxel, fpos, fsize, world::VFACE_NORTH, entropy);
+ if(vis & VVIS_NORTH) {
+ push_quad_v(voxel, fpos, fsize, VFACE_NORTH, entropy);
}
- if(vis & world::VVIS_SOUTH) {
- push_quad_v(voxel, fpos, fsize, world::VFACE_SOUTH, entropy);
+ if(vis & VVIS_SOUTH) {
+ push_quad_v(voxel, fpos, fsize, VFACE_SOUTH, entropy);
}
- if(vis & world::VVIS_EAST) {
- push_quad_v(voxel, fpos, fsize, world::VFACE_EAST, entropy);
+ if(vis & VVIS_EAST) {
+ push_quad_v(voxel, fpos, fsize, VFACE_EAST, entropy);
}
- if(vis & world::VVIS_WEST) {
- push_quad_v(voxel, fpos, fsize, world::VFACE_WEST, entropy);
+ if(vis & VVIS_WEST) {
+ push_quad_v(voxel, fpos, fsize, VFACE_WEST, entropy);
}
- if(vis & world::VVIS_UP) {
- push_quad_v(voxel, fpos, fsize, world::VFACE_TOP, entropy);
+ if(vis & VVIS_UP) {
+ push_quad_v(voxel, fpos, fsize, VFACE_TOP, entropy);
}
- if(vis & world::VVIS_DOWN) {
- push_quad_v(voxel, fpos, fsize, world::VFACE_BOTTOM, entropy);
+ if(vis & VVIS_DOWN) {
+ push_quad_v(voxel, fpos, fsize, VFACE_BOTTOM, entropy);
}
}
}
@@ -356,7 +355,7 @@ void GL_MeshingTask::cache_chunk(const chunk_pos& cpos)
// Bogus internal flag component
struct NeedsMeshingComponent final {};
-static void on_chunk_create(const world::ChunkCreateEvent& event)
+static void on_chunk_create(const ChunkCreateEvent& event)
{
const std::array<chunk_pos, 6> neighbours = {
event.cpos + DIR_NORTH<chunk_pos::value_type>,
@@ -370,14 +369,14 @@ static void on_chunk_create(const world::ChunkCreateEvent& event)
globals::dimension->chunks.emplace_or_replace<NeedsMeshingComponent>(event.chunk->get_entity());
for(const chunk_pos& cpos : neighbours) {
- if(const world::Chunk* chunk = globals::dimension->find_chunk(cpos)) {
+ if(const Chunk* chunk = globals::dimension->find_chunk(cpos)) {
globals::dimension->chunks.emplace_or_replace<NeedsMeshingComponent>(chunk->get_entity());
continue;
}
}
}
-static void on_chunk_update(const world::ChunkUpdateEvent& event)
+static void on_chunk_update(const ChunkUpdateEvent& event)
{
const std::array<chunk_pos, 6> neighbours = {
event.cpos + DIR_NORTH<chunk_pos::value_type>,
@@ -391,14 +390,14 @@ static void on_chunk_update(const world::ChunkUpdateEvent& event)
globals::dimension->chunks.emplace_or_replace<NeedsMeshingComponent>(event.chunk->get_entity());
for(const chunk_pos& cpos : neighbours) {
- if(const world::Chunk* chunk = globals::dimension->find_chunk(cpos)) {
+ if(const Chunk* chunk = globals::dimension->find_chunk(cpos)) {
globals::dimension->chunks.emplace_or_replace<NeedsMeshingComponent>(chunk->get_entity());
continue;
}
}
}
-static void on_voxel_set(const world::VoxelSetEvent& event)
+static void on_voxel_set(const VoxelSetEvent& event)
{
globals::dimension->chunks.emplace_or_replace<NeedsMeshingComponent>(event.chunk->get_entity());
@@ -420,25 +419,25 @@ static void on_voxel_set(const world::VoxelSetEvent& event)
}
for(const chunk_pos& cpos : neighbours) {
- if(const world::Chunk* chunk = globals::dimension->find_chunk(cpos)) {
+ if(const Chunk* chunk = globals::dimension->find_chunk(cpos)) {
globals::dimension->chunks.emplace_or_replace<NeedsMeshingComponent>(chunk->get_entity());
continue;
}
}
}
-void world::chunk_mesher::init(void)
+void chunk_mesher::init(void)
{
globals::dispatcher.sink<ChunkCreateEvent>().connect<&on_chunk_create>();
globals::dispatcher.sink<ChunkUpdateEvent>().connect<&on_chunk_update>();
globals::dispatcher.sink<VoxelSetEvent>().connect<&on_voxel_set>();
}
-void world::chunk_mesher::shutdown(void)
+void chunk_mesher::shutdown(void)
{
}
-void world::chunk_mesher::update(void)
+void chunk_mesher::update(void)
{
if(session::is_ingame()) {
const auto group = globals::dimension->chunks.group<NeedsMeshingComponent>(entt::get<ChunkComponent>);
diff --git a/src/game/client/world/chunk_mesher.hh b/src/game/client/world/chunk_mesher.hh
index cb0c7c5..d3ead5c 100644
--- a/src/game/client/world/chunk_mesher.hh
+++ b/src/game/client/world/chunk_mesher.hh
@@ -2,17 +2,14 @@
#include "client/world/chunk_vbo.hh"
-namespace world
-{
struct ChunkMesh final {
std::vector<ChunkVBO> quad_nb;
std::vector<ChunkVBO> quad_b;
};
-} // namespace world
-namespace world::chunk_mesher
+namespace chunk_mesher
{
void init(void);
void shutdown(void);
void update(void);
-} // namespace world::chunk_mesher
+} // namespace chunk_mesher
diff --git a/src/game/client/world/chunk_quad.hh b/src/game/client/world/chunk_quad.hh
index 01ed5f2..a28193a 100644
--- a/src/game/client/world/chunk_quad.hh
+++ b/src/game/client/world/chunk_quad.hh
@@ -4,15 +4,10 @@
#include "shared/world/voxel_registry.hh"
-namespace world
-{
// [0] XXXXXXXXYYYYYYYYZZZZZZZZWWWWHHHH
// [1] FFFFTTTTTTTTTTTAAAAA------------
using ChunkQuad = std::array<std::uint32_t, 2>;
-} // namespace world
-namespace world
-{
constexpr inline static ChunkQuad make_chunk_quad(const glm::fvec3& position, const glm::fvec2& size, VoxelFace face, std::size_t texture,
std::size_t frames)
{
@@ -38,4 +33,3 @@ constexpr inline static ChunkQuad make_chunk_quad(const glm::fvec3& position, co
return result;
}
-} // namespace world
diff --git a/src/game/client/world/chunk_renderer.cc b/src/game/client/world/chunk_renderer.cc
index 573d1b7..ea85eee 100644
--- a/src/game/client/world/chunk_renderer.cc
+++ b/src/game/client/world/chunk_renderer.cc
@@ -45,7 +45,7 @@ static std::size_t u_quad_textures;
static GLuint quad_vaobj;
static GLuint quad_vbo;
-void world::chunk_renderer::init(void)
+void chunk_renderer::init(void)
{
globals::client_config.add_value("chunk_renderer.depth_sort_chunks", depth_sort_chunks);
@@ -82,14 +82,14 @@ void world::chunk_renderer::init(void)
glVertexAttribPointer(0, 3, GL_FLOAT, false, sizeof(glm::fvec3), nullptr);
}
-void world::chunk_renderer::shutdown(void)
+void chunk_renderer::shutdown(void)
{
glDeleteBuffers(1, &quad_vbo);
glDeleteVertexArrays(1, &quad_vaobj);
quad_program.destroy();
}
-void world::chunk_renderer::render(void)
+void chunk_renderer::render(void)
{
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
@@ -115,17 +115,17 @@ void world::chunk_renderer::render(void)
GLuint timings[3];
timings[0] = static_cast<GLuint>(globals::window_frametime);
timings[1] = static_cast<GLuint>(globals::window_frametime_avg);
- timings[2] = static_cast<GLuint>(world::voxel_anims::frame);
+ timings[2] = static_cast<GLuint>(voxel_anims::frame);
- const auto group = globals::dimension->chunks.group<ChunkComponent>(entt::get<world::ChunkMesh>);
+ const auto group = globals::dimension->chunks.group<ChunkComponent>(entt::get<ChunkMesh>);
if(depth_sort_chunks.get_value()) {
// FIXME: speed! sorting every frame doesn't look
// like a good idea. Can we store the group elsewhere and
// still have all the up-to-date chunk things inside?
group.sort([](entt::entity ea, entt::entity eb) {
- const auto dir_a = globals::dimension->chunks.get<ChunkComponent>(ea).cpos - entity::camera::position_chunk;
- const auto dir_b = globals::dimension->chunks.get<ChunkComponent>(eb).cpos - entity::camera::position_chunk;
+ const auto dir_a = globals::dimension->chunks.get<ChunkComponent>(ea).cpos - camera::position_chunk;
+ const auto dir_b = globals::dimension->chunks.get<ChunkComponent>(eb).cpos - camera::position_chunk;
const auto da = dir_a[0] * dir_a[0] + dir_a[1] * dir_a[1] + dir_a[2] * dir_a[2];
const auto db = dir_b[0] * dir_b[0] + dir_b[1] * dir_b[1] + dir_b[2] * dir_b[2];
@@ -134,18 +134,18 @@ void world::chunk_renderer::render(void)
});
}
- for(std::size_t plane_id = 0; plane_id < world::voxel_atlas::plane_count(); ++plane_id) {
+ for(std::size_t plane_id = 0; plane_id < voxel_atlas::plane_count(); ++plane_id) {
glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D_ARRAY, world::voxel_atlas::plane_texture(plane_id));
+ glBindTexture(GL_TEXTURE_2D_ARRAY, voxel_atlas::plane_texture(plane_id));
glBindVertexArray(quad_vaobj);
glUseProgram(quad_program.handle);
- glUniformMatrix4fv(quad_program.uniforms[u_quad_vproj_matrix].location, 1, false, glm::value_ptr(entity::camera::matrix));
+ glUniformMatrix4fv(quad_program.uniforms[u_quad_vproj_matrix].location, 1, false, glm::value_ptr(camera::matrix));
glUniform3uiv(quad_program.uniforms[u_quad_timings].location, 1, timings);
- glUniform4fv(quad_program.uniforms[u_quad_fog_color].location, 1, glm::value_ptr(world::skybox::fog_color));
+ glUniform4fv(quad_program.uniforms[u_quad_fog_color].location, 1, glm::value_ptr(skybox::fog_color));
glUniform1f(quad_program.uniforms[u_quad_view_distance].location,
- static_cast<GLfloat>(entity::camera::view_distance.get_value() * CHUNK_SIZE));
+ static_cast<GLfloat>(camera::view_distance.get_value() * CHUNK_SIZE));
glUniform1i(quad_program.uniforms[u_quad_textures].location, 0); // GL_TEXTURE0
glDisable(GL_BLEND);
@@ -156,7 +156,7 @@ void world::chunk_renderer::render(void)
for(const auto [entity, chunk, mesh] : group.each()) {
if(plane_id < mesh.quad_nb.size() && mesh.quad_nb[plane_id].handle && mesh.quad_nb[plane_id].size) {
- const auto wpos = coord::to_fvec3(chunk.cpos - entity::camera::position_chunk);
+ const auto wpos = coord::to_fvec3(chunk.cpos - camera::position_chunk);
glUniform3fv(quad_program.uniforms[u_quad_world_position].location, 1, glm::value_ptr(wpos));
glBindBuffer(GL_ARRAY_BUFFER, mesh.quad_nb[plane_id].handle);
@@ -177,7 +177,7 @@ void world::chunk_renderer::render(void)
for(const auto [entity, chunk, mesh] : group.each()) {
if(plane_id < mesh.quad_b.size() && mesh.quad_b[plane_id].handle && mesh.quad_b[plane_id].size) {
- const auto wpos = coord::to_fvec3(chunk.cpos - entity::camera::position_chunk);
+ const auto wpos = coord::to_fvec3(chunk.cpos - camera::position_chunk);
glUniform3fv(quad_program.uniforms[u_quad_world_position].location, 1, glm::value_ptr(wpos));
glBindBuffer(GL_ARRAY_BUFFER, mesh.quad_b[plane_id].handle);
@@ -195,11 +195,11 @@ void world::chunk_renderer::render(void)
}
if(toggles::get(TOGGLE_CHUNK_AABB)) {
- world::outline::prepare();
+ outline::prepare();
for(const auto [entity, chunk, mesh] : group.each()) {
const auto size = glm::fvec3(CHUNK_SIZE, CHUNK_SIZE, CHUNK_SIZE);
- world::outline::cube(chunk.cpos, glm::fvec3(0.0f, 0.0f, 0.0f), size, 1.0f, glm::fvec4(1.0f, 1.0f, 0.0f, 1.0f));
+ outline::cube(chunk.cpos, glm::fvec3(0.0f, 0.0f, 0.0f), size, 1.0f, glm::fvec4(1.0f, 1.0f, 0.0f, 1.0f));
}
}
}
diff --git a/src/game/client/world/chunk_renderer.hh b/src/game/client/world/chunk_renderer.hh
index 2b73225..53272a4 100644
--- a/src/game/client/world/chunk_renderer.hh
+++ b/src/game/client/world/chunk_renderer.hh
@@ -1,8 +1,8 @@
#pragma once
-namespace world::chunk_renderer
+namespace chunk_renderer
{
void init(void);
void shutdown(void);
void render(void);
-} // namespace world::chunk_renderer
+} // namespace chunk_renderer
diff --git a/src/game/client/world/chunk_vbo.hh b/src/game/client/world/chunk_vbo.hh
index 175b34f..da8270e 100644
--- a/src/game/client/world/chunk_vbo.hh
+++ b/src/game/client/world/chunk_vbo.hh
@@ -1,7 +1,5 @@
#pragma once
-namespace world
-{
class ChunkVBO final {
public:
std::size_t size;
@@ -19,4 +17,3 @@ public:
}
}
};
-} // namespace world
diff --git a/src/game/client/world/chunk_visibility.cc b/src/game/client/world/chunk_visibility.cc
index 871c04b..5af2901 100644
--- a/src/game/client/world/chunk_visibility.cc
+++ b/src/game/client/world/chunk_visibility.cc
@@ -23,8 +23,8 @@
// we throttle the client's ever increasing itch for new chunks
constexpr static unsigned int MAX_CHUNKS_REQUESTS_PER_FRAME = 16U;
-static world::ChunkAABB current_view_box;
-static world::ChunkAABB previous_view_box;
+static ChunkAABB current_view_box;
+static ChunkAABB previous_view_box;
static std::vector<chunk_pos> requests;
static void update_requests(void)
@@ -42,16 +42,16 @@ static void update_requests(void)
}
std::sort(requests.begin(), requests.end(), [](const chunk_pos& cpos_a, const chunk_pos& cpos_b) {
- auto da = math::distance2(cpos_a, entity::camera::position_chunk);
- auto db = math::distance2(cpos_b, entity::camera::position_chunk);
+ auto da = math::distance2(cpos_a, camera::position_chunk);
+ auto db = math::distance2(cpos_b, camera::position_chunk);
return da > db;
});
}
-void world::chunk_visibility::update_late(void)
+void chunk_visibility::update_late(void)
{
- current_view_box.min = entity::camera::position_chunk - static_cast<chunk_pos::value_type>(entity::camera::view_distance.get_value());
- current_view_box.max = entity::camera::position_chunk + static_cast<chunk_pos::value_type>(entity::camera::view_distance.get_value());
+ current_view_box.min = camera::position_chunk - static_cast<chunk_pos::value_type>(camera::view_distance.get_value());
+ current_view_box.max = camera::position_chunk + static_cast<chunk_pos::value_type>(camera::view_distance.get_value());
if(!session::is_ingame()) {
// This makes sure the previous view box
diff --git a/src/game/client/world/chunk_visibility.hh b/src/game/client/world/chunk_visibility.hh
index 8d1f3cd..d0b4487 100644
--- a/src/game/client/world/chunk_visibility.hh
+++ b/src/game/client/world/chunk_visibility.hh
@@ -1,6 +1,6 @@
#pragma once
-namespace world::chunk_visibility
+namespace chunk_visibility
{
void update_late(void);
-} // namespace world::chunk_visibility
+} // namespace chunk_visibility
diff --git a/src/game/client/world/outline.cc b/src/game/client/world/outline.cc
index 763debf..d4980c2 100644
--- a/src/game/client/world/outline.cc
+++ b/src/game/client/world/outline.cc
@@ -28,7 +28,7 @@ static GLuint vaobj;
static GLuint cube_vbo;
static GLuint line_vbo;
-void world::outline::init(void)
+void outline::init(void)
{
if(!program.setup("shaders/outline.vert", "shaders/outline.frag")) {
spdlog::critical("outline: program setup failed");
@@ -90,7 +90,7 @@ void world::outline::init(void)
glVertexAttribDivisor(0, 0);
}
-void world::outline::shutdown(void)
+void outline::shutdown(void)
{
glDeleteVertexArrays(1, &vaobj);
glDeleteBuffers(1, &line_vbo);
@@ -98,7 +98,7 @@ void world::outline::shutdown(void)
program.destroy();
}
-void world::outline::prepare(void)
+void outline::prepare(void)
{
program.set_variant_vert(WORLD_CURVATURE, client_game::world_curvature.get_value());
@@ -111,17 +111,17 @@ void world::outline::prepare(void)
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glUseProgram(program.handle);
- glUniformMatrix4fv(program.uniforms[u_vpmatrix].location, 1, false, glm::value_ptr(entity::camera::matrix));
- glUniform1f(program.uniforms[u_viewdist].location, static_cast<GLfloat>(CHUNK_SIZE * entity::camera::view_distance.get_value()));
+ glUniformMatrix4fv(program.uniforms[u_vpmatrix].location, 1, false, glm::value_ptr(camera::matrix));
+ glUniform1f(program.uniforms[u_viewdist].location, static_cast<GLfloat>(CHUNK_SIZE * camera::view_distance.get_value()));
glBindVertexArray(vaobj);
glEnableVertexAttribArray(0);
glVertexAttribDivisor(0, 0);
}
-void world::outline::cube(const chunk_pos& cpos, const glm::fvec3& fpos, const glm::fvec3& size, float thickness, const glm::fvec4& color)
+void outline::cube(const chunk_pos& cpos, const glm::fvec3& fpos, const glm::fvec3& size, float thickness, const glm::fvec4& color)
{
- auto patch_cpos = cpos - entity::camera::position_chunk;
+ auto patch_cpos = cpos - camera::position_chunk;
glLineWidth(thickness);
@@ -134,9 +134,9 @@ void world::outline::cube(const chunk_pos& cpos, const glm::fvec3& fpos, const g
glDrawArrays(GL_LINES, 0, 24);
}
-void world::outline::line(const chunk_pos& cpos, const glm::fvec3& fpos, const glm::fvec3& size, float thickness, const glm::fvec4& color)
+void outline::line(const chunk_pos& cpos, const glm::fvec3& fpos, const glm::fvec3& size, float thickness, const glm::fvec4& color)
{
- auto patch_cpos = cpos - entity::camera::position_chunk;
+ auto patch_cpos = cpos - camera::position_chunk;
glLineWidth(thickness);
diff --git a/src/game/client/world/outline.hh b/src/game/client/world/outline.hh
index 2456a32..8fdfdeb 100644
--- a/src/game/client/world/outline.hh
+++ b/src/game/client/world/outline.hh
@@ -2,15 +2,15 @@
#include "shared/types.hh"
-namespace world::outline
+namespace outline
{
void init(void);
void shutdown(void);
void prepare(void);
-} // namespace world::outline
+} // namespace outline
-namespace world::outline
+namespace outline
{
void cube(const chunk_pos& cpos, const glm::fvec3& fpos, const glm::fvec3& size, float thickness, const glm::fvec4& color);
void line(const chunk_pos& cpos, const glm::fvec3& fpos, const glm::fvec3& size, float thickness, const glm::fvec4& color);
-} // namespace world::outline
+} // namespace outline
diff --git a/src/game/client/world/player_target.cc b/src/game/client/world/player_target.cc
index 5969381..c8a7583 100644
--- a/src/game/client/world/player_target.cc
+++ b/src/game/client/world/player_target.cc
@@ -16,49 +16,49 @@
constexpr static float MAX_REACH = 16.0f;
-voxel_pos world::player_target::coord;
-voxel_pos world::player_target::normal;
-const world::Voxel* world::player_target::voxel;
+voxel_pos player_target::coord;
+voxel_pos player_target::normal;
+const Voxel* player_target::voxel;
-void world::player_target::init(void)
+void player_target::init(void)
{
- world::player_target::coord = voxel_pos();
- world::player_target::normal = voxel_pos();
- world::player_target::voxel = nullptr;
+ player_target::coord = voxel_pos();
+ player_target::normal = voxel_pos();
+ player_target::voxel = nullptr;
}
-void world::player_target::update(void)
+void player_target::update(void)
{
if(session::is_ingame()) {
- RayDDA ray(globals::dimension, entity::camera::position_chunk, entity::camera::position_local, entity::camera::direction);
+ RayDDA ray(globals::dimension, camera::position_chunk, camera::position_local, camera::direction);
do {
- world::player_target::voxel = ray.step();
+ player_target::voxel = ray.step();
- if(world::player_target::voxel) {
- world::player_target::coord = ray.vpos;
- world::player_target::normal = ray.vnormal;
+ if(player_target::voxel) {
+ player_target::coord = ray.vpos;
+ player_target::normal = ray.vnormal;
break;
}
- world::player_target::coord = voxel_pos();
- world::player_target::normal = voxel_pos();
+ player_target::coord = voxel_pos();
+ player_target::normal = voxel_pos();
} while(ray.distance < MAX_REACH);
}
else {
- world::player_target::voxel = nullptr;
- world::player_target::coord = voxel_pos();
- world::player_target::normal = voxel_pos();
+ player_target::voxel = nullptr;
+ player_target::coord = voxel_pos();
+ player_target::normal = voxel_pos();
}
}
-void world::player_target::render(void)
+void player_target::render(void)
{
- if(world::player_target::voxel && !client_game::hide_hud) {
- auto cpos = coord::to_chunk(world::player_target::coord);
- auto fpos = coord::to_local(world::player_target::coord);
+ if(player_target::voxel && !client_game::hide_hud) {
+ auto cpos = coord::to_chunk(player_target::coord);
+ auto fpos = coord::to_local(player_target::coord);
- world::outline::prepare();
- world::outline::cube(cpos, glm::fvec3(fpos), glm::fvec3(1.0f), 2.0f, glm::fvec4(0.0f, 0.0f, 0.0f, 1.0f));
+ outline::prepare();
+ outline::cube(cpos, glm::fvec3(fpos), glm::fvec3(1.0f), 2.0f, glm::fvec4(0.0f, 0.0f, 0.0f, 1.0f));
}
}
diff --git a/src/game/client/world/player_target.hh b/src/game/client/world/player_target.hh
index 175be02..2c8bd22 100644
--- a/src/game/client/world/player_target.hh
+++ b/src/game/client/world/player_target.hh
@@ -2,16 +2,16 @@
#include "shared/world/voxel_registry.hh"
-namespace world::player_target
+namespace player_target
{
extern voxel_pos coord;
extern voxel_pos normal;
extern const Voxel* voxel;
-} // namespace world::player_target
+} // namespace player_target
-namespace world::player_target
+namespace player_target
{
void init(void);
void update(void);
void render(void);
-} // namespace world::player_target
+} // namespace player_target
diff --git a/src/game/client/world/skybox.cc b/src/game/client/world/skybox.cc
index 5e52fa4..393c260 100644
--- a/src/game/client/world/skybox.cc
+++ b/src/game/client/world/skybox.cc
@@ -2,10 +2,10 @@
#include "client/world/skybox.hh"
-glm::fvec3 world::skybox::fog_color;
+glm::fvec3 skybox::fog_color;
-void world::skybox::init(void)
+void skybox::init(void)
{
// https://convertingcolors.com/hex-color-B1F3FF.html
- world::skybox::fog_color = glm::fvec3(0.690f, 0.950f, 1.000f);
+ skybox::fog_color = glm::fvec3(0.690f, 0.950f, 1.000f);
}
diff --git a/src/game/client/world/skybox.hh b/src/game/client/world/skybox.hh
index 40113cd..d90336a 100644
--- a/src/game/client/world/skybox.hh
+++ b/src/game/client/world/skybox.hh
@@ -1,11 +1,11 @@
#pragma once
-namespace world::skybox
+namespace skybox
{
extern glm::fvec3 fog_color;
-} // namespace world::skybox
+} // namespace skybox
-namespace world::skybox
+namespace skybox
{
void init(void);
-} // namespace world::skybox
+} // namespace skybox
diff --git a/src/game/client/world/voxel_anims.cc b/src/game/client/world/voxel_anims.cc
index 3d7cfd4..2286027 100644
--- a/src/game/client/world/voxel_anims.cc
+++ b/src/game/client/world/voxel_anims.cc
@@ -12,22 +12,21 @@
static config::Unsigned base_framerate(16U, 1U, 16U);
-std::uint64_t world::voxel_anims::nextframe = 0U;
-std::uint32_t world::voxel_anims::frame = 0U;
+std::uint64_t voxel_anims::nextframe = 0U;
+std::uint32_t voxel_anims::frame = 0U;
-void world::voxel_anims::init(void)
+void voxel_anims::init(void)
{
globals::client_config.add_value("voxel_anims.base_framerate", base_framerate);
- world::voxel_anims::nextframe = 0U;
- world::voxel_anims::frame = 0U;
+ voxel_anims::nextframe = 0U;
+ voxel_anims::frame = 0U;
}
-void world::voxel_anims::update(void)
+void voxel_anims::update(void)
{
- if(globals::curtime >= world::voxel_anims::nextframe) {
- world::voxel_anims::nextframe = globals::curtime
- + static_cast<std::uint64_t>(1000000.0 / static_cast<float>(base_framerate.get_value()));
- world::voxel_anims::frame += 1U;
+ if(globals::curtime >= voxel_anims::nextframe) {
+ voxel_anims::nextframe = globals::curtime + static_cast<std::uint64_t>(1000000.0 / static_cast<float>(base_framerate.get_value()));
+ voxel_anims::frame += 1U;
}
}
diff --git a/src/game/client/world/voxel_anims.hh b/src/game/client/world/voxel_anims.hh
index 0d8a0d0..63a4fc1 100644
--- a/src/game/client/world/voxel_anims.hh
+++ b/src/game/client/world/voxel_anims.hh
@@ -1,13 +1,13 @@
#pragma once
-namespace world::voxel_anims
+namespace voxel_anims
{
extern std::uint64_t nextframe;
extern std::uint32_t frame;
-} // namespace world::voxel_anims
+} // namespace voxel_anims
-namespace world::voxel_anims
+namespace voxel_anims
{
void init(void);
void update(void);
-} // namespace world::voxel_anims
+} // namespace voxel_anims
diff --git a/src/game/client/world/voxel_atlas.cc b/src/game/client/world/voxel_atlas.cc
index 4307dad..9762998 100644
--- a/src/game/client/world/voxel_atlas.cc
+++ b/src/game/client/world/voxel_atlas.cc
@@ -10,7 +10,7 @@
struct AtlasPlane final {
std::unordered_map<std::size_t, std::size_t> lookup;
- std::vector<world::AtlasStrip> strips;
+ std::vector<AtlasStrip> strips;
std::size_t layer_count_max;
std::size_t layer_count;
std::size_t plane_id;
@@ -46,7 +46,7 @@ static void plane_setup(AtlasPlane& plane)
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
-static world::AtlasStrip* plane_lookup(AtlasPlane& plane, std::size_t hash_value)
+static AtlasStrip* plane_lookup(AtlasPlane& plane, std::size_t hash_value)
{
const auto it = plane.lookup.find(hash_value);
@@ -57,9 +57,9 @@ static world::AtlasStrip* plane_lookup(AtlasPlane& plane, std::size_t hash_value
return nullptr;
}
-static world::AtlasStrip* plane_new_strip(AtlasPlane& plane, const std::vector<std::string>& paths, std::size_t hash_value)
+static AtlasStrip* plane_new_strip(AtlasPlane& plane, const std::vector<std::string>& paths, std::size_t hash_value)
{
- world::AtlasStrip strip = {};
+ AtlasStrip strip = {};
strip.offset = plane.layer_count;
strip.plane = plane.plane_id;
@@ -86,7 +86,7 @@ static world::AtlasStrip* plane_new_strip(AtlasPlane& plane, const std::vector<s
return &plane.strips[index];
}
-void world::voxel_atlas::create(int width, int height, std::size_t count)
+void voxel_atlas::create(int width, int height, std::size_t count)
{
GLint max_plane_layers;
@@ -115,7 +115,7 @@ void world::voxel_atlas::create(int width, int height, std::size_t count)
spdlog::debug("voxel_atlas: max_plane_layers={}", max_plane_layers);
}
-void world::voxel_atlas::destroy(void)
+void voxel_atlas::destroy(void)
{
for(const AtlasPlane& plane : planes)
glDeleteTextures(1, &plane.gl_texture);
@@ -124,12 +124,12 @@ void world::voxel_atlas::destroy(void)
planes.clear();
}
-std::size_t world::voxel_atlas::plane_count(void)
+std::size_t voxel_atlas::plane_count(void)
{
return planes.size();
}
-GLuint world::voxel_atlas::plane_texture(std::size_t plane_id)
+GLuint voxel_atlas::plane_texture(std::size_t plane_id)
{
if(plane_id < planes.size()) {
return planes[plane_id].gl_texture;
@@ -139,7 +139,7 @@ GLuint world::voxel_atlas::plane_texture(std::size_t plane_id)
}
}
-void world::voxel_atlas::generate_mipmaps(void)
+void voxel_atlas::generate_mipmaps(void)
{
for(const AtlasPlane& plane : planes) {
glBindTexture(GL_TEXTURE_2D_ARRAY, plane.gl_texture);
@@ -147,7 +147,7 @@ void world::voxel_atlas::generate_mipmaps(void)
}
}
-world::AtlasStrip* world::voxel_atlas::find_or_load(const std::vector<std::string>& paths)
+AtlasStrip* voxel_atlas::find_or_load(const std::vector<std::string>& paths)
{
const std::size_t hash_value = vector_hash(paths);
@@ -170,7 +170,7 @@ world::AtlasStrip* world::voxel_atlas::find_or_load(const std::vector<std::strin
return nullptr;
}
-world::AtlasStrip* world::voxel_atlas::find(const std::vector<std::string>& paths)
+AtlasStrip* voxel_atlas::find(const std::vector<std::string>& paths)
{
const std::size_t hash_value = vector_hash(paths);
diff --git a/src/game/client/world/voxel_atlas.hh b/src/game/client/world/voxel_atlas.hh
index 70e8a1e..acfcfbd 100644
--- a/src/game/client/world/voxel_atlas.hh
+++ b/src/game/client/world/voxel_atlas.hh
@@ -1,28 +1,25 @@
#pragma once
-namespace world
-{
struct AtlasStrip final {
std::size_t offset;
std::size_t plane;
};
-} // namespace world
-namespace world::voxel_atlas
+namespace voxel_atlas
{
void create(int width, int height, std::size_t count);
void destroy(void);
-} // namespace world::voxel_atlas
+} // namespace voxel_atlas
-namespace world::voxel_atlas
+namespace voxel_atlas
{
std::size_t plane_count(void);
GLuint plane_texture(std::size_t plane_id);
void generate_mipmaps(void);
-} // namespace world::voxel_atlas
+} // namespace voxel_atlas
-namespace world::voxel_atlas
+namespace voxel_atlas
{
AtlasStrip* find_or_load(const std::vector<std::string>& paths);
AtlasStrip* find(const std::vector<std::string>& paths);
-} // namespace world::voxel_atlas
+} // namespace voxel_atlas
diff --git a/src/game/client/world/voxel_sounds.cc b/src/game/client/world/voxel_sounds.cc
index 42552f5..b60df94 100644
--- a/src/game/client/world/voxel_sounds.cc
+++ b/src/game/client/world/voxel_sounds.cc
@@ -4,21 +4,21 @@
#include "client/resource/sound_effect.hh"
-static std::vector<resource_ptr<SoundEffect>> footsteps_sounds[world::VMAT_COUNT];
+static std::vector<resource_ptr<SoundEffect>> footsteps_sounds[VMAT_COUNT];
static std::mt19937_64 randomizer;
-static void add_footsteps_effect(world::VoxelMaterial material, std::string_view name)
+static void add_footsteps_effect(VoxelMaterial material, std::string_view name)
{
if(auto effect = resource::load<SoundEffect>(name)) {
footsteps_sounds[material].push_back(effect);
}
}
-static resource_ptr<SoundEffect> get_footsteps_effect(world::VoxelMaterial material)
+static resource_ptr<SoundEffect> get_footsteps_effect(VoxelMaterial material)
{
auto surface_index = static_cast<std::size_t>(material);
- if(surface_index >= world::VMAT_COUNT) {
+ if(surface_index >= VMAT_COUNT) {
// Surface index out of range
return nullptr;
}
@@ -34,7 +34,7 @@ static resource_ptr<SoundEffect> get_footsteps_effect(world::VoxelMaterial mater
return sounds.at(dist(randomizer));
}
-void world::voxel_sounds::init(void)
+void voxel_sounds::init(void)
{
add_footsteps_effect(VMAT_DEFAULT, "sounds/surface/default1.wav");
add_footsteps_effect(VMAT_DEFAULT, "sounds/surface/default2.wav");
@@ -57,14 +57,14 @@ void world::voxel_sounds::init(void)
add_footsteps_effect(VMAT_WOOD, "sounds/surface/wood3.wav");
}
-void world::voxel_sounds::shutdown(void)
+void voxel_sounds::shutdown(void)
{
- for(std::size_t i = 0; i < world::VMAT_COUNT; ++i) {
+ for(std::size_t i = 0; i < VMAT_COUNT; ++i) {
footsteps_sounds[i].clear();
}
}
-resource_ptr<SoundEffect> world::voxel_sounds::get_footsteps(world::VoxelMaterial material)
+resource_ptr<SoundEffect> voxel_sounds::get_footsteps(VoxelMaterial material)
{
if(auto effect = get_footsteps_effect(material)) {
return effect;
@@ -77,7 +77,7 @@ resource_ptr<SoundEffect> world::voxel_sounds::get_footsteps(world::VoxelMateria
return nullptr;
}
-resource_ptr<SoundEffect> world::voxel_sounds::get_placebreak(world::VoxelMaterial material)
+resource_ptr<SoundEffect> voxel_sounds::get_placebreak(VoxelMaterial material)
{
return nullptr;
}
diff --git a/src/game/client/world/voxel_sounds.hh b/src/game/client/world/voxel_sounds.hh
index dc02cbd..1b14698 100644
--- a/src/game/client/world/voxel_sounds.hh
+++ b/src/game/client/world/voxel_sounds.hh
@@ -6,14 +6,14 @@
struct SoundEffect;
-namespace world::voxel_sounds
+namespace voxel_sounds
{
void init(void);
void shutdown(void);
-} // namespace world::voxel_sounds
+} // namespace voxel_sounds
-namespace world::voxel_sounds
+namespace voxel_sounds
{
resource_ptr<SoundEffect> get_footsteps(VoxelMaterial material);
resource_ptr<SoundEffect> get_placebreak(VoxelMaterial material);
-} // namespace world::voxel_sounds
+} // namespace voxel_sounds