[Bf-blender-cvs] [7070e4c15e6] master: Revert "Particle system: Move runtime data to runtime field"

Sergey Sharybin noreply at git.blender.org
Fri Jun 21 12:13:07 CEST 2019


Commit: 7070e4c15e6c57da2bd46534e654ed5f9a1e6600
Author: Sergey Sharybin
Date:   Fri Jun 21 11:49:43 2019 +0200
Branches: master
https://developer.blender.org/rB7070e4c15e6c57da2bd46534e654ed5f9a1e6600

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

This reverts commit 36faf739a71624b6ca10cec7233779f9eeace0bd.

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

===================================================================

M	source/blender/blenkernel/BKE_particle.h
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/particle.c
M	source/blender/blenkernel/intern/particle_distribute.c
M	source/blender/blenkernel/intern/particle_system.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/draw/intern/draw_cache_impl_particles.c
M	source/blender/editors/physics/particle_edit.c
M	source/blender/editors/physics/particle_object.c
M	source/blender/editors/transform/transform_conversions.c
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_particle.c
M	source/blender/modifiers/intern/MOD_explode.c
M	source/blender/modifiers/intern/MOD_particleinstance.c
M	source/blender/modifiers/intern/MOD_particlesystem.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index ca3a560286f..164dbbbf482 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -38,7 +38,6 @@ struct ParticleKey;
 struct ParticleSettings;
 struct ParticleSystem;
 struct ParticleSystemModifierData;
-struct ParticleSystemModifierDataRuntime;
 
 struct BVHTreeRay;
 struct BVHTreeRayHit;
@@ -609,13 +608,6 @@ float psys_get_current_display_percentage(struct ParticleSystem *psys,
 #define DMCACHE_NOTFOUND -1
 #define DMCACHE_ISCHILD -2
 
-/* **** Particle system modifier helpers.  **** */
-
-struct Mesh *BKE_particle_modifier_mesh_final_get(struct ParticleSystemModifierData *psmd);
-struct Mesh *BKE_particle_modifier_mesh_original_get(struct ParticleSystemModifierData *psmd);
-struct ParticleSystemModifierDataRuntime *BKE_particle_modifier_runtime_ensure(
-    struct ParticleSystemModifierData *psmd);
-
 /* **** Depsgraph evaluation **** */
 
 struct Depsgraph;
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index e74b2b0f671..2a66edc8d42 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -497,13 +497,12 @@ void BKE_object_free_caches(Object *object)
   for (md = object->modifiers.first; md != NULL; md = md->next) {
     if (md->type == eModifierType_ParticleSystem) {
       ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
-      ParticleSystemModifierDataRuntime *psmd_runtime = BKE_particle_modifier_runtime_ensure(psmd);
-      if (psmd_runtime->mesh_final) {
-        BKE_id_free(NULL, psmd_runtime->mesh_final);
-        psmd_runtime->mesh_final = NULL;
-        if (psmd_runtime->mesh_original) {
-          BKE_id_free(NULL, psmd_runtime->mesh_original);
-          psmd_runtime->mesh_original = NULL;
+      if (psmd->mesh_final) {
+        BKE_id_free(NULL, psmd->mesh_final);
+        psmd->mesh_final = NULL;
+        if (psmd->mesh_original) {
+          BKE_id_free(NULL, psmd->mesh_original);
+          psmd->mesh_original = NULL;
         }
         psmd->flag |= eParticleSystemFlag_file_loaded;
         update_flag |= ID_RECALC_GEOMETRY;
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 61ee5685451..13649eaf096 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -1889,8 +1889,7 @@ void psys_particle_on_emitter(ParticleSystemModifierData *psmd,
                               float vtan[3],
                               float orco[3])
 {
-  Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(psmd);
-  if (psmd && mesh_final) {
+  if (psmd && psmd->mesh_final) {
     if (psmd->psys->part->distr == PART_DISTR_GRID && psmd->psys->part->from != PART_FROM_VERT) {
       if (vec) {
         copy_v3_v3(vec, fuv);
@@ -1903,7 +1902,7 @@ void psys_particle_on_emitter(ParticleSystemModifierData *psmd,
     }
     /* we cant use the num_dmcache */
     psys_particle_on_dm(
-        mesh_final, from, index, index_dmcache, fuv, foffset, vec, nor, utan, vtan, orco);
+        psmd->mesh_final, from, index, index_dmcache, fuv, foffset, vec, nor, utan, vtan, orco);
   }
   else {
     psys_particle_on_shape(from, index, fuv, vec, nor, utan, vtan, orco);
@@ -2254,15 +2253,13 @@ void psys_find_parents(ParticleSimulationData *sim, const bool use_render_params
 
   tree = BLI_kdtree_3d_new(totparent);
 
-  Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(sim->psmd);
-
   for (p = 0, cpa = sim->psys->child; p < totparent; p++, cpa++) {
     psys_particle_on_emitter(
         sim->psmd, from, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co, 0, 0, 0, orco);
 
     /* Check if particle doesn't exist because of texture influence.
      * Insert only existing particles into kdtree. */
-    get_cpa_texture(mesh_final,
+    get_cpa_texture(sim->psmd->mesh_final,
                     psys,
                     part,
                     psys->particles + cpa->pa[0],
@@ -2430,8 +2427,6 @@ static void psys_thread_create_path(ParticleTask *task,
     return;
   }
 
-  Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(ctx->sim.psmd);
-
   if (ctx->between) {
     ParticleData *pa = psys->particles + cpa->pa[0];
     int w, needupdate;
@@ -2536,7 +2531,7 @@ static void psys_thread_create_path(ParticleTask *task,
       sub_v3_v3v3(off1[w], co, key[w]->co);
     }
 
-    psys_mat_hair_to_global(ob, mesh_final, psys->part->from, pa, hairmat);
+    psys_mat_hair_to_global(ob, ctx->sim.psmd->mesh_final, psys->part->from, pa, hairmat);
   }
   else {
     ParticleData *pa = psys->particles + cpa->parent;
@@ -2567,7 +2562,7 @@ static void psys_thread_create_path(ParticleTask *task,
                                                                            pa->num_dmcache;
 
     /* XXX hack to avoid messed up particle num and subsequent crash (#40733) */
-    if (cpa_num > mesh_final->totface) {
+    if (cpa_num > ctx->sim.psmd->mesh_final->totface) {
       cpa_num = 0;
     }
     cpa_fuv = pa->fuv;
@@ -2584,7 +2579,7 @@ static void psys_thread_create_path(ParticleTask *task,
                              0,
                              orco);
 
-    psys_mat_hair_to_global(ob, mesh_final, psys->part->from, pa, hairmat);
+    psys_mat_hair_to_global(ob, ctx->sim.psmd->mesh_final, psys->part->from, pa, hairmat);
   }
 
   child_keys->segments = ctx->segments;
@@ -2930,21 +2925,19 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
     copy_v3_v3(col, &ma->r);
   }
 
-  Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(psmd);
-
   if ((psys->flag & PSYS_GLOBAL_HAIR) == 0) {
     if ((psys->part->flag & PART_CHILD_EFFECT) == 0) {
-      vg_effector = psys_cache_vgroup(mesh_final, psys, PSYS_VG_EFFECTOR);
+      vg_effector = psys_cache_vgroup(psmd->mesh_final, psys, PSYS_VG_EFFECTOR);
     }
 
     if (!psys->totchild) {
-      vg_length = psys_cache_vgroup(mesh_final, psys, PSYS_VG_LENGTH);
+      vg_length = psys_cache_vgroup(psmd->mesh_final, psys, PSYS_VG_LENGTH);
     }
   }
 
   /* ensure we have tessfaces to be used for mapping */
   if (part->from != PART_FROM_VERT) {
-    BKE_mesh_tessface_ensure(mesh_final);
+    BKE_mesh_tessface_ensure(psmd->mesh_final);
   }
 
   /*---first main loop: create all actual particles' paths---*/
@@ -2954,7 +2947,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
       psys_get_texture(sim, pa, &ptex, PAMAP_LENGTH, 0.f);
       pa_length = ptex.length * (1.0f - part->randlength * psys_frand(psys, psys->seed + p));
       if (vg_length) {
-        pa_length *= psys_particle_value_from_verts(mesh_final, part->from, pa, vg_length);
+        pa_length *= psys_particle_value_from_verts(psmd->mesh_final, part->from, pa, vg_length);
       }
     }
 
@@ -2972,7 +2965,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
     init_particle_interpolation(sim->ob, sim->psys, pa, &pind);
 
     /* hairmat is needed for for non-hair particle too so we get proper rotations */
-    psys_mat_hair_to_global(sim->ob, mesh_final, psys->part->from, pa, hairmat);
+    psys_mat_hair_to_global(sim->ob, psmd->mesh_final, psys->part->from, pa, hairmat);
     copy_v3_v3(rotmat[0], hairmat[2]);
     copy_v3_v3(rotmat[1], hairmat[1]);
     copy_v3_v3(rotmat[2], hairmat[0]);
@@ -3030,7 +3023,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
         float effector = 1.0f;
         if (vg_effector) {
           effector *= psys_particle_value_from_verts(
-              mesh_final, psys->part->from, pa, vg_effector);
+              psmd->mesh_final, psys->part->from, pa, vg_effector);
         }
 
         sub_v3_v3v3(vec, (cache[p] + 1)->co, cache[p]->co);
@@ -3165,8 +3158,7 @@ static void psys_cache_edit_paths_iter(void *__restrict iter_data_v,
   init_particle_interpolation(ob, psys, pa, &pind);
 
   if (psys) {
-    Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(psmd);
-    psys_mat_hair_to_global(ob, mesh_final, psys->part->from, pa, hairmat);
+    psys_mat_hair_to_global(ob, psmd->mesh_final, psys->part->from, pa, hairmat);
     copy_v3_v3(rotmat[0], hairmat[2]);
     copy_v3_v3(rotmat[1], hairmat[1]);
     copy_v3_v3(rotmat[2], hairmat[0]);
@@ -4046,9 +4038,8 @@ void psys_get_texture(
             mul_m4_v3(mtex->object->imat, texvec);
           }
           break;
-        case TEXCO_UV: {
-          Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(sim->psmd);
-          if (get_particle_uv(mesh_final,
+        case TEXCO_UV:
+          if (get_particle_uv(sim->psmd->mesh_final,
                               pa,
                               0,
                               pa->fuv,
@@ -4059,7 +4050,6 @@ void psys_get_texture(
           }
           /* no break, failed to get uv's, so let's try orco's */
           ATTR_FALLTHROUGH;
-        }
         case TEXCO_ORCO:
           psys_particle_on_emitter(sim->psmd,
                                    sim->psys->part->from,
@@ -4333,8 +4323,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim,
       }
       else if (!keyed && !cached && !(psys->flag & PSYS_GLOBAL_HAIR)) {
         if ((pa->flag & PARS_REKEY) == 0) {
-          Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(sim->psmd);
-          psys_mat_hair_to_global(sim->ob, mesh_final, part->from, pa, hairmat);
+          psys_mat_hair_to_global(sim->ob, sim->psmd->mesh_final, part->from, pa, hairmat);
           mul_m4_v3(hairmat, state->co);
           mul_mat3_m4_v3(hairmat, state->vel);
 
@@ -4416,8 +4405,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim,
                                  0,
                                  par_orco);
         if (part->type == PART_HAIR) {
-          Mesh *mesh_final = BKE_particle_modifier_mesh_final_get(psmd);
-          psys_mat_hair_to_global(sim->ob, mesh_final, psys->part->from, pa, hairmat);
+          psys_mat_hair_to_global(sim->ob, sim->psmd->mesh_final, psys->part->from, pa, hairmat);
         }
         

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list