| #ifndef HITTABLE_H |
| #define HITTABLE_H |
| //============================================================================================== |
| // Originally written in 2016 by Peter Shirley <ptrshrl@gmail.com> |
| // |
| // To the extent possible under law, the author(s) have dedicated all copyright |
| // and related and neighboring rights to this software to the public domain |
| // worldwide. This software is distributed without any warranty. |
| // |
| // You should have received a copy (see file COPYING.txt) of the CC0 Public |
| // Domain Dedication along with this software. If not, see |
| // <http://creativecommons.org/publicdomain/zero/1.0/>. |
| // |
| // The original source code is from |
| // https://github.com/RayTracing/raytracing.github.io/tree/release/src/InOneWeekend |
| // |
| // Changes to the original code follow the following license. |
| // |
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| // See https://llvm.org/LICENSE.txt for license information. |
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| //============================================================================================== |
| |
| #include "rtweekend.h" |
| |
| class material; |
| |
| class hit_record { |
| public: |
| point3 p; |
| vec3 normal; |
| SharedPtr<material> mat; |
| double t; |
| bool front_face; |
| |
| __host__ __device__ void set_face_normal(const ray &r, |
| const vec3 &outward_normal) { |
| // Sets the hit record normal vector. |
| // NOTE: the parameter `outward_normal` is assumed to have unit length. |
| |
| front_face = dot(r.direction(), outward_normal) < 0; |
| normal = front_face ? outward_normal : -outward_normal; |
| } |
| }; |
| |
| class hittable { |
| public: |
| __host__ __device__ virtual ~hittable() = default; |
| |
| __host__ __device__ virtual bool hit(const ray &r, interval ray_t, |
| hit_record &rec) const = 0; |
| }; |
| |
| #endif |