diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2016-12-28 19:30:58 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2016-12-28 19:30:58 +0300 |
commit | 6ecab6dd8e48d564a2b43e0e81e79d079e8b4c77 (patch) | |
tree | 618e2d24eb34a05a81f726dd52eb2b7468e9296d /source/blender/makesrna/intern/rna_object_api.c | |
parent | 605263177b8eea24c1449e4dbf0138175ec3dddf (diff) |
Revert particle system and point cache removal in blender2.8 branch.
This reverts commit 5aa19be91263a249ffae75573e3b32f24269d890 and b4a721af694817fa921b119df83d33ede7d7fed0.
Due to postponement of particle system rewrite it was decided to put particle code
back into the 2.8 branch for the time being.
Diffstat (limited to 'source/blender/makesrna/intern/rna_object_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_object_api.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 06affc7787c..c680abe71a4 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -146,9 +146,54 @@ static Mesh *rna_Object_to_mesh( return rna_Main_meshes_new_from_object(G.main, reports, sce, ob, apply_modifiers, settings, calc_tessface, calc_undeformed); } +/* mostly a copy from convertblender.c */ +static void dupli_render_particle_set(Scene *scene, Object *ob, int level, int enable) +{ + /* ugly function, but we need to set particle systems to their render + * settings before calling object_duplilist, to get render level duplis */ + Group *group; + GroupObject *go; + ParticleSystem *psys; + DerivedMesh *dm; + float mat[4][4]; + + unit_m4(mat); + + if (level >= MAX_DUPLI_RECUR) + return; + + if (ob->transflag & OB_DUPLIPARTS) { + for (psys = ob->particlesystem.first; psys; psys = psys->next) { + if (ELEM(psys->part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { + if (enable) + psys_render_set(ob, psys, mat, mat, 1, 1, 0.f); + else + psys_render_restore(ob, psys); + } + } + + if (enable) { + /* this is to make sure we get render level duplis in groups: + * the derivedmesh must be created before init_render_mesh, + * since object_duplilist does dupliparticles before that */ + dm = mesh_create_derived_render(scene, ob, CD_MASK_BAREMESH | CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL); + dm->release(dm); + + for (psys = ob->particlesystem.first; psys; psys = psys->next) + psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated; + } + } + + if (ob->dup_group == NULL) return; + group = ob->dup_group; + + for (go = group->gobject.first; go; go = go->next) + dupli_render_particle_set(scene, go->ob, level + 1, enable); +} /* When no longer needed, duplilist should be freed with Object.free_duplilist */ static void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene *sce, int settings) { + bool for_render = (settings == DAG_EVAL_RENDER); EvaluationContext eval_ctx; DEG_evaluation_context_init(&eval_ctx, settings); @@ -164,7 +209,11 @@ static void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene * free_object_duplilist(ob->duplilist); ob->duplilist = NULL; } + if (for_render) + dupli_render_particle_set(sce, ob, 0, 1); ob->duplilist = object_duplilist(&eval_ctx, sce, ob); + if (for_render) + dupli_render_particle_set(sce, ob, 0, 0); /* ob->duplilist should now be freed with Object.free_duplilist */ } |