added camera pan for parallax and improved line drawing with preview line

This commit is contained in:
2017-05-06 23:22:34 +01:00
parent 427dd66976
commit f800df6cf5
10 changed files with 183 additions and 22 deletions

View File

@@ -7,6 +7,7 @@ std::vector<CanvasMode*> ui::Canvas::modes[] = {
{ new CanvasModePen, new CanvasModeBasicCamera },
{ new CanvasModePen, new CanvasModeBasicCamera },
{ new CanvasModeLine, new CanvasModeBasicCamera },
{ new CanvasModeCamera, new CanvasModeBasicCamera },
};
glm::vec3 ui::Canvas::m_plane_origin[6] = {
{ 0, 0,-1}, // front
@@ -47,9 +48,18 @@ void ui::Canvas::clear(const glm::vec4& c/*={0,0,0,1}*/)
}
void ui::Canvas::stroke_end()
{
stroke_commit();
m_current_stroke = nullptr;
m_show_tmp = false;
if (!m_current_stroke)
return;
if (m_current_stroke->has_sample())
{
m_commit_delayed = true;
}
else
{
stroke_commit();
m_current_stroke = nullptr;
m_show_tmp = false;
}
}
void ui::Canvas::stroke_draw()
{
@@ -146,7 +156,7 @@ void ui::Canvas::stroke_draw()
{
glm::mat4 plane_camera = glm::lookAt(m_plane_origin[i], m_plane_normal[i], m_plane_tangent[i]);
glm::vec4 plane_local = plane_camera * glm::vec4(hit, 1);
if (glm::abs(plane_local.x) < 1.f && glm::abs(plane_local.y) < 1.f)
if (glm::abs(plane_local.x) < 1.5f && glm::abs(plane_local.y) < 1.5f)
{
fb_pos.x = -(plane_local.x * 0.5f - 0.5f) * m_width;
fb_pos.y = (plane_local.y * 0.5f + 0.5f) * m_height;
@@ -234,6 +244,13 @@ void ui::Canvas::stroke_draw()
glViewport(vp[0], vp[1], vp[2], vp[3]);
glClearColor(cc[0], cc[1], cc[2], cc[3]);
if (m_commit_delayed)
{
stroke_commit();
m_current_stroke = nullptr;
m_show_tmp = false;
m_commit_delayed = false;
}
}
void ui::Canvas::stroke_commit()
{