Fix for SPE-1618 - Place on face gizmo doesn't work correctly with instances
This commit is contained in:
parent
b0cc0e98fa
commit
88f4fa20df
@ -60,11 +60,13 @@ void GLGizmoFlatten::data_changed(bool is_serializing)
|
|||||||
{
|
{
|
||||||
const Selection & selection = m_parent.get_selection();
|
const Selection & selection = m_parent.get_selection();
|
||||||
const ModelObject *model_object = nullptr;
|
const ModelObject *model_object = nullptr;
|
||||||
|
int instance_id = -1;
|
||||||
if (selection.is_single_full_instance() ||
|
if (selection.is_single_full_instance() ||
|
||||||
selection.is_from_single_object() ) {
|
selection.is_from_single_object() ) {
|
||||||
model_object = selection.get_model()->objects[selection.get_object_idx()];
|
model_object = selection.get_model()->objects[selection.get_object_idx()];
|
||||||
|
instance_id = selection.get_instance_idx();
|
||||||
}
|
}
|
||||||
set_flattening_data(model_object);
|
set_flattening_data(model_object, instance_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLGizmoFlatten::on_init()
|
bool GLGizmoFlatten::on_init()
|
||||||
@ -156,9 +158,9 @@ void GLGizmoFlatten::on_unregister_raycasters_for_picking()
|
|||||||
m_planes_casters.clear();
|
m_planes_casters.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoFlatten::set_flattening_data(const ModelObject* model_object)
|
void GLGizmoFlatten::set_flattening_data(const ModelObject* model_object, int instance_id)
|
||||||
{
|
{
|
||||||
if (model_object != m_old_model_object) {
|
if (model_object != m_old_model_object || instance_id != m_old_instance_id) {
|
||||||
m_planes.clear();
|
m_planes.clear();
|
||||||
on_unregister_raycasters_for_picking();
|
on_unregister_raycasters_for_picking();
|
||||||
}
|
}
|
||||||
@ -363,6 +365,7 @@ void GLGizmoFlatten::update_planes()
|
|||||||
m_first_instance_scale = mo->instances.front()->get_scaling_factor();
|
m_first_instance_scale = mo->instances.front()->get_scaling_factor();
|
||||||
m_first_instance_mirror = mo->instances.front()->get_mirror();
|
m_first_instance_mirror = mo->instances.front()->get_mirror();
|
||||||
m_old_model_object = mo;
|
m_old_model_object = mo;
|
||||||
|
m_old_instance_id = m_c->selection_info()->get_active_instance();
|
||||||
|
|
||||||
// And finally create respective VBOs. The polygon is convex with
|
// And finally create respective VBOs. The polygon is convex with
|
||||||
// the vertices in order, so triangulation is trivial.
|
// the vertices in order, so triangulation is trivial.
|
||||||
|
@ -39,6 +39,7 @@ private:
|
|||||||
std::vector<std::shared_ptr<SceneRaycasterItem>> m_planes_casters;
|
std::vector<std::shared_ptr<SceneRaycasterItem>> m_planes_casters;
|
||||||
bool m_mouse_left_down = false; // for detection left_up of this gizmo
|
bool m_mouse_left_down = false; // for detection left_up of this gizmo
|
||||||
const ModelObject* m_old_model_object = nullptr;
|
const ModelObject* m_old_model_object = nullptr;
|
||||||
|
int m_old_instance_id{ -1 };
|
||||||
|
|
||||||
void update_planes();
|
void update_planes();
|
||||||
bool is_plane_update_necessary() const;
|
bool is_plane_update_necessary() const;
|
||||||
@ -46,7 +47,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
GLGizmoFlatten(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
GLGizmoFlatten(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||||
|
|
||||||
void set_flattening_data(const ModelObject* model_object);
|
void set_flattening_data(const ModelObject* model_object, int instance_id);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Apply rotation on select plane
|
/// Apply rotation on select plane
|
||||||
|
Loading…
Reference in New Issue
Block a user