mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-08-05 14:20:40 +08:00
FIX:Brim ears used incorrect volume ID and serialized it
jira: STUDIO-12156 Change-Id: I9038e85d05d096e83ef2e7ad3e0daaa9770e37f8
This commit is contained in:
parent
37a4a21eee
commit
a6488d49ce
@ -60,7 +60,7 @@ struct BrimPoint
|
||||
bool operator!=(const BrimPoint &sp) const { return !(sp == (*this)); }
|
||||
template<class Archive> void serialize(Archive &ar)
|
||||
{
|
||||
ar(pos, head_front_radius);
|
||||
ar(pos, head_front_radius, volume_idx);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -134,8 +134,10 @@ void GLGizmoBrimEars::render_points(const Selection &selection, bool picking) co
|
||||
const bool &error = editing_cache[i].is_error;
|
||||
if (!is_use_point(brim_point) && !hover)
|
||||
continue;
|
||||
if (brim_point.volume_idx >= 0)
|
||||
volume_matrix = selection.get_volume(brim_point.volume_idx)->get_volume_transformation().get_matrix();
|
||||
if (brim_point.volume_idx >= 0) {
|
||||
const GLVolume* v = selection.get_volume_by_object_volumn_id(brim_point.volume_idx);
|
||||
volume_matrix = v->get_volume_transformation().get_matrix();
|
||||
}
|
||||
|
||||
// keep show brim ear
|
||||
// if (is_mesh_point_clipped(brim_point.pos.cast<double>()))
|
||||
@ -314,7 +316,7 @@ bool GLGizmoBrimEars::gizmo_event(SLAGizmoEventType action, const Vec2d &mouse_p
|
||||
std::pair<Vec3f, Vec3f> pos_and_normal;
|
||||
if (unproject_on_mesh2(mouse_position, pos_and_normal)) {
|
||||
int volume_idx = m_last_hit_volume->volume_idx();
|
||||
Transform3d v_trsf = selection.get_volume(volume_idx)->get_volume_transformation().get_matrix();
|
||||
Transform3d v_trsf = selection.get_volume_by_object_volumn_id(volume_idx)->get_volume_transformation().get_matrix();
|
||||
Vec3d set_volume_trsf_pos = v_trsf.inverse() * pos_and_normal.first.cast<double>();
|
||||
render_hover_point = CacheEntry(BrimPoint(set_volume_trsf_pos.cast<float>(), m_new_point_head_diameter / 2.f, volume_idx), false, (inverse_trsf * m_world_normal).cast<float>(), true);
|
||||
} else {
|
||||
@ -350,7 +352,7 @@ bool GLGizmoBrimEars::gizmo_event(SLAGizmoEventType action, const Vec2d &mouse_p
|
||||
const GLVolume *volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||
Transform3d trsf = volume->get_instance_transformation().get_matrix();
|
||||
Transform3d inverse_trsf = volume->get_instance_transformation().get_matrix(true).inverse();
|
||||
Transform3d v_trsf = selection.get_volume(volume_idx)->get_volume_transformation().get_matrix();
|
||||
Transform3d v_trsf = selection.get_volume_by_object_volumn_id(volume_idx)->get_volume_transformation().get_matrix();
|
||||
// BBS brim ear postion is placed on the bottom side
|
||||
Vec3d world_pos = trsf * pos_and_normal.first.cast<double>();
|
||||
world_pos[2] = -0.0001;
|
||||
@ -1082,7 +1084,7 @@ void GLGizmoBrimEars::find_single()
|
||||
int volume_idx = it->second.brim_point.volume_idx;
|
||||
Geometry::Transformation trsf = volume->get_instance_transformation();
|
||||
if (volume_idx >= 0){
|
||||
const Geometry::Transformation v_trsf = selection.get_volume(volume_idx)->get_volume_transformation();
|
||||
const Geometry::Transformation v_trsf = selection.get_volume_by_object_volumn_id(volume_idx)->get_volume_transformation();
|
||||
trsf = trsf * v_trsf;
|
||||
}
|
||||
|
||||
|
@ -885,6 +885,17 @@ GLVolume *Selection::get_volume(unsigned int volume_idx) {
|
||||
return (m_valid && (volume_idx < (unsigned int) m_volumes->size())) ? (*m_volumes)[volume_idx] : nullptr;
|
||||
}
|
||||
|
||||
|
||||
const GLVolume *Selection::get_volume_by_object_volumn_id(unsigned int volume_id) const
|
||||
{
|
||||
if (!m_valid || m_volumes->size() <= 0)
|
||||
return nullptr;
|
||||
for (const GLVolume *v : *m_volumes) {
|
||||
if (v->object_idx() == get_object_idx() && v->volume_idx() == volume_id)
|
||||
return const_cast<GLVolume *>(v);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
const BoundingBoxf3& Selection::get_bounding_box() const
|
||||
{
|
||||
if (!m_bounding_box.has_value()) {
|
||||
|
@ -380,6 +380,7 @@ public:
|
||||
const IndicesList& get_volume_idxs() const { return m_list; }
|
||||
const GLVolume* get_volume(unsigned int volume_idx) const;
|
||||
GLVolume* get_volume(unsigned int volume_idx);
|
||||
const GLVolume* get_volume_by_object_volumn_id(unsigned int volume_id) const;
|
||||
const GLVolume* get_first_volume() const { return get_volume(*m_list.begin()); }
|
||||
const ObjectIdxsToInstanceIdxsMap& get_content() const { return m_cache.content; }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user