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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2022-03-17 14:48:41 +0300
committerJacques Lucke <jacques@blender.org>2022-03-17 14:48:41 +0300
commitd0968a9c52019b817c001562adbb875780d94786 (patch)
tree4f5548adcd757cb75443bde77b082487fbf81839 /source/blender/nodes
parent8f68cff01b85bfde18c9442e6a638eda181ee159 (diff)
BLI: add probabilistic rounding utility
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc6
1 files changed, 2 insertions, 4 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
index bdd4d74fe4b..8e28a4ba9b9 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
@@ -114,10 +114,8 @@ static void sample_mesh_surface(const Mesh &mesh,
const int looptri_seed = noise::hash(looptri_index, seed);
RandomNumberGenerator looptri_rng(looptri_seed);
- const float points_amount_fl = area * base_density * looptri_density_factor;
- const float add_point_probability = fractf(points_amount_fl);
- const bool add_point = add_point_probability > looptri_rng.get_float();
- const int point_amount = (int)points_amount_fl + (int)add_point;
+ const int point_amount = looptri_rng.round_probabilistic(area * base_density *
+ looptri_density_factor);
for (int i = 0; i < point_amount; i++) {
const float3 bary_coord = looptri_rng.get_barycentric_coordinates();