Apply transform to meshes before displaying the 3D preview canvas

This commit is contained in:
Alessandro Ranellucci 2014-06-14 22:51:57 +02:00
parent 707dd8db86
commit 57a9486692

View File

@ -77,7 +77,7 @@ sub new {
sub load_object { sub load_object {
my ($self, $object) = @_; my ($self, $object) = @_;
my $bb = $object->raw_mesh->bounding_box; my $bb = $object->instance_bounding_box;
my $center = $bb->center; my $center = $bb->center;
$self->object_shift(Slic3r::Pointf3->new(-$center->x, -$center->y, -$bb->z_min)); #,, $self->object_shift(Slic3r::Pointf3->new(-$center->x, -$center->y, -$bb->z_min)); #,,
$bb->translate(@{ $self->object_shift }); $bb->translate(@{ $self->object_shift });
@ -91,6 +91,7 @@ sub load_object {
my @volumes = sort { ($a->modifier // 0) <=> ($b->modifier // 0) } @{$object->volumes}; my @volumes = sort { ($a->modifier // 0) <=> ($b->modifier // 0) } @{$object->volumes};
foreach my $volume (@volumes) { foreach my $volume (@volumes) {
my $mesh = $volume->mesh->clone; my $mesh = $volume->mesh->clone;
$object->instances->[0]->transform_mesh($mesh);
$mesh->translate(@{ $self->object_shift }); $mesh->translate(@{ $self->object_shift });
my $material_id = $volume->material_id // '_'; my $material_id = $volume->material_id // '_';