intersection.h 997 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * DoRayMe - a quick and dirty Raytracer
  3. * Intersection header
  4. *
  5. * Created by Manoël Trapier
  6. * Copyright (c) 2020 986-Studio.
  7. *
  8. */
  9. #ifndef DORAYME_INTERSECTION_H
  10. #define DORAYME_INTERSECTION_H
  11. #include <stdlib.h>
  12. #include <ray.h>
  13. class Shape;
  14. struct Computation
  15. {
  16. Computation(Shape *object, double t, Tuple point, Tuple eyev, Tuple normalv, bool inside) :
  17. object(object), t(t), hitPoint(point), eyeVector(eyev), normalVector(normalv), inside(inside) { };
  18. Shape *object;
  19. double t;
  20. Tuple hitPoint;
  21. Tuple eyeVector;
  22. Tuple normalVector;
  23. bool inside;
  24. };
  25. class Intersection
  26. {
  27. public:
  28. double t;
  29. Shape *object;
  30. public:
  31. Intersection(double t, Shape *object) : t(t), object(object) { };
  32. bool nothing() { return (this->object == nullptr); };
  33. Computation prepareComputation(Ray r);
  34. bool operator==(const Intersection &b) const { return ((this->t == b.t) && (this->object == b.object)); };
  35. };
  36. #endif //DORAYME_INTERSECTION_H