2026-05-11 23:06:39 +03:00
|
|
|
/*
|
|
|
|
|
* InfiniPaint
|
|
|
|
|
* Copyright (C) 2025-2026 Yousef Khadadeh
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2025-12-11 16:05:41 +03:00
|
|
|
#pragma once
|
2026-05-23 18:27:45 +03:00
|
|
|
#include "BrushComponentCode.hpp"
|
2025-12-11 16:05:41 +03:00
|
|
|
#include "CanvasComponent.hpp"
|
|
|
|
|
#include "Helpers/SCollision.hpp"
|
|
|
|
|
#include <Helpers/Serializers.hpp>
|
|
|
|
|
#include <include/core/SkPath.h>
|
|
|
|
|
#include <include/core/SkPathBuilder.h>
|
|
|
|
|
|
2026-05-23 18:27:45 +03:00
|
|
|
class MeshCanvasComponent : public CanvasComponent {
|
2025-12-11 16:05:41 +03:00
|
|
|
public:
|
2025-12-15 15:36:42 +03:00
|
|
|
virtual CanvasComponentType get_type() const override;
|
2025-12-13 13:03:27 +03:00
|
|
|
virtual void save(cereal::PortableBinaryOutputArchive& a) const override;
|
|
|
|
|
virtual void load(cereal::PortableBinaryInputArchive& a) override;
|
2025-12-11 16:05:41 +03:00
|
|
|
virtual void save_file(cereal::PortableBinaryOutputArchive& a) const override;
|
|
|
|
|
virtual void load_file(cereal::PortableBinaryInputArchive& a, VersionNumber version) override;
|
2025-12-29 19:57:36 +03:00
|
|
|
virtual std::unique_ptr<CanvasComponent> get_data_copy() const override;
|
2026-01-27 16:55:09 +03:00
|
|
|
virtual void change_stroke_color(const Vector4f& newStrokeColor) override;
|
2026-05-26 17:08:43 +03:00
|
|
|
virtual std::vector<CanvasComponentContainer*> attempt_split(DrawingProgram& drawP) const override;
|
2026-01-27 16:55:09 +03:00
|
|
|
virtual std::optional<Vector4f> get_stroke_color() const override;
|
2026-05-23 18:27:45 +03:00
|
|
|
virtual void set_data_from(const CanvasComponent& other) override;
|
2026-05-27 06:34:43 +03:00
|
|
|
virtual void simplify_paths() override;
|
2025-12-11 16:05:41 +03:00
|
|
|
|
|
|
|
|
struct Data {
|
2026-05-24 11:58:52 +03:00
|
|
|
SkPath meshPath;
|
2025-12-11 16:05:41 +03:00
|
|
|
Vector4f color;
|
2026-01-27 16:55:09 +03:00
|
|
|
} d;
|
2025-12-13 13:03:27 +03:00
|
|
|
private:
|
2026-02-07 18:49:56 +03:00
|
|
|
virtual void draw(SkCanvas* canvas, const DrawData& drawData, const std::shared_ptr<void>& predrawData) const override;
|
|
|
|
|
virtual bool accurate_draw(SkCanvas* canvas, const DrawData& drawData, const CoordSpaceHelper& coords, const std::shared_ptr<void>& predrawData) const override;
|
|
|
|
|
virtual std::shared_ptr<void> get_predraw_data_accurate(const DrawData& drawData, const CoordSpaceHelper& coords) const override;
|
2025-12-11 16:05:41 +03:00
|
|
|
virtual void initialize_draw_data(DrawingProgram& drawP) override;
|
2026-05-24 11:58:52 +03:00
|
|
|
virtual bool collides_within_coords_point(const Vector2f& checkAgainst) const override;
|
2026-05-23 18:27:45 +03:00
|
|
|
virtual bool collides_within_coords_skpath(const SkPath& checkAgainst) const override;
|
2026-05-24 20:32:21 +03:00
|
|
|
virtual bool can_erase_detail() const override;
|
|
|
|
|
virtual CanvasComponentEraseDetailResult erase_detail(const SkPath& eraseAgainst) override;
|
2026-02-08 13:27:18 +03:00
|
|
|
bool should_draw_extra(const DrawData& drawData, const CoordSpaceHelper& coords) const override;
|
2025-12-11 16:05:41 +03:00
|
|
|
virtual SCollision::AABB<float> get_obj_coord_bounds() const override;
|
2026-05-23 18:27:45 +03:00
|
|
|
SCollision::BVHContainer<float> collisionTree;
|
2025-12-11 16:05:41 +03:00
|
|
|
};
|
|
|
|
|
|