@@ -119,42 +119,42 @@ inline vec3 unit_vector(vec3 v) {
119119 return v / v.length ();
120120}
121121
122- vec3 random_unit_vector () {
122+ inline vec3 random_unit_vector () {
123123 auto a = random_double (0 , 2 *pi);
124124 auto z = random_double (-1 , 1 );
125125 auto r = sqrt (1 - z*z);
126126 return vec3 (r*cos (a), r*sin (a), z);
127127}
128128
129- vec3 random_in_unit_disk () {
129+ inline vec3 random_in_unit_disk () {
130130 while (true ) {
131131 auto p = vec3 (random_double (-1 ,1 ), random_double (-1 ,1 ), 0 );
132132 if (p.length_squared () >= 1 ) continue ;
133133 return p;
134134 }
135135}
136136
137- vec3 random_in_unit_sphere () {
137+ inline vec3 random_in_unit_sphere () {
138138 while (true ) {
139139 auto p = vec3::random (-1 ,1 );
140140 if (p.length_squared () >= 1 ) continue ;
141141 return p;
142142 }
143143}
144144
145- vec3 random_in_hemisphere (const vec3& normal) {
145+ inline vec3 random_in_hemisphere (const vec3& normal) {
146146 vec3 in_unit_sphere = random_in_unit_sphere ();
147147 if (dot (in_unit_sphere, normal) > 0.0 ) // In the same hemisphere as the normal
148148 return in_unit_sphere;
149149 else
150150 return -in_unit_sphere;
151151}
152152
153- vec3 reflect (const vec3& v, const vec3& n) {
153+ inline vec3 reflect (const vec3& v, const vec3& n) {
154154 return v - 2 *dot (v,n)*n;
155155}
156156
157- vec3 refract (const vec3& uv, const vec3& n, double etai_over_etat) {
157+ inline vec3 refract (const vec3& uv, const vec3& n, double etai_over_etat) {
158158 auto cos_theta = fmin (dot (-uv, n), 1.0 );
159159 vec3 r_out_perp = etai_over_etat * (uv + cos_theta*n);
160160 vec3 r_out_parallel = -sqrt (fabs (1.0 - r_out_perp.length_squared ())) * n;
0 commit comments