Make lattice deform safe for threading
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 19 Aug 2013 10:11:48 +0000 (10:11 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 19 Aug 2013 10:11:48 +0000 (10:11 +0000)
Lattice deformation used to store some runtime data
inside of lattice datablock itself. It's something
which is REALLY bad. Ideally DNA shouldn't contain
and runtime data.

For now solved it in a way that initialization of
lattice deform will create a structure which contains
lattice object for which deformation is calculating
and that runtime data which used to be stored in
lattice datablock itself.

It works really fine for mesh deform modifier, but
there's still runtime data stored in particle system
DNA, It didn't look something easy to be solved, so
leaving this as-is for now.

--
svn merge -r58277:58278 -r58795:58796 ^/branches/soc-2013-depsgraph_mt

13 files changed:
source/blender/blenkernel/BKE_lattice.h
source/blender/blenkernel/BKE_particle.h
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/lattice.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_system.c
source/blender/editors/space_view3d/drawobject.c
source/blender/makesdna/DNA_lattice_types.h
source/blender/makesdna/DNA_particle_types.h
source/blender/modifiers/intern/MOD_explode.c
source/blender/modifiers/intern/MOD_particleinstance.c
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/pointdensity.c

index 9b29412675bd00dba7497722edd5d72b0d0fdffe..ba33da7729c5fb5f37210eaf1ef7eb44621831b7 100644 (file)
@@ -49,9 +49,14 @@ void BKE_lattice_free(struct Lattice *lt);
 void BKE_lattice_make_local(struct Lattice *lt);
 void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du);
 
-void init_latt_deform(struct Object *oblatt, struct Object *ob);
-void calc_latt_deform(struct Object *, float co[3], float weight);
-void end_latt_deform(struct Object *);
+struct LatticeDeformData;
+struct LatticeDeformData *init_latt_deform(struct Object *oblatt, struct Object *ob)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+#endif
+;
+void calc_latt_deform(struct LatticeDeformData *lattice_deform_data, float co[3], float weight);
+void end_latt_deform(struct LatticeDeformData *lattice_deform_data);
 
 int object_deform_mball(struct Object *ob, struct ListBase *dispbase);
 void outside_lattice(struct Lattice *lt);
index 56b550a6f5d74b7249bf2ff5109b9538a3f4a41d..d4965cf55febc3f935e536518899036058c9da86 100644 (file)
@@ -54,6 +54,7 @@ struct MCol;
 struct MFace;
 struct MVert;
 struct IpoCurve;
+struct LatticeDeformData;
 struct LinkNode;
 struct KDTree;
 struct RNG;
@@ -258,7 +259,7 @@ void psys_set_current_num(Object *ob, int index);
 /* UNUSED */
 // struct Object *psys_find_object(struct Scene *scene, struct ParticleSystem *psys);
 
-struct Object *psys_get_lattice(struct ParticleSimulationData *sim);
+struct LatticeDeformData *psys_create_lattice_deform_data(struct ParticleSimulationData *sim);
 
 int psys_in_edit_mode(struct Scene *scene, struct ParticleSystem *psys);
 int psys_check_enabled(struct Object *ob, struct ParticleSystem *psys);
index b5a560249767d0bf34cbeabc8f9bf81b8f00a2e4..1b1bcffb4932ca79c830e9bc865001fe35d1da6a 100644 (file)
@@ -1330,7 +1330,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
 
                psys_check_group_weights(part);
 
-               psys->lattice = psys_get_lattice(&sim);
+               psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
 
                /* gather list of objects or single object */
                if (part->ren_as == PART_DRAW_GR) {
@@ -1567,9 +1567,9 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
        if (obcopylist)
                MEM_freeN(obcopylist);
 
-       if (psys->lattice) {
-               end_latt_deform(psys->lattice);
-               psys->lattice = NULL;
+       if (psys->lattice_deform_data) {
+               end_latt_deform(psys->lattice_deform_data);
+               psys->lattice_deform_data = NULL;
        }
 }
 
index b6baeea51b181c7f73044d3361d36d5b0df57093..60b4db6aa9b4e5e26bf4fb9b9453b7a524810bac 100644 (file)
@@ -307,7 +307,13 @@ void BKE_lattice_make_local(Lattice *lt)
        }
 }
 
-void init_latt_deform(Object *oblatt, Object *ob)
+typedef struct LatticeDeformData {
+       Object *object;
+       float *latticedata;
+       float latmat[4][4];
+} LatticeDeformData;
+
+LatticeDeformData *init_latt_deform(Object *oblatt, Object *ob)
 {
        /* we make an array with all differences */
        Lattice *lt = oblatt->data;
@@ -317,27 +323,30 @@ void init_latt_deform(Object *oblatt, Object *ob)
        float *fp, imat[4][4];
        float fu, fv, fw;
        int u, v, w;
+       float *latticedata;
+       float latmat[4][4];
+       LatticeDeformData *lattice_deform_data;
 
        if (lt->editlatt) lt = lt->editlatt->latt;
        bp = lt->def;
        
-       fp = lt->latticedata = MEM_mallocN(sizeof(float) * 3 * lt->pntsu * lt->pntsv * lt->pntsw, "latticedata");
+       fp = latticedata = MEM_mallocN(sizeof(float) * 3 * lt->pntsu * lt->pntsv * lt->pntsw, "latticedata");
        
        /* for example with a particle system: (ob == NULL) */
        if (ob == NULL) {
                /* in deformspace, calc matrix  */
-               invert_m4_m4(lt->latmat, oblatt->obmat);
+               invert_m4_m4(latmat, oblatt->obmat);
        
                /* back: put in deform array */
-               invert_m4_m4(imat, lt->latmat);
+               invert_m4_m4(imat, latmat);
        }
        else {
                /* in deformspace, calc matrix */
                invert_m4_m4(imat, oblatt->obmat);
-               mul_m4_m4m4(lt->latmat, imat, ob->obmat);
+               mul_m4_m4m4(latmat, imat, ob->obmat);
        
                /* back: put in deform array */
-               invert_m4_m4(imat, lt->latmat);
+               invert_m4_m4(imat, latmat);
        }
        
        for (w = 0, fw = lt->fw; w < lt->pntsw; w++, fw += lt->dw) {
@@ -358,10 +367,18 @@ void init_latt_deform(Object *oblatt, Object *ob)
                        }
                }
        }
+
+       lattice_deform_data = MEM_mallocN(sizeof(LatticeDeformData), "Lattice Deform Data");
+       lattice_deform_data->latticedata = latticedata;
+       lattice_deform_data->object = oblatt;
+       copy_m4_m4(lattice_deform_data->latmat, latmat);
+
+       return lattice_deform_data;
 }
 
-void calc_latt_deform(Object *ob, float co[3], float weight)
+void calc_latt_deform(LatticeDeformData *lattice_deform_data, float co[3], float weight)
 {
+       Object *ob = lattice_deform_data->object;
        Lattice *lt = ob->data;
        float u, v, w, tu[4], tv[4], tw[4];
        float vec[3];
@@ -375,7 +392,7 @@ void calc_latt_deform(Object *ob, float co[3], float weight)
 
 
        if (lt->editlatt) lt = lt->editlatt->latt;
-       if (lt->latticedata == NULL) return;
+       if (lattice_deform_data->latticedata == NULL) return;
 
        if (lt->vgroup[0] && dvert) {
                defgrp_index = defgroup_name_index(ob, lt->vgroup);
@@ -383,7 +400,7 @@ void calc_latt_deform(Object *ob, float co[3], float weight)
        }
 
        /* co is in local coords, treat with latmat */
-       mul_v3_m4v3(vec, lt->latmat, co);
+       mul_v3_m4v3(vec, lattice_deform_data->latmat, co);
 
        /* u v w coords */
 
@@ -456,7 +473,7 @@ void calc_latt_deform(Object *ob, float co[3], float weight)
                                                                idx_u = idx_v;
                                                        }
 
-                                                       madd_v3_v3fl(co, &lt->latticedata[idx_u * 3], u);
+                                                       madd_v3_v3fl(co, &lattice_deform_data->latticedata[idx_u * 3], u);
 
                                                        if (defgrp_index != -1)
                                                                weight_blend += (u * defvert_find_weight(dvert + idx_u, defgrp_index));
@@ -472,15 +489,12 @@ void calc_latt_deform(Object *ob, float co[3], float weight)
 
 }
 
-void end_latt_deform(Object *ob)
+void end_latt_deform(LatticeDeformData *lattice_deform_data)
 {
-       Lattice *lt = ob->data;
-       
-       if (lt->editlatt) lt = lt->editlatt->latt;
-       
-       if (lt->latticedata)
-               MEM_freeN(lt->latticedata);
-       lt->latticedata = NULL;
+       if (lattice_deform_data->latticedata)
+               MEM_freeN(lattice_deform_data->latticedata);
+
+       MEM_freeN(lattice_deform_data);
 }
 
 /* calculations is in local space of deformed object
@@ -815,13 +829,14 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target,
 void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm,
                           float (*vertexCos)[3], int numVerts, const char *vgroup, float fac)
 {
+       LatticeDeformData *lattice_deform_data;
        int a;
        int use_vgroups;
 
        if (laOb->type != OB_LATTICE)
                return;
 
-       init_latt_deform(laOb, target);
+       lattice_deform_data = init_latt_deform(laOb, target);
 
        /* check whether to use vertex groups (only possible if target is a Mesh)
         * we want either a Mesh with no derived data, or derived data with
@@ -855,16 +870,16 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm,
                                weight = defvert_find_weight(dvert, defgrp_index);
 
                                if (weight > 0.0f)
-                                       calc_latt_deform(laOb, vertexCos[a], weight * fac);
+                                       calc_latt_deform(lattice_deform_data, vertexCos[a], weight * fac);
                        }
                }
        }
        else {
                for (a = 0; a < numVerts; a++) {
-                       calc_latt_deform(laOb, vertexCos[a], fac);
+                       calc_latt_deform(lattice_deform_data, vertexCos[a], fac);
                }
        }
-       end_latt_deform(laOb);
+       end_latt_deform(lattice_deform_data);
 }
 
 int object_deform_mball(Object *ob, ListBase *dispbase)
index 6b754743c111e664010a48f85e72ace2fda41756..216bc94a058d2493d566532dfe22cae56a6b6cae 100644 (file)
@@ -221,12 +221,12 @@ Object *psys_find_object(Scene *scene, ParticleSystem *psys)
 }
 #endif
 
-Object *psys_get_lattice(ParticleSimulationData *sim)
+struct LatticeDeformData *psys_create_lattice_deform_data(ParticleSimulationData *sim)
 {
-       Object *lattice = NULL;
-       
-       if (psys_in_edit_mode(sim->scene, sim->psys) == 0) {
+       struct LatticeDeformData *lattice_deform_data = NULL;
 
+       if (psys_in_edit_mode(sim->scene, sim->psys) == 0) {
+               Object *lattice = NULL;
                ModifierData *md = (ModifierData *)psys_get_modifier(sim->ob, sim->psys);
 
                for (; md; md = md->next) {
@@ -237,10 +237,10 @@ Object *psys_get_lattice(ParticleSimulationData *sim)
                        }
                }
                if (lattice)
-                       init_latt_deform(lattice, NULL);
+                       lattice_deform_data = init_latt_deform(lattice, NULL);
        }
 
-       return lattice;
+       return lattice_deform_data;
 }
 void psys_disable_all(Object *ob)
 {
@@ -2513,7 +2513,7 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c
        ctx->cfra = cfra;
        ctx->editupdate = editupdate;
 
-       psys->lattice = psys_get_lattice(&ctx->sim);
+       psys->lattice_deform_data = psys_create_lattice_deform_data(&ctx->sim);
 
        /* cache all relevant vertex groups if they exist */
        ctx->vg_length = psys_cache_vgroup(ctx->dm, psys, PSYS_VG_LENGTH);
@@ -2974,7 +2974,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
        psys_free_path_cache(psys, psys->edit);
        cache = psys->pathcache = psys_alloc_path_cache_buffers(&psys->pathcachebufs, totpart, steps + 1);
 
-       psys->lattice = psys_get_lattice(sim);
+       psys->lattice_deform_data = psys_create_lattice_deform_data(sim);
        ma = give_current_material(sim->ob, psys->part->omat);
        if (ma && (psys->part->draw_col == PART_DRAW_COL_MAT))
                copy_v3_v3(col, &ma->r);
@@ -3079,9 +3079,9 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
                        }
 
                        /* lattices have to be calculated separately to avoid mixups between effector calculations */
-                       if (psys->lattice) {
+                       if (psys->lattice_deform_data) {
                                for (k = 0, ca = cache[p]; k <= steps; k++, ca++)
-                                       calc_latt_deform(psys->lattice, ca->co, 1.0f);
+                                       calc_latt_deform(psys->lattice_deform_data, ca->co, 1.0f);
                        }
                }
 
@@ -3112,9 +3112,9 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
 
        psys->totcached = totpart;
 
-       if (psys->lattice) {
-               end_latt_deform(psys->lattice);
-               psys->lattice = NULL;
+       if (psys->lattice_deform_data) {
+               end_latt_deform(psys->lattice_deform_data);
+               psys->lattice_deform_data = NULL;
        }
 
        if (vg_effector)
@@ -4166,8 +4166,8 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
                                                /* TODO: proper velocity handling */
                                        }
 
-                                       if (psys->lattice && edit == 0)
-                                               calc_latt_deform(psys->lattice, state->co, 1.0f);
+                                       if (psys->lattice_deform_data && edit == 0)
+                                               calc_latt_deform(psys->lattice_deform_data, state->co, 1.0f);
                                }
                        }
                }
@@ -4402,8 +4402,8 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
                        unit_m4(mat);
                        do_child_modifiers(sim, NULL, key1, key1->rot, cpa, cpa->fuv, mat, state, t);
 
-                       if (psys->lattice)
-                               calc_latt_deform(sim->psys->lattice, state->co, 1.0f);
+                       if (psys->lattice_deform_data)
+                               calc_latt_deform(psys->lattice_deform_data, state->co, 1.0f);
                }
                else {
                        if (pa->state.time == cfra || ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED))
@@ -4461,8 +4461,8 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
                                }
                        }
 
-                       if (sim->psys->lattice)
-                               calc_latt_deform(sim->psys->lattice, state->co, 1.0f);
+                       if (sim->psys->lattice_deform_data)
+                               calc_latt_deform(sim->psys->lattice_deform_data, state->co, 1.0f);
                }
                
                return 1;
@@ -4678,9 +4678,9 @@ void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys)
        sim.psys = psys;
        sim.psmd = psys_get_modifier(ob, psys);
 
-       psys->lattice = psys_get_lattice(&sim);
+       psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
 
-       if (psys->lattice) {
+       if (psys->lattice_deform_data) {
                ParticleData *pa = psys->particles;
                HairKey *hkey;
                int p, h;
@@ -4693,13 +4693,13 @@ void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys)
                        hkey = pa->hair;
                        for (h = 0; h < pa->totkey; h++, hkey++) {
                                mul_m4_v3(hairmat, hkey->co);
-                               calc_latt_deform(psys->lattice, hkey->co, 1.0f);
+                               calc_latt_deform(psys->lattice_deform_data, hkey->co, 1.0f);
                                mul_m4_v3(imat, hkey->co);
                        }
                }
                
-               end_latt_deform(psys->lattice);
-               psys->lattice = NULL;
+               end_latt_deform(psys->lattice_deform_data);
+               psys->lattice_deform_data = NULL;
 
                /* protect the applied shape */
                psys->flag |= PSYS_EDITED;
index 16ea71204ccbe53eb45ee92e99d6f6b68572a02d..ee3f3332ec35297199cca74e39b358ca3ebc8e93 100644 (file)
@@ -1514,9 +1514,9 @@ void psys_threads_free(ParticleThread *threads)
        if (ctx->vg_roughe)
                MEM_freeN(ctx->vg_roughe);
 
-       if (ctx->sim.psys->lattice) {
-               end_latt_deform(ctx->sim.psys->lattice);
-               ctx->sim.psys->lattice= NULL;
+       if (ctx->sim.psys->lattice_deform_data) {
+               end_latt_deform(ctx->sim.psys->lattice_deform_data);
+               ctx->sim.psys->lattice_deform_data = NULL;
        }
 
        /* distribution */
@@ -4108,7 +4108,7 @@ static void save_hair(ParticleSimulationData *sim, float UNUSED(cfra))
 
        invert_m4_m4(ob->imat, ob->obmat);
        
-       psys->lattice= psys_get_lattice(sim);
+       psys->lattice_deform_data= psys_create_lattice_deform_data(sim);
 
        if (psys->totpart==0) return;
        
@@ -4479,7 +4479,7 @@ static void cached_step(ParticleSimulationData *sim, float cfra)
                if (part->randsize > 0.0f)
                        pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
 
-               psys->lattice= psys_get_lattice(sim);
+               psys->lattice_deform_data = psys_create_lattice_deform_data(sim);
 
                dietime = pa->dietime;
 
@@ -4494,9 +4494,9 @@ static void cached_step(ParticleSimulationData *sim, float cfra)
                else
                        pa->alive = PARS_ALIVE;
 
-               if (psys->lattice) {
-                       end_latt_deform(psys->lattice);
-                       psys->lattice= NULL;
+               if (psys->lattice_deform_data) {
+                       end_latt_deform(psys->lattice_deform_data);
+                       psys->lattice_deform_data = NULL;
                }
 
                if (PSYS_FRAND(p) > disp)
@@ -4777,9 +4777,9 @@ static void system_step(ParticleSimulationData *sim, float cfra)
        update_children(sim);
 
 /* cleanup */
-       if (psys->lattice) {
-               end_latt_deform(psys->lattice);
-               psys->lattice= NULL;
+       if (psys->lattice_deform_data) {
+               end_latt_deform(psys->lattice_deform_data);
+               psys->lattice_deform_data = NULL;
        }
 }
 
index fcea69295319850a40b83eb2f5c8b635b88936d4..e02e285ee589acec22e2386c443665b31c5ecd71 100644 (file)
@@ -4569,7 +4569,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
                pdd->ma_col = ma_col;
        }
 
-       psys->lattice = psys_get_lattice(&sim);
+       psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
 
        /* circles don't use drawdata, so have to add a special case here */
        if ((pdd || draw_as == PART_DRAW_CIRC) && draw_as != PART_DRAW_PATH) {
@@ -4895,9 +4895,9 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
                pdd->flag &= ~PARTICLE_DRAW_DATA_UPDATED;
        }
 
-       if (psys->lattice) {
-               end_latt_deform(psys->lattice);
-               psys->lattice = NULL;
+       if (psys->lattice_deform_data) {
+               end_latt_deform(psys->lattice_deform_data);
+               psys->lattice_deform_data = NULL;
        }
 
        if (pdd) {
index 837f0c354e6246e61524bf03350d28fd098ee02e..242d6f0feeb42159aa452701671cd6588607ab61 100644 (file)
@@ -68,10 +68,6 @@ typedef struct Lattice {
        struct MDeformVert *dvert;
        char vgroup[64]; /* multiply the influence, MAX_VGROUP_NAME */
        
-       /* used while deforming, always free and NULL after use */
-       float *latticedata;
-       float latmat[4][4];
-       
        struct EditLatt *editlatt;
 } Lattice;
 
index 29fcaf3bf735a434c3df2fed137ec9b892e3f0cc..b7ca3066b4f8338ef14c78193afffcedc1011acd 100644 (file)
@@ -272,7 +272,9 @@ typedef struct ParticleSystem {
        struct DerivedMesh *hair_in_dm, *hair_out_dm;   /* input/output for cloth simulation */
 
        struct Object *target_ob;
-       struct Object *lattice;
+
+       struct LatticeDeformData *lattice_deform_data;          /* run-time only lattice deformation data */
+
        struct Object *parent;                                  /* particles from global space -> parent space */
 
        struct ListBase targets;                                /* used for keyed and boid physics */
index fe680041197796abec5a4c06033b2f9a098ec101..c4aa41cd566485ef4321172ceb69e0078053fc65 100644 (file)
@@ -869,7 +869,7 @@ static DerivedMesh *explodeMesh(ExplodeModifierData *emd,
        /* getting back to object space */
        invert_m4_m4(imat, ob->obmat);
 
-       psmd->psys->lattice = psys_get_lattice(&sim);
+       psmd->psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
 
        /* duplicate & displace vertices */
        ehi = BLI_edgehashIterator_new(vertpahash);
@@ -973,9 +973,9 @@ static DerivedMesh *explodeMesh(ExplodeModifierData *emd,
        CDDM_tessfaces_to_faces(explode);
        explode->dirty |= DM_DIRTY_NORMALS;
 
-       if (psmd->psys->lattice) {
-               end_latt_deform(psmd->psys->lattice);
-               psmd->psys->lattice = NULL;
+       if (psmd->psys->lattice_deform_data) {
+               end_latt_deform(psmd->psys->lattice_deform_data);
+               psmd->psys->lattice_deform_data = NULL;
        }
 
        return explode;
index e846ce11262b8d0a294da57a069b729f56d3c90a..c51fa329df22fc7eb810bdf9d3922fe1249a01bd 100644 (file)
@@ -261,7 +261,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
                maxloop += totloop;
        }
 
-       psys->lattice = psys_get_lattice(&sim);
+       psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
 
        if (psys->flag & (PSYS_HAIR_DONE | PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) {
                float min_r[3], max_r[3];
@@ -378,9 +378,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
 
        CDDM_calc_edges(result);
 
-       if (psys->lattice) {
-               end_latt_deform(psys->lattice);
-               psys->lattice = NULL;
+       if (psys->lattice_deform_data) {
+               end_latt_deform(psys->lattice_deform_data);
+               psys->lattice_deform_data = NULL;
        }
 
        if (size)
index ab888ba198b52762e30a1b4302b603f519d2d02a..698c46c1e8d2319fc152561b2c2531074549c712 100644 (file)
@@ -1741,7 +1741,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
        }
 
        if (path_nbr == 0)
-               psys->lattice = psys_get_lattice(&sim);
+               psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
 
 /* 3. start creating renderable things */
        for (a=0, pa=pars; a<totpart+totchild; a++, pa++, seed++) {
@@ -2094,9 +2094,9 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
 
        psys->flag &= ~PSYS_DRAWING;
 
-       if (psys->lattice) {
-               end_latt_deform(psys->lattice);
-               psys->lattice= NULL;
+       if (psys->lattice_deform_data) {
+               end_latt_deform(psys->lattice_deform_data);
+               psys->lattice_deform_data = NULL;
        }
 
        if (path_nbr && (ma->mode_l & MA_TANGENT_STR)==0)
index d4d6bfa5b7f10294490dcb78ea8a762505fc45b1..ce87888b6a0aac1ed8222216e0d650f2ac6c50ef 100644 (file)
@@ -140,7 +140,7 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa
        invert_m4_m4(ob->imat, ob->obmat);
        
        total_particles = psys->totpart+psys->totchild;
-       psys->lattice=psys_get_lattice(&sim);
+       psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
        
        pd->point_tree = BLI_bvhtree_new(total_particles, 0.0, 4, 6);
        alloc_point_data(pd, total_particles, data_used);
@@ -215,9 +215,9 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa
        BLI_bvhtree_balance(pd->point_tree);
        dm->release(dm);
        
-       if (psys->lattice) {
-               end_latt_deform(psys->lattice);
-               psys->lattice = NULL;
+       if (psys->lattice_deform_data) {
+               end_latt_deform(psys->lattice_deform_data);
+               psys->lattice_deform_data = NULL;
        }
        
        psys_render_restore(ob, psys);