Minor improvement to plater: select/drag uppermost object when user clicks on overlapping objects
This commit is contained in:
parent
a5df9fb795
commit
875035c09e
1 changed files with 4 additions and 2 deletions
|
@ -183,9 +183,11 @@ sub mouse_event {
|
||||||
my $point = $self->point_to_model_units([ $pos->x, $pos->y ]); #]]
|
my $point = $self->point_to_model_units([ $pos->x, $pos->y ]); #]]
|
||||||
if ($event->ButtonDown) {
|
if ($event->ButtonDown) {
|
||||||
$self->{on_select_object}->(undef);
|
$self->{on_select_object}->(undef);
|
||||||
OBJECTS: for my $obj_idx (0 .. $#{$self->{objects}}) {
|
# traverse objects and instances in reverse order, so that if they're overlapping
|
||||||
|
# we get the one that gets drawn last, thus on top (as user expects that to move)
|
||||||
|
OBJECTS: for my $obj_idx (reverse 0 .. $#{$self->{objects}}) {
|
||||||
my $object = $self->{objects}->[$obj_idx];
|
my $object = $self->{objects}->[$obj_idx];
|
||||||
for my $instance_idx (0 .. $#{ $object->instance_thumbnails }) {
|
for my $instance_idx (reverse 0 .. $#{ $object->instance_thumbnails }) {
|
||||||
my $thumbnail = $object->instance_thumbnails->[$instance_idx];
|
my $thumbnail = $object->instance_thumbnails->[$instance_idx];
|
||||||
if (defined first { $_->contour->contains_point($point) } @$thumbnail) {
|
if (defined first { $_->contour->contains_point($point) } @$thumbnail) {
|
||||||
$self->{on_select_object}->($obj_idx);
|
$self->{on_select_object}->($obj_idx);
|
||||||
|
|
Loading…
Reference in a new issue