[Bf-blender-cvs] [8a96d864a67] temp-geometry-nodes-distribute-points-cleanup: Simplify calls

Dalai Felinto noreply at git.blender.org
Fri Dec 11 02:00:48 CET 2020


Commit: 8a96d864a67bbe3d2c0cd338cd007d376f3d83dc
Author: Dalai Felinto
Date:   Thu Dec 10 11:52:47 2020 +0100
Branches: temp-geometry-nodes-distribute-points-cleanup
https://developer.blender.org/rB8a96d864a67bbe3d2c0cd338cd007d376f3d83dc

Simplify calls

===================================================================

M	source/blender/nodes/geometry/nodes/cySampleElim.hh
M	source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc

===================================================================

diff --git a/source/blender/nodes/geometry/nodes/cySampleElim.hh b/source/blender/nodes/geometry/nodes/cySampleElim.hh
index 7959d03114f..b089afa2843 100644
--- a/source/blender/nodes/geometry/nodes/cySampleElim.hh
+++ b/source/blender/nodes/geometry/nodes/cySampleElim.hh
@@ -134,21 +134,11 @@ template<> PointCloud<blender::float3, float, 3, size_t>::~PointCloud()
   BLI_kdtree_3d_free((KDTree_3d *)kd_tree);
 }
 
-// ------
-// Blender functions end
-// ------
-
-//! An implementation of the weighted sample elimination method.
-//!
-
-//! This class keeps a number of parameters for the weighted sample elimination
-//! algorithm. The main algorithm is implemented in the Eliminate method.
-
 template<typename PointType, typename FType, int DIMENSIONS, typename SIZE_TYPE = size_t>
 class WeightedSampleElimination {
  public:
   //! The constructor sets the default parameters.
-  WeightedSampleElimination()
+  WeightedSampleElimination(PointType const &bmax)
   {
     for (int d = 0; d < DIMENSIONS; d++) {
       boundsMin[d] = FType(0);
@@ -157,122 +147,11 @@ class WeightedSampleElimination {
     alpha = FType(8);
     beta = FType(0.65);
     gamma = FType(1.5);
-    tiling = false;
+    tiling = true;
     weightLimiting = true;
-  }
-
-  //! Tiling determines whether the generated samples are tile-able.
-  //! Tiling is off by default, but it is a good idea to turn it on for
-  //! box-shaped sampling domains. Note that when tiling is off, weighted sample
-  //! elimination is less likely to eliminate samples near the boundaries of the
-  //! sampling domain. If you turn on tiling, make sure to set the correct
-  //! boundaries for the sampling domain.
-  void SetTiling(bool on = true)
-  {
-    tiling = on;
-  }
-
-  //! Returns true if the tiling parameter is turned on.
-  bool IsTiling() const
-  {
-    return tiling;
-  }
-
-  //! Weight limiting is used by the default weight function and it is on by
-  //! default. Using weight limiting typically leads to more pronounced blue
-  //! noise characteristics; therefore, it is recommended. The beta parameter
-  //! determines the amount of weight limiting. Setting the beta parameter to
-  //! zero effectively turns off weight limiting.
-  void SetWeightLimiting(bool on = true)
-  {
-    weightLimiting = on;
-  }
-
-  //! Returns true if weight limiting is turned on.
-  bool IsWeightLimiting() const
-  {
-    return weightLimiting;
-  }
-
-  //! Returns the minimum bounds of the sampling domain.
-  //! The sampling domain boundaries are used for tiling and computing the
-  //! maximum possible Poisson disk radius for the sampling domain. The default
-  //! boundaries are between 0 and 1.
-  PointType const &GetBoundsMin() const
-  {
-    return boundsMin;
-  }
-
-  //! Returns the maximum bounds of the sampling domain.
-  //! The sampling domain boundaries are used for tiling and computing the
-  //! maximum possible Poisson disk radius for the sampling domain. The default
-  //! boundaries are between 0 and 1.
-  PointType const &GetBoundsMax() const
-  {
-    return boundsMax;
-  }
-
-  //! Sets the minimum bounds of the sampling domain.
-  //! The sampling domain boundaries are used for tiling and computing the
-  //! maximum possible Poisson disk radius for the sampling domain. The default
-  //! boundaries are between 0 and 1.
-  void SetBoundsMin(PointType const &bmin)
-  {
-    boundsMin = bmin;
-  }
-
-  //! Sets the maximum bounds of the sampling domain.
-  //! The sampling domain boundaries are used for tiling and computing the
-  //! maximum possible Poisson disk radius for the sampling domain. The default
-  //! boundaries are between 0 and 1.
-  void SetBoundsMax(PointType const &bmax)
-  {
     boundsMax = bmax;
   }
 
-  //! Sets the alpha parameter that is used by the default weight function.
-  void SetParamAlpha(FType a)
-  {
-    alpha = a;
-  }
-
-  //! Returns the alpha parameter that is used by the default weight function.
-  FType GetParamAlpha() const
-  {
-    return alpha;
-  }
-
-  //! Sets the beta parameter that is used by weight limiting for the default
-  //! weight function. Setting the beta parameter to zero effectively turns off
-  //! weight limiting. If weight limiting is off, this parameter has no effect.
-  void SetParamBeta(FType b)
-  {
-    beta = b;
-  }
-
-  //! Returns the beta parameter that is used by weight limiting for the default
-  //! weight function.
-  FType GetParamBeta() const
-  {
-    return beta;
-  }
-
-  //! Sets the gamma parameter that is used by weight limiting for the default
-  //! weight function. The gamma parameter adjusts weight limiting based on the
-  //! ratio of the input and output counts. If weight limiting is off, this
-  //! parameter has no effect.
-  void SetParamGamma(FType c)
-  {
-    gamma = c;
-  }
-
-  //! Returns the gamma parameter that is used by weight limiting for the
-  //! default weight function.
-  FType GetParamGamma() const
-  {
-    return gamma;
-  }
-
   //! This is the main method that uses weighted sample elimination for
   //! selecting a subset of samples with blue noise (Poisson disk)
   //! characteristics from a given input sample set (inputPoints). The selected
diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
index 38c8ec026d9..b0259370bf0 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
@@ -174,15 +174,10 @@ static Vector<float3> poisson_scatter_points_from_mesh(const Mesh *mesh,
   const float required_area = output_points_target * (2.0f * sqrtf(3.0f) * min_dist * min_dist);
   const float point_scale_multiplier = sqrtf(required_area);
 
-  cy::WeightedSampleElimination<float3, float, 3, size_t> wse;
   {
     const int rnd_seed = BLI_hash_int(seed);
     RandomNumberGenerator point_rng(rnd_seed);
 
-    float3 bounds_max = float3(point_scale_multiplier, point_scale_multiplier, 0);
-    wse.SetBoundsMax(bounds_max);
-    wse.SetTiling();
-
     for (int i = 0; i < points.size(); i++) {
       points[i].x = point_rng.get_float() * point_scale_multiplier;
       points[i].y = point_rng.get_float() * point_scale_multiplier;
@@ -194,8 +189,10 @@ static Vector<float3> poisson_scatter_points_from_mesh(const Mesh *mesh,
   Vector<float3> output_points(output_points_target);
 
   bool is_progressive = true;
-
   float d_max = 2 * min_dist;
+
+  float3 bounds_max = float3(point_scale_multiplier, point_scale_multiplier, 0);
+  cy::WeightedSampleElimination<float3, float, 3, size_t> wse(bounds_max);
   wse.Eliminate(points.data(),
                 points.size(),
                 output_points.data(),



More information about the Bf-blender-cvs mailing list