diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-06-05 13:39:40 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-06-13 12:34:01 +0300 |
commit | 36faf739a71624b6ca10cec7233779f9eeace0bd (patch) | |
tree | ad57fbc75b6bce4bdc590384a3fdf4eeb5fdbaf0 /source/blender/editors/physics/particle_object.c | |
parent | 27537daee1b62aab0fb0d01b89b7d2c044e796cd (diff) |
Particle system: Move runtime data to runtime field
Allows it to be preserved during copy-on-write update when on-geometry
related update is needed.
This is a required part for T63537, where we need to preserve the entire
evaluation data when object is tagged for only RECALC_COPY_ON_WRITE.
Reviewers: brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D5023
Diffstat (limited to 'source/blender/editors/physics/particle_object.c')
-rw-r--r-- | source/blender/editors/physics/particle_object.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index b03ec56c7e4..d85bf72851d 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -620,6 +620,7 @@ 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) { @@ -627,7 +628,7 @@ static void disconnect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Part point++; } - psys_mat_hair_to_global(ob, psmd_eval->mesh_final, psys->part->from, pa, hairmat); + psys_mat_hair_to_global(ob, mesh_final, psys->part->from, pa, hairmat); for (k = 0, key = pa->hair; k < pa->totkey; k++, key++) { mul_m4_v3(hairmat, key->co); @@ -725,7 +726,8 @@ 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]; - if (!target_psmd->mesh_final) { + Mesh *target_mesh_final = BKE_particle_modifier_mesh_final_get(target_psmd); + if (!target_mesh_final) { return false; } if (!psys->part || psys->part->type != PART_HAIR) { @@ -742,14 +744,14 @@ static bool remap_hair_emitter(Depsgraph *depsgraph, invert_m4_m4(from_imat, from_mat); invert_m4_m4(to_imat, to_mat); - if (target_psmd->mesh_final->runtime.deformed_only) { + if (target_mesh_final->runtime.deformed_only) { /* we don't want to mess up target_psmd->dm when converting to global coordinates below */ - mesh = target_psmd->mesh_final; + mesh = target_mesh_final; } else { - mesh = target_psmd->mesh_original; + mesh = BKE_particle_modifier_mesh_original_get(target_psmd); } - target_mesh = target_psmd->mesh_final; + target_mesh = target_mesh_final; if (mesh == NULL) { return false; } @@ -1155,10 +1157,13 @@ 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); - BKE_mesh_calc_normals(psmd->mesh_final); - BKE_mesh_tessface_ensure(psmd->mesh_final); + /* 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); if (psys_from->edit) { copy_particle_edit(depsgraph, scene, ob_to, psys, psys_from); |