Skip to content

Commit 3c93cee

Browse files
authored
Merge pull request #719 from JankoDedic/vec3-inline
Mark vec3.h free functions inline
2 parents 94753a6 + a2a1d1b commit 3c93cee

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/common/vec3.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)