From c4b2de95033e3721bc5392083eb1bc85e0e499e6 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Mon, 15 Jan 2024 15:34:54 -0500 Subject: [PATCH] sexy nodes --- .../Testing/Temporary/LastTest.log | 4 +- src/main.cpp | 86 +++++++++++++++++-- 2 files changed, 80 insertions(+), 10 deletions(-) diff --git a/cmake-build-release/Testing/Temporary/LastTest.log b/cmake-build-release/Testing/Temporary/LastTest.log index c728996..af0e397 100644 --- a/cmake-build-release/Testing/Temporary/LastTest.log +++ b/cmake-build-release/Testing/Temporary/LastTest.log @@ -1,3 +1,3 @@ -Start testing: Jan 14 13:37 EST +Start testing: Jan 15 14:34 EST ---------------------------------------------------------- -End testing: Jan 14 13:37 EST +End testing: Jan 15 14:34 EST diff --git a/src/main.cpp b/src/main.cpp index 55d8f15..f70efd7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,22 +1,92 @@ #include -#include +#include #include #include #include +#include #include "blt/gfx/renderer/resource_manager.h" #include "blt/gfx/renderer/batch_2d_renderer.h" - -class node -{ - node* left; - node* right; - -}; +#include +#include blt::gfx::matrix_state_manager global_matrices; blt::gfx::resource_manager resources; blt::gfx::batch_renderer_2d renderer_2d(resources); +struct node; + +blt::area_allocator allocator; + +std::variant input_t; + +enum class function_t +{ + // FUNC // inputs + ADD, // 2 + SUB, // 2 + MUL, // 2 + DIV, // 2 + + LOG, // 1 + EXP, // 1 + SQRT, // 1 + POW, // 1 + QUAD, // 1 + + RANDOM, // 0 + NOISE, // 0 + COLOR, // 0 + SCALAR // 0 +}; + +static constexpr int OPERATOR_COUNT = 13; + +class tree; + +struct node +{ + friend tree; + private: + node* left; + node* right; + function_t type; + std::array data; + public: + + static node* construct_random() + { + node* n = allocator.allocate(1); + allocator.construct(n); + + std::random_device dev; + std::mt19937_64 engine{dev()}; + std::uniform_real_distribution dist(0.0f, 1.0f); + for (float& f : n->data) + f = dist(engine); + + std::uniform_int_distribution op(0, OPERATOR_COUNT - 1); + n->type = static_cast(op(engine)); + + return n; + } + + ~node() + { + allocator.destroy(left); + allocator.deallocate(left, 1); + allocator.destroy(right); + allocator.deallocate(right, 1); + } +}; + +class tree +{ + public: + node* root; + + +}; + void init() { global_matrices.create_internals();