diff options
-rw-r--r-- | intern/cycles/blender/blender_curves.cpp | 9 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_particle.c | 31 |
3 files changed, 26 insertions, 20 deletions
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp index 8fb4813fab7..5b8d495084d 100644 --- a/intern/cycles/blender/blender_curves.cpp +++ b/intern/cycles/blender/blender_curves.cpp @@ -37,7 +37,6 @@ void curveinterp_v3_v3v3v3v3(float3 *p, float3 *v1, float3 *v2, float3 *v3, floa void interp_weights(float t, float data[4], int type); float shaperadius(float shape, float root, float tip, float time); void InterpolateKeySegments(int seg, int segno, int key, int curve, float3 *keyloc, float *time, ParticleCurveData *CData, int interpolation); -void ToggleRender(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, BL::Scene *scene); bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, bool background, int uv_num); bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, bool background, int vcol_num); bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, bool background); @@ -380,14 +379,14 @@ bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par } -void ToggleRender(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, BL::Scene *scene) +static void set_resolution(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, BL::Scene *scene, bool render) { BL::Object::modifiers_iterator b_mod; for(b_ob->modifiers.begin(b_mod); b_mod != b_ob->modifiers.end(); ++b_mod) { if ((b_mod->type() == b_mod->type_PARTICLE_SYSTEM) && (b_mod->show_viewport()) && (b_mod->show_render())) { BL::ParticleSystemModifier psmd((const PointerRNA)b_mod->ptr); BL::ParticleSystem b_psys((const PointerRNA)psmd.particle_system().ptr); - b_psys.ToggleRender(*scene, *b_ob); + b_psys.set_resolution(*scene, *b_ob, (render)? 2: 1); } } } @@ -1017,7 +1016,7 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool ParticleCurveData CData; if(!preview) - ToggleRender(mesh, &b_mesh, &b_ob, &b_scene); + set_resolution(mesh, &b_mesh, &b_ob, &b_scene, true); ObtainCacheParticleData(mesh, &b_mesh, &b_ob, &CData, use_parents, !preview); @@ -1166,7 +1165,7 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool } if(!preview) - ToggleRender(mesh, &b_mesh, &b_ob, &b_scene); + set_resolution(mesh, &b_mesh, &b_ob, &b_scene, false); mesh->compute_bounds(); } 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"); |