brush scale for non-square brushes

This commit is contained in:
2019-02-24 21:00:53 +01:00
parent 399bc3d433
commit bfaff312f8
9 changed files with 52 additions and 22 deletions

View File

@@ -141,9 +141,9 @@ StrokeSample Stroke::randomize_sample(const glm::vec3& pos, float pressure, floa
float randflipy = m_brush->m_tip_randflipy ? rnd_bneg() : 1.f;
StrokeSample s;
s.scale.x = m_brush->m_tip_width * randflipx * (m_brush->m_tip_flipx ? -1.f : 1.f) *
s.scale.x = m_brush->m_tip_scale.x * randflipx * (m_brush->m_tip_flipx ? -1.f : 1.f) *
(m_brush->m_tip_aspect <= 0.5 ? m_brush->m_tip_aspect * 2.f : 1.f);
s.scale.y = randflipy * (m_brush->m_tip_flipy ? -1.f : 1.f) *
s.scale.y = m_brush->m_tip_scale.y * randflipy * (m_brush->m_tip_flipy ? -1.f : 1.f) *
(m_brush->m_tip_aspect > 0.5 ? 1.f - (m_brush->m_tip_aspect - .5f) * 2.f : 1.f);
s.origin = pos;
s.angle = -curve_angle + (m_brush->m_tip_angle + rnd_neg() * m_brush->m_jitter_angle) * (float)(M_PI * 2.0);
@@ -188,6 +188,8 @@ std::vector<StrokeSample> Stroke::compute_samples()
m_dir_angle = -glm::orientedAngle(v, m_dir_ref);
if (m_brush->m_tip_angle_delay > 0 && (glm::abs(m_dir_angle) > glm::pi<float>() / 2.f || !m_dir_valid))
{
//if (glm::abs(m_dir_angle) > glm::radians(110.f))
// LOG("BIG ANGLE");
auto old_dir = m_dir_ref;
m_dir_ref = v;
m_dir_ref_angle = -glm::orientedAngle(m_dir_ref, { 1, 0 });
@@ -256,7 +258,7 @@ void Stroke::add_point(glm::vec3 pos, float pressure)
if (m_brush->m_tip_size_pressure)
{
float aspect_width = glm::min(1.f, m_brush->m_tip_aspect * 2.f);
float raw_size = aspect_width * m_brush->m_tip_width * m_brush->m_tip_size;
float raw_size = aspect_width * glm::min(m_brush->m_tip_scale.x, m_brush->m_tip_scale.y) * m_brush->m_tip_size;
float size = glm::clamp(raw_size / glm::tan(glm::radians(m_camera.fov * 0.5f)), 1.f, m_max_size);
if (raw_size < 2.f)
@@ -301,7 +303,7 @@ void Stroke::start(const std::shared_ptr<Brush>& brush)
m_brush = brush;
float aspect_width = glm::min(1.f, m_brush->m_tip_aspect * 2.f);
float raw_size = aspect_width * m_brush->m_tip_width * m_brush->m_tip_size;
float raw_size = aspect_width * glm::min(m_brush->m_tip_scale.x, m_brush->m_tip_scale.y) * m_brush->m_tip_size;
float size = glm::clamp(raw_size / glm::tan(glm::radians(m_camera.fov * 0.5f)), 1.f, m_max_size);
if (raw_size < 2.f)