From 5692f616c6201b39184e4353b6a4cb850a84a450 Mon Sep 17 00:00:00 2001 From: ladevieq Date: Wed, 15 Jun 2022 23:02:29 +0200 Subject: Fix formatting and linting --- include/aabb.hpp | 16 ++++++++-------- include/gltf.hpp | 32 ++++++++++++++++---------------- include/scene.hpp | 5 +---- include/utils.hpp | 6 +++--- include/vec3.hpp | 1 + 5 files changed, 29 insertions(+), 31 deletions(-) (limited to 'include') diff --git a/include/aabb.hpp b/include/aabb.hpp index 475c04e..85b3c21 100644 --- a/include/aabb.hpp +++ b/include/aabb.hpp @@ -4,7 +4,7 @@ #include "vec3.hpp" #include "triangle.hpp" #include -#include +#include class aabb { public: @@ -36,27 +36,27 @@ class aabb { maximum.max(point); } - int32_t maximum_axis() { + int32_t maximum_axis() const { vec3 diag = diagonal(); if (diag.v[0] > diag.v[1] && diag.v[0] > diag.v[2]) { return 0; - } else if (diag.v[1] > diag.v[2]) { + } + if (diag.v[1] > diag.v[2]) { return 1; - } else { - return 2; } + return 2; } - vec3 diagonal() { + vec3 diagonal() const { return maximum - minimum; } - vec3 center() { + vec3 center() const { return diagonal() / 2.f; } - float surface_area() { + float surface_area() const { auto diag = diagonal(); return 2.f * (diag.v[0] * diag.v[1] + diag.v[0] * diag.v[2] + diag.v[1] * diag.v[2]); } diff --git a/include/gltf.hpp b/include/gltf.hpp index 7df5e7a..0364ca8 100644 --- a/include/gltf.hpp +++ b/include/gltf.hpp @@ -10,46 +10,46 @@ using json = nlohmann::json; #include "material.hpp" -#include "vec3.hpp" #include "vk-renderer.hpp" struct mesh_part { - std::vector indices; - std::vector positions; - std::vector normals; - std::vector uvs; - material mat; - uint32_t triangles_count = 0; - uint32_t vertices_count = 0; + std::vector indices; + std::vector positions; + std::vector normals; + std::vector uvs; + material mat; + uint32_t triangles_count = 0; + uint32_t vertices_count = 0; }; struct mesh { std::vector parts; - uint32_t triangles_count = 0; - uint32_t vertices_count = 0; + uint32_t triangles_count = 0; + uint32_t vertices_count = 0; }; struct node { - std::vector children; + std::vector children; std::optional mesh; }; class gltf { -public: + public: static node load(std::filesystem::path &path, std::string &filename, vkrenderer &renderer); -private: - + private: static void load_node(json &gltf_json, uint32_t index, node &parent, std::vector &meshes); - static std::vector load_meshes(json &gltf_json, std::vector> &buffers_content, std::vector &materials); + static std::vector load_meshes( + json &gltf_json, std::vector> &buffers_content, std::vector &materials); static std::vector load_textures(json &gltf_json, std::filesystem::path &path, vkrenderer &renderer); static std::vector load_materials(json &gltf_json, std::vector &textures); - static mesh_part load_primitive(json &gltf_json, json &primitive, std::vector> &buffers_content, std::vector &materials); + static mesh_part load_primitive(json &gltf_json, json &primitive, + std::vector> &buffers_content, std::vector &materials); }; #endif diff --git a/include/scene.hpp b/include/scene.hpp index 4bce1a7..8e47ab0 100644 --- a/include/scene.hpp +++ b/include/scene.hpp @@ -1,9 +1,6 @@ #ifndef __SCENE_HPP_ #define __SCENE_HPP_ -#include "vec3.hpp" -#include "sphere.hpp" -#include "triangle.hpp" #include "camera.hpp" #include "bvh-node.hpp" @@ -26,7 +23,7 @@ class scene { int32_t downscale_factor = 1; metadata(camera cam, uint32_t width, uint32_t height) - : cam(cam), width(width), height(height) {} + : cam(std::move(cam)), width(width), height(height) {} }; // void random_scene(); diff --git a/include/utils.hpp b/include/utils.hpp index 8548a5f..201976f 100644 --- a/include/utils.hpp +++ b/include/utils.hpp @@ -12,11 +12,11 @@ std::vector read_file(std::string& path); #define EPSILON 0.000001 inline float deg_to_rad(float deg) { - return deg * PI / 180.0; + return deg * PI / 180.f; } inline float randd() { - return rand() / (RAND_MAX + 1.0); + return rand() / (RAND_MAX + 1.f); } inline float randd(float min, float max) { @@ -24,7 +24,7 @@ inline float randd(float min, float max) { } inline int32_t randi(int32_t min, int32_t max) { - return static_cast(randd(min, max + 1)); + return (int32_t)(randd(min, max + 1.f)); } inline float clamp(float x, float min, float max) { diff --git a/include/vec3.hpp b/include/vec3.hpp index 429d747..0250345 100644 --- a/include/vec3.hpp +++ b/include/vec3.hpp @@ -13,6 +13,7 @@ class vec3 { vec3(__m128& v); vec3(__m128&& v); vec3(const vec3& vec); + vec3(const vec3&& vec); vec3 operator-() const; -- cgit v1.3