This commit is contained in:
2017-05-31 08:45:26 +01:00
3 changed files with 19 additions and 4 deletions

View File

@@ -164,8 +164,8 @@ ui::StrokeSample ui::Stroke::randomize_sample(const glm::vec2& pos, float pressu
StrokeSample s; StrokeSample s;
s.angle = (m_brush.m_tip_angle + rnd_nor() * m_brush.m_jitter_angle) * (float)(M_PI * 2.0); s.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.pos = pos + (rnd_vec() * m_brush.m_jitter_spread * 100.f);
s.size = 100.f * m_brush.m_tip_size * (1.f - rnd_nor() * m_brush.m_jitter_scale); s.size = 800.f * glm::pow(m_brush.m_tip_size, 2.f) * (1.f - rnd_nor() * m_brush.m_jitter_scale);
s.flow = m_brush.m_tip_flow * (1.f - rnd_nor() * m_brush.m_jitter_flow) * pressure; s.flow = glm::pow(m_brush.m_tip_flow, 2.f) * (1.f - rnd_nor() * m_brush.m_jitter_flow) * pressure;
return s; return s;
} }
std::vector<ui::StrokeSample> ui::Stroke::compute_samples() std::vector<ui::StrokeSample> ui::Stroke::compute_samples()
@@ -214,7 +214,7 @@ void ui::Stroke::start(const ui::Brush& brush)
{ {
m_last_kp = 0; m_last_kp = 0;
m_dist = 0.f; m_dist = 0.f;
m_step = glm::max(brush.m_tip_spacing * brush.m_tip_size * 30, 0.1f); m_step = glm::max(brush.m_tip_spacing * 10, 1.f);
m_brush = brush; m_brush = brush;
prng.seed(0); prng.seed(0);
} }

View File

@@ -65,8 +65,10 @@ void NodeStrokePreview::draw_stroke()
glEnable(GL_BLEND); glEnable(GL_BLEND);
glm::mat4 proj = glm::ortho<float>(0, (float)m_rtt.getWidth(), 0, (float)m_rtt.getHeight(), -1, 1); glm::mat4 proj = glm::ortho<float>(0, (float)m_rtt.getWidth(), 0, (float)m_rtt.getHeight(), -1, 1);
auto b = m_brush;
b.m_tip_size *= .7f; // reduce the size in the preview
m_stroke.reset(); m_stroke.reset();
m_stroke.start(m_brush); m_stroke.start(b);
auto samples = m_stroke.compute_samples(); auto samples = m_stroke.compute_samples();
auto& tex = TextureManager::get(m_brush.m_tex_id); auto& tex = TextureManager::get(m_brush.m_tex_id);
tex.bind(); tex.bind();

View File

@@ -49,6 +49,19 @@ static const char* gl2str(GLenum err)
} }
} }
double now_seconds()
{
time_t timer;
struct tm y2k = { 0 };
double seconds;
y2k.tm_hour = 0; y2k.tm_min = 0; y2k.tm_sec = 0;
y2k.tm_year = 100; y2k.tm_mon = 0; y2k.tm_mday = 1;
time(&timer); /* get current time; same as: timer = time(NULL) */
seconds = difftime(timer, mktime(&y2k));
}
void check_OpenGLError(const char* stmt, const char* fname, int line) void check_OpenGLError(const char* stmt, const char* fname, int line)
{ {
GLenum err; GLenum err;