You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.8 KiB
54 lines
1.8 KiB
#pragma once
|
|
|
|
#include <data/data_center.hpp>
|
|
|
|
namespace internal
|
|
{
|
|
enum class eNodeOperation : uint32_t { unionOp = 0, intersectionOp = 1, differenceOp = 2, unsetOp = 3 };
|
|
|
|
struct runtime_node_t {
|
|
std::variant<eNodeOperation, primitive*> node_data{};
|
|
|
|
runtime_node_t* parent{nullptr};
|
|
runtime_node_t* left_child{nullptr};
|
|
runtime_node_t* right_child{nullptr};
|
|
|
|
~runtime_node_t() noexcept;
|
|
|
|
bool is_operation_node() const noexcept;
|
|
bool is_primitive_node() const noexcept;
|
|
bool is_parent_null() const noexcept;
|
|
bool is_left_child_null() const noexcept;
|
|
bool is_right_child_null() const noexcept;
|
|
|
|
bool set_parent(runtime_node_t* parent) noexcept;
|
|
bool remove_parent();
|
|
bool set_left_child(runtime_node_t* child) noexcept;
|
|
bool set_right_child(runtime_node_t* child) noexcept;
|
|
bool add_child(runtime_node_t* child) noexcept;
|
|
bool remove_child(runtime_node_t* child);
|
|
};
|
|
|
|
// ======================================================================
|
|
// Node
|
|
// ======================================================================
|
|
|
|
struct BS_API node_t {
|
|
uint32_t operation : 2; // 0 for union, 1 for intersection, 2 for difference, 3 for unset
|
|
uint32_t type : 6; // [0, 62] for primitive type, 63 for invalid/operation node
|
|
uint32_t primitive_index : 24;
|
|
uint32_t parent_index; // 0xFFFFFFFF for null
|
|
uint32_t left_child_index; // 0xFFFFFFFF for null
|
|
uint32_t right_child_index; // 0xFFFFFFFF for null
|
|
|
|
node_t() noexcept;
|
|
|
|
eNodeOperation get_operation() const noexcept;
|
|
void set_operation(eNodeOperation op) noexcept;
|
|
bool is_primitive_node() const noexcept;
|
|
bool is_operation_node() const noexcept;
|
|
bool is_parent_null() const noexcept;
|
|
bool is_left_child_null() const noexcept;
|
|
bool is_right_child_null() const noexcept;
|
|
};
|
|
} // namespace internal
|