replace macros with bli math functions for particles code
[blender.git] / source / blender / editors / physics / particle_edit.c
index b0a17c6f9a9dfb62c4fa86de38acb77e04f2fd5b..52e6d4f6ab8500cfdf2f2dfcf2ec35baff34e664 100644 (file)
@@ -390,7 +390,7 @@ static void PE_set_view3d_data(bContext *C, PEData *data)
 
 /*************************** selection utilities *******************************/
 
-static int key_test_depth(PEData *data, float co[3])
+static int key_test_depth(PEData *data, const float co[3])
 {
        View3D *v3d= data->vc.v3d;
        double ux, uy, uz;
@@ -407,7 +407,7 @@ static int key_test_depth(PEData *data, float co[3])
                return 0;
 
        gluProject(co[0],co[1],co[2], data->mats.modelview, data->mats.projection,
-               (GLint *)data->mats.viewport, &ux, &uy, &uz);
+                  (GLint *)data->mats.viewport, &ux, &uy, &uz);
 
        x=wco[0];
        y=wco[1];
@@ -434,7 +434,7 @@ static int key_test_depth(PEData *data, float co[3])
                return 1;
 }
 
-static int key_inside_circle(PEData *data, float rad, float co[3], float *distance)
+static int key_inside_circle(PEData *data, float rad, const float co[3], float *distance)
 {
        float dx, dy, dist;
        int sco[2];
@@ -461,7 +461,7 @@ static int key_inside_circle(PEData *data, float rad, float co[3], float *distan
        return 0;
 }
 
-static int key_inside_rect(PEData *data, float co[3])
+static int key_inside_rect(PEData *data, const float co[3])
 {
        int sco[2];
 
@@ -477,7 +477,7 @@ static int key_inside_rect(PEData *data, float co[3])
        return 0;
 }
 
-static int key_inside_test(PEData *data, float co[3])
+static int key_inside_test(PEData *data, const float co[3])
 {
        if(data->mval)
                return key_inside_circle(data, data->rad, co, NULL);
@@ -719,7 +719,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
        LOOP_PARTICLES {
                key = pa->hair;
                psys_mat_hair_to_orco(ob, psmd->dm, psys->part->from, pa, mat);
-               VECCOPY(co, key->co);
+               copy_v3_v3(co, key->co);
                mul_m4_v3(mat, co);
                BLI_kdtree_insert(tree, p, co, NULL);
        }
@@ -733,7 +733,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
        LOOP_PARTICLES {
                key = pa->hair;
                psys_mat_hair_to_orco(ob, psmd->dm, psys->part->from, pa, mat);
-               VECCOPY(co, key->co);
+               copy_v3_v3(co, key->co);
                mul_m4_v3(mat, co);
                co[0]= -co[0];
 
@@ -818,7 +818,7 @@ static void PE_mirror_particle(Object *ob, DerivedMesh *dm, ParticleSystem *psys
        key= point->keys;
        mkey= mpoint->keys;
        for(k=0; k<pa->totkey; k++, hkey++, mhkey++, key++, mkey++) {
-               VECCOPY(mhkey->co, hkey->co);
+               copy_v3_v3(mhkey->co, hkey->co);
                mul_m4_v3(mat, mhkey->co);
                mhkey->co[0]= -mhkey->co[0];
                mul_m4_v3(immat, mhkey->co);
@@ -918,7 +918,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit)
                                sub_v3_v3v3(dvec, key->co, vec);
 
                                dot=dot_v3v3(dvec,nor);
-                               VECCOPY(dvec,nor);
+                               copy_v3_v3(dvec,nor);
 
                                if(dot>0.0f) {
                                        if(dot<dist_1st) {
@@ -1019,7 +1019,7 @@ static void pe_iterate_lengths(Scene *scene, PTCacheEdit *edit)
                                        add_v3_v3((key-1)->co, dv1);
                                }
 
-                               VECADD(dv1,dv0,dv2);
+                               add_v3_v3v3(dv1, dv0, dv2);
                        }
                }
        }
@@ -1071,20 +1071,20 @@ static void recalc_emitter_field(Object *ob, ParticleSystem *psys)
                MVert *mvert;
 
                mvert=dm->getVertData(dm,mface->v1,CD_MVERT);
-               VECCOPY(vec,mvert->co);
+               copy_v3_v3(vec,mvert->co);
                VECCOPY(nor,mvert->no);
 
                mvert=dm->getVertData(dm,mface->v2,CD_MVERT);
-               VECADD(vec,vec,mvert->co);
+               add_v3_v3v3(vec,vec,mvert->co);
                VECADD(nor,nor,mvert->no);
 
                mvert=dm->getVertData(dm,mface->v3,CD_MVERT);
-               VECADD(vec,vec,mvert->co);
+               add_v3_v3v3(vec,vec,mvert->co);
                VECADD(nor,nor,mvert->no);
 
                if(mface->v4) {
                        mvert=dm->getVertData(dm,mface->v4,CD_MVERT);
-                       VECADD(vec,vec,mvert->co);
+                       add_v3_v3v3(vec,vec,mvert->co);
                        VECADD(nor,nor,mvert->no);
                        
                        mul_v3_fl(vec,0.25);
@@ -1144,7 +1144,7 @@ static void update_world_cos(Object *ob, PTCacheEdit *edit)
                        psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles+p, hairmat);
 
                LOOP_KEYS {
-                       VECCOPY(key->world_co,key->co);
+                       copy_v3_v3(key->world_co,key->co);
                        if(!(psys->flag & PSYS_GLOBAL_HAIR))
                                mul_m4_v3(hairmat, key->world_co);
                }
@@ -1170,13 +1170,13 @@ static void update_velocities(PTCacheEdit *edit)
                                if(dfra <= 0.0f)
                                        continue;
 
-                               VECSUB(key->vel, (key+1)->co, key->co);
+                               sub_v3_v3v3(key->vel, (key+1)->co, key->co);
 
                                if(point->totkey>2) {
-                                       VECSUB(vec1, (key+1)->co, (key+2)->co);
+                                       sub_v3_v3v3(vec1, (key+1)->co, (key+2)->co);
                                        project_v3_v3v3(vec2, vec1, key->vel);
-                                       VECSUB(vec2, vec1, vec2);
-                                       VECADDFAC(key->vel, key->vel, vec2, 0.5f);
+                                       sub_v3_v3v3(vec2, vec1, vec2);
+                                       madd_v3_v3fl(key->vel, vec2, 0.5f);
                                }
                        }
                        else if(k==point->totkey-1) {
@@ -1185,13 +1185,13 @@ static void update_velocities(PTCacheEdit *edit)
                                if(dfra <= 0.0f)
                                        continue;
 
-                               VECSUB(key->vel, key->co, (key-1)->co);
+                               sub_v3_v3v3(key->vel, key->co, (key-1)->co);
 
                                if(point->totkey>2) {
-                                       VECSUB(vec1, (key-2)->co, (key-1)->co);
+                                       sub_v3_v3v3(vec1, (key-2)->co, (key-1)->co);
                                        project_v3_v3v3(vec2, vec1, key->vel);
-                                       VECSUB(vec2, vec1, vec2);
-                                       VECADDFAC(key->vel, key->vel, vec2, 0.5f);
+                                       sub_v3_v3v3(vec2, vec1, vec2);
+                                       madd_v3_v3fl(key->vel, vec2, 0.5f);
                                }
                        }
                        else {
@@ -1200,7 +1200,7 @@ static void update_velocities(PTCacheEdit *edit)
                                if(dfra <= 0.0f)
                                        continue;
 
-                               VECSUB(key->vel, (key+1)->co, (key-1)->co);
+                               sub_v3_v3v3(key->vel, (key+1)->co, (key-1)->co);
                        }
                        mul_v3_fl(key->vel, frs_sec/dfra);
                }
@@ -1623,7 +1623,7 @@ int PE_lasso_select(bContext *C, int mcords[][2], short moves, short extend, sho
 
                if(pset->selectmode==SCE_SELECT_POINT) {
                        LOOP_KEYS {
-                               VECCOPY(co, key->co);
+                               copy_v3_v3(co, key->co);
                                mul_m4_v3(mat, co);
                                project_int(ar, co, vertco);
                                if((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1]) && key_test_depth(&data, co)) {
@@ -1641,7 +1641,7 @@ int PE_lasso_select(bContext *C, int mcords[][2], short moves, short extend, sho
                else if(pset->selectmode==SCE_SELECT_END) {
                        key= point->keys + point->totkey - 1;
 
-                       VECCOPY(co, key->co);
+                       copy_v3_v3(co, key->co);
                        mul_m4_v3(mat, co);
                        project_int(ar, co,vertco);
                        if((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1]) && key_test_depth(&data, co)) {
@@ -1934,8 +1934,8 @@ static void rekey_particle(PEData *data, int pa_index)
 
        okey = pa->hair;
        /* root and tip stay the same */
-       VECCOPY(key->co, okey->co);
-       VECCOPY((key + data->totrekey - 1)->co, (okey + pa->totkey - 1)->co);
+       copy_v3_v3(key->co, okey->co);
+       copy_v3_v3((key + data->totrekey - 1)->co, (okey + pa->totkey - 1)->co);
 
        sta= key->time= okey->time;
        end= (key + data->totrekey - 1)->time= (okey + pa->totkey - 1)->time;
@@ -1945,7 +1945,7 @@ static void rekey_particle(PEData *data, int pa_index)
        for(k=1,key++; k<data->totrekey-1; k++,key++) {
                state.time= (float)k / (float)(data->totrekey-1);
                psys_get_particle_on_path(&sim, pa_index, &state, 0);
-               VECCOPY(key->co, state.co);
+               copy_v3_v3(key->co, state.co);
                key->time= sta + k * dval;
        }
 
@@ -2038,7 +2038,7 @@ static void rekey_particle_to_time(Scene *scene, Object *ob, int pa_index, float
        for(k=1, key++; k < pa->totkey; k++, key++) {
                state.time= path_time * (float)k / (float)(pa->totkey-1);
                psys_get_particle_on_path(&sim, pa_index, &state, 0);
-               VECCOPY(key->co, state.co);
+               copy_v3_v3(key->co, state.co);
        }
 
        /* replace hair keys */
@@ -2188,7 +2188,7 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys)
                                }
 
                                if(hkey < pa->hair + pa->totkey) {
-                                       VECCOPY(nhkey->co, hkey->co);
+                                       copy_v3_v3(nhkey->co, hkey->co);
                                        nhkey->editflag = hkey->editflag;
                                        nhkey->time= hkey->time;
                                        nhkey->weight= hkey->weight;
@@ -2199,7 +2199,7 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys)
                                        nkey->flag = key->flag;
                                        nkey->ftime = key->ftime;
                                        nkey->length = key->length;
-                                       VECCOPY(nkey->world_co, key->world_co);
+                                       copy_v3_v3(nkey->world_co, key->world_co);
                                }
                                nkey++;
                                nhkey++;
@@ -2275,7 +2275,7 @@ static void subdivide_particle(PEData *data, int pa_index)
                        nkey->time= (key->time + (key+1)->time)*0.5f;
                        state.time= (endtime != 0.0f)? nkey->time/endtime: 0.0f;
                        psys_get_particle_on_path(&sim, pa_index, &state, 0);
-                       VECCOPY(nkey->co, state.co);
+                       copy_v3_v3(nkey->co, state.co);
 
                        nekey->co= nkey->co;
                        nekey->time= &nkey->time;
@@ -2365,7 +2365,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
                /* insert particles into kd tree */
                LOOP_SELECTED_POINTS {
                        psys_mat_hair_to_object(ob, psmd->dm, psys->part->from, psys->particles+p, mat);
-                       VECCOPY(co, point->keys->co);
+                       copy_v3_v3(co, point->keys->co);
                        mul_m4_v3(mat, co);
                        BLI_kdtree_insert(tree, p, co, NULL);
                }
@@ -2375,7 +2375,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
                /* tag particles to be removed */
                LOOP_SELECTED_POINTS {
                        psys_mat_hair_to_object(ob, psmd->dm, psys->part->from, psys->particles+p, mat);
-                       VECCOPY(co, point->keys->co);
+                       copy_v3_v3(co, point->keys->co);
                        mul_m4_v3(mat, co);
 
                        totn= BLI_kdtree_find_n_nearest(tree,10,co,NULL,nearest);
@@ -2747,10 +2747,10 @@ static void brush_comb(PEData *data, float UNUSED(mat[][4]), float imat[][4], in
 
        fac= (float)pow((double)(1.0f - data->dist / data->rad), (double)data->combfac);
 
-       VECCOPY(cvec,data->dvec);
+       copy_v3_v3(cvec,data->dvec);
        mul_mat3_m4_v3(imat,cvec);
        mul_v3_fl(cvec, fac);
-       VECADD(key->co, key->co, cvec);
+       add_v3_v3(key->co, cvec);
 
        (data->edit->points + point_index)->flag |= PEP_EDIT_RECALC;
 }
@@ -2861,13 +2861,13 @@ static void brush_length(PEData *data, int point_index)
 
        LOOP_KEYS {
                if(k==0) {
-                       VECCOPY(pvec,key->co);
+                       copy_v3_v3(pvec,key->co);
                }
                else {
-                       VECSUB(dvec,key->co,pvec);
-                       VECCOPY(pvec,key->co);
+                       sub_v3_v3v3(dvec,key->co,pvec);
+                       copy_v3_v3(pvec,key->co);
                        mul_v3_fl(dvec,data->growfac);
-                       VECADD(key->co,(key-1)->co,dvec);
+                       add_v3_v3v3(key->co,(key-1)->co,dvec);
                }
        }
 
@@ -2904,14 +2904,14 @@ static void brush_puff(PEData *data, int point_index)
        LOOP_KEYS {
                if(k==0) {
                        /* find root coordinate and normal on emitter */
-                       VECCOPY(co, key->co);
+                       copy_v3_v3(co, key->co);
                        mul_m4_v3(mat, co);
                        mul_v3_m4v3(kco, data->ob->imat, co); /* use 'kco' as the object space version of worldspace 'co', ob->imat is set before calling */
 
                        point_index= BLI_kdtree_find_nearest(edit->emitter_field, kco, NULL, NULL);
                        if(point_index == -1) return;
 
-                       VECCOPY(rootco, co);
+                       copy_v3_v3(rootco, co);
                        copy_v3_v3(nor, &edit->emitter_cosnos[point_index*6+3]);
                        mul_mat3_m4_v3(data->ob->obmat, nor); /* normal into worldspace */
 
@@ -2926,19 +2926,19 @@ static void brush_puff(PEData *data, int point_index)
                else {
                        /* compute position as if hair was standing up straight.
                         * */
-                       VECCOPY(lastco, co);
-                       VECCOPY(co, key->co);
+                       copy_v3_v3(lastco, co);
+                       copy_v3_v3(co, key->co);
                        mul_m4_v3(mat, co);
                        length += len_v3v3(lastco, co);
                        if((data->select==0 || (key->flag & PEK_SELECT)) && !(key->flag & PEK_HIDE)) {
-                               VECADDFAC(kco, rootco, nor, length);
+                               madd_v3_v3v3fl(kco, rootco, nor, length);
 
                                /* blend between the current and straight position */
-                               VECSUB(dco, kco, co);
-                               VECADDFAC(co, co, dco, fac);
+                               sub_v3_v3v3(dco, kco, co);
+                               madd_v3_v3fl(co, dco, fac);
 
                                /* re-use dco to compare before and after translation and add to the offset  */
-                               VECCOPY(dco, key->co);
+                               copy_v3_v3(dco, key->co);
 
                                mul_v3_m4v3(key->co, imat, co);
 
@@ -2965,7 +2965,7 @@ static void brush_puff(PEData *data, int point_index)
                                                /* Move the unselected point on a vector based on the
                                                 * hair direction and the offset */
                                                float c1[3], c2[3];
-                                               VECSUB(dco, lastco, co);
+                                               sub_v3_v3v3(dco, lastco, co);
                                                mul_mat3_m4_v3(imat, dco); /* into particle space */
 
                                                /* move the point along a vector perpendicular to the
@@ -2979,7 +2979,7 @@ static void brush_puff(PEData *data, int point_index)
                                                /* Move the unselected point on a vector based on the
                                                 * the normal of the closest geometry */
                                                float oco[3], onor[3];
-                                               VECCOPY(oco, key->co);
+                                               copy_v3_v3(oco, key->co);
                                                mul_m4_v3(mat, oco);
                                                mul_v3_m4v3(kco, data->ob->imat, oco); /* use 'kco' as the object space version of worldspace 'co', ob->imat is set before calling */
 
@@ -3028,7 +3028,7 @@ static void brush_smooth_get(PEData *data, float mat[][4], float UNUSED(imat[][4
 
                sub_v3_v3v3(dvec,key->co,(key-1)->co);
                mul_mat3_m4_v3(mat,dvec);
-               VECADD(data->vec,data->vec,dvec);
+               add_v3_v3(data->vec, dvec);
                data->tot++;
        }
 }
@@ -3038,57 +3038,61 @@ static void brush_smooth_do(PEData *data, float UNUSED(mat[][4]), float imat[][4
        float vec[3], dvec[3];
        
        if(key_index) {
-               VECCOPY(vec,data->vec);
+               copy_v3_v3(vec, data->vec);
                mul_mat3_m4_v3(imat,vec);
 
                sub_v3_v3v3(dvec,key->co,(key-1)->co);
 
-               VECSUB(dvec,vec,dvec);
+               sub_v3_v3v3(dvec,vec,dvec);
                mul_v3_fl(dvec,data->smoothfac);
                
-               VECADD(key->co,key->co,dvec);
+               add_v3_v3(key->co, dvec);
        }
 
        (data->edit->points + point_index)->flag |= PEP_EDIT_RECALC;
 }
 
 /* convert from triangle barycentric weights to quad mean value weights */
-static void intersect_dm_quad_weights(float *v1, float *v2, float *v3, float *v4, float *w)
+static void intersect_dm_quad_weights(const float v1[3], const float v2[3], const float v3[3], const float v4[3], float w[4])
 {
        float co[3], vert[4][3];
 
-       VECCOPY(vert[0], v1);
-       VECCOPY(vert[1], v2);
-       VECCOPY(vert[2], v3);
-       VECCOPY(vert[3], v4);
+       copy_v3_v3(vert[0], v1);
+       copy_v3_v3(vert[1], v2);
+       copy_v3_v3(vert[2], v3);
+       copy_v3_v3(vert[3], v4);
 
        co[0]= v1[0]*w[0] + v2[0]*w[1] + v3[0]*w[2] + v4[0]*w[3];
        co[1]= v1[1]*w[0] + v2[1]*w[1] + v3[1]*w[2] + v4[1]*w[3];
        co[2]= v1[2]*w[0] + v2[2]*w[1] + v3[2]*w[2] + v4[2]*w[3];
 
-       interp_weights_poly_v3( w,vert, 4, co);
+       interp_weights_poly_v3(w, vert, 4, co);
 }
 
 /* check intersection with a derivedmesh */
-static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, float *vert_cos, float *co1, float* co2, float *min_d, int *min_face, float *min_w,
-                                                 float *face_minmax, float *pa_minmax, float radius, float *ipoint)
+static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm,
+                                 float *vert_cos,
+                                 const float co1[3], const float co2[3],
+                                 float *min_d, int *min_face, float *min_w,
+                                 float *face_minmax, float *pa_minmax,
+                                 float radius, float *ipoint)
 {
-       MFace *mface=0;
-       MVert *mvert=0;
+       MFace *mface= NULL;
+       MVert *mvert= NULL;
        int i, totface, intersect=0;
        float cur_d, cur_uv[2], v1[3], v2[3], v3[3], v4[3], min[3], max[3], p_min[3],p_max[3];
        float cur_ipoint[3];
        
-       if(dm==0){
+       if(dm == NULL){
                psys_disable_all(ob);
 
                dm=mesh_get_derived_final(scene, ob, 0);
-               if(dm==0)
+               if(dm == NULL)
                        dm=mesh_get_derived_deform(scene, ob, 0);
 
                psys_enable_all(ob);
 
-               if(dm==0)
+               if(dm == NULL)
                        return 0;
        }
 
@@ -3100,8 +3104,8 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, floa
                DO_MINMAX(co2,p_min,p_max);
        }
        else{
-               VECCOPY(p_min,pa_minmax);
-               VECCOPY(p_max,pa_minmax+3);
+               copy_v3_v3(p_min,pa_minmax);
+               copy_v3_v3(p_max,pa_minmax+3);
        }
 
        totface=dm->getNumFaces(dm);
@@ -3111,18 +3115,18 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, floa
        /* lets intersect the faces */
        for(i=0; i<totface; i++,mface++){
                if(vert_cos){
-                       VECCOPY(v1,vert_cos+3*mface->v1);
-                       VECCOPY(v2,vert_cos+3*mface->v2);
-                       VECCOPY(v3,vert_cos+3*mface->v3);
+                       copy_v3_v3(v1,vert_cos+3*mface->v1);
+                       copy_v3_v3(v2,vert_cos+3*mface->v2);
+                       copy_v3_v3(v3,vert_cos+3*mface->v3);
                        if(mface->v4)
-                               VECCOPY(v4,vert_cos+3*mface->v4)
+                               copy_v3_v3(v4,vert_cos+3*mface->v4);
                }
                else{
-                       VECCOPY(v1,mvert[mface->v1].co);
-                       VECCOPY(v2,mvert[mface->v2].co);
-                       VECCOPY(v3,mvert[mface->v3].co);
+                       copy_v3_v3(v1,mvert[mface->v1].co);
+                       copy_v3_v3(v2,mvert[mface->v2].co);
+                       copy_v3_v3(v3,mvert[mface->v3].co);
                        if(mface->v4)
-                               VECCOPY(v4,mvert[mface->v4].co)
+                               copy_v3_v3(v4,mvert[mface->v4].co);
                }
 
                if(face_minmax==0){
@@ -3136,8 +3140,8 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, floa
                                continue;
                }
                else{
-                       VECCOPY(min, face_minmax+6*i);
-                       VECCOPY(max, face_minmax+6*i+3);
+                       copy_v3_v3(min, face_minmax+6*i);
+                       copy_v3_v3(max, face_minmax+6*i+3);
                        if(isect_aabb_aabb_v3(min,max,p_min,p_max)==0)
                                continue;
                }
@@ -3146,7 +3150,7 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, floa
                        if(isect_sweeping_sphere_tri_v3(co1, co2, radius, v2, v3, v1, &cur_d, cur_ipoint)){
                                if(cur_d<*min_d){
                                        *min_d=cur_d;
-                                       VECCOPY(ipoint,cur_ipoint);
+                                       copy_v3_v3(ipoint,cur_ipoint);
                                        *min_face=i;
                                        intersect=1;
                                }
@@ -3155,7 +3159,7 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, floa
                                if(isect_sweeping_sphere_tri_v3(co1, co2, radius, v4, v1, v3, &cur_d, cur_ipoint)){
                                        if(cur_d<*min_d){
                                                *min_d=cur_d;
-                                               VECCOPY(ipoint,cur_ipoint);
+                                               copy_v3_v3(ipoint,cur_ipoint);
                                                *min_face=i;
                                                intersect=1;
                                        }
@@ -3363,27 +3367,27 @@ static int brush_add(PEData *data, short number)
                                                key3[1].time= key3[0].time;
                                                psys_get_particle_on_path(&sim, ptn[1].index, &key3[1], 0);
                                                mul_v3_fl(key3[1].co, weight[1]);
-                                               VECADD(key3[0].co, key3[0].co, key3[1].co);
+                                               add_v3_v3(key3[0].co, key3[1].co);
 
                                                if(maxw>2) {                                            
                                                        key3[2].time= key3[0].time;
                                                        psys_get_particle_on_path(&sim, ptn[2].index, &key3[2], 0);
                                                        mul_v3_fl(key3[2].co, weight[2]);
-                                                       VECADD(key3[0].co, key3[0].co, key3[2].co);
+                                                       add_v3_v3(key3[0].co, key3[2].co);
                                                }
                                        }
 
                                        if(k==0)
-                                               VECSUB(co1, pa->state.co, key3[0].co);
+                                               sub_v3_v3v3(co1, pa->state.co, key3[0].co);
 
-                                       VECADD(thkey->co, key3[0].co, co1);
+                                       add_v3_v3v3(thkey->co, key3[0].co, co1);
 
                                        thkey->time= key3[0].time;
                                }
                        }
                        else {
                                for(k=0, hkey=pa->hair; k<pset->totaddkey; k++, hkey++) {
-                                       VECADDFAC(hkey->co, pa->state.co, pa->state.vel, k * framestep * timestep);
+                                       madd_v3_v3v3fl(hkey->co, pa->state.co, pa->state.vel, k * framestep * timestep);
                                        hkey->time += k * framestep;
                                        hkey->weight = 1.f - (float)k/(float)(pset->totaddkey-1);
                                }
@@ -4043,7 +4047,7 @@ const char *PE_undo_get_name(Scene *scene, int nr, int *active)
 
 /************************ utilities ******************************/
 
-int PE_minmax(Scene *scene, float *min, float *max)
+int PE_minmax(Scene *scene, float min[3], float max[3])
 {
        Object *ob= OBACT;
        PTCacheEdit *edit= PE_get_current(scene, ob);
@@ -4065,7 +4069,7 @@ int PE_minmax(Scene *scene, float *min, float *max)
                        psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles+p, mat);
 
                LOOP_SELECTED_KEYS {
-                       VECCOPY(co, key->co);
+                       copy_v3_v3(co, key->co);
                        mul_m4_v3(mat, co);
                        DO_MINMAX(co, min, max);                
                        ok= 1;