worldoptimiser.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * DoRayMe - a quick and dirty Raytracer
  3. * World optimiser header
  4. *
  5. * Created by Manoël Trapier
  6. * Copyright (c) 2020 986-Studio.
  7. *
  8. */
  9. #ifndef DORAYME_WORLDOPTIMISER_H
  10. #define DORAYME_WORLDOPTIMISER_H
  11. #include <group.h>
  12. /* World Optimiser subclasses will created move objects around to try to optimise the raytrace of the world, to
  13. * have as least as possible object to intersect per ray.
  14. * This class is abstract to we can implement different type and change at runtime or build time
  15. */
  16. class WorldOptimiser
  17. {
  18. protected:
  19. Group *root;
  20. void moveInfiniteObjects(Shape *s = nullptr);
  21. void moveAllObjects(Shape *s = nullptr);
  22. public:
  23. void setRoot(Group *root) { this->root = root; };
  24. virtual void run() = 0;
  25. };
  26. class NoWorldOptimisation : public WorldOptimiser
  27. {
  28. public:
  29. void run() {};
  30. };
  31. class BVHOptimisation : public WorldOptimiser
  32. {
  33. private:
  34. void makeTree(Group *leaf, int depth = 0);
  35. public:
  36. void run();
  37. };
  38. class OctreeOptimisation : public WorldOptimiser
  39. {
  40. private:
  41. void makeTree(Group *leaf, int depth = 0);
  42. public:
  43. void run();
  44. };
  45. #endif /* DORAYME_WORLDOPTIMISER_H */