change brush size based on camera fov / zoom, refactor brush value curves
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "pch.h"
|
||||
#include "log.h"
|
||||
#include "brush.h"
|
||||
#include "canvas.h"
|
||||
|
||||
void ui::BrushMesh::draw(const std::vector<StrokeSample>& samples, const glm::mat4& proj)
|
||||
{
|
||||
@@ -168,8 +169,8 @@ ui::StrokeSample ui::Stroke::randomize_sample(const glm::vec2& pos, float pressu
|
||||
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 * glm::pow(m_brush.m_tip_size, 3.f) * (1.f - rnd_nor() * m_brush.m_jitter_scale) * size_dyn;
|
||||
s.flow = glm::pow(m_brush.m_tip_flow, 2.f) * (1.f - rnd_nor() * m_brush.m_jitter_flow) * flow_dyn;
|
||||
s.size = 800.f * m_brush.m_tip_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;
|
||||
return s;
|
||||
}
|
||||
std::vector<ui::StrokeSample> ui::Stroke::compute_samples()
|
||||
@@ -226,7 +227,7 @@ void ui::Stroke::add_point(glm::vec2 pos, float pressure)
|
||||
pressure = pressure * glm::pow(m_curve, 2.f);
|
||||
|
||||
if (m_brush.m_tip_size_pressure)
|
||||
m_step = glm::max(glm::pow(m_brush.m_tip_spacing * 4.f, 2.f) * glm::pow(m_brush.m_tip_size, 3.f) * 800.f * pressure, 1.f);
|
||||
m_step = glm::max(m_brush.m_tip_spacing * m_brush.m_tip_size * pressure * 800.f, 1.f);
|
||||
|
||||
float dist = m_keypoints.empty() ? 0.f :
|
||||
m_keypoints.back().dist + glm::distance(m_keypoints.back().pos, pos);
|
||||
@@ -245,6 +246,7 @@ void ui::Stroke::start(const ui::Brush& brush)
|
||||
m_last_kp = 0;
|
||||
m_dist = 0.f;
|
||||
m_brush = brush;
|
||||
m_step = glm::max(glm::pow(m_brush.m_tip_spacing * 4.f, 2.f) * glm::pow(m_brush.m_tip_size, 3.f) * 800.f, 1.f);
|
||||
m_brush.m_tip_size *= 1.f / glm::tan(glm::radians(Canvas::I->m_cam_fov * 0.5f));
|
||||
m_step = glm::max(m_brush.m_tip_spacing * m_brush.m_tip_size * 800.f, 1.f);
|
||||
prng.seed(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user