refactor Brush to be used in shared_ptr

This commit is contained in:
2019-01-22 22:49:43 +01:00
parent 9e76cf3194
commit e26fcf1163
22 changed files with 254 additions and 197 deletions

View File

@@ -1,14 +1,19 @@
#pragma once
#include "rtt.h"
#include "shader.h"
#include "texture.h"
class Brush
{
public:
Brush() = default;
Brush(const Brush& brush) = default;
int id = 0;
std::string m_name;
uint16_t m_tex_id = 0;
uint16_t m_tex_stencil_id = const_hash("data/paper.jpg");
std::shared_ptr<Texture2D> m_tip_texture;
std::shared_ptr<Texture2D> m_stencil_texture;
//uint16_t m_tex_id = 0;
//uint16_t m_tex_stencil_id = const_hash("data/paper.jpg");
glm::vec4 m_tip_color{0, 0, 0, 1};
float m_tip_size = 0;
float m_tip_spacing = 0;
@@ -36,6 +41,8 @@ public:
float m_jitter_sat = 0;
float m_jitter_val = 0;
int m_blend_mode = 0;
bool load_texture(const std::string& path);
bool load_stencil(const std::string& path);
};
struct StrokeSample
@@ -88,7 +95,7 @@ public:
float m_dist = 0;
float m_step = 0;
Camera m_camera;
Brush m_brush;
std::shared_ptr<Brush> m_brush;
cbuffer<float, 3> m_curve_angles;
cbuffer<float, 10> m_pressure_buff;
cbuffer<glm::vec3, 3> m_hsv_jitter;
@@ -98,7 +105,7 @@ public:
std::vector<StrokeSample> m_samples;
int m_last_kp;
std::minstd_rand prng;
void start(const Brush& brush);
void start(const std::shared_ptr<Brush>& brush);
void add_point(glm::vec3 pos, float pressure);
void reset(bool clear_keypoints = false);
bool has_sample();