refactor Brush to be used in shared_ptr

This commit is contained in:
2019-01-22 22:49:43 +01:00
parent 9e76cf3194
commit e26fcf1163
22 changed files with 254 additions and 197 deletions

View File

@@ -67,7 +67,7 @@ void NodeStrokePreview::draw_stroke()
glEnable(GL_BLEND);
glm::mat4 proj = glm::ortho<float>(0, (float)m_rtt.getWidth(), 0, (float)m_rtt.getHeight(), -1, 1);
auto b = m_brush;
const auto& b = m_brush;
m_stroke.m_camera.fov = Canvas::I->m_cam_fov;
m_stroke.m_camera.rot = Canvas::I->m_cam_rot;
m_stroke.reset();
@@ -75,12 +75,12 @@ void NodeStrokePreview::draw_stroke()
if (!m_stroke.m_keypoints.empty())
m_stroke.m_prev_sample.origin = m_stroke.m_keypoints[0].pos;
auto samples = m_stroke.compute_samples();
auto& tex = TextureManager::get(b.m_tex_id);
auto& tex = *b->m_tip_texture;
glActiveTexture(GL_TEXTURE0);
tex.bind();
m_sampler_brush.bind(0);
auto& stencil = TextureManager::get(b.m_tex_stencil_id);
auto& stencil = *b->m_stencil_texture;
glActiveTexture(GL_TEXTURE1);
stencil.bind();
m_sampler.bind(1);
@@ -93,13 +93,13 @@ void NodeStrokePreview::draw_stroke()
ShaderManager::u_int(kShaderUniform::TexStencil, 1); // stencil
ShaderManager::u_vec2(kShaderUniform::Resolution, { m_rtt.getWidth(), m_rtt.getHeight() });
ShaderManager::u_vec2(kShaderUniform::StencilOffset, glm::vec2(0));
ShaderManager::u_float(kShaderUniform::StencilAlpha, b.m_tip_stencil);
ShaderManager::u_float(kShaderUniform::StencilAlpha, b->m_tip_stencil);
m_mesh.draw(samples, proj);
}
//else
//{
// ShaderManager::use("stroke");
// ShaderManager::u_vec4(kShaderUniform::Col, m_brush.m_tip_color);
// ShaderManager::u_vec4(kShaderUniform::Col, m_brush->m_tip_color);
// ShaderManager::u_int(kShaderUniform::Tex, 0);
// for (const auto& s : samples)
// {