diff --git a/engine/asset/include/asset.hpp b/engine/asset/include/asset.hpp index 7883461..896e872 100644 --- a/engine/asset/include/asset.hpp +++ b/engine/asset/include/asset.hpp @@ -19,10 +19,10 @@ namespace std { } template -std::unique_ptr load_asset(const prism::path p); +std::unique_ptr load_asset(const prism::path& p); template -bool can_load_asset(const prism::path p); +bool can_load_asset(const prism::path& p); template using AssetStore = std::unordered_map>; @@ -91,7 +91,7 @@ public: std::unordered_map> reference_blocks; private: - ReferenceBlock* get_reference_block(const prism::path path) { + ReferenceBlock* get_reference_block(const prism::path& path) { if(!reference_blocks.count(path)) reference_blocks.try_emplace(path, std::make_unique()); @@ -99,7 +99,7 @@ private: } template - void load_asset_generic(const prism::path path, Asset*& at, ReferenceBlock*& block) { + void load_asset_generic(const prism::path& path, Asset*& at, ReferenceBlock*& block) { if(can_load_asset(path)) { if(!AssetStore::count(path)) AssetStore::try_emplace(path, load_asset(path)); @@ -126,14 +126,14 @@ using AssetManager = AssetPool; inline std::unique_ptr assetm; -std::unique_ptr load_mesh(const prism::path path); -std::unique_ptr load_material(const prism::path path); -std::unique_ptr load_texture(const prism::path path); +std::unique_ptr load_mesh(prism::path path); +std::unique_ptr load_material(prism::path path); +std::unique_ptr load_texture(prism::path path); -void save_material(Material* material, const prism::path path); +void save_material(Material* material, prism::path path); template -std::unique_ptr load_asset(const prism::path path) { +std::unique_ptr load_asset(const prism::path& path) { if constexpr (std::is_same_v) { return load_mesh(path); } else if constexpr(std::is_same_v) { @@ -144,7 +144,7 @@ std::unique_ptr load_asset(const prism::path path) { } template -bool can_load_asset(const prism::path path) { +bool can_load_asset(const prism::path& path) { if constexpr(std::is_same_v) { return path.extension() == ".model"; } else if constexpr(std::is_same_v) { diff --git a/engine/asset/include/assetptr.hpp b/engine/asset/include/assetptr.hpp index f533055..bf3b497 100644 --- a/engine/asset/include/assetptr.hpp +++ b/engine/asset/include/assetptr.hpp @@ -14,7 +14,7 @@ public: template struct AssetPtr { - AssetPtr() {} + AssetPtr() = default; AssetPtr(T* ptr, ReferenceBlock* block) : handle(ptr), block(block) { block->references++; @@ -54,7 +54,7 @@ struct AssetPtr { T* handle = nullptr; ReferenceBlock* block = nullptr; - operator bool() const{ + explicit operator bool() const{ return handle != nullptr; } diff --git a/engine/asset/include/material_nodes.hpp b/engine/asset/include/material_nodes.hpp index 455aea2..a22ea0c 100644 --- a/engine/asset/include/material_nodes.hpp +++ b/engine/asset/include/material_nodes.hpp @@ -104,20 +104,11 @@ public: std::string get_property_value(MaterialProperty& property) { switch(property.type) { case DataType::Vector3: - { return "vec3(" + std::to_string(property.value.x) + ", " + std::to_string(property.value.y) + ", " + std::to_string(property.value.z) + ")"; - } - break; case DataType::Float: - { return std::to_string(property.float_value); - } - break; case DataType::AssetTexture: - { return "texture(" + get_property_variable_name(property) + ", in_uv).rgb"; - } - break; } } diff --git a/engine/asset/src/asset.cpp b/engine/asset/src/asset.cpp index 17f9665..56f4950 100644 --- a/engine/asset/src/asset.cpp +++ b/engine/asset/src/asset.cpp @@ -356,7 +356,7 @@ void save_material(Material* material, const prism::path path) { n["properties"].push_back(p); } - for(auto output : node->outputs) { + for(const auto& output : node->outputs) { if(output.connected_connector != nullptr) { nlohmann::json c; c["name"] = output.name; diff --git a/engine/audio/include/audio.hpp b/engine/audio/include/audio.hpp index 777c6d1..2dd9b01 100755 --- a/engine/audio/include/audio.hpp +++ b/engine/audio/include/audio.hpp @@ -8,5 +8,5 @@ namespace audio { void initialize(); - void play_file(const prism::path path, const float gain = 1.0f); + void play_file(const prism::path& path, float gain = 1.0f); } diff --git a/engine/audio/src/audio.cpp b/engine/audio/src/audio.cpp index def5158..50137d4 100755 --- a/engine/audio/src/audio.cpp +++ b/engine/audio/src/audio.cpp @@ -71,7 +71,7 @@ void audio::initialize() { Pa_StartStream(stream); } -void audio::play_file(const prism::path path, const float gain) { +void audio::play_file(const prism::path& path, const float gain) { auto audio_file = prism::open_file(path); if(audio_file == std::nullopt) return; diff --git a/engine/core/include/console.hpp b/engine/core/include/console.hpp index ce64726..0eb80f0 100755 --- a/engine/core/include/console.hpp +++ b/engine/core/include/console.hpp @@ -27,6 +27,8 @@ namespace prism::console { return argument_type::Integer; else if (std::holds_alternative(data)) return argument_type::Boolean; + + return argument_type::String; // fallback?? } std::variant data; diff --git a/engine/core/include/cutscene.hpp b/engine/core/include/cutscene.hpp index 1cda410..22ce601 100755 --- a/engine/core/include/cutscene.hpp +++ b/engine/core/include/cutscene.hpp @@ -17,12 +17,12 @@ inline bool operator==(const PositionKeyFrame& lhs, const PositionKeyFrame& rhs) } struct RotationKeyFrame { - float time; + float time = 0.0f; Quaternion value; }; struct ScaleKeyFrame { - float time; + float time = 0.0f; prism::float3 value; }; diff --git a/engine/core/include/engine.hpp b/engine/core/include/engine.hpp index 7a9fd4f..604fe11 100755 --- a/engine/core/include/engine.hpp +++ b/engine/core/include/engine.hpp @@ -223,7 +223,7 @@ namespace prism { * Called when text has been inputted. This is only emitted when text input is enabled thru input system * @param string */ - void process_text_input(const std::string_view string); + void process_text_input(std::string_view string); /** Adds a timer to the list of timers. @param timer The timer to add. diff --git a/engine/core/include/scene.hpp b/engine/core/include/scene.hpp index 2a4fcd6..e159366 100755 --- a/engine/core/include/scene.hpp +++ b/engine/core/include/scene.hpp @@ -255,5 +255,5 @@ public: */ void camera_look_at(Scene& scene, Object cam, prism::float3 pos, prism::float3 target); -Object load_object(Scene& scene, const nlohmann::json obj); +Object load_object(Scene& scene, const nlohmann::json& obj); nlohmann::json save_object(Object obj); diff --git a/engine/core/src/console.cpp b/engine/core/src/console.cpp index 1b71bef..b562bd6 100644 --- a/engine/core/src/console.cpp +++ b/engine/core/src/console.cpp @@ -66,6 +66,8 @@ void prism::console::invoke_command(const std::string_view name, const prism::co case console::argument_type::Boolean: *std::get(variable_data.data) = std::get(argument.data); break; + default: // non-bool types are not handled yet. + break; } } @@ -91,8 +93,6 @@ void prism::console::parse_and_invoke_command(const std::string_view command) { } else { return console_argument(arg); } - - return std::nullopt; }; std::vector arguments; diff --git a/engine/core/src/debug.cpp b/engine/core/src/debug.cpp index 5d4635f..276557d 100644 --- a/engine/core/src/debug.cpp +++ b/engine/core/src/debug.cpp @@ -36,7 +36,7 @@ void draw_asset() { for(auto& [path, block] : assetm->reference_blocks) { ImGui::PushID(&block); - ImGui::Text("- %s has %llu reference(s)", path.string().c_str(), block->references); + ImGui::Text("- %s has %lu reference(s)", path.string().c_str(), block->references); ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor(200, 0, 0)); diff --git a/engine/core/src/engine.cpp b/engine/core/src/engine.cpp index 3c7a2db..f05a242 100755 --- a/engine/core/src/engine.cpp +++ b/engine/core/src/engine.cpp @@ -324,9 +324,9 @@ void engine::save_cutscene(const std::string_view path) { s["begin"] = shot.begin; s["end"] = shot.length; - for(auto& [path, scene] : path_to_scene) { + for(auto& [scene_path, scene] : path_to_scene) { if(shot.scene == scene) - s["scene"] = path; + s["scene"] = scene_path; } j["shots"].push_back(s); @@ -352,7 +352,7 @@ Object engine::add_prefab(Scene& scene, const prism::path& path, const std::stri std::map parent_queue; - for(const auto obj : j["objects"]) { + for(const auto& obj : j["objects"]) { auto o = load_object(scene, obj); if(obj.contains("parent")) { @@ -457,7 +457,7 @@ void engine::process_key_up(const unsigned int keyCode) { imgui->process_key_up(keyCode); } -void engine::process_mouse_down(const int button, const prism::Offset offset) { +void engine::process_mouse_down(const int button, const prism::Offset) { imgui->process_mouse_down(button); } diff --git a/engine/core/src/file.cpp b/engine/core/src/file.cpp index be770de..5036a43 100755 --- a/engine/core/src/file.cpp +++ b/engine/core/src/file.cpp @@ -2,11 +2,10 @@ #include -#include "string_utils.hpp" #include "log.hpp" #include "assertions.hpp" -prism::path prism::root_path(const path path) { +prism::path prism::root_path(const path& path) { auto p = path; while(p.parent_path() != p && p.parent_path() != "/") { p = p.parent_path(); @@ -15,7 +14,7 @@ prism::path prism::root_path(const path path) { return p; } -std::optional prism::open_file(const prism::path path, const bool binary_mode) { +std::optional prism::open_file(const prism::path& path, const bool binary_mode) { Expects(!path.empty()); auto str = get_file_path(path).string(); @@ -48,7 +47,7 @@ prism::path parent_domain(const prism::path& path) { return path; } -prism::path prism::get_relative_path(const domain domain, const path path) { +prism::path prism::get_relative_path(const domain, const path& path) { // unimplemented return path; } diff --git a/engine/core/src/imgui_backend.cpp b/engine/core/src/imgui_backend.cpp index cfe31de..0440eeb 100644 --- a/engine/core/src/imgui_backend.cpp +++ b/engine/core/src/imgui_backend.cpp @@ -228,7 +228,7 @@ void imgui_backend::begin_frame(const float delta_time) { if(ImGui::Selectable("..", false, ImGuiSelectableFlags_DontClosePopups)) data.current_path = data.current_path.parent_path(); - for(auto dir_ent : std::filesystem::directory_iterator(data.current_path)) { + for(const auto& dir_ent : std::filesystem::directory_iterator(data.current_path)) { if(ImGui::Selectable(dir_ent.path().c_str(), data.selected_path == dir_ent.path(), ImGuiSelectableFlags_DontClosePopups)) { if(dir_ent.is_directory()) data.current_path = dir_ent.path(); @@ -291,7 +291,7 @@ void prism::imgui_backend::process_text_input(const std::string_view string) { io.AddInputCharactersUTF8(string.data()); } -void prism::imgui_backend::open_dialog(const bool existing, std::function returnFunction, bool openDirectory) { +void prism::imgui_backend::open_dialog(const bool, std::function returnFunction, bool) { open_dialog_next_frame = true; open_dialog_data.current_path = std::filesystem::current_path(); open_dialog_data.return_function = returnFunction; diff --git a/engine/core/src/input.cpp b/engine/core/src/input.cpp index 649d24f..113d495 100755 --- a/engine/core/src/input.cpp +++ b/engine/core/src/input.cpp @@ -3,7 +3,6 @@ #include #include "engine.hpp" -#include "log.hpp" using prism::input_system; @@ -139,7 +138,7 @@ float input_system::get_value(const std::string& name) { } bool input_system::is_pressed(const std::string &name, bool repeating) { - return get_value(name) == 1.0 && (repeating ? true : !is_repeating(name)); + return get_value(name) == 1.0 && (repeating || !is_repeating(name)); } bool input_system::is_repeating(const std::string& name) { diff --git a/engine/core/src/physics.cpp b/engine/core/src/physics.cpp index a4fe8c7..3f49b85 100755 --- a/engine/core/src/physics.cpp +++ b/engine/core/src/physics.cpp @@ -129,7 +129,7 @@ Physics::RayResult Physics::raycast(prism::float3 from, prism::float3 to) { if(closestCollisionObject != NullObject) { result.hasHit = true; - auto vec = res.m_hitPointWorld[closestCollisionObject];; + auto vec = res.m_hitPointWorld[closestCollisionObject]; result.location = prism::float3(vec.x(), vec.y(), vec.z()); } diff --git a/engine/core/src/scene.cpp b/engine/core/src/scene.cpp index 879302e..7809d45 100755 --- a/engine/core/src/scene.cpp +++ b/engine/core/src/scene.cpp @@ -76,7 +76,7 @@ void load_probe_component(nlohmann::json j, EnvironmentProbe& probe) { probe.intensity = j["intensity"]; } -Object load_object(Scene& scene, const nlohmann::json obj) { +Object load_object(Scene& scene, const nlohmann::json& obj) { Object o = scene.add_object(); auto& data = scene.get(o); diff --git a/engine/gfx/public/gfx_commandbuffer.hpp b/engine/gfx/public/gfx_commandbuffer.hpp index 002f280..ad8f6b1 100755 --- a/engine/gfx/public/gfx_commandbuffer.hpp +++ b/engine/gfx/public/gfx_commandbuffer.hpp @@ -161,7 +161,7 @@ struct GFXDrawCommand { } insert_label; struct DispatchData { - uint32_t group_count_x, group_count_y, group_count_z; + uint32_t group_count_x = 0, group_count_y = 0, group_count_z = 0; } dispatch; } data; }; diff --git a/engine/gfx/public/gfx_object.hpp b/engine/gfx/public/gfx_object.hpp index 927b1b1..b4718e3 100755 --- a/engine/gfx/public/gfx_object.hpp +++ b/engine/gfx/public/gfx_object.hpp @@ -2,5 +2,5 @@ class GFXObject { public: - virtual ~GFXObject() {} + virtual ~GFXObject() = default; }; diff --git a/engine/gfx/vulkan/src/gfx_vulkan.cpp b/engine/gfx/vulkan/src/gfx_vulkan.cpp index 6cbfa7d..f93ce25 100755 --- a/engine/gfx/vulkan/src/gfx_vulkan.cpp +++ b/engine/gfx/vulkan/src/gfx_vulkan.cpp @@ -1970,22 +1970,22 @@ void GFXVulkan::createSwapchain(NativeSurface* native_surface, VkSwapchainKHR ol native_surface->swapchainImageViews.resize(native_surface->swapchainImages.size()); for (size_t i = 0; i < native_surface->swapchainImages.size(); i++) { - VkImageViewCreateInfo createInfo = {}; - createInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; - createInfo.image = native_surface->swapchainImages[i]; - createInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; - createInfo.format = swapchainSurfaceFormat.format; - createInfo.components.r = VK_COMPONENT_SWIZZLE_IDENTITY; - createInfo.components.g = VK_COMPONENT_SWIZZLE_IDENTITY; - createInfo.components.b = VK_COMPONENT_SWIZZLE_IDENTITY; - createInfo.components.a = VK_COMPONENT_SWIZZLE_IDENTITY; - createInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - createInfo.subresourceRange.baseMipLevel = 0; - createInfo.subresourceRange.levelCount = 1; - createInfo.subresourceRange.baseArrayLayer = 0; - createInfo.subresourceRange.layerCount = 1; + VkImageViewCreateInfo view_create_info = {}; + view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; + view_create_info.image = native_surface->swapchainImages[i]; + view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; + view_create_info.format = swapchainSurfaceFormat.format; + view_create_info.components.r = VK_COMPONENT_SWIZZLE_IDENTITY; + view_create_info.components.g = VK_COMPONENT_SWIZZLE_IDENTITY; + view_create_info.components.b = VK_COMPONENT_SWIZZLE_IDENTITY; + view_create_info.components.a = VK_COMPONENT_SWIZZLE_IDENTITY; + view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + view_create_info.subresourceRange.baseMipLevel = 0; + view_create_info.subresourceRange.levelCount = 1; + view_create_info.subresourceRange.baseArrayLayer = 0; + view_create_info.subresourceRange.layerCount = 1; - vkCreateImageView(device, &createInfo, nullptr, &native_surface->swapchainImageViews[i]); + vkCreateImageView(device, &view_create_info, nullptr, &native_surface->swapchainImageViews[i]); } // create render pass diff --git a/engine/gfx/vulkan/src/gfx_vulkan_buffer.hpp b/engine/gfx/vulkan/src/gfx_vulkan_buffer.hpp index b8b3475..30e118a 100755 --- a/engine/gfx/vulkan/src/gfx_vulkan_buffer.hpp +++ b/engine/gfx/vulkan/src/gfx_vulkan_buffer.hpp @@ -7,9 +7,9 @@ class GFXVulkanBuffer : public GFXBuffer { public: - VkBuffer handle; - VkDeviceMemory memory; + VkBuffer handle = VK_NULL_HANDLE; + VkDeviceMemory memory = VK_NULL_HANDLE; - VkDeviceSize size; + VkDeviceSize size = 0; uint32_t frame_index = 0; }; diff --git a/engine/gfx/vulkan/src/gfx_vulkan_framebuffer.hpp b/engine/gfx/vulkan/src/gfx_vulkan_framebuffer.hpp index 6aa7d4d..fdf1a60 100755 --- a/engine/gfx/vulkan/src/gfx_vulkan_framebuffer.hpp +++ b/engine/gfx/vulkan/src/gfx_vulkan_framebuffer.hpp @@ -6,7 +6,7 @@ class GFXVulkanFramebuffer : public GFXFramebuffer { public: - VkFramebuffer handle; + VkFramebuffer handle = VK_NULL_HANDLE; int width = 0, height = 0; }; diff --git a/engine/gfx/vulkan/src/gfx_vulkan_pipeline.hpp b/engine/gfx/vulkan/src/gfx_vulkan_pipeline.hpp index cea2af2..97cabc6 100755 --- a/engine/gfx/vulkan/src/gfx_vulkan_pipeline.hpp +++ b/engine/gfx/vulkan/src/gfx_vulkan_pipeline.hpp @@ -10,10 +10,10 @@ class GFXVulkanPipeline : public GFXPipeline { public: std::string label; - VkPipeline handle; - VkPipelineLayout layout; + VkPipeline handle = VK_NULL_HANDLE; + VkPipelineLayout layout = VK_NULL_HANDLE; - VkDescriptorSetLayout descriptorLayout; + VkDescriptorSetLayout descriptorLayout = VK_NULL_HANDLE; std::vector bindings_marked_as_normal_images; std::vector bindings_marked_as_storage_images; diff --git a/engine/gfx/vulkan/src/gfx_vulkan_sampler.hpp b/engine/gfx/vulkan/src/gfx_vulkan_sampler.hpp index d6c9974..72d06f9 100644 --- a/engine/gfx/vulkan/src/gfx_vulkan_sampler.hpp +++ b/engine/gfx/vulkan/src/gfx_vulkan_sampler.hpp @@ -6,5 +6,5 @@ class GFXVulkanSampler: public GFXSampler { public: - VkSampler sampler; + VkSampler sampler = VK_NULL_HANDLE; }; diff --git a/engine/gfx/vulkan/src/gfx_vulkan_texture.hpp b/engine/gfx/vulkan/src/gfx_vulkan_texture.hpp index 9dae0bd..c1f1acc 100755 --- a/engine/gfx/vulkan/src/gfx_vulkan_texture.hpp +++ b/engine/gfx/vulkan/src/gfx_vulkan_texture.hpp @@ -6,14 +6,14 @@ class GFXVulkanTexture : public GFXTexture { public: - VkImage handle; - VkDeviceMemory memory; - VkImageView view; - VkSampler sampler; + VkImage handle = VK_NULL_HANDLE; + VkDeviceMemory memory = VK_NULL_HANDLE; + VkImageView view = VK_NULL_HANDLE; + VkSampler sampler = VK_NULL_HANDLE; - int width, height; + int width = 0, height = 0; - VkFormat format; + VkFormat format = VK_FORMAT_UNDEFINED; VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED; VkImageLayout current_layout = VK_IMAGE_LAYOUT_UNDEFINED; VkImageAspectFlagBits aspect; diff --git a/engine/math/include/matrix.hpp b/engine/math/include/matrix.hpp index a775c84..eb89f7c 100755 --- a/engine/math/include/matrix.hpp +++ b/engine/math/include/matrix.hpp @@ -8,7 +8,7 @@ template class Matrix { public: - constexpr Matrix(const T diagonal = T(1)) { + constexpr explicit Matrix(const T diagonal = T(1)) { for(std::size_t i = 0; i < (M * N); i++) unordered_data[i] = ((i / M) == (i % N) ? diagonal : T(0)); } @@ -20,7 +20,7 @@ public: columns[3] = m4_; } - constexpr inline void operator*=(const Matrix rhs); + constexpr inline void operator*=(Matrix rhs); using VectorType = prism::Vector; diff --git a/engine/math/src/math.cpp b/engine/math/src/math.cpp index 531609e..3282255 100755 --- a/engine/math/src/math.cpp +++ b/engine/math/src/math.cpp @@ -55,13 +55,15 @@ Quaternion quat_from_matrix(const Matrix3x3 m) { switch(biggestIndex) { case 0: - return Quaternion((m[1][2] - m[2][1]) * mult, (m[2][0] - m[0][2]) * mult, (m[0][1] - m[1][0]) * mult, biggestVal); + return {(m[1][2] - m[2][1]) * mult, (m[2][0] - m[0][2]) * mult, (m[0][1] - m[1][0]) * mult, biggestVal}; case 1: - return Quaternion(biggestVal, (m[0][1] + m[1][0]) * mult, (m[2][0] + m[0][2]) * mult, (m[1][2] - m[2][1]) * mult); + return {biggestVal, (m[0][1] + m[1][0]) * mult, (m[2][0] + m[0][2]) * mult, (m[1][2] - m[2][1]) * mult}; case 2: - return Quaternion((m[0][1] + m[1][0]) * mult, biggestVal, (m[1][2] + m[2][1]) * mult, (m[2][0] - m[0][2]) * mult); + return {(m[0][1] + m[1][0]) * mult, biggestVal, (m[1][2] + m[2][1]) * mult, (m[2][0] - m[0][2]) * mult}; case 3: - return Quaternion((m[2][0] + m[0][2]) * mult, (m[1][2] + m[2][1]) * mult, biggestVal, (m[0][1] - m[1][0]) * mult); + return {(m[2][0] + m[0][2]) * mult, (m[1][2] + m[2][1]) * mult, biggestVal, (m[0][1] - m[1][0]) * mult}; + default: + return {}; } } @@ -97,7 +99,7 @@ prism::float3 quat_to_euler(const Quaternion q) { const float yaw = asinf(-2.0f * (q.x * q.z - q.w * q.y)); - return prism::float3(pitch, yaw, roll); + return {pitch, yaw, roll}; } Matrix4x4 inverse(const Matrix4x4 m) { diff --git a/engine/platform/include/file.hpp b/engine/platform/include/file.hpp index 03596ac..4c3e503 100755 --- a/engine/platform/include/file.hpp +++ b/engine/platform/include/file.hpp @@ -77,8 +77,7 @@ namespace prism { /// Reads the entire file as a string. std::string read_as_string() { auto s = read_as_stream(); - return std::string((std::istreambuf_iterator(s)), - std::istreambuf_iterator()); + return {(std::istreambuf_iterator(s)), std::istreambuf_iterator()}; } /// Reads the entire file as a ifstream, useful for JSON deserialization. @@ -109,11 +108,11 @@ namespace prism { @param mode The access mode. @param path The absolute file path. */ - void set_domain_path(domain domain, path domain_path); + void set_domain_path(domain domain, const path& domain_path); path get_domain_path(domain domain); /// Converts an absolute path to a domain relative path. - path get_relative_path(domain domain, path domain_relative_path); + path get_relative_path(domain domain, const path& domain_relative_path); /// Returns the path to a writeable directory. path get_writeable_directory(); @@ -125,9 +124,9 @@ namespace prism { @param binary_mode Whether or not to open the file as binary or ASCII. Defaults to false. @return An optional with a value if the file was loaded correctly, otherwise it's empty. */ - std::optional open_file(path file_path, bool binary_mode = false); + std::optional open_file(const path& file_path, bool binary_mode = false); - path root_path(path path); + path root_path(const path& path); path get_file_path(const path& path); inline path internal_domain = "/internal", app_domain = "/app"; diff --git a/engine/renderer/include/dofpass.hpp b/engine/renderer/include/dofpass.hpp index a72efe9..14da041 100755 --- a/engine/renderer/include/dofpass.hpp +++ b/engine/renderer/include/dofpass.hpp @@ -14,7 +14,7 @@ namespace prism { class DoFPass { public: - DoFPass(GFX* gfx, prism::renderer* renderer); + DoFPass(GFX* gfx); void render(GFXCommandBuffer* command_buffer, Scene& scene); @@ -27,7 +27,5 @@ public: GFXRenderPass* renderpass = nullptr; private: - prism::renderer* renderer = nullptr; - GFXPipeline* pipeline = nullptr; }; diff --git a/engine/renderer/include/imguipass.hpp b/engine/renderer/include/imguipass.hpp index 453e05f..7ac8b8a 100755 --- a/engine/renderer/include/imguipass.hpp +++ b/engine/renderer/include/imguipass.hpp @@ -17,10 +17,10 @@ public: void create_render_target_resources(RenderTarget& target) override; - void render_post(GFXCommandBuffer* command_buffer, RenderTarget& target, const platform::window_ptr index) override; + void render_post(GFXCommandBuffer* command_buffer, RenderTarget& target, platform::window_ptr index) override; private: - void load_font(const std::string_view filename); + void load_font(std::string_view filename); void create_font_texture(); void update_buffers(RenderTarget& target, const ImDrawData& draw_data); diff --git a/engine/renderer/include/pass.hpp b/engine/renderer/include/pass.hpp index 0d85a12..721bb08 100755 --- a/engine/renderer/include/pass.hpp +++ b/engine/renderer/include/pass.hpp @@ -15,7 +15,7 @@ class RenderTarget; class Pass { public: - virtual ~Pass() {} + virtual ~Pass() = default; virtual void initialize() {} diff --git a/engine/renderer/include/scenecapture.hpp b/engine/renderer/include/scenecapture.hpp index 5eebf62..036feb6 100755 --- a/engine/renderer/include/scenecapture.hpp +++ b/engine/renderer/include/scenecapture.hpp @@ -16,7 +16,7 @@ const int irradiance_cubemap_resolution = 32; class SceneCapture { public: - SceneCapture(GFX* gfx); + explicit SceneCapture(GFX* gfx); void create_scene_resources(Scene& scene); diff --git a/engine/renderer/include/smaapass.hpp b/engine/renderer/include/smaapass.hpp index 3a8ce40..df29d1c 100755 --- a/engine/renderer/include/smaapass.hpp +++ b/engine/renderer/include/smaapass.hpp @@ -17,7 +17,7 @@ namespace prism { class SMAAPass { public: - SMAAPass(GFX* gfx, prism::renderer* renderer); + SMAAPass(GFX* gfx); void create_render_target_resources(RenderTarget& target); @@ -28,8 +28,6 @@ private: void create_render_pass(); void create_pipelines(); - prism::renderer* renderer = nullptr; - GFXTexture* area_image = nullptr; GFXTexture* search_image = nullptr; diff --git a/engine/renderer/src/dofpass.cpp b/engine/renderer/src/dofpass.cpp index e865c86..a4027b4 100755 --- a/engine/renderer/src/dofpass.cpp +++ b/engine/renderer/src/dofpass.cpp @@ -8,7 +8,7 @@ AssetPtr aperture_texture; -DoFPass::DoFPass(GFX* gfx, prism::renderer* renderer) : renderer(renderer) { +DoFPass::DoFPass(GFX* gfx) { aperture_texture = assetm->get(prism::app_domain / "textures/aperture.png"); GFXRenderPassCreateInfo renderPassInfo = {}; diff --git a/engine/renderer/src/materialcompiler.cpp b/engine/renderer/src/materialcompiler.cpp index 3108f4c..8ad46de 100755 --- a/engine/renderer/src/materialcompiler.cpp +++ b/engine/renderer/src/materialcompiler.cpp @@ -10,7 +10,7 @@ #include "material_nodes.hpp" #include "renderer.hpp" -ShaderSource get_shader(std::string filename, bool skinned, bool cubemap) { +ShaderSource get_shader(const std::string& filename, bool skinned, bool cubemap) { auto shader_file = prism::open_file(prism::internal_domain / filename); if(!shader_file.has_value()) { prism::log("Failed to open shader file {}!", filename); diff --git a/engine/renderer/src/renderer.cpp b/engine/renderer/src/renderer.cpp index ba4bf39..5507f67 100755 --- a/engine/renderer/src/renderer.cpp +++ b/engine/renderer/src/renderer.cpp @@ -1,7 +1,5 @@ #include "renderer.hpp" -#include - #include "gfx_commandbuffer.hpp" #include "math.hpp" #include "file.hpp" @@ -90,7 +88,7 @@ renderer::renderer(GFX* gfx, const bool enable_imgui) : gfx(gfx) { shadow_pass = std::make_unique(gfx); scene_capture = std::make_unique(gfx); - smaa_pass = std::make_unique(gfx, this); + smaa_pass = std::make_unique(gfx); if(enable_imgui) addPass(); diff --git a/engine/renderer/src/scenecapture.cpp b/engine/renderer/src/scenecapture.cpp index ecc1e6f..a54d586 100755 --- a/engine/renderer/src/scenecapture.cpp +++ b/engine/renderer/src/scenecapture.cpp @@ -3,7 +3,6 @@ #include "gfx_commandbuffer.hpp" #include "scene.hpp" #include "gfx.hpp" -#include "log.hpp" #include "engine.hpp" #include "renderer.hpp" #include "shadowpass.hpp" diff --git a/engine/renderer/src/shadowpass.cpp b/engine/renderer/src/shadowpass.cpp index fe72c43..f18c22a 100755 --- a/engine/renderer/src/shadowpass.cpp +++ b/engine/renderer/src/shadowpass.cpp @@ -3,7 +3,6 @@ #include "gfx_commandbuffer.hpp" #include "scene.hpp" #include "gfx.hpp" -#include "log.hpp" #include "engine.hpp" #include "materialcompiler.hpp" #include "assertions.hpp" @@ -113,7 +112,7 @@ void ShadowPass::render(GFXCommandBuffer* command_buffer, Scene& scene) { } } -void ShadowPass::render_meshes(GFXCommandBuffer* command_buffer, Scene& scene, const Matrix4x4 light_matrix, const Matrix4x4 model, const prism::float3 light_position, const Light::Type type, const CameraFrustum& frustum, const int base_instance) { +void ShadowPass::render_meshes(GFXCommandBuffer* command_buffer, Scene& scene, const Matrix4x4 light_matrix, const Matrix4x4 model, const prism::float3, const Light::Type type, const CameraFrustum& frustum, const int base_instance) { for(auto [obj, mesh] : scene.get_all()) { if(!mesh.mesh) continue; diff --git a/engine/renderer/src/smaapass.cpp b/engine/renderer/src/smaapass.cpp index 26488fb..39ce08b 100755 --- a/engine/renderer/src/smaapass.cpp +++ b/engine/renderer/src/smaapass.cpp @@ -9,10 +9,9 @@ #include #include -SMAAPass::SMAAPass(GFX* gfx, prism::renderer* renderer) : renderer(renderer) { +SMAAPass::SMAAPass(GFX* gfx) { Expects(gfx != nullptr); - Expects(renderer != nullptr); - + create_textures(); create_render_pass(); create_pipelines(); diff --git a/engine/shadercompiler/src/includer.hpp b/engine/shadercompiler/src/includer.hpp index d2a625e..6114ae1 100755 --- a/engine/shadercompiler/src/includer.hpp +++ b/engine/shadercompiler/src/includer.hpp @@ -50,14 +50,14 @@ class DirStackFileIncluder : public glslang::TShader::Includer { public: DirStackFileIncluder() : externalLocalDirectoryCount(0) { } - virtual IncludeResult* includeLocal(const char* headerName, + IncludeResult* includeLocal(const char* headerName, const char* includerName, size_t inclusionDepth) override { return readLocalPath(headerName, includerName, (int)inclusionDepth); } - virtual IncludeResult* includeSystem(const char* headerName, + IncludeResult* includeSystem(const char* headerName, const char* /*includerName*/, size_t /*inclusionDepth*/) override { @@ -76,7 +76,7 @@ public: externalLocalDirectoryCount = (int)directoryStack.size(); } - virtual void releaseInclude(IncludeResult* result) override + void releaseInclude(IncludeResult* result) override { if (result != nullptr) { delete [] static_cast(result->userData); @@ -84,7 +84,7 @@ public: } } - virtual ~DirStackFileIncluder() override { } + ~DirStackFileIncluder() override = default; protected: typedef char tUserDataElement; diff --git a/engine/shadercompiler/src/shadercompiler.cpp b/engine/shadercompiler/src/shadercompiler.cpp index b5c6f4f..2abd428 100755 --- a/engine/shadercompiler/src/shadercompiler.cpp +++ b/engine/shadercompiler/src/shadercompiler.cpp @@ -1,6 +1,5 @@ #include "shadercompiler.hpp" -#include #include #include diff --git a/engine/utility/include/common.hpp b/engine/utility/include/common.hpp index b64afb5..61ce94a 100755 --- a/engine/utility/include/common.hpp +++ b/engine/utility/include/common.hpp @@ -21,7 +21,7 @@ namespace prism { /// A 2D rectangle defined by a offset and an etent. struct Rectangle { - Rectangle() {} + Rectangle() = default; Rectangle(const Offset offset, const Extent extent) : offset(offset), extent(extent) {} Rectangle(const int32_t x, const int32_t y, const uint32_t width, const uint32_t height) : offset(x, y), extent(width, height) {} diff --git a/example/src/example.cpp b/example/src/example.cpp index 4e836ac..16a9c16 100644 --- a/example/src/example.cpp +++ b/example/src/example.cpp @@ -7,7 +7,7 @@ #include "asset.hpp" #include "path.hpp" -void app_main(prism::engine* engine) { +void app_main(prism::engine*) { prism::set_domain_path(prism::domain::app, "{resource_dir}/data"); prism::set_domain_path(prism::domain::internal, "{resource_dir}/shaders"); diff --git a/platforms/sdl/file.cpp b/platforms/sdl/file.cpp index 3d18fbb..b18a7dd 100644 --- a/platforms/sdl/file.cpp +++ b/platforms/sdl/file.cpp @@ -2,7 +2,7 @@ #include "string_utils.hpp" -void prism::set_domain_path(const prism::domain domain, const prism::path path) { +void prism::set_domain_path(const prism::domain domain, const prism::path& path) { #ifdef PLATFORM_MACOS domain_data[(int)domain] = replace_substring(path.string(), "{resource_dir}/", "../Resources/"); #else diff --git a/tools/common/include/commoneditor.hpp b/tools/common/include/commoneditor.hpp index c698854..50bfaee 100755 --- a/tools/common/include/commoneditor.hpp +++ b/tools/common/include/commoneditor.hpp @@ -108,7 +108,7 @@ constexpr int thumbnail_resolution = 256; class CommonEditor : public prism::app { public: - CommonEditor(std::string id); + explicit CommonEditor(std::string_view id); void initialize_render() override; @@ -130,7 +130,7 @@ public: virtual void updateEditor([[maybe_unused]] float deltaTime) {} virtual void object_selected([[maybe_unused]] Object object) {} - virtual void asset_selected([[maybe_unused]] std::filesystem::path path, [[maybe_unused]] AssetType type) {} + virtual void asset_selected([[maybe_unused]] const std::filesystem::path& path, [[maybe_unused]] AssetType type) {} bool wants_no_scene_rendering() override { return true; } bool is_multimodal() override { return true; } @@ -145,7 +145,7 @@ public: int getDefaultWidth() const; int getDefaultHeight() const; - void addOpenedFile(std::string path); + void addOpenedFile(std::string_view path); void clearOpenedFiles(); std::vector getOpenedFiles() const; @@ -160,7 +160,7 @@ public: GFXTexture* get_material_preview(Material& material); GFXTexture* get_mesh_preview(Mesh& mesh); GFXTexture* get_texture_preview(Texture& texture); - GFXTexture* generate_common_preview(Scene& scene, const prism::float3 camera_position); + GFXTexture* generate_common_preview(Scene& scene, prism::float3 camera_position); template GFXTexture* get_asset_thumbnail(AssetPtr& asset) { @@ -193,7 +193,7 @@ public: } } - GFXTexture* get_asset_thumbnail(const prism::path path) { + GFXTexture* get_asset_thumbnail(const prism::path& path) { if(asset_thumbnails.count(path.string())) { return asset_thumbnails[path.string()]; } else { @@ -303,7 +303,7 @@ public: } template - void open_asset(const AssetType type, const std::function func_ptr) { + void open_asset(const AssetType type, const std::function& func_ptr) { current_asset_type = type; open_asset_popup = true; on_asset_select = func_ptr; @@ -353,10 +353,6 @@ private: void editTransform(Object object, Transform transform); void editRenderable(Renderable& mesh); - - void edit_asset_mesh(const char* name, AssetPtr& asset); - void edit_asset_texture(const char* name, AssetPtr& asset); - void edit_asset_material(const char* name, AssetPtr& asset); }; inline void editPath(const char* label, std::string& path, bool editable = true, const std::function on_selected = nullptr) { diff --git a/tools/common/src/commoneditor.cpp b/tools/common/src/commoneditor.cpp index e3c320c..8e74c2a 100755 --- a/tools/common/src/commoneditor.cpp +++ b/tools/common/src/commoneditor.cpp @@ -6,15 +6,11 @@ #include #include "engine.hpp" -#include "imguipass.hpp" #include "file.hpp" -#include "json_conversions.hpp" #include "platform.hpp" #include "transform.hpp" #include "log.hpp" #include "shadowpass.hpp" -#include "string_utils.hpp" -#include "assertions.hpp" #include "gfx.hpp" #include "gfx_commandbuffer.hpp" #include "imgui_utility.hpp" @@ -46,7 +42,7 @@ const std::map imToPl = { {ImGuiKey_Z, InputButton::Z} }; -CommonEditor::CommonEditor(std::string id) : id(id) { +CommonEditor::CommonEditor(const std::string_view id) : id(id) { prism::set_domain_path(prism::domain::app, "{resource_dir}/data"); prism::set_domain_path(prism::domain::internal, "{resource_dir}/shaders"); @@ -265,7 +261,7 @@ void CommonEditor::begin_frame() { if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); - ImGui::Text(p.c_str()); + ImGui::Text("%s", p.c_str()); ImGui::EndTooltip(); } @@ -303,8 +299,8 @@ int CommonEditor::getDefaultHeight() const { return defaultHeight; } -void CommonEditor::addOpenedFile(std::string path) { - lastOpenedFiles.push_back(path); +void CommonEditor::addOpenedFile(const std::string_view path) { + lastOpenedFiles.emplace_back(path.data()); } void CommonEditor::clearOpenedFiles() { @@ -430,7 +426,7 @@ void CommonEditor::editRenderable(Renderable& mesh) { } if(ImGui::Button("Add material")) - mesh.materials.push_back({}); + mesh.materials.emplace_back(); } void editLight(Light& light) { @@ -706,7 +702,7 @@ void CommonEditor::set_undo_stack(UndoStack *stack) { current_stack = stack; } -bool mesh_readable(const prism::path path) { +bool mesh_readable(const prism::path& path) { auto file = prism::open_file(path); if(!file.has_value()) { prism::log("Failed to load mesh from {}!", path.string()); @@ -719,7 +715,7 @@ bool mesh_readable(const prism::path path) { return version == 5 || version == 6; } -bool material_readable(const prism::path path) { +bool material_readable(const prism::path& path) { auto file = prism::open_file(path); if(!file.has_value()) { prism::log("Failed to load material from {}!", path.string()); diff --git a/tools/common/src/debugpass.cpp b/tools/common/src/debugpass.cpp index f82cbc2..ce745dc 100755 --- a/tools/common/src/debugpass.cpp +++ b/tools/common/src/debugpass.cpp @@ -7,8 +7,6 @@ #include "file.hpp" #include "gfx.hpp" #include "asset.hpp" -#include "log.hpp" -#include "materialcompiler.hpp" #include "renderer.hpp" struct BillPushConstant { @@ -261,7 +259,7 @@ void DebugPass::render_scene(Scene& scene, GFXCommandBuffer* commandBuffer) { struct DebugBillboard { prism::float3 position; - GFXTexture* texture; + GFXTexture* texture = nullptr; prism::float4 color; }; @@ -561,7 +559,7 @@ void DebugPass::get_selected_object(int x, int y, std::functionget_gfx()->copy_texture(selectTexture, selectBuffer); - uint8_t* mapped_texture = reinterpret_cast(engine->get_gfx()->get_buffer_contents(selectBuffer)); + auto mapped_texture = reinterpret_cast(engine->get_gfx()->get_buffer_contents(selectBuffer)); const int buffer_position = 4 * (y * extent.width + x); diff --git a/tools/cutsceneeditor/src/cutsceneeditor.cpp b/tools/cutsceneeditor/src/cutsceneeditor.cpp index 4e83614..772feff 100755 --- a/tools/cutsceneeditor/src/cutsceneeditor.cpp +++ b/tools/cutsceneeditor/src/cutsceneeditor.cpp @@ -9,7 +9,6 @@ #include "file.hpp" #include "json_conversions.hpp" #include "platform.hpp" -#include "screen.hpp" #include "cutscene.hpp" Shot* currentShot = nullptr; @@ -19,7 +18,7 @@ PositionKeyFrame* currentFrame = nullptr; std::string currentPath; void app_main(prism::engine* engine) { - CommonEditor* editor = (CommonEditor*)engine->get_app(); + auto editor = (CommonEditor*)engine->get_app(); platform::open_window("Cutscene Editor", {editor->getDefaultX(), @@ -80,16 +79,16 @@ void CutsceneEditor::drawUI() { if(ImGui::MenuItem("New", "CTRL+N")) { engine->cutscene = std::make_unique(); - platform::set_window_title(0, "Cutscene Editor"); + platform::set_window_title(engine->get_main_window(), "Cutscene Editor"); } if(ImGui::MenuItem("Open", "CTRL+O")) { - platform::open_dialog(true, [this](std::string path){ + engine->get_imgui().open_dialog(true, [this](std::string path){ currentPath = path; engine->load_cutscene(path); - platform::set_window_title(0, ("Cutscene Editor - " + path).c_str()); + platform::set_window_title(engine->get_main_window(), ("Cutscene Editor - " + path).c_str()); addOpenedFile(path); }); @@ -200,7 +199,7 @@ void CutsceneEditor::drawUI() { if(ImGui::Begin("Timeline")) { if(engine->cutscene != nullptr) { if(ImGui::Button("Add Shot")) { - engine->cutscene->shots.push_back(Shot()); + engine->cutscene->shots.emplace_back(); currentShot = &engine->cutscene->shots.back(); } @@ -279,7 +278,7 @@ void CutsceneEditor::drawUI() { ImGui::BeginChild("animations", ImVec2(150, -1), true); if(ImGui::Button("Add Channel")) { - currentShot->channels.push_back(AnimationChannel()); + currentShot->channels.emplace_back(); currentChannel = ¤tShot->channels.back(); } @@ -303,7 +302,7 @@ void CutsceneEditor::drawUI() { if(currentChannel != nullptr) { if(ImGui::Button("Add Position Frame")) { - currentChannel->positions.push_back(PositionKeyFrame()); + currentChannel->positions.emplace_back(); currentFrame = ¤tChannel->positions.back(); } @@ -383,8 +382,8 @@ void CutsceneEditor::drawUI() { ImVec2 a = ImVec2(p.x + (keyframe.time * 5) - 5, p.y - 5); ImVec2 b = ImVec2(p.x + (keyframe.time * 5) + 5, p.y + 5); - auto c = ImGui::GetMousePos(); - if(c.x > a.x && c.x < b.x && c.y > a.y && c.y < b.y) { + auto mouse_pos = ImGui::GetMousePos(); + if(mouse_pos.x > a.x && mouse_pos.x < b.x && mouse_pos.y > a.y && mouse_pos.y < b.y) { if(currentFrame == &keyframe) { currentFrame = nullptr; } else { diff --git a/tools/editor/include/prismeditor.hpp b/tools/editor/include/prismeditor.hpp index 4f5162e..fe9362c 100755 --- a/tools/editor/include/prismeditor.hpp +++ b/tools/editor/include/prismeditor.hpp @@ -58,11 +58,11 @@ public: void updateEditor(float deltaTime) override; void object_selected(Object object) override; - void asset_selected(std::filesystem::path path, AssetType type) override; + void asset_selected(const std::filesystem::path& path, AssetType type) override; private: - void open_asset(const prism::path path); + void open_asset(prism::path path); void setup_editor(Editor* editor); }; -std::string get_filename(const std::string path); +std::string get_filename(std::string path); diff --git a/tools/editor/src/materialeditor.cpp b/tools/editor/src/materialeditor.cpp index 1a2d6df..8b71623 100755 --- a/tools/editor/src/materialeditor.cpp +++ b/tools/editor/src/materialeditor.cpp @@ -179,12 +179,12 @@ void MaterialEditor::draw(CommonEditor* editor) { ImGui::EndMenuBar(); } - Scene* scene = engine->get_scene(); + auto viewport_scene = engine->get_scene(); - if(scene != nullptr) { + if(viewport_scene != nullptr) { ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); if(begin("Viewport")) - editor->drawViewport(scene); + editor->drawViewport(viewport_scene); ImGui::End(); @@ -222,13 +222,7 @@ void MaterialEditor::draw(CommonEditor* editor) { draw_list->AddText(ImVec2(input_rect.Min.x + 20.0f, input_rect.Min.y), IM_COL32(255, 255, 255, 255), input.name.c_str()); ImGui::ItemAdd(input_rect, ImGui::GetID(node.get())); - - bool might_connect = false; - - if(dragging_connector && ImGui::IsItemHovered()) { - might_connect = true; - } - + if(dragging_connector && ImGui::IsItemHovered() && ImGui::IsMouseReleased(ImGuiMouseButton_Left)) { input.connected_connector = drag_connector; input.connected_node = dragging_node; @@ -331,8 +325,8 @@ void MaterialEditor::draw(CommonEditor* editor) { ImGui::EndChild(); - for(auto& node : deferred_deletions) { - material->delete_node(node); + for(auto& node_to_delete : deferred_deletions) { + material->delete_node(node_to_delete); changed = true; } diff --git a/tools/editor/src/prefabeditor.cpp b/tools/editor/src/prefabeditor.cpp index be930b5..62e998f 100755 --- a/tools/editor/src/prefabeditor.cpp +++ b/tools/editor/src/prefabeditor.cpp @@ -65,9 +65,9 @@ void PrefabEditor::draw(CommonEditor* editor) { ImGui::EndMenuBar(); } - Scene* scene = engine->get_scene(); + auto viewport_scene = engine->get_scene(); - if(scene != nullptr) { + if(viewport_scene != nullptr) { auto window_class = get_window_class(); if(showOutliner) { @@ -92,7 +92,7 @@ void PrefabEditor::draw(CommonEditor* editor) { ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); if(begin("Viewport")) - editor->drawViewport(scene); + editor->drawViewport(viewport_scene); ImGui::End(); diff --git a/tools/editor/src/prismeditor.cpp b/tools/editor/src/prismeditor.cpp index 1538403..d993375 100755 --- a/tools/editor/src/prismeditor.cpp +++ b/tools/editor/src/prismeditor.cpp @@ -117,9 +117,7 @@ struct OpenAssetRequest { std::vector open_requests; -void PrismEditor::setup_editor(Editor* editor) { - -} +void PrismEditor::setup_editor(Editor*) {} void PrismEditor::open_asset(const prism::path path) { if(path.extension() == ".prefab") { @@ -315,7 +313,7 @@ void PrismEditor::object_selected(Object object) { selected_object = object; } -void PrismEditor::asset_selected(std::filesystem::path path, AssetType) { +void PrismEditor::asset_selected(const std::filesystem::path& path, AssetType) { open_requests.emplace_back(path.string(), true); } diff --git a/tools/editor/src/sceneeditor.cpp b/tools/editor/src/sceneeditor.cpp index e43c714..f8c103a 100755 --- a/tools/editor/src/sceneeditor.cpp +++ b/tools/editor/src/sceneeditor.cpp @@ -129,8 +129,8 @@ void SceneEditor::draw(CommonEditor* editor) { ImGui::EndMenuBar(); } - Scene* scene = engine->get_scene(); - if(scene != nullptr) { + auto viewport_scene = engine->get_scene(); + if(viewport_scene != nullptr) { if(showSceneSettings) { if(begin("Scene Settings", &showSceneSettings)) { @@ -156,7 +156,7 @@ void SceneEditor::draw(CommonEditor* editor) { if(showViewport) { ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); if(begin("Viewport", &showViewport)) - editor->drawViewport(scene); + editor->drawViewport(viewport_scene); ImGui::PopStyleVar(); diff --git a/tools/fontcompiler/main.cpp b/tools/fontcompiler/main.cpp index b12b6db..ebd64ad 100755 --- a/tools/fontcompiler/main.cpp +++ b/tools/fontcompiler/main.cpp @@ -4,7 +4,6 @@ #include #include -#include #include constexpr std::array sizes_to_pack = { @@ -74,11 +73,11 @@ int main(int argc, char* argv[]) { fwrite(&descent, sizeof(int), 1, file); fwrite(&gap, sizeof(int), 1, file); - for(int i = 0; i < sizes_to_pack.size(); i++) - fwrite(&packed_chars[i], sizeof(packed_chars[i]), 1, file); + for(auto& packed_char : packed_chars) + fwrite(&packed_char, sizeof(packed_char), 1, file); - for(int i = 0; i < sizes_to_pack.size(); i++) { - const float f = (ascent + descent) * stbtt_ScaleForPixelHeight(&font_info, ranges[i].font_size); + for(auto& range : ranges) { + const float f = (ascent + descent) * stbtt_ScaleForPixelHeight(&font_info, range.font_size); fwrite(&f, sizeof(float), 1, file); } diff --git a/tools/modelcompiler/src/modeleditor.cpp b/tools/modelcompiler/src/modeleditor.cpp index 9a5e3cd..115f31d 100755 --- a/tools/modelcompiler/src/modeleditor.cpp +++ b/tools/modelcompiler/src/modeleditor.cpp @@ -18,7 +18,7 @@ #include "platform.hpp" #include "utility.hpp" -void app_main(Engine* engine) { +void app_main(prism::engine* engine) { ModelEditor* editor = (ModelEditor*)engine->get_app(); if(utility::contains(engine->command_line_arguments, "--no_ui")) diff --git a/tools/shadercompiler/main.cpp b/tools/shadercompiler/main.cpp index 73bc23f..f376145 100755 --- a/tools/shadercompiler/main.cpp +++ b/tools/shadercompiler/main.cpp @@ -1,4 +1,3 @@ -#include #include #include @@ -6,7 +5,7 @@ #include "log.hpp" #include "string_utils.hpp" -bool has_extension(const std::filesystem::path path, const std::string_view extension) { +bool has_extension(const std::filesystem::path& path, const std::string_view extension) { return string_contains(path.filename().string(), extension); } @@ -58,12 +57,6 @@ int main(int argc, char* argv[]) { out.write((char*)spirv.data(), spirv.size() * sizeof(uint32_t)); } break; - case ShaderLanguage::MSL: - { - std::ofstream out(destination_path); // remove .glsl - out << compiled_source->as_string(); - } - break; default: break; }