Undo revision 23130 which was a merge with 2.5, a messy one because I did something...
[blender.git] / source / blender / editors / transform / transform_conversions.c
index aaede54..57a77ae 100644 (file)
@@ -698,8 +698,6 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob)
                        bone->flag &= ~BONE_HINGE_CHILD_TRANSFORM;
                        bone->flag &= ~BONE_TRANSFORM_CHILD;
                }
-               else
-                       bone->flag &= ~BONE_TRANSFORM;
        }
 
        /* make sure no bone can be transformed when a parent is transformed */
@@ -1617,32 +1615,31 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
        TransDataExtension *tx;
        Base *base = CTX_data_active_base(C);
        Object *ob = CTX_data_active_object(C);
-       ParticleEditSettings *pset = PE_settings(t->scene);
-       PTCacheEdit *edit = PE_get_current(t->scene, ob);
-       ParticleSystem *psys = NULL;
+       ParticleSystem *psys = PE_get_current(t->scene, ob);
        ParticleSystemModifierData *psmd = NULL;
-       PTCacheEditPoint *point;
-       PTCacheEditKey *key;
+       ParticleEditSettings *pset = PE_settings(t->scene);
+       ParticleData *pa = NULL;
+       ParticleEdit *edit;
+       ParticleEditKey *key;
        float mat[4][4];
-       int i,k, transformparticle;
+       int i,k, totpart, transformparticle;
        int count = 0, hasselected = 0;
        int propmode = t->flag & T_PROP_EDIT;
 
-       if(edit==NULL || t->settings->particle.selectmode==SCE_SELECT_PATH) return;
-
-       psys = edit->psys;
+       if(psys==NULL || t->settings->particle.selectmode==SCE_SELECT_PATH) return;
 
-       if(psys)
-               psmd = psys_get_modifier(ob,psys);
+       psmd = psys_get_modifier(ob,psys);
 
+       edit = psys->edit;
+       totpart = psys->totpart;
        base->flag |= BA_HAS_RECALC_DATA;
 
-       for(i=0, point=edit->points; i<edit->totpoint; i++, point++) {
-               point->flag &= ~PEP_TRANSFORM;
+       for(i=0, pa=psys->particles; i<totpart; i++, pa++) {
+               pa->flag &= ~PARS_TRANSFORM;
                transformparticle= 0;
 
-               if((point->flag & PEP_HIDE)==0) {
-                       for(k=0, key=point->keys; k<point->totkey; k++, key++) {
+               if((pa->flag & PARS_HIDE)==0) {
+                       for(k=0, key=edit->keys[i]; k<pa->totkey; k++, key++) {
                                if((key->flag&PEK_HIDE)==0) {
                                        if(key->flag&PEK_SELECT) {
                                                hasselected= 1;
@@ -1655,8 +1652,8 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
                }
 
                if(transformparticle) {
-                       count += point->totkey;
-                       point->flag |= PEP_TRANSFORM;
+                       count += pa->totkey;
+                       pa->flag |= PARS_TRANSFORM;
                }
        }
 
@@ -1675,23 +1672,18 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
 
        Mat4Invert(ob->imat,ob->obmat);
 
-       for(i=0, point=edit->points; i<edit->totpoint; i++, point++) {
+       for(i=0, pa=psys->particles; i<totpart; i++, pa++) {
                TransData *head, *tail;
                head = tail = td;
 
-               if(!(point->flag & PEP_TRANSFORM)) continue;
+               if(!(pa->flag & PARS_TRANSFORM)) continue;
 
-               if(psys)
-                       psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles + i, mat);
+               psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, mat);
 
-               for(k=0, key=point->keys; k<point->totkey; k++, key++) {
-                       if(psys) {
-                               VECCOPY(key->world_co, key->co);
-                               Mat4MulVecfl(mat, key->world_co);
-                               td->loc = key->world_co;
-                       }
-                       else
-                               td->loc = key->co;
+               for(k=0, key=edit->keys[i]; k<pa->totkey; k++, key++) {
+                       VECCOPY(key->world_co, key->co);
+                       Mat4MulVecfl(mat, key->world_co);
+                       td->loc = key->world_co;
 
                        VECCOPY(td->iloc, td->loc);
                        VECCOPY(td->center, td->loc);
@@ -1719,7 +1711,7 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
                                if(k==0) tx->size = 0;
                                else tx->size = (key - 1)->time;
 
-                               if(k == point->totkey - 1) tx->quat = 0;
+                               if(k == pa->totkey - 1) tx->quat = 0;
                                else tx->quat = (key + 1)->time;
                        }
 
@@ -1737,42 +1729,35 @@ void flushTransParticles(TransInfo *t)
 {
        Scene *scene = t->scene;
        Object *ob = OBACT;
-       PTCacheEdit *edit = PE_get_current(scene, ob);
-       ParticleSystem *psys = edit->psys;
+       ParticleSystem *psys = PE_get_current(scene, ob);
        ParticleSystemModifierData *psmd;
-       PTCacheEditPoint *point;
-       PTCacheEditKey *key;
+       ParticleData *pa;
+       ParticleEditKey *key;
        TransData *td;
        float mat[4][4], imat[4][4], co[3];
        int i, k, propmode = t->flag & T_PROP_EDIT;
 
-       if(psys)
-               psmd = psys_get_modifier(ob, psys);
+       psmd = psys_get_modifier(ob, psys);
 
        /* we do transform in world space, so flush world space position
-        * back to particle local space (only for hair particles) */
+        * back to particle local space */
        td= t->data;
-       for(i=0, point=edit->points; i<edit->totpoint; i++, point++, td++) {
-               if(!(point->flag & PEP_TRANSFORM)) continue;
-
-               if(psys) {
-                       psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles + i, mat);
-                       Mat4Invert(imat,mat);
+       for(i=0, pa=psys->particles; i<psys->totpart; i++, pa++, td++) {
+               if(!(pa->flag & PARS_TRANSFORM)) continue;
 
-                       for(k=0, key=point->keys; k<point->totkey; k++, key++) {
-                               VECCOPY(co, key->world_co);
-                               Mat4MulVecfl(imat, co);
+               psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, mat);
+               Mat4Invert(imat,mat);
 
+               for(k=0, key=psys->edit->keys[i]; k<pa->totkey; k++, key++) {
+                       VECCOPY(co, key->world_co);
+                       Mat4MulVecfl(imat, co);
 
-                               /* optimization for proportional edit */
-                               if(!propmode || !FloatCompare(key->co, co, 0.0001f)) {
-                                       VECCOPY(key->co, co);
-                                       point->flag |= PEP_EDIT_RECALC;
-                               }
+                       /* optimization for proportional edit */
+                       if(!propmode || !FloatCompare(key->co, co, 0.0001f)) {
+                               VECCOPY(key->co, co);
+                               pa->flag |= PARS_EDIT_RECALC;
                        }
                }
-               else
-                       point->flag |= PEP_EDIT_RECALC;
        }
 
        PE_update_object(scene, OBACT, 1);
@@ -4749,7 +4734,7 @@ void special_aftertrans_update(TransInfo *t)
                                 *      - sync this with actdata_filter_gpencil() in editaction.c
                                 */
                                for (sa= sc->areabase.first; sa; sa= sa->next) {
-                                       bGPdata *gpd= gpencil_data_get_active(sa);
+                                       bGPdata *gpd= gpencil_data_getactive(sa);
                                        
                                        if (gpd)
                                                posttrans_gpd_clean(gpd);
@@ -5269,8 +5254,7 @@ void createTransData(bContext *C, TransInfo *t)
                }
                CTX_DATA_END;
        }
-       else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT) 
-               && PE_start_edit(PE_get_current(scene, ob))) {
+       else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_can_edit(PE_get_current(scene, ob))) {
                createTransParticleVerts(C, t);
 
                if(t->data && t->flag & T_PROP_EDIT) {