diff --git a/CMakeLists.txt b/CMakeLists.txt index f438c0b..95ba16a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,28 @@ -cmake_minimum_required(VERSION 3.8) -project(Phoenix) +cmake_minimum_required(VERSION 3.12) +project( + Phoenix + VERSION 0.2 + LANGUAGES CXX) + +# Use folders. set_property(GLOBAL PROPERTY USE_FOLDERS ON) +# Update git submodules. +find_package(Git QUIET) +if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") + option(UPDATE_SUBMODULES "Update git submodules during build." ON) + if(UPDATE_SUBMODULES) + message(STATUS "Updating git submodules.") + execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE GIT_SUBMODULE_RESULT) + if(NOT GIT_SUBMODULE_RESULT EQUAL "0") + message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMODULE_RESULT}, please checkout submodules.") + endif() + else() + message(STATUS "Git submodules set to manual update only, this can be changed with the UPDATE_SUBMODULES option.") + endif() +endif() + add_subdirectory(Phoenix) diff --git a/Phoenix/Client/Include/Client/Graphics/ChunkRenderer.hpp b/Phoenix/Client/Include/Client/Graphics/ChunkRenderer.hpp index 3996b63..87b1fc8 100644 --- a/Phoenix/Client/Include/Client/Graphics/ChunkRenderer.hpp +++ b/Phoenix/Client/Include/Client/Graphics/ChunkRenderer.hpp @@ -127,9 +127,10 @@ namespace phx::gfx static std::vector getRequiredShaderLayout(); /** - * @brief Gets the table of textures and how they are allocated on the - * GPU. - * @return The locations of the textures on the GPU. + * @brief Gets the table telling everything where each texture is in the + * GPU-side array. + * @return An associative table storing which textures are on which + * layers within the texture array. */ const AssociativeTextureTable& getTextureTable() const; diff --git a/Phoenix/Client/Include/Client/Voxels/BlockRegistry.hpp b/Phoenix/Client/Include/Client/Voxels/BlockRegistry.hpp index 7140216..2b95b82 100644 --- a/Phoenix/Client/Include/Client/Voxels/BlockRegistry.hpp +++ b/Phoenix/Client/Include/Client/Voxels/BlockRegistry.hpp @@ -53,7 +53,8 @@ namespace phx::client { BlockRegistry() { - textures.add(voxels::BlockType::UNKNOWN_BLOCK, {"Assets/unknown.png"}); + textures.add(voxels::BlockType::UNKNOWN_BLOCK, + {"Assets/unknown.png"}); textures.setUnknownReturnVal( textures.get(voxels::BlockType::UNKNOWN_BLOCK)); } diff --git a/Phoenix/Common/Source/PlayerView.cpp b/Phoenix/Common/Source/PlayerView.cpp index 5b4b8c5..936c7a3 100644 --- a/Phoenix/Common/Source/PlayerView.cpp +++ b/Phoenix/Common/Source/PlayerView.cpp @@ -60,8 +60,13 @@ std::vector PlayerView::update(entt::registry* registry, math::vec3 chunkToCheck = {static_cast(x + posX), static_cast(y + posY), static_cast(z + posZ)}; - chunkToCheck = chunkToCheck * - static_cast(voxels::Chunk::CHUNK_WIDTH); + + // this will allow it to work if we choose to make chunks non cube. + chunkToCheck = + chunkToCheck * math::vec3 {voxels::Chunk::CHUNK_WIDTH, + voxels::Chunk::CHUNK_HEIGHT, + voxels::Chunk::CHUNK_DEPTH}; + bool hasChunk = false; for (const auto chunk : view.chunks) { @@ -71,6 +76,7 @@ std::vector PlayerView::update(entt::registry* registry, break; } } + if (!hasChunk) { voxels::Chunk* chunk = view.map->getChunk(chunkToCheck); @@ -84,5 +90,6 @@ std::vector PlayerView::update(entt::registry* registry, } } } + return newChunks; } diff --git a/Phoenix/Common/Source/Voxels/Map.cpp b/Phoenix/Common/Source/Voxels/Map.cpp index 6cb28df..104abb2 100644 --- a/Phoenix/Common/Source/Voxels/Map.cpp +++ b/Phoenix/Common/Source/Voxels/Map.cpp @@ -257,9 +257,9 @@ void Map::save(const phx::math::vec3& pos) } std::ofstream saveFile; - std::string position = "." + std::to_string(int(pos.x)) + "_" + - std::to_string(int(pos.y)) + "_" + - std::to_string(int(pos.z)); + std::string position = "." + std::to_string(static_cast(pos.x)) + "_" + + std::to_string(static_cast(pos.y)) + "_" + + std::to_string(static_cast(pos.z)); saveFile.open("Saves/" + m_save->getName() + "/" + m_mapName + position + ".save"); std::string saveString; diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ceb3439..cafb8ab 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -44,9 +44,7 @@ jobs: # key: 'ccache | "$(Agent.JobName)"' # path: $(CCACHE_DIR) # displayName: 'CCache' - - script: git submodule update --init - displayName: 'Cloning Submodules' - - script: cmake -H. -BBuild + - script: cmake -S . -B Build displayName: 'CMake Configure' - script: cmake --build Build displayName: 'CMake Build' @@ -62,9 +60,7 @@ jobs: CMakeArgs: '' steps: - - script: git submodule update --init - displayName: 'Cloning Submodules' - - script: cmake -H. -BBuild + - script: cmake -S . -B Build displayName: 'CMake Configure' - script: cmake --build Build displayName: 'CMake Build' @@ -75,9 +71,7 @@ jobs: vmImage: 'macOS-latest' steps: - - script: git submodule update --init - displayName: 'Cloning Submodules' - - script: cmake -H. -BBuild + - script: cmake -S . -B Build displayName: 'CMake Configure' - script: cmake --build Build displayName: 'CMake Build'