Fixed assert after try to add Part to Object with several Instances from the ObjectList.

+ Fixed selection on the 3DScene before a context menu showing
This commit is contained in:
YuSanka 2019-03-07 10:08:21 +01:00
parent 2a6de99f06
commit aa0737fa5e
2 changed files with 12 additions and 5 deletions

View file

@ -5308,14 +5308,18 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
&& m_gizmos.get_current_type() != Gizmos::SlaSupports) // disable context menu when the gizmo is open
{
// forces the selection of the volume
if (!m_selection.is_multiple_full_instance())
/** #ys_FIXME_to_delete after testing:
* Next condition allows a multiple instance selection for the context menu,
* which has no reason. So it's commented till next testing
*/
// if (!m_selection.is_multiple_full_instance()) // #ys_FIXME_to_delete
m_selection.add(m_hover_volume_id);
m_gizmos.update_on_off_state(m_selection);
post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT));
_update_gizmos_data();
wxGetApp().obj_manipul()->update_settings_value(m_selection);
// // forces a frame render to update the view before the context menu is shown
// render();
// forces a frame render to update the view before the context menu is shown
render();
Vec2d logical_pos = pos.cast<double>();
#if ENABLE_RETINA_GL

View file

@ -1256,8 +1256,11 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const Mode
const GLCanvas3D::Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
assert(obj_idx == selection.get_object_idx());
// Selected instance index in ModelObject. Only valid if there is only one instance selected in the selection.
int instance_idx = selection.get_instance_idx();
/** Any changes of the Object's composition is duplicated for all Object's Instances
* So, It's enough to take a bounding box of a first selected Instance and calculate Part(generic_subobject) position
*/
int instance_idx = *selection.get_instance_idxs().begin();
assert(instance_idx != -1);
if (instance_idx == -1)
return;