Revert "Particle system: Move runtime data to runtime field"

This reverts commit 36faf739a7.

Somewhat annoying but this change had some unforeseen consequences,
which lead to an actual bug.

Since this change was not sufficient to get original report fixed
is easier to simply revert for now.

Fixes T65842: Hair disappears when clicking on particle system name
This commit is contained in:
2019-06-21 11:49:43 +02:00
parent 964e319a39
commit 7070e4c15e
15 changed files with 223 additions and 324 deletions

View File

@@ -620,7 +620,6 @@ static void disconnect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Part
edit = psys->edit;
point = edit ? edit->points : NULL;
Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(psmd_eval);
for (i = 0, pa = psys->particles; i < psys->totpart; i++, pa++) {
if (point) {
@@ -628,7 +627,7 @@ static void disconnect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Part
point++;
}
psys_mat_hair_to_global(ob, mesh_final, psys->part->from, pa, hairmat);
psys_mat_hair_to_global(ob, psmd_eval->mesh_final, psys->part->from, pa, hairmat);
for (k = 0, key = pa->hair; k < pa->totkey; k++, key++) {
mul_m4_v3(hairmat, key->co);
@@ -726,8 +725,7 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
float from_ob_imat[4][4], to_ob_imat[4][4];
float from_imat[4][4], to_imat[4][4];
Mesh *target_mesh_final = BKE_particle_modifier_mesh_final_get(target_psmd);
if (!target_mesh_final) {
if (!target_psmd->mesh_final) {
return false;
}
if (!psys->part || psys->part->type != PART_HAIR) {
@@ -744,14 +742,14 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
invert_m4_m4(from_imat, from_mat);
invert_m4_m4(to_imat, to_mat);
if (target_mesh_final->runtime.deformed_only) {
if (target_psmd->mesh_final->runtime.deformed_only) {
/* we don't want to mess up target_psmd->dm when converting to global coordinates below */
mesh = target_mesh_final;
mesh = target_psmd->mesh_final;
}
else {
mesh = BKE_particle_modifier_mesh_original_get(target_psmd);
mesh = target_psmd->mesh_original;
}
target_mesh = target_mesh_final;
target_mesh = target_psmd->mesh_final;
if (mesh == NULL) {
return false;
}
@@ -1157,13 +1155,10 @@ static bool copy_particle_systems_to_object(const bContext *C,
modifier_unique_name(&ob_to->modifiers, (ModifierData *)psmd);
psmd->psys = psys;
BKE_id_copy_ex(NULL, &final_mesh->id, (ID **)&psmd->mesh_final, LIB_ID_COPY_LOCALIZE);
/* TODO(sergey): This should probably be accessing evaluated psmd. */
ParticleSystemModifierDataRuntime *runtime = BKE_particle_modifier_runtime_ensure(psmd);
BKE_id_copy_ex(NULL, &final_mesh->id, (ID **)&runtime->mesh_final, LIB_ID_COPY_LOCALIZE);
BKE_mesh_calc_normals(runtime->mesh_final);
BKE_mesh_tessface_ensure(runtime->mesh_final);
BKE_mesh_calc_normals(psmd->mesh_final);
BKE_mesh_tessface_ensure(psmd->mesh_final);
if (psys_from->edit) {
copy_particle_edit(depsgraph, scene, ob_to, psys, psys_from);