Fix T59963: Can't manipulate hair keys with G, R, S or mirror transforms

Need to pass proper evaluated mesh to calculate hair matrix.
This commit is contained in:
Sergey Sharybin 2019-01-28 15:45:34 +01:00
parent 9bc43223c1
commit 56cc219070
Notes: blender-bot 2023-02-14 04:16:05 +01:00
Referenced by issue #59963, Can't manipulate hair keys with G, R, S or mirror transforms
1 changed files with 7 additions and 11 deletions

View File

@ -2087,7 +2087,6 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
ParticleEditSettings *pset = PE_settings(t->scene);
PTCacheEdit *edit = PE_get_current(t->scene, ob);
ParticleSystem *psys = NULL;
ParticleSystemModifierData *psmd = NULL;
PTCacheEditPoint *point;
PTCacheEditKey *key;
float mat[4][4];
@ -2099,9 +2098,6 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
psys = edit->psys;
if (psys)
psmd = psys_get_modifier(ob, psys);
for (i = 0, point = edit->points; i < edit->totpoint; i++, point++) {
point->flag &= ~PEP_TRANSFORM;
transformparticle = 0;
@ -2146,8 +2142,10 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
if (!(point->flag & PEP_TRANSFORM)) continue;
if (psys && !(psys->flag & PSYS_GLOBAL_HAIR))
psys_mat_hair_to_global(ob, psmd->mesh_final, psys->part->from, psys->particles + i, mat);
if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
ParticleSystemModifierData *psmd_eval = edit->psmd_eval;
psys_mat_hair_to_global(ob, psmd_eval->mesh_final, psys->part->from, psys->particles + i, mat);
}
for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
if (key->flag & PEK_USE_WCO) {
@ -2206,7 +2204,6 @@ void flushTransParticles(TransInfo *t)
Object *ob = OBACT(view_layer);
PTCacheEdit *edit = PE_get_current(scene, ob);
ParticleSystem *psys = edit->psys;
ParticleSystemModifierData *psmd = NULL;
PTCacheEditPoint *point;
PTCacheEditKey *key;
TransData *td;
@ -2214,9 +2211,6 @@ void flushTransParticles(TransInfo *t)
int i, k;
const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
if (psys)
psmd = psys_get_modifier(ob, psys);
/* we do transform in world space, so flush world space position
* back to particle local space (only for hair particles) */
td = tc->data;
@ -2224,7 +2218,8 @@ void flushTransParticles(TransInfo *t)
if (!(point->flag & PEP_TRANSFORM)) continue;
if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
psys_mat_hair_to_global(ob, psmd->mesh_final, psys->part->from, psys->particles + i, mat);
ParticleSystemModifierData *psmd_eval = edit->psmd_eval;
psys_mat_hair_to_global(ob, psmd_eval->mesh_final, psys->part->from, psys->particles + i, mat);
invert_m4_m4(imat, mat);
for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
@ -2244,6 +2239,7 @@ void flushTransParticles(TransInfo *t)
}
PE_update_object(t->depsgraph, scene, OBACT(view_layer), 1);
DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
}
}