@@ -1298,9 +1298,9 @@ void GCodeExport::writeRetraction(const RetractionConfig& config, bool force, bo
12981298 extr_attr.prime_volume_ += config.prime_volume ;
12991299}
13001300
1301- void GCodeExport::writeZhopStart (const coord_t hop_height, Velocity speed /* = 0*/ , const double retract_distance, const Ratio& retract_ratio)
1301+ void GCodeExport::writeZhopStart (const coord_t hop_height, Velocity speed /* = 0*/ , const std::optional< double > retract_distance, const Ratio& retract_ratio)
13021302{
1303- if (retract_ratio > 0.0 && retract_ratio < 1.0 )
1303+ if (retract_distance. has_value () && retract_ratio > 0.0 && retract_ratio < 1.0 )
13041304 {
13051305 // We have to split the z-hop move in two sub-moves, one with retraction and one without
13061306 writeZhopStart (hop_height * retract_ratio, speed, retract_distance, 0.0 );
@@ -1314,7 +1314,7 @@ void GCodeExport::writeZhopStart(const coord_t hop_height, Velocity speed /*= 0*
13141314 }
13151315}
13161316
1317- void GCodeExport::writeZhopEnd (Velocity speed /* = 0*/ , const coord_t height, const double prime_distance, const Ratio& prime_ratio)
1317+ void GCodeExport::writeZhopEnd (Velocity speed /* = 0*/ , const coord_t height, const std::optional< double > prime_distance, const Ratio& prime_ratio)
13181318{
13191319 if (z_hop_prime_leftover_.has_value ())
13201320 {
@@ -1325,7 +1325,7 @@ void GCodeExport::writeZhopEnd(Velocity speed /*= 0*/, const coord_t height, con
13251325
13261326 if (is_z_hopped_)
13271327 {
1328- if (prime_ratio > 0.0 && prime_ratio < 1.0 )
1328+ if (prime_distance. has_value () && prime_ratio > 0.0 && prime_ratio < 1.0 )
13291329 {
13301330 // We have to split the z-hop move in two sub-moves, one without prime and one with
13311331 writeZhopEnd (speed, is_z_hopped_ * prime_ratio, extruder_attr_[current_extruder_].retraction_e_amount_current_ , 0.0 );
@@ -1338,15 +1338,19 @@ void GCodeExport::writeZhopEnd(Velocity speed /*= 0*/, const coord_t height, con
13381338 }
13391339}
13401340
1341- void GCodeExport::writeZhop (Velocity speed /* = 0*/ , const coord_t height, const double retract_distance)
1341+ void GCodeExport::writeZhop (Velocity speed /* = 0*/ , const coord_t height, const std::optional< double > retract_distance)
13421342{
13431343 if (speed == 0 )
13441344 {
13451345 const ExtruderTrain& extruder = Application::getInstance ().current_slice_ ->scene .extruders [current_extruder_];
13461346 speed = extruder.settings_ .get <Velocity>(" speed_z_hop" );
13471347 }
13481348
1349- RetractionAmounts retraction_amounts = computeRetractionAmounts (extruder_attr_[current_extruder_], retract_distance);
1349+ RetractionAmounts retraction_amounts;
1350+ if (retract_distance.has_value ())
1351+ {
1352+ retraction_amounts = computeRetractionAmounts (extruder_attr_[current_extruder_], *retract_distance);
1353+ }
13501354
13511355 is_z_hopped_ = height;
13521356 const coord_t target_z = current_layer_z_ + is_z_hopped_;
0 commit comments