diff --git a/modules/asset_baker/src/baker.cpp b/modules/asset_baker/src/baker.cpp index eba6fed..d9dc6c0 100644 --- a/modules/asset_baker/src/baker.cpp +++ b/modules/asset_baker/src/baker.cpp @@ -21,16 +21,18 @@ void log(Args &&...args) std::cout << '\n'; } -bool convert_image(const std::filesystem::path &input, const std::filesystem::path &output) +auto convert_image(const std::filesystem::path &input, const std::filesystem::path &output) -> bool { - int width, height, channels; + auto width = int {}; + auto height = int {}; + auto channels = int {}; - stbi_uc *pixels = stbi_load(input.string().c_str(), &width, &height, &channels, 4); + auto *pixels = stbi_load(input.string().c_str(), &width, &height, &channels, 4); if (!pixels) return false; - Assets::TextureInfo texInfo { + auto texture_info = Assets::TextureInfo { .size = static_cast(width * height * 4), .format = Assets::TextureFormat::RGBA8, .pixel_size = { @@ -41,7 +43,7 @@ bool convert_image(const std::filesystem::path &input, const std::filesystem::pa .original_file = input.string(), }; - Assets::AssetFile file = Assets::pack_texture(&texInfo, pixels); + auto file = Assets::pack_texture(&texture_info, pixels); stbi_image_free(pixels); @@ -59,7 +61,7 @@ int main(int argc, char *argv[]) "Argc MUST be 3, 1: execution-path(implicit), 2: input-directory, 3: output-directory" ); - for (auto &p : std::filesystem::directory_iterator(argv[1])) + for (const auto &p : std::filesystem::directory_iterator(argv[1])) { if (p.path().extension() == ".png") { diff --git a/modules/asset_parser/include/asset_parser/assets/texture.hpp b/modules/asset_parser/include/asset_parser/assets/texture.hpp index ad17646..7a9a1bd 100644 --- a/modules/asset_parser/include/asset_parser/assets/texture.hpp +++ b/modules/asset_parser/include/asset_parser/assets/texture.hpp @@ -1,10 +1,11 @@ #pragma once +#include #include namespace Assets { -enum class TextureFormat +enum class TextureFormat : uint8_t { None = 0, RGBA8, @@ -15,11 +16,11 @@ struct TextureInfo size_t size; CompressionMode compression_mode; TextureFormat format; - uint32_t pixel_size[3]; + std::array pixel_size; std::string original_file; }; -TextureInfo read_texture_info(AssetFile *file); +auto read_texture_info(AssetFile *file) -> TextureInfo; void unpack_texture( TextureInfo *info, @@ -28,6 +29,6 @@ void unpack_texture( void *destination ); -AssetFile pack_texture(TextureInfo *info, void *pixel_data); +auto pack_texture(TextureInfo *info, void *pixel_data) -> AssetFile; } // namespace Assets diff --git a/modules/asset_parser/include/asset_parser/parser.hpp b/modules/asset_parser/include/asset_parser/parser.hpp index 47d54c9..5dcb56b 100644 --- a/modules/asset_parser/include/asset_parser/parser.hpp +++ b/modules/asset_parser/include/asset_parser/parser.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -10,7 +10,7 @@ struct AssetFile { uint32_t version; - enum class Type : uint32_t + enum class Type : uint32_t // NOLINT(performance-enum-size) { Texture, Mesh, @@ -21,14 +21,14 @@ struct AssetFile std::vector blob; }; -enum class CompressionMode : uint32_t +enum class CompressionMode : uint32_t // NOLINT(performance-enum-size) { None, LZ4, LZ4HC, }; -bool save_binary_file(const char* path, const AssetFile& in_file); -bool load_binary_file(const char* path, AssetFile& out_file); +auto save_binary_file(const char *path, const AssetFile &in_file) -> bool; +auto load_binary_file(const char *path, AssetFile &out_file) -> bool; } // namespace Assets diff --git a/modules/asset_parser/src/assets/texture.cpp b/modules/asset_parser/src/assets/texture.cpp index fea4e16..850524f 100644 --- a/modules/asset_parser/src/assets/texture.cpp +++ b/modules/asset_parser/src/assets/texture.cpp @@ -6,7 +6,7 @@ namespace Assets { using namespace nlohmann; -TextureInfo read_texture_info(AssetFile *file) +auto read_texture_info(AssetFile *file) -> TextureInfo { json texture_meta_data = json::parse(file->json); @@ -45,7 +45,7 @@ void unpack_texture( } } -AssetFile pack_texture(TextureInfo *info, void *pixel_data) +auto pack_texture(TextureInfo *info, void *pixel_data) -> AssetFile { json metadata; metadata["format"] = info->format; diff --git a/modules/asset_parser/src/parser.cpp b/modules/asset_parser/src/parser.cpp index 840ea7e..55849c4 100644 --- a/modules/asset_parser/src/parser.cpp +++ b/modules/asset_parser/src/parser.cpp @@ -5,7 +5,7 @@ namespace Assets { -bool save_binary_file(const char *path, const AssetFile &file) +auto save_binary_file(const char *path, const AssetFile &file) -> bool { std::ofstream outstream(path, std::ios::binary | std::ios::out); @@ -27,7 +27,7 @@ bool save_binary_file(const char *path, const AssetFile &file) return true; } -bool load_binary_file(const char *path, AssetFile &out_file) +auto load_binary_file(const char *path, AssetFile &out_file) -> bool { std::ifstream instream(path, std::ios::binary); instream.seekg(0ull);