ENH: Change the collision calculation

of the wipe tower's outer wall to use the actual outer wall path.

jira: none
Change-Id: Ib45ecbc328c88c1abe6d9e8567f715331a3ddd37
(cherry picked from commit 0a20f1fe6d6d63cdcb13bc19fd9ae553f45b6f59)
This commit is contained in:
jiangkai.zhao
2025-02-10 15:58:34 +08:00
committed by Noisyfox
parent f133dd1733
commit d463858fda
5 changed files with 49 additions and 39 deletions

View File

@@ -600,7 +600,7 @@ struct FakeWipeTower
float rotation_angle;
float cone_angle;
Vec2d plate_origin;
BoundingBoxf real_bbx;
Polylines outer_wall; //wipe tower's true outer wall
void set_fake_extrusion_data(Vec2f p, float w, float h, float lh, float d, float bd, Vec2d o)
{
@@ -625,11 +625,6 @@ struct FakeWipeTower
cone_angle = ca;
plate_origin = o;
}
void set_bbx()
{
real_bbx.min += pos.cast<double>();
real_bbx.max += pos.cast<double>();
}
void set_pos(Vec2f p) { pos = p; }
void set_pos_and_rotation(const Vec2f& p, float rotation) { pos = p; rotation_angle = rotation; }
@@ -639,10 +634,8 @@ struct FakeWipeTower
int d = scale_(depth);
int w = scale_(width);
int bd = scale_(brim_width);
//Point minCorner = {scale_(pos.x()), scale_(pos.y())};
//Point maxCorner = {minCorner.x() + w, minCorner.y() + d};
Point minCorner = {scale_(real_bbx.min.x()), scale_(real_bbx.min.y())};
Point maxCorner = {scale_(real_bbx.max.x()), scale_(real_bbx.max.y())};
Point minCorner = {scale_(pos.x()), scale_(pos.y())};
Point maxCorner = {minCorner.x() + w, minCorner.y() + d};
std::vector<ExtrusionPaths> paths;
for (float h = 0.f; h < height; h += layer_height) {
@@ -650,13 +643,26 @@ struct FakeWipeTower
path.polyline = {minCorner, {maxCorner.x(), minCorner.y()}, maxCorner, {minCorner.x(), maxCorner.y()}, minCorner};
paths.push_back({path});
//if (h == 0.f) { // add brim
// ExtrusionPath fakeBrim(ExtrusionRole::erBrim, 0.0, 0.0, layer_height);
// Point wtbminCorner = {minCorner - Point{bd, bd}};
// Point wtbmaxCorner = {maxCorner + Point{bd, bd}};
// fakeBrim.polyline = {wtbminCorner, {wtbmaxCorner.x(), wtbminCorner.y()}, wtbmaxCorner, {wtbminCorner.x(), wtbmaxCorner.y()}, wtbminCorner};
// paths.back().push_back(fakeBrim);
//}
if (h == 0.f) { // add brim
ExtrusionPath fakeBrim(ExtrusionRole::erBrim, 0.0, 0.0, layer_height);
Point wtbminCorner = {minCorner - Point{bd, bd}};
Point wtbmaxCorner = {maxCorner + Point{bd, bd}};
fakeBrim.polyline = {wtbminCorner, {wtbmaxCorner.x(), wtbminCorner.y()}, wtbmaxCorner, {wtbminCorner.x(), wtbmaxCorner.y()}, wtbminCorner};
paths.back().push_back(fakeBrim);
}
}
return paths;
}
std::vector<ExtrusionPaths> getTrueExtrusionPathsFromWipeTower() const
{
std::vector<ExtrusionPaths> paths;
Point trans = {scale_(pos.x()), scale_(pos.y())};
for (auto &polyline : outer_wall) {
ExtrusionPath path(ExtrusionRole::erWipeTower, 0.0, 0.0, layer_height);
path.polyline.points.reserve( polyline.points.size());
for (auto &p : polyline.points) path.polyline.points.push_back(p + trans);
paths.push_back({path});
}
return paths;
}