Tech ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES - Use vertex attributes and matrices in shaders.
Shader: flat - Gizmo Move grabber extension
This commit is contained in:
parent
bc3341160b
commit
0376571a93
@ -276,17 +276,25 @@ double GLGizmoMove3D::calc_projection(const UpdateData& data) const
|
|||||||
|
|
||||||
void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box, bool picking)
|
void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box, bool picking)
|
||||||
{
|
{
|
||||||
float mean_size = float((box.size().x() + box.size().y() + box.size().z()) / 3.0);
|
const float mean_size = float((box.size().x() + box.size().y() + box.size().z()) / 3.0);
|
||||||
double size = m_dragging ? double(m_grabbers[axis].get_dragging_half_size(mean_size)) : double(m_grabbers[axis].get_half_size(mean_size));
|
const double size = m_dragging ? double(m_grabbers[axis].get_dragging_half_size(mean_size)) : double(m_grabbers[axis].get_half_size(mean_size));
|
||||||
|
|
||||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
GLShaderProgram* shader = wxGetApp().get_shader(picking ? "flat_attr" : "gouraud_light");
|
||||||
|
#else
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader(picking ? "flat" : "gouraud_light");
|
GLShaderProgram* shader = wxGetApp().get_shader(picking ? "flat" : "gouraud_light");
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
#else
|
#else
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
bool use_attributes = boost::algorithm::iends_with(shader->get_name(), "_attr");
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
m_cone.set_color((!picking && m_hover_id != -1) ? complementary(m_grabbers[axis].color) : m_grabbers[axis].color);
|
m_cone.set_color((!picking && m_hover_id != -1) ? complementary(m_grabbers[axis].color) : m_grabbers[axis].color);
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
@ -299,16 +307,34 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box
|
|||||||
}
|
}
|
||||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
|
||||||
glsafe(::glPushMatrix());
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
glsafe(::glTranslated(m_grabbers[axis].center.x(), m_grabbers[axis].center.y(), m_grabbers[axis].center.z()));
|
if (use_attributes) {
|
||||||
if (axis == X)
|
Transform3d matrix = wxGetApp().plater()->get_camera().get_projection_view_matrix() * Geometry::assemble_transform(m_grabbers[axis].center);
|
||||||
glsafe(::glRotated(90.0, 0.0, 1.0, 0.0));
|
if (axis == X)
|
||||||
else if (axis == Y)
|
matrix = matrix * Geometry::assemble_transform(Vec3d::Zero(), 0.5 * PI * Vec3d::UnitY());
|
||||||
glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0));
|
else if (axis == Y)
|
||||||
|
matrix = matrix * Geometry::assemble_transform(Vec3d::Zero(), -0.5 * PI * Vec3d::UnitX());
|
||||||
|
matrix = matrix * Geometry::assemble_transform(2.0 * size * Vec3d::UnitZ(), Vec3d::Zero(), Vec3d(0.75 * size, 0.75 * size, 3.0 * size));
|
||||||
|
shader->set_uniform("projection_view_model_matrix", matrix);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
glsafe(::glPushMatrix());
|
||||||
|
glsafe(::glTranslated(m_grabbers[axis].center.x(), m_grabbers[axis].center.y(), m_grabbers[axis].center.z()));
|
||||||
|
if (axis == X)
|
||||||
|
glsafe(::glRotated(90.0, 0.0, 1.0, 0.0));
|
||||||
|
else if (axis == Y)
|
||||||
|
glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0));
|
||||||
|
|
||||||
glsafe(::glTranslated(0.0, 0.0, 2.0 * size));
|
glsafe(::glTranslated(0.0, 0.0, 2.0 * size));
|
||||||
glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size));
|
glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size));
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
}
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
m_cone.render();
|
m_cone.render();
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
if (!use_attributes)
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
glsafe(::glPopMatrix());
|
glsafe(::glPopMatrix());
|
||||||
|
|
||||||
#if !ENABLE_GLBEGIN_GLEND_REMOVAL
|
#if !ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
Loading…
Reference in New Issue
Block a user