mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-09-21 07:03:11 +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;
|
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()
|
void GLGizmoAdvancedCut::update_plane_points()
|
||||||
{
|
{
|
||||||
Vec3d plane_center = get_plane_center();
|
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);
|
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
|
else
|
||||||
render_color = GrabberColor;
|
render_color = GrabberColor;
|
||||||
|
|
||||||
const GLModel &cube = m_move_grabber.get_cube();
|
GLModel& cube = m_move_grabber.get_cube();
|
||||||
// BBS set to fixed size grabber
|
// BBS set to fixed size grabber
|
||||||
// float fullsize = 2 * (dragging ? get_dragging_half_size(size) : get_half_size(size));
|
// float fullsize = 2 * (dragging ? get_dragging_half_size(size) : get_half_size(size));
|
||||||
float fullsize = 8.0f;
|
float fullsize = 8.0f;
|
||||||
@ -934,18 +955,11 @@ void GLGizmoAdvancedCut::render_cut_plane_and_grabbers()
|
|||||||
fullsize = m_move_grabber.FixedGrabberSize * GLGizmoBase::INV_ZOOM;
|
fullsize = m_move_grabber.FixedGrabberSize * GLGizmoBase::INV_ZOOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
const_cast<GLModel*>(&cube)->set_color(-1, render_color);
|
Transform3d cube_mat = Geometry::translation_transform(m_move_grabber.center) * m_rotate_matrix * Geometry::scale_transform(fullsize); //
|
||||||
|
render_glmodel(cube, render_color, cube_mat);
|
||||||
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());
|
|
||||||
|
|
||||||
// Should be placed at last, because GLGizmoRotate3D clears depth buffer
|
// 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();
|
GLGizmoRotate3D::on_render();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1009,7 +1023,7 @@ void GLGizmoAdvancedCut::render_connectors()
|
|||||||
|
|
||||||
const Transform3d view_model_matrix = translate_tf * m_rotate_matrix * scale_tf;
|
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);
|
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()
|
void GLGizmoAdvancedCut::clear_selection()
|
||||||
{
|
{
|
||||||
m_selected.clear();
|
m_selected.clear();
|
||||||
|
@ -137,7 +137,7 @@ public:
|
|||||||
bool unproject_on_cut_plane(const Vec2d &mouse_pos, Vec3d &pos, Vec3d &pos_world);
|
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:
|
protected:
|
||||||
virtual bool on_init();
|
virtual bool on_init();
|
||||||
virtual void on_load(cereal::BinaryInputArchive &ar) override;
|
virtual void on_load(cereal::BinaryInputArchive &ar) override;
|
||||||
@ -204,7 +204,6 @@ private:
|
|||||||
void render_connectors();
|
void render_connectors();
|
||||||
void render_clipper_cut();
|
void render_clipper_cut();
|
||||||
void render_cut_line();
|
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 clear_selection();
|
||||||
void init_connector_shapes();
|
void init_connector_shapes();
|
||||||
|
@ -100,7 +100,7 @@ float GLGizmoBase::Grabber::get_dragging_half_size(float size) const
|
|||||||
return get_half_size(size) * DraggingScaleFactor;
|
return get_half_size(size) * DraggingScaleFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
const GLModel& GLGizmoBase::Grabber::get_cube() const
|
GLModel& GLGizmoBase::Grabber::get_cube()
|
||||||
{
|
{
|
||||||
if (! cube_initialized) {
|
if (! cube_initialized) {
|
||||||
// This cannot be done in constructor, OpenGL is not yet
|
// This cannot be done in constructor, OpenGL is not yet
|
||||||
|
@ -77,7 +77,7 @@ protected:
|
|||||||
|
|
||||||
float get_half_size(float size) const;
|
float get_half_size(float size) const;
|
||||||
float get_dragging_half_size(float size) const;
|
float get_dragging_half_size(float size) const;
|
||||||
const GLModel& get_cube() const;
|
GLModel& get_cube();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void render(float size, const std::array<float, 4>& render_color, bool picking) const;
|
void render(float size, const std::array<float, 4>& render_color, bool picking) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user