implement brush presets save and restore from file, fix stencil nullptr, limit preview stroke max size
This commit is contained in:
@@ -135,12 +135,13 @@ StrokeSample Stroke::randomize_sample(const glm::vec3& pos, float pressure, floa
|
||||
|
||||
float size_dyn = m_brush->m_tip_size_pressure ? pressure : 1.f;
|
||||
float flow_dyn = m_brush->m_tip_flow_pressure ? pressure : 1.f;
|
||||
float size = glm::min(m_brush->m_tip_size / glm::tan(glm::radians(m_camera.fov * 0.5f)), m_max_size);
|
||||
|
||||
StrokeSample s;
|
||||
s.origin = pos;
|
||||
s.angle = -curve_angle + (m_brush->m_tip_angle + rnd_nor() * m_brush->m_jitter_angle) * (float)(M_PI * 2.0);
|
||||
s.pos = pos + (rnd_vec() * m_brush->m_jitter_spread * 100.f);
|
||||
s.size = 800.f * m_brush->m_tip_size * (1.f - rnd_nor() * m_brush->m_jitter_scale) * size_dyn;
|
||||
s.size = 800.f * size * (1.f - rnd_nor() * m_brush->m_jitter_scale) * size_dyn;
|
||||
s.flow = m_brush->m_tip_flow * (1.f - rnd_nor() * m_brush->m_jitter_flow) * flow_dyn;
|
||||
auto hsv = convert_rgb2hsv(m_brush->m_tip_color);
|
||||
hsv.x = glm::clamp(glm::mix(hsv.x, (pressure - 0.5f) * 2.0f, m_brush->m_tip_hue * (float)m_brush->m_tip_hue_pressure) + (rnd_nor() - 0.5f) * m_brush->m_jitter_hue, 0.f, 1.f);
|
||||
@@ -215,7 +216,10 @@ void Stroke::add_point(glm::vec3 pos, float pressure)
|
||||
//pressure = m_pressure_buff.average();
|
||||
|
||||
if (m_brush->m_tip_size_pressure)
|
||||
m_step = glm::max(m_brush->m_tip_spacing * m_brush->m_tip_size * pressure * 800.f, 1.f);
|
||||
{
|
||||
float size = glm::min(m_brush->m_tip_size / glm::tan(glm::radians(m_camera.fov * 0.5f)), m_max_size);
|
||||
m_step = glm::max(m_brush->m_tip_spacing * size * pressure * 800.f, 1.f);
|
||||
}
|
||||
|
||||
float dist = m_keypoints.empty() ? m_step :
|
||||
m_keypoints.back().dist + glm::distance(m_keypoints.back().pos, pos);
|
||||
@@ -238,28 +242,31 @@ void Stroke::start(const std::shared_ptr<Brush>& brush)
|
||||
m_hsv_jitter.clear();
|
||||
m_last_kp = 0;
|
||||
m_dist = 0.f;
|
||||
m_brush = std::make_shared<Brush>(*brush);
|
||||
m_brush->m_tip_size *= 1.f / glm::tan(glm::radians(m_camera.fov * 0.5f));
|
||||
m_step = glm::max(m_brush->m_tip_spacing * m_brush->m_tip_size * 800.f, 1.f);
|
||||
m_brush = brush;
|
||||
float size = glm::min(m_brush->m_tip_size / glm::tan(glm::radians(m_camera.fov * 0.5f)), m_max_size);
|
||||
m_step = glm::max(m_brush->m_tip_spacing * size * 800.f, 1.f);
|
||||
prng.seed(0);
|
||||
}
|
||||
|
||||
bool Brush::load_texture(const std::string & path)
|
||||
bool Brush::load_texture(const std::string& path, const std::string& thumb)
|
||||
{
|
||||
m_tip_texture = std::make_shared<Texture2D>();
|
||||
if (!m_tip_texture->load(path))
|
||||
return false;
|
||||
m_tip_texture->create_mipmaps();
|
||||
m_tip_texture->auto_destroy = true;
|
||||
m_brush_path = path;
|
||||
m_brush_thumb_path = thumb;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Brush::load_stencil(const std::string & path)
|
||||
bool Brush::load_stencil(const std::string& path)
|
||||
{
|
||||
m_stencil_texture = std::make_shared<Texture2D>();
|
||||
if (!m_stencil_texture->load(path))
|
||||
return false;
|
||||
m_stencil_texture->create_mipmaps();
|
||||
m_stencil_texture->auto_destroy = true;
|
||||
m_stencil_path = path;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user