~ubuntu-branches/ubuntu/utopic/blender/utopic-proposed

« back to all changes in this revision

Viewing changes to source/blender/blenkernel/intern/particle.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-02-19 11:24:23 UTC
  • mfrom: (14.2.23 sid)
  • Revision ID: package-import@ubuntu.com-20140219112423-rkmaz2m7ha06d4tk
Tags: 2.69-3ubuntu1
* Merge with Debian; remaining changes:
  - Configure without OpenImageIO on armhf, as it is not available on
    Ubuntu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
221
221
}
222
222
#endif
223
223
 
224
 
Object *psys_get_lattice(ParticleSimulationData *sim)
 
224
struct LatticeDeformData *psys_create_lattice_deform_data(ParticleSimulationData *sim)
225
225
{
226
 
        Object *lattice = NULL;
227
 
        
 
226
        struct LatticeDeformData *lattice_deform_data = NULL;
 
227
 
228
228
        if (psys_in_edit_mode(sim->scene, sim->psys) == 0) {
229
 
 
 
229
                Object *lattice = NULL;
230
230
                ModifierData *md = (ModifierData *)psys_get_modifier(sim->ob, sim->psys);
231
231
 
232
232
                for (; md; md = md->next) {
237
237
                        }
238
238
                }
239
239
                if (lattice)
240
 
                        init_latt_deform(lattice, NULL);
 
240
                        lattice_deform_data = init_latt_deform(lattice, NULL);
241
241
        }
242
242
 
243
 
        return lattice;
 
243
        return lattice_deform_data;
244
244
}
245
245
void psys_disable_all(Object *ob)
246
246
{
1729
1729
                return 0;
1730
1730
 
1731
1731
        if (dm->deformedOnly || index_dmcache == DMCACHE_ISCHILD) {
1732
 
                /* for meshes that are either only defined or for child particles, the
 
1732
                /* for meshes that are either only deformed or for child particles, the
1733
1733
                 * index and fw do not require any mapping, so we can directly use it */
1734
1734
                if (from == PART_FROM_VERT) {
1735
1735
                        if (index >= dm->getNumVerts(dm))
1817
1817
                        copy_v3_v3(orco, orcodata[mapindex]);
1818
1818
 
1819
1819
                if (ornor) {
1820
 
                        dm->getVertNo(dm, mapindex, nor);
1821
 
                        normalize_v3(nor);
 
1820
                        dm->getVertNo(dm, mapindex, ornor);
 
1821
                        normalize_v3(ornor);
1822
1822
                }
1823
1823
 
1824
1824
                if (utan && vtan) {
1843
1843
                        if (nor)
1844
1844
                                copy_v3_v3(nor, tmpnor);
1845
1845
 
1846
 
                        normalize_v3(tmpnor);
 
1846
                        normalize_v3(tmpnor);  /* XXX Why not normalize tmpnor before copying it into nor??? -- mont29 */
1847
1847
                        mul_v3_fl(tmpnor, -foffset);
1848
1848
                        add_v3_v3(vec, tmpnor);
1849
1849
                }
2513
2513
        ctx->cfra = cfra;
2514
2514
        ctx->editupdate = editupdate;
2515
2515
 
2516
 
        psys->lattice = psys_get_lattice(&ctx->sim);
 
2516
        psys->lattice_deform_data = psys_create_lattice_deform_data(&ctx->sim);
2517
2517
 
2518
2518
        /* cache all relevant vertex groups if they exist */
2519
2519
        ctx->vg_length = psys_cache_vgroup(ctx->dm, psys, PSYS_VG_LENGTH);
2974
2974
        psys_free_path_cache(psys, psys->edit);
2975
2975
        cache = psys->pathcache = psys_alloc_path_cache_buffers(&psys->pathcachebufs, totpart, steps + 1);
2976
2976
 
2977
 
        psys->lattice = psys_get_lattice(sim);
 
2977
        psys->lattice_deform_data = psys_create_lattice_deform_data(sim);
2978
2978
        ma = give_current_material(sim->ob, psys->part->omat);
2979
2979
        if (ma && (psys->part->draw_col == PART_DRAW_COL_MAT))
2980
2980
                copy_v3_v3(col, &ma->r);
3079
3079
                        }
3080
3080
 
3081
3081
                        /* lattices have to be calculated separately to avoid mixups between effector calculations */
3082
 
                        if (psys->lattice) {
 
3082
                        if (psys->lattice_deform_data) {
3083
3083
                                for (k = 0, ca = cache[p]; k <= steps; k++, ca++)
3084
 
                                        calc_latt_deform(psys->lattice, ca->co, 1.0f);
 
3084
                                        calc_latt_deform(psys->lattice_deform_data, ca->co, 1.0f);
3085
3085
                        }
3086
3086
                }
3087
3087
 
3112
3112
 
3113
3113
        psys->totcached = totpart;
3114
3114
 
3115
 
        if (psys->lattice) {
3116
 
                end_latt_deform(psys->lattice);
3117
 
                psys->lattice = NULL;
 
3115
        if (psys->lattice_deform_data) {
 
3116
                end_latt_deform(psys->lattice_deform_data);
 
3117
                psys->lattice_deform_data = NULL;
3118
3118
        }
3119
3119
 
3120
3120
        if (vg_effector)
3836
3836
 
3837
3837
        for (m = 0; m < MAX_MTEX; m++, mtexp++) {
3838
3838
                mtex = *mtexp;
3839
 
                if (mtex && mtex->mapto) {
 
3839
                if (mtex && mtex->tex && mtex->mapto) {
3840
3840
                        float def = mtex->def_var;
3841
3841
                        short blend = mtex->blendtype;
3842
3842
                        short texco = mtex->texco;
3904
3904
 
3905
3905
        for (m = 0; m < MAX_MTEX; m++, mtexp++) {
3906
3906
                mtex = *mtexp;
3907
 
                if (mtex && mtex->mapto) {
 
3907
                if (mtex && mtex->tex && mtex->mapto) {
3908
3908
                        float def = mtex->def_var;
3909
3909
                        short blend = mtex->blendtype;
3910
3910
                        short texco = mtex->texco;
4166
4166
                                                /* TODO: proper velocity handling */
4167
4167
                                        }
4168
4168
 
4169
 
                                        if (psys->lattice && edit == 0)
4170
 
                                                calc_latt_deform(psys->lattice, state->co, 1.0f);
 
4169
                                        if (psys->lattice_deform_data && edit == 0)
 
4170
                                                calc_latt_deform(psys->lattice_deform_data, state->co, 1.0f);
4171
4171
                                }
4172
4172
                        }
4173
4173
                }
4402
4402
                        unit_m4(mat);
4403
4403
                        do_child_modifiers(sim, NULL, key1, key1->rot, cpa, cpa->fuv, mat, state, t);
4404
4404
 
4405
 
                        if (psys->lattice)
4406
 
                                calc_latt_deform(sim->psys->lattice, state->co, 1.0f);
 
4405
                        if (psys->lattice_deform_data)
 
4406
                                calc_latt_deform(psys->lattice_deform_data, state->co, 1.0f);
4407
4407
                }
4408
4408
                else {
4409
4409
                        if (pa->state.time == cfra || ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED))
4461
4461
                                }
4462
4462
                        }
4463
4463
 
4464
 
                        if (sim->psys->lattice)
4465
 
                                calc_latt_deform(sim->psys->lattice, state->co, 1.0f);
 
4464
                        if (sim->psys->lattice_deform_data)
 
4465
                                calc_latt_deform(sim->psys->lattice_deform_data, state->co, 1.0f);
4466
4466
                }
4467
4467
                
4468
4468
                return 1;
4678
4678
        sim.psys = psys;
4679
4679
        sim.psmd = psys_get_modifier(ob, psys);
4680
4680
 
4681
 
        psys->lattice = psys_get_lattice(&sim);
 
4681
        psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
4682
4682
 
4683
 
        if (psys->lattice) {
 
4683
        if (psys->lattice_deform_data) {
4684
4684
                ParticleData *pa = psys->particles;
4685
4685
                HairKey *hkey;
4686
4686
                int p, h;
4693
4693
                        hkey = pa->hair;
4694
4694
                        for (h = 0; h < pa->totkey; h++, hkey++) {
4695
4695
                                mul_m4_v3(hairmat, hkey->co);
4696
 
                                calc_latt_deform(psys->lattice, hkey->co, 1.0f);
 
4696
                                calc_latt_deform(psys->lattice_deform_data, hkey->co, 1.0f);
4697
4697
                                mul_m4_v3(imat, hkey->co);
4698
4698
                        }
4699
4699
                }
4700
4700
                
4701
 
                end_latt_deform(psys->lattice);
4702
 
                psys->lattice = NULL;
 
4701
                end_latt_deform(psys->lattice_deform_data);
 
4702
                psys->lattice_deform_data = NULL;
4703
4703
 
4704
4704
                /* protect the applied shape */
4705
4705
                psys->flag |= PSYS_EDITED;