GCodeViewer -> Added bounding box to fix camera frustum tighting
This commit is contained in:
parent
9776d7c5a1
commit
83816afb3f
3 changed files with 12 additions and 3 deletions
|
@ -104,6 +104,7 @@ void GCodeViewer::reset()
|
|||
buffer.reset();
|
||||
}
|
||||
|
||||
m_bounding_box = BoundingBoxf3();
|
||||
m_extrusions.reset_role_visibility_flags();
|
||||
m_shells.volumes.clear();
|
||||
m_layers_zs = std::vector<double>();
|
||||
|
@ -198,13 +199,14 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result)
|
|||
if (m_vertices.vertices_count == 0)
|
||||
return;
|
||||
|
||||
// vertex data -> extract from result
|
||||
// vertex data / bounding box -> extract from result
|
||||
std::vector<float> vertices_data;
|
||||
for (const GCodeProcessor::MoveVertex& move : gcode_result.moves)
|
||||
{
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
vertices_data.insert(vertices_data.end(), move.position[j]);
|
||||
m_bounding_box.merge(move.position.cast<double>());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -97,6 +97,7 @@ public:
|
|||
private:
|
||||
VBuffer m_vertices;
|
||||
std::vector<IBuffer> m_buffers{ static_cast<size_t>(GCodeProcessor::EMoveType::Extrude) };
|
||||
BoundingBoxf3 m_bounding_box;
|
||||
|
||||
unsigned int m_last_result_id{ 0 };
|
||||
std::vector<double> m_layers_zs;
|
||||
|
@ -117,6 +118,7 @@ public:
|
|||
void reset();
|
||||
void render() const;
|
||||
|
||||
const BoundingBoxf3& get_bounding_box() const { return m_bounding_box; }
|
||||
const std::vector<double>& get_layers_zs() const { return m_layers_zs; };
|
||||
|
||||
EViewType get_view_type() const { return m_view_type; }
|
||||
|
|
|
@ -2841,9 +2841,8 @@ void GLCanvas3D::load_gcode_preview_2(const GCodeProcessor::Result& gcode_result
|
|||
}
|
||||
out.close();
|
||||
}
|
||||
|
||||
m_gcode_viewer.load(gcode_result , *this->fff_print(), m_initialized);
|
||||
#endif // ENABLE_GCODE_VIEWER_DEBUG_OUTPUT
|
||||
m_gcode_viewer.load(gcode_result, *this->fff_print(), m_initialized);
|
||||
}
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
|
@ -5213,6 +5212,12 @@ BoundingBoxf3 GLCanvas3D::_max_bounding_box(bool include_gizmos, bool include_be
|
|||
#else
|
||||
bb.merge(m_bed.get_bounding_box(include_bed_model));
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
if (!m_main_toolbar.is_enabled())
|
||||
bb.merge(m_gcode_viewer.get_bounding_box());
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
return bb;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue