Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavelMikus <pavel.mikus.mail@seznam.cz>2022-08-18 18:19:06 +0300
committerPavelMikus <pavel.mikus.mail@seznam.cz>2022-08-18 18:19:58 +0300
commitbe9cae74a03c1e54cb3819336da1fd531d6f1ffd (patch)
treea9abb26f174e61e2c43553ad3b7bc868d77d03d1
parentd746ece41a75aaeaa9cdf5ba5e5a3fa51324f542 (diff)
Random seam fix - pseudorandom generator instead of rand()
-rw-r--r--src/libslic3r/GCode/SeamPlacer.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libslic3r/GCode/SeamPlacer.cpp b/src/libslic3r/GCode/SeamPlacer.cpp
index ae6cd7397..6096d6075 100644
--- a/src/libslic3r/GCode/SeamPlacer.cpp
+++ b/src/libslic3r/GCode/SeamPlacer.cpp
@@ -968,6 +968,10 @@ void pick_random_seam_point(const std::vector<SeamCandidate> &perimeter_points,
};
std::vector<Viable> viables;
+ const Vec3f pseudornd_seed = perimeter_points[viable_example_index].position;
+ float rand = std::abs(sin(pseudornd_seed.dot(Vec3f(12.9898f,78.233f, 133.3333f))) * 43758.5453f);
+ rand = rand - (int) rand;
+
for (size_t index = start_index; index < end_index; ++index) {
if (comparator.are_similar(perimeter_points[index], perimeter_points[viable_example_index])) {
// index ok, push info into viables
@@ -995,7 +999,7 @@ void pick_random_seam_point(const std::vector<SeamCandidate> &perimeter_points,
float len_sum = std::accumulate(viables.begin(), viables.end(), 0.0f, [](const float acc, const Viable &v) {
return acc + v.edge_length;
});
- float picked_len = len_sum * (rand() / (float(RAND_MAX) + 1));
+ float picked_len = len_sum * rand;
size_t point_idx = 0;
while (picked_len - viables[point_idx].edge_length > 0) {