From 3360e351861c394160ed96f6a8a40ad13d7684c6 Mon Sep 17 00:00:00 2001 From: Andrew Golovashevich Date: Mon, 23 Dec 2024 16:14:00 +0300 Subject: [PATCH] Test shaders for lab2 --- programs/labs1_5/CMakeLists.txt | 1 + programs/labs1_5/src/main.cpp | 6 + .../labs1_5/src/variants/lab2/variant3.cpp | 130 ++++++++++++++++++ programs/labs1_5/src/variants/sprite_data.hpp | 10 +- programs/labs1_5/src/variants/variants.hpp | 54 ++++++-- programs/labs1_5/src/zoomed_scene_sprite.hpp | 1 + .../qt_utilities/owned_qimage.hpp | 2 +- .../qt_utilities/renderer_widget.hpp | 9 ++ .../renderer_api/sprite.hpp | 2 +- .../utilities/shader.hpp | 31 +++-- .../utilities/shapes/circle.hpp | 10 +- .../utilities/zoomed_voxel_painter.hpp | 5 +- 12 files changed, 221 insertions(+), 40 deletions(-) create mode 100644 programs/labs1_5/src/variants/lab2/variant3.cpp diff --git a/programs/labs1_5/CMakeLists.txt b/programs/labs1_5/CMakeLists.txt index c3068f5..b3af060 100644 --- a/programs/labs1_5/CMakeLists.txt +++ b/programs/labs1_5/CMakeLists.txt @@ -14,5 +14,6 @@ add_executable( src/variants/lab1/variant6.cpp src/variants/lab1/variant8.cpp src/variants/lab1/variant9.cpp + src/variants/lab2/variant3.cpp ) target_link_libraries(labs PRIVATE Qt5::Core Qt5::Widgets renderer_api utilities qt_utilities) diff --git a/programs/labs1_5/src/main.cpp b/programs/labs1_5/src/main.cpp index 57a5078..6ade92b 100644 --- a/programs/labs1_5/src/main.cpp +++ b/programs/labs1_5/src/main.cpp @@ -53,8 +53,14 @@ namespace BGTU::ComputerGraphicsLabWork::Impl { QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_4, &vmngr, &Variants::VariantsManager::set_variant_4); QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_5, &vmngr, &Variants::VariantsManager::set_variant_5); QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_6, &vmngr, &Variants::VariantsManager::set_variant_6); + QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_7, &vmngr, &Variants::VariantsManager::set_variant_7); QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_8, &vmngr, &Variants::VariantsManager::set_variant_8); QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_9, &vmngr, &Variants::VariantsManager::set_variant_9); + QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_F1, &vmngr, &Variants::VariantsManager::set_lab_1); + QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_F2, &vmngr, &Variants::VariantsManager::set_lab_2); + QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_F3, &vmngr, &Variants::VariantsManager::set_lab_3); + QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_F4, &vmngr, &Variants::VariantsManager::set_lab_4); + QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_F5, &vmngr, &Variants::VariantsManager::set_lab_5); QtUtilities::SeparateThreadedDefaultRendererLinear renderer{}; renderer.set_sprite_data_provider(&sprites_data); diff --git a/programs/labs1_5/src/variants/lab2/variant3.cpp b/programs/labs1_5/src/variants/lab2/variant3.cpp new file mode 100644 index 0000000..15e28d2 --- /dev/null +++ b/programs/labs1_5/src/variants/lab2/variant3.cpp @@ -0,0 +1,130 @@ +#include +#include +#include +#include "../variants.hpp" +#include "../sprite_data.hpp" + +namespace BGTU::ComputerGraphicsLabWork::Impl::Variants::Lab2 { + namespace { + template + class Circle : public RendererApi::Sprite> { + private: + QMutex sync; + + enum class ShaderType : unsigned { + SOLID_RED, + SOLID_GREEN, + SOLID_BLUE, + RADIAL_DARK_RED, + RADIAL_DARK_GREEN, + RADIAL_DARK_BLUE, + RADIAL_LIGHT_RED, + RADIAL_LIGHT_GREEN, + RADIAL_LIGHT_BLUE, + RADIAL_TRANSPARENT_RED, + RADIAL_TRANSPARENT_GREEN, + RADIAL_TRANSPARENT_BLUE, + SECTOR_STATIC, + SECTOR_ROTATED_POS, + SECTOR_ROTATED_NEG, + }; + + ShaderType current_shader; + + template + void _select_shader(SpriteData::ShapeData const *data, receiver_t receiver) const { + const_cast(&(this->sync))->lock(); + ShaderType t = this->current_shader; + const_cast(&(this->sync))->unlock(); + switch (t) { + case ShaderType::SOLID_RED: { + auto s = Utilities::MonoShader::static_; + receiver(s); + return; + } + case ShaderType::SOLID_GREEN: { + auto s = Utilities::MonoShader::static_; + receiver(s); + return; + } + case ShaderType::SOLID_BLUE: { + auto s = Utilities::MonoShader::static_; + receiver(s); + return; + } + case ShaderType::RADIAL_DARK_RED: + case ShaderType::RADIAL_DARK_GREEN: + case ShaderType::RADIAL_DARK_BLUE: + case ShaderType::RADIAL_LIGHT_RED: + case ShaderType::RADIAL_LIGHT_GREEN: + case ShaderType::RADIAL_LIGHT_BLUE: + case ShaderType::RADIAL_TRANSPARENT_RED: + case ShaderType::RADIAL_TRANSPARENT_GREEN: + case ShaderType::RADIAL_TRANSPARENT_BLUE: + case ShaderType::SECTOR_STATIC: + case ShaderType::SECTOR_ROTATED_POS: + case ShaderType::SECTOR_ROTATED_NEG:; + } + }; + + + static inline ShaderType const next_shader_type[] = { + ShaderType::SOLID_GREEN, + ShaderType::SOLID_BLUE, + ShaderType::RADIAL_DARK_RED, + ShaderType::RADIAL_DARK_GREEN, + ShaderType::RADIAL_DARK_BLUE, + ShaderType::RADIAL_LIGHT_RED, + ShaderType::RADIAL_LIGHT_GREEN, + ShaderType::RADIAL_LIGHT_BLUE, + ShaderType::RADIAL_TRANSPARENT_RED, + ShaderType::RADIAL_TRANSPARENT_GREEN, + ShaderType::RADIAL_TRANSPARENT_BLUE, + ShaderType::SECTOR_STATIC, + ShaderType::SECTOR_ROTATED_POS, + ShaderType::SECTOR_ROTATED_NEG, + ShaderType::SOLID_RED + }; + + public: + Circle() : sync{}, current_shader{ShaderType::SOLID_RED} {} + + + Circle(Circle &&other) : sync{}, current_shader{other.current_shader} { + + } + + void draw(Utilities::ZoomedVoxelPainter *frame, SpriteData::ShapeData const *data) const final { + this->_select_shader( + data, + [&](shader_t const &shader) { + Utilities::Shapes::iterate_circle_fill( + data->pos_rotated(data->radius * center_distance_multiplier, center_angle_degrees), + data->radius * radius_multiplier, + [&](bool is_edge, RendererApi::PointI<2>::component_t x, RendererApi::PointI<2>::component_t y) { + if (is_edge) { + frame->add_voxel(x, y, z, edge_color); + } else { + frame->add_voxel(x, y, z, shader.get_color(x, y)); + } + } + ); + } + ); + } + + void clicked() final { + this->sync.lock(); + this->current_shader = next_shader_type[(unsigned)this->current_shader]; + this->sync.unlock(); + } + }; + } + variant_sprites variant3 = variant_sprites::make( + Circle<4.0, {255, 255, 255}, 0.0, 0.0, 1.0>{}, + Circle<2.0, {255, 255, 255}, 0.6666666666666, 0.0, 0.16666666666666666>{}, + Circle<2.0, {255, 255, 255}, 0.6666666666666, 120.0, 0.16666666666666666>{}, + Circle<2.0, {255, 255, 255}, 0.6666666666666, -120.0, 0.16666666666666666>{}, + Circle<1.0, {255, 255, 255}, 0.0, 0.0, 0.5>{} + ); +} \ No newline at end of file diff --git a/programs/labs1_5/src/variants/sprite_data.hpp b/programs/labs1_5/src/variants/sprite_data.hpp index 59bc10c..9c5568d 100644 --- a/programs/labs1_5/src/variants/sprite_data.hpp +++ b/programs/labs1_5/src/variants/sprite_data.hpp @@ -7,11 +7,11 @@ #include #include #include -#include "bgtu/computer_graphics_lab_work/renderer_api/point.hpp" -#include "bgtu/computer_graphics_lab_work/renderer_api/sprite.hpp" -#include "bgtu/computer_graphics_lab_work/utilities/matrix.hpp" -#include "bgtu/computer_graphics_lab_work/utilities/default_renderer_linear.hpp" -#include "bgtu/computer_graphics_lab_work/utilities/zoomed_voxel_painter.hpp" +#include +#include +#include +#include +#include namespace BGTU::ComputerGraphicsLabWork::Impl { diff --git a/programs/labs1_5/src/variants/variants.hpp b/programs/labs1_5/src/variants/variants.hpp index 6406666..56ac1f3 100644 --- a/programs/labs1_5/src/variants/variants.hpp +++ b/programs/labs1_5/src/variants/variants.hpp @@ -41,7 +41,7 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants { public: e0 value; - constexpr _make(e0 v) : value{std::move(v)} {}; + constexpr _make(e0 &v) : value{std::move(v)} {}; constexpr void export_pointers(sprite_t **dst, std::size_t pos) { dst[pos] = &this->value; @@ -54,7 +54,7 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants { e0 value; _make next; - constexpr _make(e0 v, en...nv) : value{std::move(v)}, next{nv...} {}; + constexpr _make(e0& v, en&...nv) : value{std::move(v)}, next{nv...} {}; constexpr void export_pointers(sprite_t **dst, std::size_t pos) { dst[pos] = &this->value; @@ -65,7 +65,7 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants { public: template - constexpr static variant_sprites make(sprites_t...sprites) { + constexpr static variant_sprites make(sprites_t&&...sprites) { static _make i{sprites...}; static sprite_t *p[sizeof...(sprites)]; @@ -73,6 +73,11 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants { return variant_sprites{p, sizeof...(sprites)}; } + template<> + constexpr variant_sprites make<>() { + return variant_sprites{nullptr, 0}; + } + private: template *frame, @@ -136,6 +141,10 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants { extern variant_sprites variant9; } + namespace Lab2 { + extern variant_sprites variant3; + } + class VariantsManager : public QObject { Q_OBJECT @@ -178,8 +187,9 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants { switch (this->get_current_lab()) { case LabNo::L1: this->_set_sprites(Lab1::variant1); + return; default: - (void) 0; + return; } }; @@ -187,8 +197,9 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants { switch (this->get_current_lab()) { case LabNo::L1: this->_set_sprites(Lab1::variant2); + return; default: - (void) 0; + return; } }; @@ -196,8 +207,12 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants { switch (this->get_current_lab()) { case LabNo::L1: this->_set_sprites(Lab1::variant3); + return; + case LabNo::L2: + this->_set_sprites(Lab2::variant3); + return; default: - (void) 0; + return; } }; @@ -205,8 +220,9 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants { switch (this->get_current_lab()) { case LabNo::L1: this->_set_sprites(Lab1::variant4); + return; default: - (void) 0; + return; } }; @@ -214,8 +230,9 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants { switch (this->get_current_lab()) { case LabNo::L1: this->_set_sprites(Lab1::variant5); + return; default: - (void) 0; + return; } }; @@ -223,8 +240,16 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants { switch (this->get_current_lab()) { case LabNo::L1: this->_set_sprites(Lab1::variant6); + return; default: - (void) 0; + return; + } + }; + + inline void set_variant_7() { + switch (this->get_current_lab()) { + default: + return; } }; @@ -232,8 +257,9 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants { switch (this->get_current_lab()) { case LabNo::L1: this->_set_sprites(Lab1::variant8); + return; default: - (void) 0; + return; } }; @@ -241,8 +267,9 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants { switch (this->get_current_lab()) { case LabNo::L1: this->_set_sprites(Lab1::variant9); + return; default: - (void) 0; + return; } }; @@ -253,22 +280,19 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants { inline void set_lab_2() { this->set_current_lab(LabNo::L2); - this->_set_sprites(Lab1::variant3); + this->_set_sprites(Lab2::variant3); }; inline void set_lab_3() { this->set_current_lab(LabNo::L3); - this->_set_sprites(Lab1::variant3); }; inline void set_lab_4() { this->set_current_lab(LabNo::L4); - this->_set_sprites(Lab1::variant3); }; inline void set_lab_5() { this->set_current_lab(LabNo::L5); - this->_set_sprites(Lab1::variant3); }; }; } \ No newline at end of file diff --git a/programs/labs1_5/src/zoomed_scene_sprite.hpp b/programs/labs1_5/src/zoomed_scene_sprite.hpp index 40b818a..3edf6c2 100644 --- a/programs/labs1_5/src/zoomed_scene_sprite.hpp +++ b/programs/labs1_5/src/zoomed_scene_sprite.hpp @@ -18,6 +18,7 @@ namespace BGTU::ComputerGraphicsLabWork::Impl { Utilities::ZoomedVoxelPainter zoomed_painter{frame, data->central_pixel_tl, data->pixel_size}; for (std::size_t i = 0; i < data->sub_sprites_count; i++) { + zoomed_painter.current_owner = data->sub_sprites[i]; data->sub_sprites[i]->draw(&zoomed_painter, &data->shape_data); } } diff --git a/qt-utilities/include/bgtu/computer_graphics_lab_work/qt_utilities/owned_qimage.hpp b/qt-utilities/include/bgtu/computer_graphics_lab_work/qt_utilities/owned_qimage.hpp index be546b2..f568ea9 100644 --- a/qt-utilities/include/bgtu/computer_graphics_lab_work/qt_utilities/owned_qimage.hpp +++ b/qt-utilities/include/bgtu/computer_graphics_lab_work/qt_utilities/owned_qimage.hpp @@ -79,7 +79,7 @@ namespace BGTU::ComputerGraphicsLabWork::QtUtilities { this->owners[y * this->width() + x] = o; } - [[nodiscard]] RendererApi::SpriteMetadata const *getPixelOwner(unsigned x, unsigned y) const { + [[nodiscard]] RendererApi::SpriteMetadata *getPixelOwner(unsigned x, unsigned y) const { assert(x < this->width()); assert(y < this->height()); diff --git a/qt-utilities/include/bgtu/computer_graphics_lab_work/qt_utilities/renderer_widget.hpp b/qt-utilities/include/bgtu/computer_graphics_lab_work/qt_utilities/renderer_widget.hpp index 8ee58b8..c3f3e3f 100644 --- a/qt-utilities/include/bgtu/computer_graphics_lab_work/qt_utilities/renderer_widget.hpp +++ b/qt-utilities/include/bgtu/computer_graphics_lab_work/qt_utilities/renderer_widget.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "owned_qimage.hpp" #include "separate_threaded_renderer.hpp" @@ -69,5 +70,13 @@ namespace BGTU::ComputerGraphicsLabWork::QtUtilities { this->renderer->set_frame_size(event->size().width(), event->size().height()); emit this->resized(event->size().width(), event->size().height()); } + + void mousePressEvent(QMouseEvent *event) override { + this->sync.lock(); + auto sprite = this->current_image->getPixelOwner(event->x(), event->y()); + this->sync.unlock(); + if (sprite != nullptr) + sprite->clicked(); + } }; } \ No newline at end of file diff --git a/renderer-api/include/bgtu/computer_graphics_lab_work/renderer_api/sprite.hpp b/renderer-api/include/bgtu/computer_graphics_lab_work/renderer_api/sprite.hpp index c213d7e..0c67ef4 100644 --- a/renderer-api/include/bgtu/computer_graphics_lab_work/renderer_api/sprite.hpp +++ b/renderer-api/include/bgtu/computer_graphics_lab_work/renderer_api/sprite.hpp @@ -6,7 +6,7 @@ namespace BGTU::ComputerGraphicsLabWork::RendererApi { class SpriteMetadata { public: - virtual void clicked() {}; + virtual inline void clicked() {}; }; template diff --git a/utilities/include/bgtu/computer_graphics_lab_work/utilities/shader.hpp b/utilities/include/bgtu/computer_graphics_lab_work/utilities/shader.hpp index 383ef43..33d64ba 100644 --- a/utilities/include/bgtu/computer_graphics_lab_work/utilities/shader.hpp +++ b/utilities/include/bgtu/computer_graphics_lab_work/utilities/shader.hpp @@ -9,11 +9,19 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities { class Shader { public: - [[nodiscard]] virtual RendererApi::Color::Transparent get_color(RendererApi::PointI<2>::component_t x, RendererApi::PointI<2>::component_t y) const = 0; + [[nodiscard]] virtual RendererApi::Color::Transparent get_color(RendererApi::PointF<2>::component_t x, RendererApi::PointF<2>::component_t y) const = 0; - [[nodiscard]] inline RendererApi::Color::Transparent get_color(RendererApi::PointI<2> p) const { + [[nodiscard]] inline RendererApi::Color::Transparent get_color(RendererApi::PointF<2> p) const { return this->get_color(p.x, p.y); }; +#if 0 + [[nodiscard]] inline RendererApi::Color::Transparent get_color(RendererApi::PointI<2>::component_t x, RendererApi::PointI<2>::component_t y) { + return this->get_color(static_cast::component_t>(x), static_cast::component_t>(y)); + }; +#endif + [[nodiscard]] inline RendererApi::Color::Transparent get_color(RendererApi::PointI<2> p) const { + return this->get_color((RendererApi::PointF<2>) p); + }; class Empty; @@ -24,7 +32,7 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities { public: constexpr Empty() noexcept = default; - [[nodiscard]] constexpr RendererApi::Color::Transparent get_color(RendererApi::PointI<2>::component_t x, RendererApi::PointI<2>::component_t y) const noexcept final { + [[nodiscard]] constexpr RendererApi::Color::Transparent get_color(RendererApi::PointF<2>::component_t x, RendererApi::PointF<2>::component_t y) const noexcept final { return RendererApi::Color::Transparent{0, 0, 0, 0}; }; @@ -88,7 +96,7 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities { public: constexpr explicit MonoShader(RendererApi::Color::Transparent c) noexcept: c{c} {} - [[nodiscard]] constexpr RendererApi::Color::Transparent get_color(RendererApi::PointI<2>::component_t x, RendererApi::PointI<2>::component_t y) const noexcept final { + [[nodiscard]] constexpr RendererApi::Color::Transparent get_color(RendererApi::PointF<2>::component_t x, RendererApi::PointF<2>::component_t y) const noexcept final { return this->c; }; @@ -99,21 +107,17 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities { static constexpr RendererApi::Color::Transparent const COLOR = _color; - [[nodiscard]] constexpr RendererApi::Color::Transparent get_color(RendererApi::PointI<2>::component_t x, RendererApi::PointI<2>::component_t y) const noexcept final { + [[nodiscard]] constexpr RendererApi::Color::Transparent get_color(RendererApi::PointF<2>::component_t x, RendererApi::PointF<2>::component_t y) const noexcept final { return _color; }; - private: - static MonoShader::Static<_color> const INSTANCE; - - public: operator MonoShader::Static<_color> const *() const noexcept { // NOLINT(*-explicit-constructor) - return &INSTANCE; + return this; } MonoShader::Static<_color> const *operator->() const noexcept { - return &INSTANCE; + return this; } @@ -127,9 +131,6 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities { static MonoShader::Static const static_; }; - template - constexpr MonoShader::Static const MonoShader::Static::INSTANCE{}; - template constexpr MonoShader::Static const MonoShader::static_{}; @@ -142,7 +143,7 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities { public: inline TransformedShader(Shader const *s, Matrix4d t) : shader{s}, transform{t} {} - [[nodiscard]] inline RendererApi::Color::Transparent get_color(RendererApi::PointI<2>::component_t x, RendererApi::PointI<2>::component_t y) const override { + [[nodiscard]] inline RendererApi::Color::Transparent get_color(RendererApi::PointF<2>::component_t x, RendererApi::PointF<2>::component_t y) const final { RendererApi::PointF<3> in{x, y, 0}; RendererApi::PointF<3> out = this->transform * in; return this->shader->get_color(out.x, out.y); diff --git a/utilities/include/bgtu/computer_graphics_lab_work/utilities/shapes/circle.hpp b/utilities/include/bgtu/computer_graphics_lab_work/utilities/shapes/circle.hpp index a7ec7bb..931335f 100644 --- a/utilities/include/bgtu/computer_graphics_lab_work/utilities/shapes/circle.hpp +++ b/utilities/include/bgtu/computer_graphics_lab_work/utilities/shapes/circle.hpp @@ -13,6 +13,10 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities::Shapes { edger_receiver_t edge_point_receiver, fill_receiver_t fill_line_receiver ) { + if (r == 0) { + edge_point_receiver(cx, cy); + return; + } RendererApi::PointI<2>::component_t x = 0, y = r; RendererApi::PointI<2>::component_t last_y = r + 1; RendererApi::PointI<2>::component_t _r2 = r * r; @@ -50,10 +54,12 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities::Shapes { edge_point_receiver(cx + x, cy + y); edge_point_receiver(cx - y, cy + x); + fill_line_receiver(cy + x, cx - y + 1, cx + y); edge_point_receiver(cx + y, cy + x); if (x > 0) { edge_point_receiver(cx - y, cy - x); + fill_line_receiver(cy - x, cx - y + 1, cx + y); edge_point_receiver(cx + y, cy - x); } @@ -84,7 +90,7 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities::Shapes { cx, cy, r, [&](RendererApi::PointI<2>::component_t x, RendererApi::PointI<2>::component_t y) { receiver(true, x, y); }, [&](RendererApi::PointI<2>::component_t y, RendererApi::PointI<2>::component_t x1, RendererApi::PointI<2>::component_t x2) { - for (RendererApi::PointI<2>::component_t x = x1; x < x2; x++) receiver(x, y); + for (RendererApi::PointI<2>::component_t x = x1; x < x2; x++) receiver(false, x, y); } ); } @@ -95,7 +101,7 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities::Shapes { RendererApi::PointI<2>::component_t r, receiver_t receiver ) { - iterate_circle_fill_lines(c.x, c.y, r, receiver); + iterate_circle_fill(c.x, c.y, r, receiver); } template diff --git a/utilities/include/bgtu/computer_graphics_lab_work/utilities/zoomed_voxel_painter.hpp b/utilities/include/bgtu/computer_graphics_lab_work/utilities/zoomed_voxel_painter.hpp index 04d4075..633f88e 100644 --- a/utilities/include/bgtu/computer_graphics_lab_work/utilities/zoomed_voxel_painter.hpp +++ b/utilities/include/bgtu/computer_graphics_lab_work/utilities/zoomed_voxel_painter.hpp @@ -28,6 +28,8 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities { std::size_t pixel_size ) noexcept: dst{dst}, cx{center_tl.x}, cy{center_tl.y}, pixel_size{pixel_size} {} + RendererApi::SpriteMetadata *current_owner = nullptr; + void add_voxel(long long x, long long y, double z, RendererApi::Color::Transparent c) final { Shapes::fill_square( this->dst, @@ -35,7 +37,8 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities { this->cy + y * this->pixel_size, this->pixel_size, z, - c + c, + current_owner ); }