Skip to content

Commit

Permalink
Temporary remove temporary workaround for chunk mesh stitching
Browse files Browse the repository at this point in the history
  • Loading branch information
yksen committed Jun 11, 2024
1 parent b472639 commit de3b497
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 27 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ project(Everland LANGUAGES CXX)

include(FetchContent)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_subdirectory(lib)
add_subdirectory(src)
8 changes: 6 additions & 2 deletions src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

#include <raylib-cpp.hpp>

namespace everland {

Application::Application(const ApplicationOptions &options) : options{options}
{
window.Init(GetScreenWidth(), GetScreenHeight(), "Everland", FLAG_FULLSCREEN_MODE);
window.SetTargetFPS(144);
window.SetTargetFPS(0);

worlds = World::discoverLocalWorlds();
appLoop();
Expand Down Expand Up @@ -53,4 +55,6 @@ void Application::appLoop()
draw();
}
CloseWindow();
}
}

} // namespace everland
4 changes: 4 additions & 0 deletions src/Application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

namespace rl = raylib;

namespace everland {

struct ApplicationOptions
{
bool debugModeEnabled{false};
Expand Down Expand Up @@ -37,3 +39,5 @@ class Application
std::unique_ptr<Game> game;
std::vector<std::unique_ptr<World>> worlds;
};

} // namespace everland
7 changes: 1 addition & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(SOURCES
Application.cpp
logic/Game.cpp
Expand All @@ -22,7 +20,4 @@ add_executable(Everland)
target_sources(Everland PRIVATE main.cpp)
target_link_libraries(Everland PRIVATE EverlandLib)

add_custom_target(run
COMMAND Everland
DEPENDS Everland
)
add_custom_target(run COMMAND Everland DEPENDS Everland)
5 changes: 5 additions & 0 deletions src/logic/Game.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Game.hpp"
#include "raylib.h"

#include <format>
#include <raylib-cpp.hpp>
Expand All @@ -15,6 +16,10 @@ void Game::processInput()
{
if (IsKeyPressed(KEY_F3))
options.debugModeEnabled = !options.debugModeEnabled;
if (IsKeyPressed(KEY_MINUS))
options.renderDistance = std::max(1, options.renderDistance - 1);
if (IsKeyPressed(KEY_EQUAL))
++options.renderDistance;

player.processInput();
}
Expand Down
4 changes: 1 addition & 3 deletions src/logic/Game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@

#include <memory>

namespace rl = raylib;

struct GameOptions
{
int renderDistance{2};
int renderDistance{4};
bool debugModeEnabled{false};
};

Expand Down
8 changes: 4 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <Application.hpp>
#include <utility/Parser.hpp>
#include "Application.hpp"
#include "utils/Parser.hpp"

int main(int argc, char **argv)
{
auto options{parseCommandLineInput(argc, argv)};
std::make_unique<Application>(options);
auto options{everland::parseCommandLineInput(argc, argv)};
std::make_unique<everland::Application>(options);

return 0;
}
18 changes: 11 additions & 7 deletions src/utility/Parser.hpp → src/utils/Parser.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#pragma once

#include "Application.hpp"

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <optional>
#include <string>

namespace everland {

std::optional<std::string> getOption(char **begin, char **end, const std::string &option)
{
char **itr = std::find(begin, end, option);
Expand All @@ -22,12 +28,8 @@ void printHelp()
static constexpr int optionWidth = 16;
std::cout << "Usage: Everland [options]\n"
<< "Options:\n"
<< std::left << std::setw(optionWidth)
<< " -h, --help"
<< " - Show this help message\n"
<< std::left << std::setw(optionWidth)
<< " -d, --debug"
<< " - Enable debug mode\n";
<< std::left << std::setw(optionWidth) << " -h, --help" << " - Show this help message\n"
<< std::left << std::setw(optionWidth) << " -d, --debug" << " - Enable debug mode\n";
}

ApplicationOptions parseCommandLineInput(int argc, char **argv)
Expand All @@ -44,4 +46,6 @@ ApplicationOptions parseCommandLineInput(int argc, char **argv)
options.debugModeEnabled = true;

return options;
}
}

} // namespace everland
2 changes: 1 addition & 1 deletion src/world/Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void Chunk::buildMesh()
return shader;
}();

auto mesh = MeshBuilder::buildMesh(*this);
auto mesh{MeshBuilder::buildMesh(*this)};
model = std::make_unique<rl::Model>(mesh);
model->materials[0].shader = shader;
}
Expand Down
8 changes: 4 additions & 4 deletions src/world/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ World::World(const fs::directory_entry &worldDirectory)

void World::update(const rl::Vector2 &playerChunk, int renderDistance)
{
if (previousPlayerChunk.Equals(playerChunk))
return;
// if (previousPlayerChunk.Equals(playerChunk))
// return;

generateChunks(playerChunk, renderDistance);
unloadChunks(playerChunk, renderDistance);
Expand Down Expand Up @@ -93,8 +93,8 @@ void World::addNeighbors(Chunk &chunk)
{
chunk.neighbors[x + 1][z + 1] = neighbor;
neighbor->neighbors[-x + 1][-z + 1] = &chunk;
chunk.buildMesh();
neighbor->buildMesh();
// chunk.buildMesh();
// neighbor->buildMesh();
}
}
}
Expand Down

0 comments on commit de3b497

Please sign in to comment.