implement motion controllers and vr drawing with brush preview
This commit is contained in:
@@ -361,7 +361,7 @@ void ui::Canvas::stroke_draw()
|
||||
glm::vec2 bb_max(0, 0);
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
auto p = (m_mixer_sample.pos + off[j] * glm::orientate2(-s.angle) + glm::vec2(0, 1)) / zoom;
|
||||
auto p = (xy(m_mixer_sample.pos) + off[j] * glm::orientate2(-s.angle) + glm::vec2(0, 1)) / zoom;
|
||||
UV2[j] = p / sz;
|
||||
bb_min = glm::max({ 0, 0 }, glm::min(bb_min, p));
|
||||
bb_max = glm::min(sz, glm::max(bb_max, p));
|
||||
@@ -427,8 +427,18 @@ void ui::Canvas::stroke_draw()
|
||||
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);
|
||||
|
||||
if (s.pos.z == 0)
|
||||
{
|
||||
point_unproject(xy(s.pos) + off[j] * glm::orientate2(-s.angle), { 0, 0, zw(m_box) }, m_mv, m_proj, ray_origin, ray_dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto m = glm::inverse(glm::lookAt({ 0, 0, 0 }, s.pos, { 0, 1, 0 }));
|
||||
glm::vec3 off_3d = m * glm::vec4(off[j], 0, 1);
|
||||
ray_origin = glm::vec3(0);
|
||||
ray_dir = s.pos + off_3d;
|
||||
}
|
||||
|
||||
glm::vec3 hit;
|
||||
if (ray_intersect(ray_origin, ray_dir, m_plane_origin[i], m_plane_normal[i], m_plane_tangent[i], hit))
|
||||
{
|
||||
@@ -498,7 +508,7 @@ void ui::Canvas::stroke_draw()
|
||||
}
|
||||
|
||||
m_mixer_sample = s;
|
||||
}
|
||||
}
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
@@ -742,11 +752,11 @@ void ui::Canvas::stroke_commit()
|
||||
action->m_stroke = std::move(m_current_stroke);
|
||||
ActionManager::add(action);
|
||||
}
|
||||
void ui::Canvas::stroke_update(glm::vec2 point, float pressure)
|
||||
void ui::Canvas::stroke_update(glm::vec3 point, float pressure)
|
||||
{
|
||||
m_current_stroke->add_point(point, pressure);
|
||||
}
|
||||
void ui::Canvas::stroke_start(glm::vec2 point, float pressure, const ui::Brush& brush)
|
||||
void ui::Canvas::stroke_start(glm::vec3 point, float pressure, const ui::Brush& brush)
|
||||
{
|
||||
// need to commit this now before starting a new stroke
|
||||
if (m_current_stroke && m_commit_delayed)
|
||||
|
||||
Reference in New Issue
Block a user