Skip to content

Commit

Permalink
Only regenerate bed triangles if actually changed (#3039)
Browse files Browse the repository at this point in the history
* Remove unused bed texture

* Only regenerate bed triangles if actually changed
  • Loading branch information
Noisyfox authored Dec 9, 2023
1 parent d24aef3 commit f598a12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/slic3r/GUI/3DBed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ void Bed3D::render_system(GLCanvas3D& canvas, const Transform3d& view_matrix, co
}*/

//BBS: add part plate related logic
void Bed3D::update_model_offset() const
void Bed3D::update_model_offset()
{
// move the model so that its origin (0.0, 0.0, 0.0) goes into the bed shape center and a bit down to avoid z-fighting with the texture quad
Vec3d shift = m_extended_bounding_box.center();
Expand All @@ -626,11 +626,14 @@ void Bed3D::update_model_offset() const

// update extended bounding box
const_cast<BoundingBoxf3&>(m_extended_bounding_box) = calc_extended_bounding_box();
m_triangles.reset();
}

void Bed3D::update_bed_triangles()
{
m_triangles.reset();
if (m_triangles.is_initialized()) {
return;
}

Vec3d shift = m_extended_bounding_box.center();
shift(2) = -0.03;
Expand Down Expand Up @@ -708,7 +711,7 @@ void Bed3D::render_custom(GLCanvas3D& canvas, const Transform3d& view_matrix, co

void Bed3D::render_default(bool bottom, const Transform3d& view_matrix, const Transform3d& projection_matrix)
{
m_texture.reset();
// m_texture.reset();

update_bed_triangles();

Expand Down
4 changes: 2 additions & 2 deletions src/slic3r/GUI/3DBed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class Bed3D
//Polygon m_polygon;
GLModel m_triangles;
//GLModel m_gridlines;
GLTexture m_texture;
// GLTexture m_texture;
// temporary texture shown until the main texture has still no levels compressed
//GLTexture m_temp_texture;
GLModel m_model;
Expand Down Expand Up @@ -154,7 +154,7 @@ class Bed3D
//BBS: add partplate related logic
// Calculate an extended bounding box from axes and current model for visualization purposes.
BoundingBoxf3 calc_extended_bounding_box(bool consider_model_offset = true) const;
void update_model_offset() const;
void update_model_offset();
//BBS: with offset
void update_bed_triangles();
static std::tuple<Type, std::string, std::string> detect_type(const Pointfs& shape);
Expand Down

0 comments on commit f598a12

Please sign in to comment.