mixer working except when changing plane, previous sample does't work in this case

This commit is contained in:
2018-08-01 16:47:13 +02:00
parent 663863fe44
commit 76033a1ca8
5 changed files with 34 additions and 5 deletions

View File

@@ -346,12 +346,28 @@ void ui::Canvas::stroke_draw()
static glm::vec2 UV2[4];
int intersected = 0;
int inside = 0;
if (m_mixer_idle)
{
m_mixer_sample = s;
m_mixer_idle = false;
}
for (int j = 0; j < 4; j++)
{
glm::vec3 ray_origin, ray_dir;
point_unproject(s.pos + off[j] * glm::orientate2(-s.angle), { 0, 0, zw(m_box) }, m_mv, m_proj, ray_origin, ray_dir);
UV2[j] = (s.pos + off[j]) / glm::vec2(m_mixer.getWidth(), m_mixer.getHeight());
UV2[j].y = 1 - UV2[j].y;
{
glm::vec2 dx(m_mixer_sample.size * 0.5f, 0), dy(0, m_mixer_sample.size * 0.5f);
glm::vec2 off[4] = {
-dx - dy, // A - bottom-left
-dx + dy, // B - top-left
+dx + dy, // C - top-right
+dx - dy, // D - bottom-right
};
UV2[j] = (m_mixer_sample.pos + off[j]) / glm::vec2(m_mixer.getWidth(), m_mixer.getHeight());
UV2[j].y = 1 - UV2[j].y;
}
glm::vec3 hit;
if (ray_intersect(ray_origin, ray_dir, m_plane_origin[i], m_plane_normal[i], m_plane_tangent[i], hit))
{
@@ -373,6 +389,8 @@ void ui::Canvas::stroke_draw()
}
}
m_mixer_sample = s;
if (intersected < 4 || inside == 0)
continue;
@@ -521,6 +539,7 @@ void ui::Canvas::stroke_commit()
if (!m_dirty || m_layers.empty())
return;
m_mixer_idle = true;
m_dirty = false;
m_dirty_stroke = true; // new stroke ready for timelapse capture
App::I.redraw = true;