worldoptimiser.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. public:
  34. void run();
  35. };
  36. class OctreeOptimisation : public WorldOptimiser
  37. {
  38. private:
  39. void makeTree(Group *leaf);
  40. public:
  41. void run();
  42. };
  43. #endif /* DORAYME_WORLDOPTIMISER_H */