diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-01-04 16:28:47 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-01-04 16:30:34 +0300 |
commit | 2c21e3e35f304afdc1a320fb8ccef91e0119dfc8 (patch) | |
tree | b30f0ac06de3b2d9d9362191defd6920cb9f70b9 /source/blender/editors/object | |
parent | 1753177ad8acfabbcc74c3d8e20fa874f2b97167 (diff) |
Fix T60132: Convert hair particles to mesh
Needed to port operator to use evaluated particle system.
But also changed interface to always show Convert button when
draw type is set to Path (Hair particle system is forced to
be draws as path). This avoid rather expensive lookup on every
redraw, but will show Convert button for un-baked particle
emitter.
Probably, an acceptable compromise.
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 15aca6a3253..79dffa17c7a 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -432,10 +432,12 @@ int ED_object_modifier_move_down(ReportList *reports, Object *ob, ModifierData * return 1; } -int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene *scene, ViewLayer *view_layer, Object *ob, ModifierData *md) +int ED_object_modifier_convert(ReportList *UNUSED(reports), + Main *bmain, Depsgraph *depsgraph, Scene *scene, ViewLayer *view_layer, + Object *ob, ModifierData *md) { Object *obn; - ParticleSystem *psys; + ParticleSystem *psys_orig, *psys_eval; ParticleCacheKey *key, **cache; ParticleSettings *part; Mesh *me; @@ -448,20 +450,25 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * if (md->type != eModifierType_ParticleSystem) return 0; if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) return 0; - psys = ((ParticleSystemModifierData *)md)->psys; - part = psys->part; + psys_orig = ((ParticleSystemModifierData *)md)->psys; + part = psys_orig->part; - if (part->ren_as != PART_DRAW_PATH || psys->pathcache == NULL) + if (part->ren_as != PART_DRAW_PATH) { return 0; + } + psys_eval = psys_eval_get(depsgraph, ob, psys_orig); + if (psys_eval->pathcache == NULL) { + return 0; + } - totpart = psys->totcached; - totchild = psys->totchildcache; + totpart = psys_eval->totcached; + totchild = psys_eval->totchildcache; if (totchild && (part->draw & PART_DRAW_PARENT) == 0) totpart = 0; /* count */ - cache = psys->pathcache; + cache = psys_eval->pathcache; for (a = 0; a < totpart; a++) { key = cache[a]; @@ -471,7 +478,7 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * } } - cache = psys->childcache; + cache = psys_eval->childcache; for (a = 0; a < totchild; a++) { key = cache[a]; @@ -498,7 +505,7 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * medge = me->medge; /* copy coordinates */ - cache = psys->pathcache; + cache = psys_eval->pathcache; for (a = 0; a < totpart; a++) { key = cache[a]; kmax = key->segments; @@ -517,7 +524,7 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * } } - cache = psys->childcache; + cache = psys_eval->childcache; for (a = 0; a < totchild; a++) { key = cache[a]; kmax = key->segments; @@ -1086,12 +1093,13 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot) static int modifier_convert_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); - if (!md || !ED_object_modifier_convert(op->reports, bmain, scene, view_layer, ob, md)) + if (!md || !ED_object_modifier_convert(op->reports, bmain, depsgraph, scene, view_layer, ob, md)) return OPERATOR_CANCELLED; DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); |