[Bf-blender-cvs] [7d1d9e60150] master: Cleanup: rename ParticleSettings.child_nbr => child_percent

Campbell Barton noreply at git.blender.org
Fri Mar 25 02:12:52 CET 2022


Commit: 7d1d9e601503fb7e921c935524fec1469363c121
Author: Campbell Barton
Date:   Fri Mar 25 12:04:21 2022 +1100
Branches: master
https://developer.blender.org/rB7d1d9e601503fb7e921c935524fec1469363c121

Cleanup: rename ParticleSettings.child_nbr => child_percent

child_nbr was used as a percentage as well as the final
number of particles. Rename to avoid confusion.

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

M	source/blender/blenkernel/intern/particle.c
M	source/blender/blenkernel/intern/particle_distribute.c
M	source/blender/blenkernel/intern/particle_system.c
M	source/blender/blenloader/intern/versioning_legacy.c
M	source/blender/makesdna/DNA_particle_defaults.h
M	source/blender/makesdna/DNA_particle_types.h
M	source/blender/makesdna/intern/dna_rename_defs.h
M	source/blender/makesrna/intern/rna_particle.c

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

diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index c47b22dcd34..9ea1336a95a 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -2661,8 +2661,8 @@ void psys_find_parents(ParticleSimulationData *sim, const bool use_render_params
   int from = PART_FROM_FACE;
   totparent = (int)(totchild * part->parents * 0.3f);
 
-  if (use_render_params && part->child_nbr && part->ren_child_nbr) {
-    totparent *= (float)part->child_nbr / (float)part->ren_child_nbr;
+  if (use_render_params && part->child_percent && part->child_render_percent) {
+    totparent *= (float)part->child_percent / (float)part->child_render_percent;
   }
 
   /* hard limit, workaround for it being ignored above */
@@ -2736,8 +2736,8 @@ static bool psys_thread_context_init_path(ParticleThreadContext *ctx,
   if (totchild && part->childtype == PART_CHILD_FACES) {
     totparent = (int)(totchild * part->parents * 0.3f);
 
-    if (use_render_params && part->child_nbr && part->ren_child_nbr) {
-      totparent *= (float)part->child_nbr / (float)part->ren_child_nbr;
+    if (use_render_params && part->child_percent && part->child_render_percent) {
+      totparent *= (float)part->child_percent / (float)part->child_render_percent;
     }
 
     /* part->parents could still be 0 so we can't test with totparent */
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index 83fb52ce1ef..d2c3776d4ea 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -64,14 +64,14 @@ static void distribute_simple_children(Scene *scene,
 {
   ChildParticle *cpa = NULL;
   int i, p;
-  int child_nbr = psys_get_child_number(scene, psys, use_render_params);
-  int totpart = psys_get_tot_child(scene, psys, use_render_params);
+  const int child_num = psys_get_child_number(scene, psys, use_render_params);
+  const int totpart = psys_get_tot_child(scene, psys, use_render_params);
   RNG *rng = BLI_rng_new_srandom(31415926 + psys->seed + psys->child_seed);
 
   alloc_child_particles(psys, totpart);
 
   cpa = psys->child;
-  for (i = 0; i < child_nbr; i++) {
+  for (i = 0; i < child_num; i++) {
     for (p = 0; p < psys->totpart; p++, cpa++) {
       float length = 2.0;
       cpa->parent = p;
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 1a74008c405..7fdc60a265b 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -98,9 +98,9 @@ float psys_get_current_display_percentage(ParticleSystem *psys, const bool use_r
   ParticleSettings *part = psys->part;
 
   if ((use_render_params &&
-       !particles_are_dynamic(psys)) ||          /* non-dynamic particles can be rendered fully */
-      (part->child_nbr && part->childtype) ||    /* display percentage applies to children */
-      (psys->pointcache->flag & PTCACHE_BAKING)) /* baking is always done with full amount */
+       !particles_are_dynamic(psys)) ||           /* non-dynamic particles can be rendered fully */
+      (part->child_percent && part->childtype) || /* display percentage applies to children */
+      (psys->pointcache->flag & PTCACHE_BAKING))  /* baking is always done with full amount */
   {
     return 1.0f;
   }
@@ -287,10 +287,10 @@ int psys_get_child_number(Scene *scene, ParticleSystem *psys, const bool use_ren
   }
 
   if (use_render_params) {
-    child_num = psys->part->ren_child_nbr;
+    child_num = psys->part->child_render_percent;
   }
   else {
-    child_num = psys->part->child_nbr;
+    child_num = psys->part->child_percent;
   }
 
   return get_render_child_particle_number(&scene->r, child_num, use_render_params);
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index 5b026c1cca0..16297149cc3 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -2064,8 +2064,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
     }
 
     for (part = bmain->particles.first; part; part = part->id.next) {
-      if (part->ren_child_nbr == 0) {
-        part->ren_child_nbr = part->child_nbr;
+      if (part->child_render_percent == 0) {
+        part->child_render_percent = part->child_percent;
       }
     }
 
diff --git a/source/blender/makesdna/DNA_particle_defaults.h b/source/blender/makesdna/DNA_particle_defaults.h
index 138aa6f1f98..108252a5e6c 100644
--- a/source/blender/makesdna/DNA_particle_defaults.h
+++ b/source/blender/makesdna/DNA_particle_defaults.h
@@ -56,8 +56,8 @@
     .rotmode = PART_ROT_VEL, \
     .avemode = PART_AVE_VELOCITY, \
  \
-    .child_nbr = 10, \
-    .ren_child_nbr = 100, \
+    .child_percent = 10, \
+    .child_render_percent = 100, \
     .childrad = 0.2f, \
     .childflat = 0.0f, \
     .clumppow = 0.0f, \
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index 397385c0f5b..f3d342e4849 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -226,7 +226,7 @@ typedef struct ParticleSettings {
   /* children */
   int child_flag;
   char _pad3[4];
-  int child_nbr, ren_child_nbr;
+  int child_percent, child_render_percent;
   float parents, childsize, childrandsize;
   float childrad, childflat;
   /* clumping */
diff --git a/source/blender/makesdna/intern/dna_rename_defs.h b/source/blender/makesdna/intern/dna_rename_defs.h
index 7b155df3084..439d3fc7bcb 100644
--- a/source/blender/makesdna/intern/dna_rename_defs.h
+++ b/source/blender/makesdna/intern/dna_rename_defs.h
@@ -86,9 +86,11 @@ DNA_STRUCT_RENAME_ELEM(Object, dup_group, instance_collection)
 DNA_STRUCT_RENAME_ELEM(Object, dupfacesca, instance_faces_scale)
 DNA_STRUCT_RENAME_ELEM(Object, restrictflag, visibility_flag)
 DNA_STRUCT_RENAME_ELEM(Object, size, scale)
+DNA_STRUCT_RENAME_ELEM(ParticleSettings, child_nbr, child_percent)
 DNA_STRUCT_RENAME_ELEM(ParticleSettings, dup_group, instance_collection)
 DNA_STRUCT_RENAME_ELEM(ParticleSettings, dup_ob, instance_object)
 DNA_STRUCT_RENAME_ELEM(ParticleSettings, dupliweights, instance_weights)
+DNA_STRUCT_RENAME_ELEM(ParticleSettings, ren_child_nbr, child_render_percent)
 DNA_STRUCT_RENAME_ELEM(RigidBodyWorld, steps_per_second, substeps_per_frame)
 DNA_STRUCT_RENAME_ELEM(RenderData, bake_filter, bake_margin)
 DNA_STRUCT_RENAME_ELEM(SpaceSeq, overlay_type, overlay_frame_type)
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 2770255802d..03f800d14d1 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -3139,15 +3139,19 @@ static void rna_def_particle_settings(BlenderRNA *brna)
   RNA_def_property_update(prop, 0, "rna_Particle_redo");
 
   /* children */
+
+  /* NOTE(@campbellbarton): name is not following conventions: `nbr`.
+   * Could be changed next major version. */
   prop = RNA_def_property(srna, "child_nbr", PROP_INT, PROP_NONE);
-  RNA_def_property_int_sdna(prop, NULL, "child_nbr"); /* Optional if prop names are the same. */
+  RNA_def_property_int_sdna(
+      prop, NULL, "child_percent"); /* Optional if prop names are the same. */
   RNA_def_property_range(prop, 0, 100000);
   RNA_def_property_ui_range(prop, 0, 1000, 1, -1);
   RNA_def_property_ui_text(prop, "Children Per Parent", "Number of children per parent");
   RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
 
   prop = RNA_def_property(srna, "rendered_child_count", PROP_INT, PROP_NONE);
-  RNA_def_property_int_sdna(prop, NULL, "ren_child_nbr");
+  RNA_def_property_int_sdna(prop, NULL, "child_render_percent");
   RNA_def_property_range(prop, 0, 100000);
   RNA_def_property_ui_range(prop, 0, 10000, 1, -1);
   RNA_def_property_ui_text(



More information about the Bf-blender-cvs mailing list