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.
This commit is contained in:
Campbell Barton 2022-03-25 12:04:21 +11:00
parent 4d46fac65d
commit 7d1d9e6015
8 changed files with 25 additions and 19 deletions

View File

@ -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 */

View File

@ -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;

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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, \

View File

@ -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 */

View File

@ -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)

View File

@ -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(