Add profiling with Remotery
This commit is contained in:
parent
c37be6798f
commit
6331a2bf79
50 changed files with 16864 additions and 11 deletions
12
sphere.hpp
12
sphere.hpp
|
|
@ -25,17 +25,27 @@ struct sphere : hittable {
|
|||
/* Virtual method implementations */
|
||||
bool sphere::hit(const ray& r, double t_min, double t_max, hit_record& rec) const
|
||||
{
|
||||
rmt_ScopedCPUSample(Sphere_Hit, RMTSF_Aggregate);
|
||||
|
||||
// Part 1
|
||||
|
||||
vec3 oc = r.origin - center;
|
||||
double a = r.direction.length_squared();
|
||||
double half_b = dot(oc, r.direction);
|
||||
double c = oc.length_squared() - radius*radius;
|
||||
|
||||
|
||||
// Part 2
|
||||
|
||||
double discriminant = half_b*half_b - a*c;
|
||||
if (discriminant < 0)
|
||||
return false;
|
||||
double sqrtd = sqrt(discriminant);
|
||||
|
||||
|
||||
// Find the nearest root that lies in the acceptable range
|
||||
// Part 3
|
||||
|
||||
double root = (-half_b - sqrtd) / a;
|
||||
if (root < t_min || t_max < root)
|
||||
{
|
||||
|
|
@ -44,6 +54,8 @@ bool sphere::hit(const ray& r, double t_min, double t_max, hit_record& rec) cons
|
|||
return false;
|
||||
}
|
||||
|
||||
// Part 4
|
||||
|
||||
rec.t = root;
|
||||
rec.p = r.at(rec.t);
|
||||
vec3 outward_normal = (rec.p - center) / radius;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue