Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.33 KB | None | 0 0
  1. #ifndef __CORE_SCENE_H__
  2. #define __CORE_SCENE_H__
  3.  
  4. #include <memory>
  5. #include <vector>
  6. #include "core/system/system.h"
  7.  
  8. class Accelerator;
  9. class Primitive;
  10. class Ray;
  11. struct PrimitiveHitInfo;
  12.  
  13. exrBEGIN_NAMESPACE
  14.  
  15. //! @brief A scene object that owns primitives
  16. //!
  17. //! A scene class that contains a collection of primitives and various helper functions
  18. //! to interact with the collection.
  19. class Scene
  20. {
  21. public:
  22.     Scene() {}
  23.     //! @brief Copy constructor
  24.     //! @param copy             The object to copy
  25.     Scene(const Scene& copy) : m_Primitives(copy.m_Primitives) {}
  26.  
  27.     Scene operator=(const Scene& copy) { return Scene(copy); }
  28.  
  29.     //! @brief Adds a primitive to the scene
  30.     //!
  31.     //! This function adds a new primitive to the scene's primitive collection
  32.     //!
  33.     //! @param primitive         A pointer to the primitive
  34.     void AddPrimitive(std::unique_ptr<Primitive> primitive);
  35.  
  36.     //! @brief Raytrace through the scene and returns the info of the nearest hit point
  37.     //!
  38.     //! This function and executes an intersection test with the scene objects
  39.     //! with the input ray.
  40.     //!
  41.     //! @param ray              The ray to test against
  42.     //! @param tMin             Min t value of ray to test
  43.     //! @param tMax             Max t value of ray to test
  44.     //! @param hitInfo          Output struct that contains the hit information of the nearest hit point
  45.     //!
  46.     //! @return                 True if the there is at least one intersection
  47.     exrBool RaytraceScene(const Ray& ray, exrFloat tMin, exrFloat tMax, PrimitiveHitInfo& hitInfo) const;
  48.  
  49.     //! @brief Initializes the scene BVH if it has yet to be initialized or needs to be updated
  50.     void InitializeBvh();
  51.  
  52. public:
  53.     //! @brief Returns the number of primitives in the scene
  54.     //! @return                 The number of primitives in the scene
  55.     inline exrU64 GetSceneSize() const { return static_cast<exrU64>(m_Primitives.size()); }
  56.  
  57. private:
  58.     //! A collection of pointers that points to primitives in the scene
  59.     std::vector<std::unique_ptr<Primitive>> m_Primitives;
  60.  
  61.     //! The accelerator to use
  62.     std::unique_ptr<Accelerator> m_Accelerator;
  63.  
  64.     //! A flag that determines if the scene has changed since the last render
  65.     exrBool m_IsDirty;
  66. };
  67.  
  68. exrEND_NAMESPACE
  69.  
  70. #endif // !__CORE_SCENE_H__
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement