raytracing.github.io icon indicating copy to clipboard operation
raytracing.github.io copied to clipboard

Book 2 Listing 17 losing “const”

Open bolin12 opened this issue 4 years ago • 1 comments

bvh_node::bvh_node( std::vector<shared_ptr>& src_objects, size_t start, size_t end, double time0, double time1 )

may be modified to:

bvh_node::bvh_node( const std::vector<shared_ptr>& src_objects, size_t start, size_t end, double time0, double time1 )

bolin12 avatar Oct 31 '21 07:10 bolin12

Book 1 listing 20 also has a function whose parameters could be trued up with const

trevordblack avatar Apr 22 '22 05:04 trevordblack

Looks like this has already been addressed (bvh_node constructor parameter src_objects).

Regarding the comment about Book 1 listing 20, it appears this is about the hittable_list class. It doesn't mention which function, but we're passing a shared_ptr to hittable_list::hittable_list(), and to hittable_list::add(). In both cases we are not modifying an underlying vector of shared pointers, so it doesn't really apply. In addition, for the single shared pointer of the caller, we want to pass that by value, rather than letting a callee mess with the caller's ref-counted pointer.

hollasch avatar Aug 12 '22 19:08 hollasch