From e75f819789fbcf01e9d4932d37a3cf5f868181c9 Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Thu, 21 Feb 2019 15:30:10 +0700 Subject: [PATCH] remove toolset to https://github.com/enduro2d/enduro2d-toolset --- .codecov.yml | 1 - BUILD_INSTRUCTIONS.md | 10 +- CMakeLists.txt | 5 - scripts/cloc_all.sh | 3 +- scripts/cloc_toolset.sh | 3 - scripts/untest_all_clang.sh | 6 - scripts/upload_coverage.sh | 2 +- toolset/CMakeLists.txt | 1 - toolset/model_converter/CMakeLists.txt | 29 -- toolset/model_converter/modules/assimp | 1 - toolset/model_converter/sources/main.cpp | 406 ----------------------- 11 files changed, 4 insertions(+), 463 deletions(-) delete mode 100755 scripts/cloc_toolset.sh delete mode 100644 toolset/CMakeLists.txt delete mode 100644 toolset/model_converter/CMakeLists.txt delete mode 160000 toolset/model_converter/modules/assimp delete mode 100644 toolset/model_converter/sources/main.cpp diff --git a/.codecov.yml b/.codecov.yml index 31cd405a..c2c97dd1 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,6 +1,5 @@ ignore: - "untests/*" - "samples/*" - - "toolset/*" - "*/3rdparty/*" - "*/modules/*" diff --git a/BUILD_INSTRUCTIONS.md b/BUILD_INSTRUCTIONS.md index 8aac80f4..e04ddcc6 100644 --- a/BUILD_INSTRUCTIONS.md +++ b/BUILD_INSTRUCTIONS.md @@ -12,14 +12,8 @@ ```bash $ git clone --recursive git://github.com/enduro2d/enduro2d.git $ cd enduro2d -``` - -> or - -```bash -$ git clone git://github.com/enduro2d/enduro2d.git -$ cd enduro2d -$ git submodule update --init --recursive +$ git lfs install +$ git lfs pull ``` ## * Building diff --git a/CMakeLists.txt b/CMakeLists.txt index 541698dd..22af503e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -189,11 +189,6 @@ if(E2D_BUILD_SAMPLES) add_subdirectory(samples) endif() -option(E2D_BUILD_TOOLSET "Build toolset" ON) -if(E2D_BUILD_TOOLSET) - add_subdirectory(toolset) -endif() - option(E2D_BUILD_UNTESTS "Build untests" ON) if(E2D_BUILD_UNTESTS) enable_testing() diff --git a/scripts/cloc_all.sh b/scripts/cloc_all.sh index 71437085..f6abdbd9 100755 --- a/scripts/cloc_all.sh +++ b/scripts/cloc_all.sh @@ -4,5 +4,4 @@ cloc \ $SCRIPT_DIR/../headers/enduro2d \ $SCRIPT_DIR/../sources/enduro2d \ $SCRIPT_DIR/../samples/sources \ - $SCRIPT_DIR/../untests/sources \ - $SCRIPT_DIR/../toolset/model_converter/sources + $SCRIPT_DIR/../untests/sources diff --git a/scripts/cloc_toolset.sh b/scripts/cloc_toolset.sh deleted file mode 100755 index 298e3b04..00000000 --- a/scripts/cloc_toolset.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -SCRIPT_DIR=`dirname "$BASH_SOURCE"` -cloc $SCRIPT_DIR/../toolset/model_converter/sources diff --git a/scripts/untest_all_clang.sh b/scripts/untest_all_clang.sh index 0b77ad50..f097ee4c 100755 --- a/scripts/untest_all_clang.sh +++ b/scripts/untest_all_clang.sh @@ -18,9 +18,3 @@ $SCRIPT_DIR/build_clear.sh CC=clang-3.8 CXX=clang++-3.8 $SCRIPT_DIR/build_all.sh $SCRIPT_DIR/build_clear.sh -CC=clang-3.7 CXX=clang++-3.7 $SCRIPT_DIR/build_all.sh - -$SCRIPT_DIR/build_clear.sh -CC=clang-3.6 CXX=clang++-3.6 $SCRIPT_DIR/build_all.sh - -$SCRIPT_DIR/build_clear.sh diff --git a/scripts/upload_coverage.sh b/scripts/upload_coverage.sh index 0193817f..c49c8de9 100755 --- a/scripts/upload_coverage.sh +++ b/scripts/upload_coverage.sh @@ -11,7 +11,7 @@ lcov -d . -z ctest --verbose lcov -d . -c -o "coverage.info" -lcov -r "coverage.info" "*/usr/*" "*/Xcode.app/*" "*/untests/*" "*/samples/*" "*/toolset/*" "*/3rdparty/*" "*/modules/*" -o "coverage.info" +lcov -r "coverage.info" "*/usr/*" "*/Xcode.app/*" "*/untests/*" "*/samples/*" "*/3rdparty/*" "*/modules/*" -o "coverage.info" lcov -l "coverage.info" bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports" diff --git a/toolset/CMakeLists.txt b/toolset/CMakeLists.txt deleted file mode 100644 index 82d636f7..00000000 --- a/toolset/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(model_converter) diff --git a/toolset/model_converter/CMakeLists.txt b/toolset/model_converter/CMakeLists.txt deleted file mode 100644 index bf5d0aef..00000000 --- a/toolset/model_converter/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# -# external 3rd party -# - -set(ASSIMP_NO_EXPORT ON CACHE BOOL "" FORCE) -set(ASSIMP_BUILD_TESTS OFF CACHE BOOL "" FORCE) -set(ASSIMP_BUILD_ASSIMP_TOOLS OFF CACHE BOOL "" FORCE) -add_subdirectory(modules/assimp) - -# -# model converter executable -# - -file(GLOB MODEL_CONVERTER_SOURCES - sources/*.*) - -source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES - ${MODEL_CONVERTER_SOURCES}) - -add_executable(model_converter - ${MODEL_CONVERTER_SOURCES}) - -target_link_libraries(model_converter - assimp) - -set_target_properties(model_converter PROPERTIES - CXX_STANDARD 14 - CXX_STANDARD_REQUIRED YES - CXX_EXTENSIONS NO) diff --git a/toolset/model_converter/modules/assimp b/toolset/model_converter/modules/assimp deleted file mode 160000 index fadfaf88..00000000 --- a/toolset/model_converter/modules/assimp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fadfaf88db12af41348f5347af2ee926723bc539 diff --git a/toolset/model_converter/sources/main.cpp b/toolset/model_converter/sources/main.cpp deleted file mode 100644 index 7446d556..00000000 --- a/toolset/model_converter/sources/main.cpp +++ /dev/null @@ -1,406 +0,0 @@ -/******************************************************************************* - * This file is part of the "Enduro2D" - * For conditions of distribution and use, see copyright notice in LICENSE.md - * Copyright (C) 2018 Matvey Cherevko - ******************************************************************************/ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace -{ - const std::uint32_t mesh_file_version = 1; - const std::string mesh_file_signature = "e2d_mesh"; - - struct opts { - bool timers = false; - bool verbose = false; - - opts(int argc, char *argv[]) { - timers = has_flag("-t", argc, argv) || has_flag("--timers", argc, argv); - verbose = has_flag("-v", argc, argv) || has_flag("--verbose", argc, argv); - } - - private: - static bool has_flag(const char* flag, int argc, char *argv[]) noexcept { - for ( int i = 0; i < argc; ++i ) { - if ( 0 == std::strcmp(argv[i], flag) ) { - return true; - } - } - return false; - } - }; - - class timer { - public: - timer() - : tp_(std::chrono::high_resolution_clock::now()) {} - - void done() const { - const auto duration_us = std::chrono::duration_cast( - std::chrono::high_resolution_clock::now() - tp_); - std::cout << duration_us.count() << "us" << std::endl; - } - private: - std::chrono::high_resolution_clock::time_point tp_; - }; - - struct v2f { - float x = 0.f; - float y = 0.f; - - v2f(float nx, float ny) - : x(nx), y(ny) {} - }; - - struct v3f { - float x = 0.f; - float y = 0.f; - float z = 0.f; - - v3f(float nx, float ny, float nz) - : x(nx), y(ny), z(nz) {} - }; - - struct mesh { - std::vector vertices; - std::vector indices; - - std::vector> uvs_channels; - std::vector> colors_channels; - - std::vector normals; - std::vector tangents; - std::vector bitangents; - }; - - template < typename T > - T saturate(T v) noexcept { - return std::min(std::max(v, T(0)), T(1)); - } - - std::uint8_t pack_color_component(float c) noexcept { - return static_cast(std::round(saturate(c) * 255.f)); - } - - std::uint32_t pack_color(float r, float g, float b, float a) noexcept { - std::uint8_t rr = pack_color_component(r); - std::uint8_t gg = pack_color_component(g); - std::uint8_t bb = pack_color_component(b); - std::uint8_t aa = pack_color_component(a); - return - static_cast(aa) << 24 | - static_cast(rr) << 16 | - static_cast(gg) << 8 | - static_cast(bb) << 0; - } - - void write_u32_to_ofstream(std::ofstream& s, const std::uint32_t v) { - s.write( - reinterpret_cast(&v), - sizeof(v)); - } - - void write_str_to_ofstream(std::ofstream& s, const std::string& v) { - s.write(v.data(), static_cast(v.length())); - } - - template < typename T > - std::size_t write_vector_to_ofstream(std::ofstream& s, const std::vector& v) { - if ( !v.empty() ) { - std::size_t data_size = v.size() * sizeof(T); - s.write( - reinterpret_cast(v.data()), - static_cast(data_size)); - return data_size; - } - return 0; - } - - bool validate_mesh(const mesh& mesh) noexcept { - if ( mesh.vertices.empty() ) { - return false; - } - if ( mesh.indices.empty() ) { - return false; - } - for ( const auto& uvs : mesh.uvs_channels ) { - if ( uvs.size() != mesh.vertices.size() ) { - return false; - } - } - for ( const auto& colors : mesh.colors_channels ) { - if ( colors.size() != mesh.vertices.size() ) { - return false; - } - } - if ( !mesh.normals.empty() && mesh.normals.size() != mesh.vertices.size() ) { - return false; - } - if ( !mesh.tangents.empty() && mesh.tangents.size() != mesh.vertices.size() ) { - return false; - } - if ( !mesh.bitangents.empty() && mesh.bitangents.size() != mesh.vertices.size() ) { - return false; - } - return true; - } - - bool save_mesh(const mesh& mesh, const std::string& out_path, const opts& opts) { - timer save_timer; - - if ( !validate_mesh(mesh) ) { - std::cerr << "Failed to validate out mesh: " << out_path << std::endl; - return false; - } - - std::ofstream stream(out_path, std::ofstream::out | std::ofstream::binary); - if ( !stream.is_open() ) { - std::cerr << "Failed to open out file stream: " << out_path << std::endl; - return false; - } - - write_str_to_ofstream(stream, mesh_file_signature); - write_u32_to_ofstream(stream, mesh_file_version); - - write_u32_to_ofstream(stream, static_cast(mesh.vertices.size())); - write_u32_to_ofstream(stream, static_cast(mesh.indices.size())); - - write_u32_to_ofstream(stream, static_cast(mesh.uvs_channels.size())); - write_u32_to_ofstream(stream, static_cast(mesh.colors_channels.size())); - - write_u32_to_ofstream(stream, static_cast(mesh.normals.size())); - write_u32_to_ofstream(stream, static_cast(mesh.tangents.size())); - write_u32_to_ofstream(stream, static_cast(mesh.bitangents.size())); - - std::size_t vertices_bytes = write_vector_to_ofstream(stream, mesh.vertices); - std::size_t indices_bytes = write_vector_to_ofstream(stream, mesh.indices); - - std::size_t uvs_bytes = 0; - for ( const auto& uvs : mesh.uvs_channels ) { - uvs_bytes += write_vector_to_ofstream(stream, uvs); - } - - std::size_t colors_bytes = 0; - for ( const auto& colors : mesh.colors_channels ) { - colors_bytes += write_vector_to_ofstream(stream, colors); - } - - std::size_t normals_bytes = write_vector_to_ofstream(stream, mesh.normals); - std::size_t tangents_bytes = write_vector_to_ofstream(stream, mesh.tangents); - std::size_t bitangents_bytes = write_vector_to_ofstream(stream, mesh.bitangents); - - if ( opts.timers ) { - std::cout << "> save mesh: "; - save_timer.done(); - std::cout << " - " << out_path << std::endl; - } - - if ( opts.verbose ) { - std::cout - << std::endl - << "> mesh info:" << std::endl - << "-> vertices: " << mesh.vertices.size() << ", " << vertices_bytes << " B" << std::endl - << "-> indices: " << mesh.indices.size() << ", " << indices_bytes << " B" << std::endl - << "-> uvs: " << mesh.uvs_channels.size() << ", " << uvs_bytes << " B" << std::endl - << "-> colors: " << mesh.colors_channels.size() << ", " << colors_bytes << " B" << std::endl - << "-> normals: " << mesh.normals.size() << ", " << normals_bytes << " B" << std::endl - << "-> tangents: " << mesh.tangents.size() << ", " << tangents_bytes << " B" << std::endl - << "-> bitangents: " << mesh.bitangents.size() << ", " << bitangents_bytes << " B" << std::endl; - } - - return true; - } - - bool convert_mesh(const aiMesh* ai_mesh, const std::string& out_path, const opts& opts) { - mesh out_mesh; - timer convert_timer; - - if ( ai_mesh->HasPositions() ) { - out_mesh.vertices.reserve(ai_mesh->mNumVertices); - std::transform( - ai_mesh->mVertices, - ai_mesh->mVertices + ai_mesh->mNumVertices, - std::back_inserter(out_mesh.vertices), - [](const aiVector3D& v) noexcept { - return v3f{v.x, v.y, v.z}; - }); - } - - if ( ai_mesh->HasFaces() ) { - out_mesh.indices.reserve(ai_mesh->mNumFaces * 3u); - std::for_each( - ai_mesh->mFaces, - ai_mesh->mFaces + ai_mesh->mNumFaces, - [&out_mesh](const aiFace& f) { - if ( f.mNumIndices != 3 ) { - throw std::logic_error("invalide face index count"); - } - out_mesh.indices.insert( - out_mesh.indices.end(), - f.mIndices, - f.mIndices + f.mNumIndices); - }); - } - - for ( unsigned int channel = 0; channel < ai_mesh->GetNumUVChannels(); ++channel ) { - std::vector uvs; - uvs.reserve(ai_mesh->mNumVertices); - std::transform( - ai_mesh->mTextureCoords[channel], - ai_mesh->mTextureCoords[channel] + ai_mesh->mNumVertices, - std::back_inserter(uvs), - [](const aiVector3D& v) noexcept { - return v2f{v.x, v.y}; - }); - out_mesh.uvs_channels.emplace_back(std::move(uvs)); - } - - for ( unsigned int channel = 0; channel < ai_mesh->GetNumColorChannels(); ++channel ) { - std::vector colors; - colors.reserve(ai_mesh->mNumVertices); - std::transform( - ai_mesh->mColors[channel], - ai_mesh->mColors[channel] + ai_mesh->mNumVertices, - std::back_inserter(colors), - [](const aiColor4D& v) noexcept { - return pack_color(v.r, v.g, v.b, v.a); - }); - out_mesh.colors_channels.emplace_back(std::move(colors)); - } - - if ( ai_mesh->HasNormals() ) { - out_mesh.normals.reserve(ai_mesh->mNumVertices); - std::transform( - ai_mesh->mNormals, - ai_mesh->mNormals + ai_mesh->mNumVertices, - std::back_inserter(out_mesh.normals), - [](const aiVector3D& v) noexcept { - return v3f{v.x, v.y, v.z}; - }); - } - - if ( ai_mesh->HasTangentsAndBitangents() ) { - out_mesh.tangents.reserve(ai_mesh->mNumVertices); - std::transform( - ai_mesh->mTangents, - ai_mesh->mTangents + ai_mesh->mNumVertices, - std::back_inserter(out_mesh.tangents), - [](const aiVector3D& v) noexcept { - return v3f{v.x, v.y, v.z}; - }); - - out_mesh.bitangents.reserve(ai_mesh->mNumVertices); - std::transform( - ai_mesh->mBitangents, - ai_mesh->mBitangents + ai_mesh->mNumVertices, - std::back_inserter(out_mesh.bitangents), - [](const aiVector3D& v) noexcept { - return v3f{v.x, v.y, v.z}; - }); - } - - if ( opts.timers ) { - std::cout << std::endl << "> convert mesh: "; - convert_timer.done(); - std::cout << " - " << out_path << std::endl; - } - - return save_mesh(out_mesh, out_path, opts); - } - - bool convert(const std::string& path, const opts& opts) { - timer convert_timer; - timer importer_timer; - - Assimp::Importer importer; - - if ( opts.timers ) { - std::cout << "> prepare importer: "; - importer_timer.done(); - } - - const unsigned int importer_flags = - aiProcess_Triangulate | - aiProcess_MakeLeftHanded | - aiProcess_OptimizeMeshes | - aiProcess_JoinIdenticalVertices; - - timer import_timer; - - const aiScene* scene = importer.ReadFile(path, importer_flags); - if ( !scene ) { - std::cerr << "Failed to import model: " << path << std::endl; - std::cerr << "Error: " << importer.GetErrorString() << std::endl; - return false; - } - - if ( opts.timers ) { - std::cout << "> import model: "; - import_timer.done(); - } - - for ( unsigned int mesh_index = 0; mesh_index < scene->mNumMeshes; ++mesh_index ) { - const aiMesh* mesh = scene->mMeshes[mesh_index]; - - const std::string mesh_name = mesh->mName.length - ? mesh->mName.C_Str() - : "mesh_" + std::to_string(mesh_index); - - std::string mesh_out_path = std::string() - .append(path) - .append(".") - .append(mesh_name) - .append(".e2d_mesh"); - - if ( opts.verbose ) { - std::cout - << std::endl - << ">> Mesh(" - << mesh_name - << ") converting..." - << std::endl; - } - - if ( !convert_mesh(mesh, mesh_out_path, opts) ) { - std::cerr << "Failed!" << std::endl; - return false; - } - - if ( opts.verbose ) { - std::cout << "OK. " << std::endl; - } - } - - if ( opts.timers ) { - std::cout << std::endl << "=====" << std::endl; - convert_timer.done(); - } - - return true; - } -} - -int main(int argc, char *argv[]) { - if ( argc < 2 ) { - std::cout << "USAGE: model_converter mesh.obj" << std::endl; - return 0; - } - return convert(argv[1], opts(argc, argv)) ? 0 : 1; -}