BUGGY last WIP from stashed changes
Esse commit está contido em:
@@ -79,7 +79,11 @@ void SubDivCube::precomputeOctree(SliceMeshStorage& mesh)
|
||||
rotation_matrix = infill_angle_mat.compose(tilt);
|
||||
|
||||
|
||||
sparse_grid = new SparseGrid3D<PolygonsPointIndex>(infill_line_distance * 2, 100000);
|
||||
if (sparse_grid)
|
||||
{
|
||||
delete sparse_grid;
|
||||
}
|
||||
sparse_grid = new SparseGrid3D<PolygonsPointIndex>(infill_line_distance, 100000);
|
||||
for (unsigned int layer_idx = 0; layer_idx < mesh.layers.size(); layer_idx++)
|
||||
{
|
||||
SliceLayer& layer = mesh.layers[layer_idx];
|
||||
@@ -247,6 +251,20 @@ bool SubDivCube::isValidSubdivision(SliceMeshStorage& mesh, Point3& center, int6
|
||||
int inside;
|
||||
double part_dist;//what percentage of the radius the target layer is away from the center along the z axis. 0 - 1
|
||||
const long int layer_height = mesh.getSettingInMicrons("layer_height");
|
||||
|
||||
bool is_near_border = false;
|
||||
std::function<bool (const PolygonsPointIndex& elem)> process_func = [&is_near_border](const PolygonsPointIndex& elem)
|
||||
{
|
||||
is_near_border = true;
|
||||
return false;
|
||||
};
|
||||
sparse_grid->processNearby(rotation_matrix.apply(center), radius, process_func);
|
||||
if (is_near_border)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
long int bottom_layer = (center.z - radius) / layer_height;
|
||||
long int top_layer = (center.z + radius) / layer_height;
|
||||
for (long int test_layer = bottom_layer; test_layer <= top_layer; test_layer += 3) // steps of three. Low-hanging speed gain.
|
||||
|
||||
+43
-30
@@ -259,9 +259,13 @@ void SGI_THIS::processLine(const std::pair<Point3, Point3> line, std::function<b
|
||||
return (in > 0)? 1 : (in < 0)? -1 : 0;
|
||||
};
|
||||
|
||||
auto sign0 = [](int in)
|
||||
auto initial_step_dir = [](int pos, int dir)
|
||||
{
|
||||
return (in > 0)? 1 : 0;
|
||||
if ((pos > 0) == (dir < 0) && pos != 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return (dir > 0)? 1 : (dir < 0)? -1 : 0;
|
||||
};
|
||||
|
||||
bool continue_ = process_func(start);
|
||||
@@ -277,57 +281,66 @@ void SGI_THIS::processLine(const std::pair<Point3, Point3> line, std::function<b
|
||||
int y_dir = sign(diff.y);
|
||||
int z_dir = sign(diff.z);
|
||||
Point3 last_cell_crossing = line.first;
|
||||
std::cerr << "start\n";
|
||||
int count = 0;
|
||||
for (GridPoint now = start; now != end;)
|
||||
{
|
||||
float best_progress;
|
||||
int best_axis = -1;
|
||||
// std::cerr << now << '\n';
|
||||
std::cerr << last_cell_crossing << '\n';
|
||||
float best_progress = std::numeric_limits<float>::max();
|
||||
GridPoint dir(0,0,0);
|
||||
if (x_dir)
|
||||
{
|
||||
coord_t next_x_coord = toLowerCoord(now.x + sign0(diff.x));
|
||||
if (next_x_coord == last_cell_crossing.x)
|
||||
{
|
||||
next_x_coord = toLowerCoord(now.x + sign(diff.x));
|
||||
}
|
||||
float next_x_progress = (next_x_coord - line.first.x) / (line.second.x - line.first.x);
|
||||
int step = (last_cell_crossing == line.first)? initial_step_dir(now.x, diff.x) : sign(diff.x);
|
||||
coord_t next_x_coord = toLowerCoord(now.x + step);
|
||||
float next_x_progress = float(next_x_coord - line.first.x) / float(line.second.x - line.first.x);
|
||||
assert(next_x_progress > 0);
|
||||
best_progress = next_x_progress;
|
||||
best_axis = 0;
|
||||
dir = GridPoint(x_dir, 0, 0);
|
||||
}
|
||||
if (y_dir)
|
||||
{
|
||||
coord_t next_y_coord = toLowerCoord(now.y + sign0(diff.y));
|
||||
if (next_y_coord == last_cell_crossing.y)
|
||||
{
|
||||
next_y_coord = toLowerCoord(now.y + sign(diff.y));
|
||||
}
|
||||
float next_y_progress = (next_y_coord - line.first.y) / (line.second.y - line.first.y);
|
||||
if (next_y_progress < best_progress || best_axis == -1)
|
||||
int step = (last_cell_crossing == line.first)? initial_step_dir(now.y, diff.y) : sign(diff.y);
|
||||
coord_t next_y_coord = toLowerCoord(now.y + step);
|
||||
float next_y_progress = float(next_y_coord - line.first.y) / float(line.second.y - line.first.y);
|
||||
if (next_y_progress < best_progress)
|
||||
{
|
||||
assert(next_y_progress > 0);
|
||||
best_progress = next_y_progress;
|
||||
best_axis = 1;
|
||||
dir = GridPoint(0, y_dir, 0);
|
||||
}
|
||||
}
|
||||
if (z_dir)
|
||||
{
|
||||
coord_t next_z_coord = toLowerCoord(now.z + sign0(diff.z));
|
||||
if (next_z_coord == last_cell_crossing.z)
|
||||
{
|
||||
next_z_coord = toLowerCoord(now.z + sign(diff.z));
|
||||
}
|
||||
float next_z_progress = (next_z_coord - line.first.z) / (line.second.z - line.first.z);
|
||||
if (next_z_progress < best_progress || best_axis == -1)
|
||||
int step = (last_cell_crossing == line.first)? initial_step_dir(now.z, diff.z) : sign(diff.z);
|
||||
coord_t next_z_coord = toLowerCoord(now.z + step);
|
||||
float next_z_progress = float(next_z_coord - line.first.z) / float(line.second.z - line.first.z);
|
||||
if (next_z_progress < best_progress)
|
||||
{
|
||||
assert(next_z_progress > 0);
|
||||
best_progress = next_z_progress;
|
||||
best_axis = 2;
|
||||
dir = GridPoint(0, 0, z_dir);
|
||||
}
|
||||
}
|
||||
Point3 next_x_crossing = line.first + diff * best_progress;
|
||||
GridPoint next = toGridPoint(next_x_crossing);
|
||||
assert(next != now && (next - now).vSize2() == 1 && "We must take step of size one!");
|
||||
assert(best_progress < std::numeric_limits<float>::max());
|
||||
Point3 next_cell_crossing = line.first + diff * best_progress;
|
||||
GridPoint next = now + dir;
|
||||
assert(next != now && "We must take step of size one!");
|
||||
assert((next - now).vSize2() == 1 && "We must take step of size one!");
|
||||
bool continue_ = process_func(now);
|
||||
if (!continue_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
assert(now == end || best_progress < 1.0);
|
||||
|
||||
last_cell_crossing = next_cell_crossing;
|
||||
now = next;
|
||||
count++;
|
||||
if (count > 1000)
|
||||
{
|
||||
std::cerr << "s\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário