From b2e29fe742189b7f6a79a52f462606bbf837892a Mon Sep 17 00:00:00 2001 From: denis_vyatkin Date: Mon, 6 Dec 2021 19:47:24 +0500 Subject: [PATCH] #pragma once --- CMakeLists.txt | 2 +- src/AABB.hpp | 8 ++------ src/Box.hpp | 9 ++------- src/BvhNode.hpp | 8 ++------ src/Camera.hpp | 9 ++------- src/CheckerTexture.hpp | 9 ++------- src/ColorHelpers.cpp | 2 +- src/ColorHelpers.h | 10 ---------- src/ColorHelpers.hpp | 6 ++++++ src/ConstantMedium.hpp | 9 ++------- src/ConstantTexture.hpp | 9 ++------- src/CosinePdf.hpp | 9 ++------- src/Dielectric.hpp | 9 ++------- src/DiffuseLight.hpp | 9 ++------- src/FlipNormals.hpp | 9 ++------- src/HitRecord.hpp | 9 ++------- src/Hitable.hpp | 9 ++------- src/HitableList.hpp | 9 ++------- src/HitablePdf.hpp | 9 ++------- src/ImageHelpers.hpp | 9 ++------- src/ImageTexture.hpp | 9 ++------- src/Isotropic.hpp | 9 ++------- src/Lambertian.hpp | 9 ++------- src/Material.hpp | 11 +++-------- src/MathHelpers.hpp | 8 ++------ src/Metal.hpp | 9 ++------- src/MixturePdf.hpp | 9 ++------- src/NoiseTexture.hpp | 9 ++------- src/Pdf.hpp | 9 ++------- src/Perlin.hpp | 9 ++------- src/Ray.hpp | 9 ++------- src/Rect.hpp | 8 ++------ src/RotateY.hpp | 9 ++------- src/{ScatterRecord.h => ScatterRecord.hpp} | 9 ++------- src/Scene.hpp | 8 ++------ src/Sphere.hpp | 7 +------ src/Texture.hpp | 9 ++------- src/Translate.hpp | 9 ++------- src/Vector3.hpp | 6 +----- src/main.cpp | 2 +- 40 files changed, 78 insertions(+), 251 deletions(-) delete mode 100644 src/ColorHelpers.h create mode 100644 src/ColorHelpers.hpp rename src/{ScatterRecord.h => ScatterRecord.hpp} (56%) diff --git a/CMakeLists.txt b/CMakeLists.txt index e651706..18af3ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,4 +3,4 @@ project(RayTracer) set(CMAKE_CXX_STANDARD 20) -add_executable(RayTracer src/main.cpp src/Vector3.cpp src/Vector3.hpp src/Ray.hpp src/HitRecord.hpp src/Hitable.hpp src/Sphere.cpp src/Sphere.hpp src/HitableList.cpp src/HitableList.hpp src/Camera.cpp src/Camera.hpp src/Material.hpp src/Lambertian.cpp src/Lambertian.hpp src/MathHelpers.cpp src/MathHelpers.hpp src/Metal.cpp src/Metal.hpp src/Dielectric.cpp src/Dielectric.hpp src/AABB.cpp src/AABB.hpp src/BvhNode.cpp src/BvhNode.hpp src/Texture.hpp src/ConstantTexture.cpp src/ConstantTexture.hpp src/CheckerTexture.cpp src/CheckerTexture.hpp src/Perlin.cpp src/Perlin.hpp src/NoiseTexture.cpp src/NoiseTexture.hpp src/ImageHelpers.cpp src/ImageHelpers.hpp src/ImageTexture.cpp src/ImageTexture.hpp src/DiffuseLight.cpp src/DiffuseLight.hpp src/Rect.hpp src/Scene.cpp src/Scene.hpp src/FlipNormals.cpp src/FlipNormals.hpp src/Box.cpp src/Box.hpp src/Translate.cpp src/Translate.hpp src/RotateY.cpp src/RotateY.hpp src/Isotropic.cpp src/Isotropic.hpp src/ConstantMedium.cpp src/ConstantMedium.hpp src/OrthoNormalBasis.cpp src/OrthoNormalBasis.hpp src/Pdf.hpp src/CosinePdf.cpp src/CosinePdf.hpp src/HitablePdf.cpp src/HitablePdf.hpp src/MixturePdf.cpp src/MixturePdf.hpp src/ScatterRecord.h src/ColorHelpers.cpp src/ColorHelpers.h) +add_executable(RayTracer src/main.cpp src/Vector3.cpp src/Vector3.hpp src/Ray.hpp src/HitRecord.hpp src/Hitable.hpp src/Sphere.cpp src/Sphere.hpp src/HitableList.cpp src/HitableList.hpp src/Camera.cpp src/Camera.hpp src/Material.hpp src/Lambertian.cpp src/Lambertian.hpp src/MathHelpers.cpp src/MathHelpers.hpp src/Metal.cpp src/Metal.hpp src/Dielectric.cpp src/Dielectric.hpp src/AABB.cpp src/AABB.hpp src/BvhNode.cpp src/BvhNode.hpp src/Texture.hpp src/ConstantTexture.cpp src/ConstantTexture.hpp src/CheckerTexture.cpp src/CheckerTexture.hpp src/Perlin.cpp src/Perlin.hpp src/NoiseTexture.cpp src/NoiseTexture.hpp src/ImageHelpers.cpp src/ImageHelpers.hpp src/ImageTexture.cpp src/ImageTexture.hpp src/DiffuseLight.cpp src/DiffuseLight.hpp src/Rect.hpp src/Scene.cpp src/Scene.hpp src/FlipNormals.cpp src/FlipNormals.hpp src/Box.cpp src/Box.hpp src/Translate.cpp src/Translate.hpp src/RotateY.cpp src/RotateY.hpp src/Isotropic.cpp src/Isotropic.hpp src/ConstantMedium.cpp src/ConstantMedium.hpp src/OrthoNormalBasis.cpp src/OrthoNormalBasis.hpp src/Pdf.hpp src/CosinePdf.cpp src/CosinePdf.hpp src/HitablePdf.cpp src/HitablePdf.hpp src/MixturePdf.cpp src/MixturePdf.hpp src/ScatterRecord.hpp src/ColorHelpers.cpp src/ColorHelpers.hpp) diff --git a/src/AABB.hpp b/src/AABB.hpp index 23918c1..4afd61b 100644 --- a/src/AABB.hpp +++ b/src/AABB.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_AABB_HPP -#define RAYTRACER_AABB_HPP - +#pragma once #include "Vector3.hpp" #include "Ray.hpp" @@ -17,6 +15,4 @@ class AABB Vector3 max; }; -AABB SurroundingBox(AABB box1, AABB box2); - -#endif //RAYTRACER_AABB_HPP +AABB SurroundingBox(AABB box1, AABB box2); \ No newline at end of file diff --git a/src/Box.hpp b/src/Box.hpp index 7484f51..6240e65 100644 --- a/src/Box.hpp +++ b/src/Box.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_BOX_HPP -#define RAYTRACER_BOX_HPP - +#pragma once #include "HitableList.hpp" @@ -15,7 +13,4 @@ class Box : public Hitable Vector3 min; Vector3 max; HitableList sides; -}; - - -#endif //RAYTRACER_BOX_HPP +}; \ No newline at end of file diff --git a/src/BvhNode.hpp b/src/BvhNode.hpp index 2e32b43..3863d4d 100644 --- a/src/BvhNode.hpp +++ b/src/BvhNode.hpp @@ -1,5 +1,4 @@ -#ifndef RAYTRACER_BVHNODE_HPP -#define RAYTRACER_BVHNODE_HPP +#pragma once #include @@ -18,7 +17,4 @@ class BvhNode : public Hitable std::shared_ptr right {}; AABB boundingBox {}; -}; - - -#endif //RAYTRACER_BVHNODE_HPP +}; \ No newline at end of file diff --git a/src/Camera.hpp b/src/Camera.hpp index 3d15ab6..d56921b 100644 --- a/src/Camera.hpp +++ b/src/Camera.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_CAMERA_HPP -#define RAYTRACER_CAMERA_HPP - +#pragma once #include "Vector3.hpp" #include "Ray.hpp" @@ -25,7 +23,4 @@ class Camera float lensRadius = 0; float timeStart = 0; float timeEnd = 1; -}; - - -#endif //RAYTRACER_CAMERA_HPP +}; \ No newline at end of file diff --git a/src/CheckerTexture.hpp b/src/CheckerTexture.hpp index a23a87b..5004c97 100644 --- a/src/CheckerTexture.hpp +++ b/src/CheckerTexture.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_CHECKERTEXTURE_HPP -#define RAYTRACER_CHECKERTEXTURE_HPP - +#pragma once #include @@ -16,7 +14,4 @@ class CheckerTexture : public Texture std::shared_ptr even; std::shared_ptr odd; -}; - - -#endif //RAYTRACER_CHECKERTEXTURE_HPP +}; \ No newline at end of file diff --git a/src/ColorHelpers.cpp b/src/ColorHelpers.cpp index 362ecce..d780c31 100644 --- a/src/ColorHelpers.cpp +++ b/src/ColorHelpers.cpp @@ -1,4 +1,4 @@ -#include "ColorHelpers.h" +#include "ColorHelpers.hpp" Vector3 DeNan(const Vector3 &color) { diff --git a/src/ColorHelpers.h b/src/ColorHelpers.h deleted file mode 100644 index 6a690e5..0000000 --- a/src/ColorHelpers.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef RAYTRACER_COLORHELPERS_H -#define RAYTRACER_COLORHELPERS_H - - -#include "Vector3.hpp" - -Vector3 DeNan(const Vector3 &color); -Vector3 GammaCorrect(const Vector3 &color); - -#endif //RAYTRACER_COLORHELPERS_H diff --git a/src/ColorHelpers.hpp b/src/ColorHelpers.hpp new file mode 100644 index 0000000..16f765e --- /dev/null +++ b/src/ColorHelpers.hpp @@ -0,0 +1,6 @@ +#pragma once + +#include "Vector3.hpp" + +Vector3 DeNan(const Vector3 &color); +Vector3 GammaCorrect(const Vector3 &color); \ No newline at end of file diff --git a/src/ConstantMedium.hpp b/src/ConstantMedium.hpp index 714b534..e03731f 100644 --- a/src/ConstantMedium.hpp +++ b/src/ConstantMedium.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_CONSTANTMEDIUM_HPP -#define RAYTRACER_CONSTANTMEDIUM_HPP - +#pragma once #include "Hitable.hpp" #include "Texture.hpp" @@ -19,7 +17,4 @@ class ConstantMedium : public Hitable std::shared_ptr hitable; float density; std::shared_ptr phaseFunction; -}; - - -#endif //RAYTRACER_CONSTANTMEDIUM_HPP +}; \ No newline at end of file diff --git a/src/ConstantTexture.hpp b/src/ConstantTexture.hpp index 7129c9c..54e1ce4 100644 --- a/src/ConstantTexture.hpp +++ b/src/ConstantTexture.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_CONSTANTTEXTURE_HPP -#define RAYTRACER_CONSTANTTEXTURE_HPP - +#pragma once #include "Texture.hpp" @@ -13,7 +11,4 @@ class ConstantTexture : public Texture Vector3 Value(float u, float v, const Vector3& point) const override; Vector3 color {}; -}; - - -#endif //RAYTRACER_CONSTANTTEXTURE_HPP +}; \ No newline at end of file diff --git a/src/CosinePdf.hpp b/src/CosinePdf.hpp index 22ee69b..4feacdd 100644 --- a/src/CosinePdf.hpp +++ b/src/CosinePdf.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_COSINEPDF_HPP -#define RAYTRACER_COSINEPDF_HPP - +#pragma once #include "Pdf.hpp" #include "OrthoNormalBasis.hpp" @@ -14,7 +12,4 @@ class CosinePdf : public Pdf Vector3 Generate() const override; OrthoNormalBasis onb; -}; - - -#endif //RAYTRACER_COSINEPDF_HPP +}; \ No newline at end of file diff --git a/src/Dielectric.hpp b/src/Dielectric.hpp index 18bb31f..c878b59 100644 --- a/src/Dielectric.hpp +++ b/src/Dielectric.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_DIELECTRIC_HPP -#define RAYTRACER_DIELECTRIC_HPP - +#pragma once #include "Material.hpp" @@ -12,7 +10,4 @@ class Dielectric : public Material bool Scatter(const Ray &ray, const HitRecord &hitRecord, ScatterRecord &scatterRecord) const override; float refractiveIndex; -}; - - -#endif //RAYTRACER_DIELECTRIC_HPP +}; \ No newline at end of file diff --git a/src/DiffuseLight.hpp b/src/DiffuseLight.hpp index 652af38..12409b2 100644 --- a/src/DiffuseLight.hpp +++ b/src/DiffuseLight.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_DIFFUSELIGHT_HPP -#define RAYTRACER_DIFFUSELIGHT_HPP - +#pragma once #include @@ -16,7 +14,4 @@ class DiffuseLight : public Material Vector3 Emitted(const Ray &ray, const HitRecord &hitRecord, float u, float v, const Vector3 &point) const override; std::shared_ptr texture; -}; - - -#endif //RAYTRACER_DIFFUSELIGHT_HPP +}; \ No newline at end of file diff --git a/src/FlipNormals.hpp b/src/FlipNormals.hpp index 864139a..e768714 100644 --- a/src/FlipNormals.hpp +++ b/src/FlipNormals.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_FLIPNORMALS_HPP -#define RAYTRACER_FLIPNORMALS_HPP - +#pragma once #include "Hitable.hpp" @@ -13,7 +11,4 @@ class FlipNormals : public Hitable bool BoundingBox(AABB &box, float timeStart, float timeEnd) const override; std::shared_ptr hitable; -}; - - -#endif //RAYTRACER_FLIPNORMALS_HPP +}; \ No newline at end of file diff --git a/src/HitRecord.hpp b/src/HitRecord.hpp index 4475e9e..64f023c 100644 --- a/src/HitRecord.hpp +++ b/src/HitRecord.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_HITRECORD_HPP -#define RAYTRACER_HITRECORD_HPP - +#pragma once #include "Vector3.hpp" @@ -14,7 +12,4 @@ struct HitRecord Material* material; float u; float v; -}; - - -#endif //RAYTRACER_HITRECORD_HPP +}; \ No newline at end of file diff --git a/src/Hitable.hpp b/src/Hitable.hpp index df3874c..d50cff1 100644 --- a/src/Hitable.hpp +++ b/src/Hitable.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_HITABLE_HPP -#define RAYTRACER_HITABLE_HPP - +#pragma once #include "Ray.hpp" #include "HitRecord.hpp" @@ -14,7 +12,4 @@ class Hitable virtual float PdfValue(const Vector3 &origin, const Vector3 &direction) const { return 0; } virtual Vector3 Random(const Vector3 &origin) const { return { 1, 0, 0 }; } -}; - - -#endif //RAYTRACER_HITABLE_HPP +}; \ No newline at end of file diff --git a/src/HitableList.hpp b/src/HitableList.hpp index 2d4add4..97bb7b9 100644 --- a/src/HitableList.hpp +++ b/src/HitableList.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_HITABLELIST_HPP -#define RAYTRACER_HITABLELIST_HPP - +#pragma once #include #include @@ -28,7 +26,4 @@ class HitableList : public Hitable private: std::vector> hitables; -}; - - -#endif //RAYTRACER_HITABLELIST_HPP +}; \ No newline at end of file diff --git a/src/HitablePdf.hpp b/src/HitablePdf.hpp index e2b7353..f9a1a47 100644 --- a/src/HitablePdf.hpp +++ b/src/HitablePdf.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_HITABLEPDF_HPP -#define RAYTRACER_HITABLEPDF_HPP - +#pragma once #include "Pdf.hpp" @@ -18,7 +16,4 @@ class HitablePdf : public Pdf std::shared_ptr hitable; Vector3 origin; -}; - - -#endif //RAYTRACER_HITABLEPDF_HPP +}; \ No newline at end of file diff --git a/src/ImageHelpers.hpp b/src/ImageHelpers.hpp index 5be5192..dccf375 100644 --- a/src/ImageHelpers.hpp +++ b/src/ImageHelpers.hpp @@ -1,13 +1,8 @@ -#ifndef RAYTRACER_IMAGEHELPERS_HPP -#define RAYTRACER_IMAGEHELPERS_HPP - +#pragma once #include #include "Vector3.hpp" unsigned char* LoadPng(const char* filename, int &width, int &height); -void SavePng(const char* filename, int width, int height, const std::vector &pixels); - - -#endif //RAYTRACER_IMAGEHELPERS_HPP +void SavePng(const char* filename, int width, int height, const std::vector &pixels); \ No newline at end of file diff --git a/src/ImageTexture.hpp b/src/ImageTexture.hpp index 693ed00..b61bd1b 100644 --- a/src/ImageTexture.hpp +++ b/src/ImageTexture.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_IMAGETEXTURE_HPP -#define RAYTRACER_IMAGETEXTURE_HPP - +#pragma once #include "Texture.hpp" @@ -14,7 +12,4 @@ class ImageTexture : public Texture int width = 0, height = 0; unsigned char* pixels; -}; - - -#endif //RAYTRACER_IMAGETEXTURE_HPP +}; \ No newline at end of file diff --git a/src/Isotropic.hpp b/src/Isotropic.hpp index ba04abc..fbbf763 100644 --- a/src/Isotropic.hpp +++ b/src/Isotropic.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_ISOTROPIC_HPP -#define RAYTRACER_ISOTROPIC_HPP - +#pragma once #include @@ -16,7 +14,4 @@ class Isotropic : public Material float ScatteringPdf(const Ray &ray, const HitRecord &hitRecord, const Ray &scattered) const override; std::shared_ptr texture; -}; - - -#endif //RAYTRACER_ISOTROPIC_HPP +}; \ No newline at end of file diff --git a/src/Lambertian.hpp b/src/Lambertian.hpp index 0fa9279..3a7b826 100644 --- a/src/Lambertian.hpp +++ b/src/Lambertian.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_LAMBERTIAN_HPP -#define RAYTRACER_LAMBERTIAN_HPP - +#pragma once #include @@ -17,7 +15,4 @@ class Lambertian : public Material float ScatteringPdf(const Ray &ray, const HitRecord &hitRecord, const Ray &scattered) const override; std::shared_ptr texture; -}; - - -#endif //RAYTRACER_LAMBERTIAN_HPP +}; \ No newline at end of file diff --git a/src/Material.hpp b/src/Material.hpp index f9cd58a..ab9267c 100644 --- a/src/Material.hpp +++ b/src/Material.hpp @@ -1,10 +1,8 @@ -#ifndef RAYTRACER_MATERIAL_HPP -#define RAYTRACER_MATERIAL_HPP - +#pragma once #include "Ray.hpp" #include "HitRecord.hpp" -#include "ScatterRecord.h" +#include "ScatterRecord.hpp" class Material { @@ -12,7 +10,4 @@ class Material virtual bool Scatter(const Ray& ray, const HitRecord& hitRecord, ScatterRecord &scatterRecord) const { return false; } virtual float ScatteringPdf(const Ray &ray, const HitRecord &hitRecord, const Ray &scattered) const { return 0; } virtual Vector3 Emitted(const Ray &ray, const HitRecord &hitRecord, float u, float v, const Vector3 &point) const { return {0, 0, 0}; } -}; - - -#endif //RAYTRACER_MATERIAL_HPP +}; \ No newline at end of file diff --git a/src/MathHelpers.hpp b/src/MathHelpers.hpp index c6510d3..c8ae5dd 100644 --- a/src/MathHelpers.hpp +++ b/src/MathHelpers.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_MATHHELPERS_HPP -#define RAYTRACER_MATHHELPERS_HPP - +#pragma once #include "Vector3.hpp" @@ -11,6 +9,4 @@ Vector3 Reflect(const Vector3& vector, const Vector3& normal); bool Refract(const Vector3& vector, const Vector3& normal, float refractiveIndexRatio, Vector3& refracted); float Schlick(float cosine, float refractiveIndex); float HermiteCubic(float value); -Vector3 GetRandomCosineDirection(); - -#endif //RAYTRACER_MATHHELPERS_HPP \ No newline at end of file +Vector3 GetRandomCosineDirection(); \ No newline at end of file diff --git a/src/Metal.hpp b/src/Metal.hpp index 8cfc4e5..ce3bbac 100644 --- a/src/Metal.hpp +++ b/src/Metal.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_METAL_HPP -#define RAYTRACER_METAL_HPP - +#pragma once #include @@ -22,7 +20,4 @@ class Metal : public Material std::shared_ptr texture; float fuzziness; -}; - - -#endif //RAYTRACER_METAL_HPP +}; \ No newline at end of file diff --git a/src/MixturePdf.hpp b/src/MixturePdf.hpp index 55a52ae..c9ceed3 100644 --- a/src/MixturePdf.hpp +++ b/src/MixturePdf.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_MIXTUREPDF_HPP -#define RAYTRACER_MIXTUREPDF_HPP - +#pragma once #include "Pdf.hpp" @@ -19,7 +17,4 @@ class MixturePdf : public Pdf Vector3 Generate() const override; const Pdf* pdfs[2] {}; -}; - - -#endif //RAYTRACER_MIXTUREPDF_HPP +}; \ No newline at end of file diff --git a/src/NoiseTexture.hpp b/src/NoiseTexture.hpp index d63baa1..8db37bd 100644 --- a/src/NoiseTexture.hpp +++ b/src/NoiseTexture.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_NOISETEXTURE_HPP -#define RAYTRACER_NOISETEXTURE_HPP - +#pragma once #include "Texture.hpp" #include "Perlin.hpp" @@ -14,7 +12,4 @@ class NoiseTexture : public Texture Perlin noise {}; float scale; -}; - - -#endif //RAYTRACER_NOISETEXTURE_HPP +}; \ No newline at end of file diff --git a/src/Pdf.hpp b/src/Pdf.hpp index f4ace6c..5907665 100644 --- a/src/Pdf.hpp +++ b/src/Pdf.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_PDF_HPP -#define RAYTRACER_PDF_HPP - +#pragma once #include "Vector3.hpp" @@ -9,7 +7,4 @@ class Pdf public: virtual float Value(const Vector3 &direction) const = 0; virtual Vector3 Generate() const = 0; -}; - - -#endif //RAYTRACER_PDF_HPP +}; \ No newline at end of file diff --git a/src/Perlin.hpp b/src/Perlin.hpp index 09583c5..9d82077 100644 --- a/src/Perlin.hpp +++ b/src/Perlin.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_PERLIN_HPP -#define RAYTRACER_PERLIN_HPP - +#pragma once #include #include "Vector3.hpp" @@ -21,7 +19,4 @@ class Perlin private: std::vector GenerateVectors(); static std::vector GeneratePermutation(); -}; - - -#endif //RAYTRACER_PERLIN_HPP +}; \ No newline at end of file diff --git a/src/Ray.hpp b/src/Ray.hpp index b0f12e8..5b03336 100644 --- a/src/Ray.hpp +++ b/src/Ray.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_RAY_HPP -#define RAYTRACER_RAY_HPP - +#pragma once #include "Vector3.hpp" @@ -15,7 +13,4 @@ struct Ray Vector3 direction; float time; -}; - - -#endif //RAYTRACER_RAY_HPP +}; \ No newline at end of file diff --git a/src/Rect.hpp b/src/Rect.hpp index 8120d46..36b206c 100644 --- a/src/Rect.hpp +++ b/src/Rect.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_RECT_HPP -#define RAYTRACER_RECT_HPP - +#pragma once #include @@ -88,6 +86,4 @@ class YZRect : public Rect<0, 1, 2> public: YZRect(float right0, float right1, float up0, float up1, float k, std::shared_ptr material) : Rect<0, 1, 2>(right0, right1, up0, up1, k, std::move(material)) {} -}; - -#endif //RAYTRACER_RECT_HPP +}; \ No newline at end of file diff --git a/src/RotateY.hpp b/src/RotateY.hpp index 151cb94..d63c825 100644 --- a/src/RotateY.hpp +++ b/src/RotateY.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_ROTATEY_HPP -#define RAYTRACER_ROTATEY_HPP - +#pragma once #include "Hitable.hpp" @@ -20,7 +18,4 @@ class RotateY : public Hitable bool hasBox; AABB boundingBox {}; -}; - - -#endif //RAYTRACER_ROTATEY_HPP +}; \ No newline at end of file diff --git a/src/ScatterRecord.h b/src/ScatterRecord.hpp similarity index 56% rename from src/ScatterRecord.h rename to src/ScatterRecord.hpp index d6a1c0f..cbc46f6 100644 --- a/src/ScatterRecord.h +++ b/src/ScatterRecord.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_SCATTERRECORD_H -#define RAYTRACER_SCATTERRECORD_H - +#pragma once #include "Ray.hpp" #include "Pdf.hpp" @@ -11,7 +9,4 @@ struct ScatterRecord bool isSpecular; Vector3 albedo; std::shared_ptr pdf; -}; - - -#endif //RAYTRACER_SCATTERRECORD_H +}; \ No newline at end of file diff --git a/src/Scene.hpp b/src/Scene.hpp index 5bab85e..8746248 100644 --- a/src/Scene.hpp +++ b/src/Scene.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_SCENE_HPP -#define RAYTRACER_SCENE_HPP - +#pragma once #include @@ -25,6 +23,4 @@ struct Scene Scene CreateRandomScene(); Scene CreateCornellBoxScene(); -Scene CreateAllFeaturesScene(); - -#endif //RAYTRACER_SCENE_HPP +Scene CreateAllFeaturesScene(); \ No newline at end of file diff --git a/src/Sphere.hpp b/src/Sphere.hpp index 30eb29a..c651188 100644 --- a/src/Sphere.hpp +++ b/src/Sphere.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_SPHERE_HPP -#define RAYTRACER_SPHERE_HPP - +#pragma once #include @@ -32,6 +30,3 @@ class Sphere : public Hitable float moveTimeStart; float moveTimeEnd; }; - - -#endif //RAYTRACER_SPHERE_HPP diff --git a/src/Texture.hpp b/src/Texture.hpp index 5ded2ce..45ec38e 100644 --- a/src/Texture.hpp +++ b/src/Texture.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_TEXTURE_HPP -#define RAYTRACER_TEXTURE_HPP - +#pragma once #include "Vector3.hpp" @@ -8,7 +6,4 @@ class Texture { public: virtual Vector3 Value(float u, float v, const Vector3& point) const = 0; -}; - - -#endif //RAYTRACER_TEXTURE_HPP +}; \ No newline at end of file diff --git a/src/Translate.hpp b/src/Translate.hpp index 2342bb2..43f2d08 100644 --- a/src/Translate.hpp +++ b/src/Translate.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_TRANSLATE_HPP -#define RAYTRACER_TRANSLATE_HPP - +#pragma once #include "Hitable.hpp" @@ -14,7 +12,4 @@ class Translate : public Hitable std::shared_ptr hitable; Vector3 offset; -}; - - -#endif //RAYTRACER_TRANSLATE_HPP +}; \ No newline at end of file diff --git a/src/Vector3.hpp b/src/Vector3.hpp index 9c44930..6965ba0 100644 --- a/src/Vector3.hpp +++ b/src/Vector3.hpp @@ -1,6 +1,4 @@ -#ifndef RAYTRACER_VECTOR3_HPP -#define RAYTRACER_VECTOR3_HPP - +#pragma once #include #include @@ -114,5 +112,3 @@ inline Vector3 Cross(const Vector3& left, const Vector3& right) -(left.x * right.z - left.z * right.x), left.x * right.y - left.y * right.x }; } - -#endif //RAYTRACER_VECTOR3_HPP diff --git a/src/main.cpp b/src/main.cpp index 9bcceb8..5ac5dd5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,7 +12,7 @@ #include "Scene.hpp" #include "HitablePdf.hpp" #include "MixturePdf.hpp" -#include "ColorHelpers.h" +#include "ColorHelpers.hpp" Vector3 GetScreenColor(const Ray& ray, const std::shared_ptr& world, const std::shared_ptr& importanceSamplingShape, int depth = 50) {