Skip to content

Developmentnow it's rendring - #37

Open
mahesh0537 wants to merge 8 commits into
wermos:developmentfrom
mahesh0537:development
Open

Developmentnow it's rendring#37
mahesh0537 wants to merge 8 commits into
wermos:developmentfrom
mahesh0537:development

Conversation

@mahesh0537

Copy link
Copy Markdown

No description provided.

constexpr vec4 unit() const{
return *this/this->norm();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that supposed to be taken care of by the std library we are using?

Comment thread Rendera/include/cube.hpp
Material m_material;
static const double m_epsilon = 1e-5;
vec3 int_pt;
const double m_epsilon = 1e-5;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you make m_epsilon a non-static member?

Comment thread Rendera/include/cube.hpp
#include "material.hpp"


//debug

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this comment mean?

Comment thread Rendera/include/cube.hpp


//debug
class HitInfo{

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HitInfo struct should be in its own header file.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a class? It should be a struct.

Comment thread Rendera/include/cube.hpp
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}{};

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Members of structs are public by default. Also, this constructor is not needed. The compiler will auto-generate it for you.

Comment thread Rendera/include/cube.hpp
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}{};

};

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are there so many blank spaces?

Comment thread Rendera/src/main.cpp
sc.render();

int max_col = 255;
std::ofstream image("sphere.ppm");

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()}{}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you trying to do here?

#include <type_traits> // for std::is_constant_evaluated

#include <xsimd/xsimd.hpp>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove this blank line? It exists to provide a little separation between a library include and our own project's include.

Comment on lines -63 to +68
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{

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread Rendera/include/cube.hpp


//debug
class HitInfo{

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a class? It should be a struct.

Comment thread Rendera/include/cube.hpp
Material m_material;
static const double m_epsilon = 1e-5;
vec3 int_pt;
const double m_epsilon = 1e-5;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you make this a non-static member? Now every Cube object will have its own copy of m_epsilon.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it static constexpr double m_epsilon = 1e-5;

Comment thread Rendera/include/scene.hpp
#include "camera.hpp"

#include "cube.hpp"
class Hitinfo{

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a One Definition Rule (ODR) violation. You can only have definition for a class. Why did you define HitInfo multiple times?

Comment thread Rendera/include/cube.hpp
Material m_material;
static const double m_epsilon = 1e-5;
vec3 int_pt;
const double m_epsilon = 1e-5;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it static constexpr double m_epsilon = 1e-5;

Comment thread Rendera/include/scene.hpp
int n_sphere;
int n_sphere = 1;
int n_cube = 0;
uint16_t img_width;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this a 32 bit int (std::uint32_t). To use these types, you should also include <cstddef>.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for img_height.

Comment thread Rendera/include/scene.hpp
int n_cube = 0;
uint16_t img_width;
uint16_t img_height;
Hitinfo *hitinfo = new Hitinfo[img_height*img_width];

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line because we are going depth-first.

Comment thread Rendera/include/scene.hpp
@@ -85,29 +90,34 @@ class Scene{

}
~Scene(){

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't a manually defined destructor because we are removing the array of HitInfo structs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants