Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2019-01-04 16:28:47 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-01-04 16:30:34 +0300
commit2c21e3e35f304afdc1a320fb8ccef91e0119dfc8 (patch)
treeb30f0ac06de3b2d9d9362191defd6920cb9f70b9 /source/blender/editors
parent1753177ad8acfabbcc74c3d8e20fa874f2b97167 (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')
-rw-r--r--source/blender/editors/include/ED_object.h2
-rw-r--r--source/blender/editors/interface/interface_templates.c6
-rw-r--r--source/blender/editors/object/object_modifier.c32
-rw-r--r--source/blender/editors/physics/particle_edit.c19
4 files changed, 25 insertions, 34 deletions
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index fd0635e31ef..7f7e74a4e4e 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -248,7 +248,7 @@ void ED_object_modifier_clear(struct Main *bmain, struct Object *ob);
int ED_object_modifier_move_down(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
int ED_object_modifier_move_up(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
int ED_object_modifier_convert(
- struct ReportList *reports, struct Main *bmain, struct Scene *scene,
+ struct ReportList *reports, struct Main *bmain, struct Depsgraph *depsgraph, struct Scene *scene,
struct ViewLayer *view_layer, struct Object *ob, struct ModifierData *md);
int ED_object_modifier_apply(
struct Main *bmain, struct ReportList *reports, struct Depsgraph *depsgraph, struct Scene *scene,
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index ec055ddb05b..d7e3dbf6e32 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1507,12 +1507,14 @@ static uiLayout *draw_modifier(
ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) {
- if (ELEM(psys->part->ren_as, PART_DRAW_GR, PART_DRAW_OB))
+ if (ELEM(psys->part->ren_as, PART_DRAW_GR, PART_DRAW_OB)) {
uiItemO(row, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Convert"), ICON_NONE,
"OBJECT_OT_duplicates_make_real");
- else if (psys->part->ren_as == PART_DRAW_PATH && psys->pathcache)
+ }
+ else if (psys->part->ren_as == PART_DRAW_PATH) {
uiItemO(row, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Convert"), ICON_NONE,
"OBJECT_OT_modifier_convert");
+ }
}
}
else {
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);
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 33ed3336355..e8afa1ae441 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -4650,25 +4650,6 @@ int PE_minmax(Scene *scene, ViewLayer *view_layer, float min[3], float max[3])
/************************ particle edit toggle operator ************************/
-static struct ParticleSystem *psys_eval_get(
- Depsgraph *depsgraph,
- Object *object,
- ParticleSystem *psys)
-{
- Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
- if (object_eval == object) {
- return psys;
- }
- ParticleSystem *psys_eval = object_eval->particlesystem.first;
- while (psys_eval != NULL) {
- if (psys_eval->orig_psys == psys) {
- return psys_eval;
- }
- psys_eval = psys_eval->next;
- }
- return psys_eval;
-}
-
/* initialize needed data for bake edit */
void PE_create_particle_edit(
Depsgraph *depsgraph, Scene *scene, Object *ob, PointCache *cache, ParticleSystem *psys)