Developmentnow it's rendring - #37
Conversation
| constexpr vec4 unit() const{ | ||
| return *this/this->norm(); | ||
| } | ||
|
|
There was a problem hiding this comment.
Isn't that supposed to be taken care of by the std library we are using?
| Material m_material; | ||
| static const double m_epsilon = 1e-5; | ||
| vec3 int_pt; | ||
| const double m_epsilon = 1e-5; |
There was a problem hiding this comment.
Why did you make m_epsilon a non-static member?
| #include "material.hpp" | ||
|
|
||
|
|
||
| //debug |
|
|
||
|
|
||
| //debug | ||
| class HitInfo{ |
There was a problem hiding this comment.
The HitInfo struct should be in its own header file.
There was a problem hiding this comment.
Why is this a class? It should be a struct.
| int depth; | ||
|
|
||
| public: | ||
| HitInfo(bool if_hit, vec3 v, Material m, ray r, int d):if_hit{if_hit}, dist_v{v}, mat{m}, r{r}, depth{d}{}; |
There was a problem hiding this comment.
Members of structs are public by default. Also, this constructor is not needed. The compiler will auto-generate it for you.
| HitInfo(bool if_hit, vec3 v, Material m, ray r, int d):if_hit{if_hit}, dist_v{v}, mat{m}, r{r}, depth{d}{}; | ||
|
|
||
| }; | ||
|
|
There was a problem hiding this comment.
Why are there so many blank spaces?
| sc.render(); | ||
|
|
||
| int max_col = 255; | ||
| std::ofstream image("sphere.ppm"); |
There was a problem hiding this comment.
Why did you add the ppm code back in, and remove the png/jpg code?
| constexpr vec3(Utype x,Utype y,Utype z) : vec4{x,y,z,0} {} | ||
| explicit vec3(xsimd::batch<Utype,UArch> x) : vec4{x} {} | ||
| constexpr vec3(vec4 a): vec4{a.x(), a.y(), a.z(), a.w()}{} | ||
| vec3() = default; |
There was a problem hiding this comment.
Why is this constructor necessary?
| constexpr explicit vec3(Utype x) : vec4{x,x,x,0} {} | ||
| constexpr vec3(Utype x,Utype y,Utype z) : vec4{x,y,z,0} {} | ||
| explicit vec3(xsimd::batch<Utype,UArch> x) : vec4{x} {} | ||
| constexpr vec3(vec4 a): vec4{a.x(), a.y(), a.z(), a.w()}{} |
| #include <type_traits> // for std::is_constant_evaluated | ||
|
|
||
| #include <xsimd/xsimd.hpp> | ||
|
|
There was a problem hiding this comment.
Why did you remove this blank line? It exists to provide a little separation between a library include and our own project's include.
| CONSTEXPR_CMATH Utype norm() const{ | ||
| constexpr Utype norm() const{ | ||
| return std::sqrt(dot(*this,*this)); | ||
| } | ||
|
|
||
| CONSTEXPR_CMATH Utype angle(const vec4& v1,const vec4& v2){ | ||
| constexpr Utype angle(const vec4& v1,const vec4& v2){ | ||
| return std::acos(dot(v1,v2)/(v1.norm()*v2.norm())); | ||
| } | ||
| CONSTEXPR_CMATH vec4 unit() const{ | ||
| constexpr vec4 unit() const{ |
There was a problem hiding this comment.
Why did you change these functions from the CONSTEXPR_CMATH macro to constexpr?
As of C++20, the <cmath> functions are not constexpr and hence cannot be used in a constant expression context. However, GCC implements the <cmath> functions as constexpr in their implementation of the standard library as a non-standard extension. That's why the CONSTEXPR_CMATH macro is necessary.
|
|
||
|
|
||
| //debug | ||
| class HitInfo{ |
There was a problem hiding this comment.
Why is this a class? It should be a struct.
| Material m_material; | ||
| static const double m_epsilon = 1e-5; | ||
| vec3 int_pt; | ||
| const double m_epsilon = 1e-5; |
There was a problem hiding this comment.
Why did you make this a non-static member? Now every Cube object will have its own copy of m_epsilon.
There was a problem hiding this comment.
Make it static constexpr double m_epsilon = 1e-5;
| #include "camera.hpp" | ||
|
|
||
| #include "cube.hpp" | ||
| class Hitinfo{ |
There was a problem hiding this comment.
This is a One Definition Rule (ODR) violation. You can only have definition for a class. Why did you define HitInfo multiple times?
| Material m_material; | ||
| static const double m_epsilon = 1e-5; | ||
| vec3 int_pt; | ||
| const double m_epsilon = 1e-5; |
There was a problem hiding this comment.
Make it static constexpr double m_epsilon = 1e-5;
| int n_sphere; | ||
| int n_sphere = 1; | ||
| int n_cube = 0; | ||
| uint16_t img_width; |
There was a problem hiding this comment.
Make this a 32 bit int (std::uint32_t). To use these types, you should also include <cstddef>.
| int n_cube = 0; | ||
| uint16_t img_width; | ||
| uint16_t img_height; | ||
| Hitinfo *hitinfo = new Hitinfo[img_height*img_width]; |
There was a problem hiding this comment.
Remove this line because we are going depth-first.
| @@ -85,29 +90,34 @@ class Scene{ | |||
|
|
|||
| } | |||
| ~Scene(){ | |||
There was a problem hiding this comment.
We don't a manually defined destructor because we are removing the array of HitInfo structs.
No description provided.