intersection.h 685 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. class Object;
  13. struct Intersection
  14. {
  15. double t;
  16. Object *object;
  17. };
  18. static Intersection *newIntersection(double t, Object *object)
  19. {
  20. Intersection *ret = (Intersection *)calloc(sizeof(Intersection), 1);
  21. if (ret != nullptr)
  22. {
  23. ret->t = t;
  24. ret->object = object;
  25. }
  26. return ret;
  27. }
  28. static void freeIntersection(Intersection *i)
  29. {
  30. if ( i != nullptr )
  31. {
  32. free(i);
  33. }
  34. }
  35. #endif //DORAYME_INTERSECTION_H