Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Created by petr on 4/4/20.
- //
- #ifndef RAYMARCHING_CSGTREE_H
- #define RAYMARCHING_CSGTREE_H
- #include <glm/vec3.hpp>
- #include <memory>
- #include <vector>
- struct CSGRawData {
- virtual std::vector<uint8_t> getRaw()=0;
- virtual ~CSGRawData() = default;
- };
- struct Operation : public CSGRawData {
- virtual ~Operation() = default;
- };
- struct OperationUnion : public Operation {
- std::vector<uint8_t> getRaw() override;
- };
- struct Shape : public CSGRawData {
- explicit Shape(const glm::vec3 &position) : position(position) {}
- glm::vec3 position;
- };
- struct BoxShape : public Shape {
- BoxShape(const glm::vec3 &position, const glm::vec3 &dimensions) : Shape(position), dimensions(dimensions) {}
- glm::vec3 dimensions;
- std::vector<uint8_t> getRaw() override { return std::vector<uint8_t>(); }
- };
- class CSGNode {
- public:
- [[nodiscard]] virtual auto getLeftChild() -> CSGNode & = 0;
- [[nodiscard]] virtual auto getRightChild() -> CSGNode & = 0;
- [[nodiscard]] virtual auto isLeaf() const -> bool = 0;
- virtual ~CSGNode() = default;
- };
- class OperationCSGNode : public CSGNode {
- public:
- auto getLeftChild() -> CSGNode & override;
- auto getRightChild() -> CSGNode & override;
- [[nodiscard]] auto isLeaf() const -> bool override;
- private:
- std::unique_ptr<CSGNode> leftChild;
- std::unique_ptr<CSGNode> rightChild;
- std::unique_ptr<Operation> operation;
- };
- class ShapeCSGNode : public CSGNode {
- public:
- auto getLeftChild() -> CSGNode & override;
- auto getRightChild() -> CSGNode & override;
- [[nodiscard]] auto isLeaf() const -> bool override;
- private:
- std::unique_ptr<Shape> shape;
- };
- class CSGTree {};
- #endif // RAYMARCHING_CSGTREE_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement