diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-02-05 17:33:54 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-02-05 17:33:54 +0400 |
commit | 1ca0d66bd20739132fb43fb07f80edac347ce745 (patch) | |
tree | e2561d451756754fd062d05ea6601db5696dc70b /source/blender | |
parent | 7ecc9cfdf4a74c7264da7e812736c0f520d02d50 (diff) |
Fix particle child render resolution access not working outside of the render thread,
and rename ToggleRender to set_resolution to follow RNA conventions.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_particle.c | 31 |
2 files changed, 22 insertions, 15 deletions
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 71854a93f4d..c01ea4e518d 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -684,8 +684,6 @@ void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[4][4], floa ParticleRenderData *data; ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys); - if (G.is_rendering == FALSE) - return; if (psys->renderdata) return; @@ -2384,7 +2382,7 @@ void psys_find_parents(ParticleSimulationData *sim) int from = PART_FROM_FACE; totparent = (int)(totchild * part->parents * 0.3f); - if (G.is_rendering && part->child_nbr && part->ren_child_nbr) + if ((sim->psys->renderdata || G.is_rendering) && part->child_nbr && part->ren_child_nbr) totparent *= (float)part->child_nbr / (float)part->ren_child_nbr; tree = BLI_kdtree_new(totparent); @@ -2461,7 +2459,7 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c if (totchild && part->childtype == PART_CHILD_FACES) { totparent = (int)(totchild * part->parents * 0.3f); - if (G.is_rendering && part->child_nbr && part->ren_child_nbr) + if ((psys->renderdata || G.is_rendering) && part->child_nbr && part->ren_child_nbr) totparent *= (float)part->child_nbr / (float)part->ren_child_nbr; /* part->parents could still be 0 so we can't test with totparent */ diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 0107cd8b51e..dbf80f01335 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -583,20 +583,22 @@ static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem, P } } -static void rna_ParticleSystem_ToggleRender(ParticleSystem *particlesystem, Scene *scene, Object *object) +static void rna_ParticleSystem_set_resolution(ParticleSystem *particlesystem, Scene *scene, Object *object, int resolution) { - ParticleSystemModifierData *psmd = psys_get_modifier(object, particlesystem); - float mat[4][4]; + if (resolution == eModifierMode_Render) { + ParticleSystemModifierData *psmd = psys_get_modifier(object, particlesystem); + float mat[4][4]; + + unit_m4(mat); - unit_m4(mat); - - if (particlesystem->renderdata) - psys_render_restore(object, particlesystem); - else { psys_render_set(object, particlesystem, mat, mat, 1, 1, 0.f); psmd->flag &= ~eParticleSystemFlag_psys_updated; particle_system_update(scene, object, particlesystem); } + else { + if (particlesystem->renderdata) + psys_render_restore(object, particlesystem); + } } static void particle_recalc(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr, short flag) @@ -3082,6 +3084,12 @@ static void rna_def_particle_system(BlenderRNA *brna) PropertyRNA *prop; FunctionRNA *func; + static EnumPropertyItem resolution_items[] = { + {eModifierMode_Realtime, "PREVIEW", 0, "Preview", "Apply modifier preview settings"}, + {eModifierMode_Render, "RENDER", 0, "Render", "Apply modifier render settings"}, + {0, NULL, 0, NULL, NULL} + }; + srna = RNA_def_struct(brna, "ParticleSystem", NULL); RNA_def_struct_ui_text(srna, "Particle System", "Particle system in an object"); RNA_def_struct_ui_icon(srna, ICON_PARTICLE_DATA); @@ -3380,11 +3388,12 @@ static void rna_def_particle_system(BlenderRNA *brna) RNA_def_struct_path_func(srna, "rna_ParticleSystem_path"); - /* Toggle Render settings */ - func = RNA_def_function(srna, "ToggleRender", "rna_ParticleSystem_ToggleRender"); - RNA_def_function_ui_description(func, "Toggle render settings"); + /* set viewport or render resolution */ + func = RNA_def_function(srna, "set_resolution", "rna_ParticleSystem_set_resolution"); + RNA_def_function_ui_description(func, "Set the resolution to use for the number of particles"); prop = RNA_def_pointer(func, "scene", "Scene", "", "Scene"); prop = RNA_def_pointer(func, "object", "Object", "", "Object"); + prop = RNA_def_enum(func, "resolution", resolution_items, 0, "", "Resolution settings to apply"); /* extract cached hair location data */ func = RNA_def_function(srna, "co_hair", "rna_ParticleSystem_co_hair"); |