From 91b9b8aebfa634ee7a6f26284a5b782c72de0fb6 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 23 May 2018 12:49:56 +0200 Subject: Fixed wrong layer height texture updates when using multiple objects --- lib/Slic3r/GUI/3DScene.pm | 21 +++++++++++++++++++-- xs/xsp/Print.xsp | 3 +++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 33c0e8d37..fca22bedd 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -360,6 +360,7 @@ sub _variable_layer_thickness_action { my ($self, $mouse_event, $do_modification) = @_; # A volume is selected. Test, whether hovering over a layer thickness bar. return if $self->{layer_height_edit_last_object_id} == -1; + if (defined($mouse_event)) { my ($bar_left, $bar_top, $bar_right, $bar_bottom) = $self->_variable_layer_thickness_bar_rect_screen; $self->{layer_height_edit_last_z} = unscale($self->{print}->get_object($self->{layer_height_edit_last_object_id})->size->z) @@ -374,9 +375,20 @@ sub _variable_layer_thickness_action { $self->{layer_height_edit_strength}, $self->{layer_height_edit_band_width}, $self->{layer_height_edit_last_action}); - $self->volumes->[$self->{layer_height_edit_last_object_id}]->generate_layer_height_texture( + + # searches the id of the first volume of the selected object + my $volume_idx = 0; + for my $i (0..$self->{layer_height_edit_last_object_id} - 1) { + my $obj = $self->{print}->get_object($i); + for my $j (0..$obj->region_volumes_count - 1) { + $volume_idx += scalar @{$obj->get_region_volumes($j)}; + } + } + + $self->volumes->[$volume_idx]->generate_layer_height_texture( $self->{print}->get_object($self->{layer_height_edit_last_object_id}), 1); - $self->Refresh; + + $self->Refresh; # Automatic action on mouse down with the same coordinate. $self->{layer_height_edit_timer}->Start(100, wxTIMER_CONTINUOUS); } @@ -1623,6 +1635,11 @@ sub draw_active_object_annotations { $self->{layer_height_edit_shader}->set_uniform('z_cursor', $z_max * $z_cursor_relative); $self->{layer_height_edit_shader}->set_uniform('z_cursor_band_width', $self->{layer_height_edit_band_width}); glBindTexture(GL_TEXTURE_2D, $self->{layer_preview_z_texture_id}); +#============================================================================================================================================= + print "texture id: "; + print $self->{layer_preview_z_texture_id}; + print "\n"; +#============================================================================================================================================= glTexImage2D_c(GL_TEXTURE_2D, 0, GL_RGBA8, $volume->layer_height_texture_width, $volume->layer_height_texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glTexImage2D_c(GL_TEXTURE_2D, 1, GL_RGBA8, $volume->layer_height_texture_width / 2, $volume->layer_height_texture_height / 2, diff --git a/xs/xsp/Print.xsp b/xs/xsp/Print.xsp index ef9c5345f..702919514 100644 --- a/xs/xsp/Print.xsp +++ b/xs/xsp/Print.xsp @@ -52,6 +52,9 @@ _constant() int region_count() %code%{ RETVAL = THIS->print()->regions.size(); %}; + int region_volumes_count() + %code%{ RETVAL = THIS->region_volumes.size(); %}; + Ref print(); Ref model_object(); Ref config() -- cgit v1.2.3 From d5268fdc97adde08bbc5165cfbde4714efc583fa Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 28 May 2018 13:04:01 +0200 Subject: Removed unneeded debug output --- lib/Slic3r/GUI/3DScene.pm | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index fca22bedd..5fc1e0b18 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1635,11 +1635,6 @@ sub draw_active_object_annotations { $self->{layer_height_edit_shader}->set_uniform('z_cursor', $z_max * $z_cursor_relative); $self->{layer_height_edit_shader}->set_uniform('z_cursor_band_width', $self->{layer_height_edit_band_width}); glBindTexture(GL_TEXTURE_2D, $self->{layer_preview_z_texture_id}); -#============================================================================================================================================= - print "texture id: "; - print $self->{layer_preview_z_texture_id}; - print "\n"; -#============================================================================================================================================= glTexImage2D_c(GL_TEXTURE_2D, 0, GL_RGBA8, $volume->layer_height_texture_width, $volume->layer_height_texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glTexImage2D_c(GL_TEXTURE_2D, 1, GL_RGBA8, $volume->layer_height_texture_width / 2, $volume->layer_height_texture_height / 2, -- cgit v1.2.3 From 40bb0b6f55c5702da34b801eb23ee891a06c723d Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 5 Jun 2018 16:07:09 +0200 Subject: Fixed overflow in Polygon::area() --- xs/src/libslic3r/Polygon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/libslic3r/Polygon.cpp b/xs/src/libslic3r/Polygon.cpp index 27f9a2ca1..b5fd7e64f 100644 --- a/xs/src/libslic3r/Polygon.cpp +++ b/xs/src/libslic3r/Polygon.cpp @@ -103,7 +103,7 @@ double Polygon::area() const double a = 0.; for (size_t i = 0, j = n - 1; i < n; ++i) { - a += double(points[j].x + points[i].x) * double(points[i].y - points[j].y); + a += ((double)points[j].x + (double)points[i].x) * ((double)points[i].y - (double)points[j].y); j = i; } return 0.5 * a; -- cgit v1.2.3