mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-09-21 05:53:12 +08:00
FIX: modify render_connector_model to render_glmodel
Jira: STUDIO-4506 Change-Id: I5739857400efda0ca6f5e3ca6f96235b84c4cd46
This commit is contained in:
parent
71d8fe1013
commit
b4e675f627
@ -265,6 +265,27 @@ bool GLGizmoAdvancedCut::unproject_on_cut_plane(const Vec2d &mouse_pos, Vec3d &p
|
||||
return true;
|
||||
}
|
||||
|
||||
void GLGizmoAdvancedCut::render_glmodel(GLModel &model, const std::array<float, 4> &color, Transform3d view_model_matrix, bool for_picking)
|
||||
{
|
||||
glPushMatrix();
|
||||
GLShaderProgram *shader = nullptr;
|
||||
if (for_picking)
|
||||
shader = wxGetApp().get_shader("cali");
|
||||
else
|
||||
shader = wxGetApp().get_shader("gouraud_light");
|
||||
if (shader) {
|
||||
shader->start_using();
|
||||
|
||||
glsafe(::glMultMatrixd(view_model_matrix.data()));
|
||||
|
||||
model.set_color(-1, color);
|
||||
model.render();
|
||||
|
||||
shader->stop_using();
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void GLGizmoAdvancedCut::update_plane_points()
|
||||
{
|
||||
Vec3d plane_center = get_plane_center();
|
||||
@ -565,7 +586,7 @@ void GLGizmoAdvancedCut::on_render_for_picking()
|
||||
|
||||
|
||||
std::array<float, 4> color = picking_color_component(i+1);
|
||||
render_connector_model(m_shapes[connectors[i].attribs], color, view_model_matrix, true);
|
||||
render_glmodel(m_shapes[connectors[i].attribs], color, view_model_matrix, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -926,7 +947,7 @@ void GLGizmoAdvancedCut::render_cut_plane_and_grabbers()
|
||||
else
|
||||
render_color = GrabberColor;
|
||||
|
||||
const GLModel &cube = m_move_grabber.get_cube();
|
||||
GLModel& cube = m_move_grabber.get_cube();
|
||||
// BBS set to fixed size grabber
|
||||
// float fullsize = 2 * (dragging ? get_dragging_half_size(size) : get_half_size(size));
|
||||
float fullsize = 8.0f;
|
||||
@ -934,18 +955,11 @@ void GLGizmoAdvancedCut::render_cut_plane_and_grabbers()
|
||||
fullsize = m_move_grabber.FixedGrabberSize * GLGizmoBase::INV_ZOOM;
|
||||
}
|
||||
|
||||
const_cast<GLModel*>(&cube)->set_color(-1, render_color);
|
||||
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslated(m_move_grabber.center.x(), m_move_grabber.center.y(), m_move_grabber.center.z()));
|
||||
glsafe(::glMultMatrixd(m_rotate_matrix.data()));
|
||||
|
||||
glsafe(::glScaled(fullsize, fullsize, fullsize));
|
||||
cube.render();
|
||||
glsafe(::glPopMatrix());
|
||||
Transform3d cube_mat = Geometry::translation_transform(m_move_grabber.center) * m_rotate_matrix * Geometry::scale_transform(fullsize); //
|
||||
render_glmodel(cube, render_color, cube_mat);
|
||||
|
||||
// Should be placed at last, because GLGizmoRotate3D clears depth buffer
|
||||
set_center(m_cut_plane_center);
|
||||
GLGizmoRotate3D::set_center(m_cut_plane_center);
|
||||
GLGizmoRotate3D::on_render();
|
||||
}
|
||||
|
||||
@ -1009,7 +1023,7 @@ void GLGizmoAdvancedCut::render_connectors()
|
||||
|
||||
const Transform3d view_model_matrix = translate_tf * m_rotate_matrix * scale_tf;
|
||||
|
||||
render_connector_model(m_shapes[connector.attribs], render_color, view_model_matrix);
|
||||
render_glmodel(m_shapes[connector.attribs], render_color, view_model_matrix);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1036,27 +1050,6 @@ void GLGizmoAdvancedCut::render_cut_line()
|
||||
glDisable(GL_LINE_STIPPLE);
|
||||
}
|
||||
|
||||
void GLGizmoAdvancedCut::render_connector_model(GLModel &model, const std::array<float, 4> &color, Transform3d view_model_matrix, bool for_picking)
|
||||
{
|
||||
glPushMatrix();
|
||||
GLShaderProgram *shader = nullptr;
|
||||
if (for_picking)
|
||||
shader = wxGetApp().get_shader("cali");
|
||||
else
|
||||
shader = wxGetApp().get_shader("gouraud_light");
|
||||
if (shader) {
|
||||
shader->start_using();
|
||||
|
||||
glsafe(::glMultMatrixd(view_model_matrix.data()));
|
||||
|
||||
model.set_color(-1, color);
|
||||
model.render();
|
||||
|
||||
shader->stop_using();
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void GLGizmoAdvancedCut::clear_selection()
|
||||
{
|
||||
m_selected.clear();
|
||||
|
@ -135,9 +135,9 @@ public:
|
||||
bool is_looking_forward() const;
|
||||
|
||||
bool unproject_on_cut_plane(const Vec2d &mouse_pos, Vec3d &pos, Vec3d &pos_world);
|
||||
|
||||
virtual bool apply_clipping_plane() { return m_connectors_editing; }
|
||||
|
||||
virtual bool apply_clipping_plane() { return m_connectors_editing; }
|
||||
static void render_glmodel(GLModel &model, const std::array<float, 4> &color, Transform3d view_model_matrix, bool for_picking = false);
|
||||
protected:
|
||||
virtual bool on_init();
|
||||
virtual void on_load(cereal::BinaryInputArchive &ar) override;
|
||||
@ -204,7 +204,6 @@ private:
|
||||
void render_connectors();
|
||||
void render_clipper_cut();
|
||||
void render_cut_line();
|
||||
void render_connector_model(GLModel &model, const std::array<float, 4>& color, Transform3d view_model_matrix, bool for_picking = false);
|
||||
|
||||
void clear_selection();
|
||||
void init_connector_shapes();
|
||||
|
@ -100,7 +100,7 @@ float GLGizmoBase::Grabber::get_dragging_half_size(float size) const
|
||||
return get_half_size(size) * DraggingScaleFactor;
|
||||
}
|
||||
|
||||
const GLModel& GLGizmoBase::Grabber::get_cube() const
|
||||
GLModel& GLGizmoBase::Grabber::get_cube()
|
||||
{
|
||||
if (! cube_initialized) {
|
||||
// This cannot be done in constructor, OpenGL is not yet
|
||||
|
@ -77,7 +77,7 @@ protected:
|
||||
|
||||
float get_half_size(float size) const;
|
||||
float get_dragging_half_size(float size) const;
|
||||
const GLModel& get_cube() const;
|
||||
GLModel& get_cube();
|
||||
|
||||
private:
|
||||
void render(float size, const std::array<float, 4>& render_color, bool picking) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user