diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-11-11 13:44:46 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-11-11 13:44:46 +0300 |
commit | 2e3326c1533e992ef7eaa43ed876375af4db5de1 (patch) | |
tree | fe0adcbf314053bd3c079abd4692dea851231aac /source/blender/editors/sculpt_paint | |
parent | 7fe52eedba00a3008d56ad0d689ed27fcf658220 (diff) | |
parent | e4f10565ea6b4a9015bd5a9e81b77d1d549e9b46 (diff) |
Sculpt: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r24330:24483
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 294 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 2 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_utils.c | 14 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 32 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 118 |
5 files changed, 229 insertions, 231 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index d8c4d505fc9..a411b0b021d 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -40,7 +40,7 @@ #ifdef WIN32 #include "BLI_winstuff.h" #endif -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" #include "BLI_linklist.h" @@ -554,7 +554,7 @@ static int project_paint_PickFace(const ProjPaintState *ps, float pt[2], float w v2= ps->screenCoords[mf->v2]; v3= ps->screenCoords[mf->v3]; - if (IsectPT2Df(pt, v1, v2, v3)) { + if (isect_point_tri_v2(pt, v1, v2, v3)) { if (ps->is_ortho) z_depth= VecZDepthOrtho(pt, v1, v2, v3, w_tmp); else z_depth= VecZDepthPersp(pt, v1, v2, v3, w_tmp); @@ -568,7 +568,7 @@ static int project_paint_PickFace(const ProjPaintState *ps, float pt[2], float w else if (mf->v4) { v4= ps->screenCoords[mf->v4]; - if (IsectPT2Df(pt, v1, v3, v4)) { + if (isect_point_tri_v2(pt, v1, v3, v4)) { if (ps->is_ortho) z_depth= VecZDepthOrtho(pt, v1, v3, v4, w_tmp); else z_depth= VecZDepthPersp(pt, v1, v3, v4, w_tmp); @@ -619,10 +619,10 @@ static int project_paint_PickColor(const ProjPaintState *ps, float pt[2], float tf = ps->dm_mtface + face_index; if (side == 0) { - Vec2Lerp3f(uv, tf->uv[0], tf->uv[1], tf->uv[2], w); + interp_v2_v2v2v2(uv, tf->uv[0], tf->uv[1], tf->uv[2], w); } else { /* QUAD */ - Vec2Lerp3f(uv, tf->uv[0], tf->uv[2], tf->uv[3], w); + interp_v2_v2v2v2(uv, tf->uv[0], tf->uv[2], tf->uv[3], w); } ibuf = tf->tpage->ibufs.first; /* we must have got the imbuf before getting here */ @@ -703,7 +703,7 @@ static int project_paint_occlude_ptv(float pt[3], float v1[3], float v2[3], floa return 0; /* do a 2D point in try intersection */ - if (!IsectPT2Df(pt, v1, v2, v3)) + if (!isect_point_tri_v2(pt, v1, v2, v3)) return 0; /* we know there is */ @@ -743,10 +743,10 @@ static int project_paint_occlude_ptv_clip( } /* Test if we're in the clipped area, */ - if (side) VecLerp3f(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w); - else VecLerp3f(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w); + if (side) interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w); + else interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w); - Mat4MulVecfl(ps->ob->obmat, wco); + mul_m4_v3(ps->ob->obmat, wco); if(!view3d_test_clipping(ps->rv3d, wco)) { return 1; } @@ -1047,51 +1047,51 @@ static void uv_image_outset(float (*orig_uv)[2], float (*outset_uv)[2], const fl } /* face edge directions */ - Vec2Subf(dir1, puv[1], puv[0]); - Vec2Subf(dir2, puv[2], puv[1]); - Normalize2(dir1); - Normalize2(dir2); + sub_v2_v2v2(dir1, puv[1], puv[0]); + sub_v2_v2v2(dir2, puv[2], puv[1]); + normalize_v2(dir1); + normalize_v2(dir2); if (is_quad) { - Vec2Subf(dir3, puv[3], puv[2]); - Vec2Subf(dir4, puv[0], puv[3]); - Normalize2(dir3); - Normalize2(dir4); + sub_v2_v2v2(dir3, puv[3], puv[2]); + sub_v2_v2v2(dir4, puv[0], puv[3]); + normalize_v2(dir3); + normalize_v2(dir4); } else { - Vec2Subf(dir3, puv[0], puv[2]); - Normalize2(dir3); + sub_v2_v2v2(dir3, puv[0], puv[2]); + normalize_v2(dir3); } if (is_quad) { - a1 = AngleToLength(NormalizedVecAngle2_2D(dir4, dir1)); - a2 = AngleToLength(NormalizedVecAngle2_2D(dir1, dir2)); - a3 = AngleToLength(NormalizedVecAngle2_2D(dir2, dir3)); - a4 = AngleToLength(NormalizedVecAngle2_2D(dir3, dir4)); + a1 = shell_angle_to_dist(angle_normalized_v2v2(dir4, dir1)); + a2 = shell_angle_to_dist(angle_normalized_v2v2(dir1, dir2)); + a3 = shell_angle_to_dist(angle_normalized_v2v2(dir2, dir3)); + a4 = shell_angle_to_dist(angle_normalized_v2v2(dir3, dir4)); } else { - a1 = AngleToLength(NormalizedVecAngle2_2D(dir3, dir1)); - a2 = AngleToLength(NormalizedVecAngle2_2D(dir1, dir2)); - a3 = AngleToLength(NormalizedVecAngle2_2D(dir2, dir3)); + a1 = shell_angle_to_dist(angle_normalized_v2v2(dir3, dir1)); + a2 = shell_angle_to_dist(angle_normalized_v2v2(dir1, dir2)); + a3 = shell_angle_to_dist(angle_normalized_v2v2(dir2, dir3)); } if (is_quad) { - Vec2Subf(no1, dir4, dir1); - Vec2Subf(no2, dir1, dir2); - Vec2Subf(no3, dir2, dir3); - Vec2Subf(no4, dir3, dir4); - Normalize2(no1); - Normalize2(no2); - Normalize2(no3); - Normalize2(no4); - Vec2Mulf(no1, a1*scaler); - Vec2Mulf(no2, a2*scaler); - Vec2Mulf(no3, a3*scaler); - Vec2Mulf(no4, a4*scaler); - Vec2Addf(outset_uv[0], puv[0], no1); - Vec2Addf(outset_uv[1], puv[1], no2); - Vec2Addf(outset_uv[2], puv[2], no3); - Vec2Addf(outset_uv[3], puv[3], no4); + sub_v2_v2v2(no1, dir4, dir1); + sub_v2_v2v2(no2, dir1, dir2); + sub_v2_v2v2(no3, dir2, dir3); + sub_v2_v2v2(no4, dir3, dir4); + normalize_v2(no1); + normalize_v2(no2); + normalize_v2(no3); + normalize_v2(no4); + mul_v2_fl(no1, a1*scaler); + mul_v2_fl(no2, a2*scaler); + mul_v2_fl(no3, a3*scaler); + mul_v2_fl(no4, a4*scaler); + add_v2_v2v2(outset_uv[0], puv[0], no1); + add_v2_v2v2(outset_uv[1], puv[1], no2); + add_v2_v2v2(outset_uv[2], puv[2], no3); + add_v2_v2v2(outset_uv[3], puv[3], no4); outset_uv[0][0] *= ibuf_x_inv; outset_uv[0][1] *= ibuf_y_inv; @@ -1105,18 +1105,18 @@ static void uv_image_outset(float (*orig_uv)[2], float (*outset_uv)[2], const fl outset_uv[3][1] *= ibuf_y_inv; } else { - Vec2Subf(no1, dir3, dir1); - Vec2Subf(no2, dir1, dir2); - Vec2Subf(no3, dir2, dir3); - Normalize2(no1); - Normalize2(no2); - Normalize2(no3); - Vec2Mulf(no1, a1*scaler); - Vec2Mulf(no2, a2*scaler); - Vec2Mulf(no3, a3*scaler); - Vec2Addf(outset_uv[0], puv[0], no1); - Vec2Addf(outset_uv[1], puv[1], no2); - Vec2Addf(outset_uv[2], puv[2], no3); + sub_v2_v2v2(no1, dir3, dir1); + sub_v2_v2v2(no2, dir1, dir2); + sub_v2_v2v2(no3, dir2, dir3); + normalize_v2(no1); + normalize_v2(no2); + normalize_v2(no3); + mul_v2_fl(no1, a1*scaler); + mul_v2_fl(no2, a2*scaler); + mul_v2_fl(no3, a3*scaler); + add_v2_v2v2(outset_uv[0], puv[0], no1); + add_v2_v2v2(outset_uv[1], puv[1], no2); + add_v2_v2v2(outset_uv[2], puv[2], no3); outset_uv[0][0] *= ibuf_x_inv; outset_uv[0][1] *= ibuf_y_inv; @@ -1173,7 +1173,7 @@ static float lambda_cp_line2(const float p[2], const float l1[2], const float l2 h[0] = p[0] - l1[0]; h[1] = p[1] - l1[1]; - return(Inp2f(u, h)/Inp2f(u, u)); + return(dot_v2v2(u, h)/dot_v2v2(u, u)); } @@ -1189,7 +1189,7 @@ static void screen_px_from_ortho( float w[3]) { BarycentricWeights2f(uv, uv1co, uv2co, uv3co, w); - VecLerp3f(pixelScreenCo, v1co, v2co, v3co, w); + interp_v3_v3v3v3(pixelScreenCo, v1co, v2co, v3co, w); } /* same as screen_px_from_ortho except we need to take into account @@ -1223,7 +1223,7 @@ static void screen_px_from_persp( } /* done re-weighting */ - VecLerp3f(pixelScreenCo, v1co, v2co, v3co, w); + interp_v3_v3v3v3(pixelScreenCo, v1co, v2co, v3co, w); } static void project_face_pixel(const MTFace *tf_other, ImBuf *ibuf_other, const float w[3], int side, unsigned char rgba_ub[4], float rgba_f[4]) @@ -1241,7 +1241,7 @@ static void project_face_pixel(const MTFace *tf_other, ImBuf *ibuf_other, const uvCo3 = (float *)tf_other->uv[2]; } - Vec2Lerp3f(uv_other, uvCo1, uvCo2, uvCo3, w); + interp_v2_v2v2v2(uv_other, uvCo1, uvCo2, uvCo3, (float*)w); /* use */ uvco_to_wrapped_pxco(uv_other, ibuf_other->x, ibuf_other->y, &x, &y); @@ -1317,11 +1317,11 @@ float project_paint_uvpixel_mask( no[0] = w[0]*no1[0] + w[1]*no2[0] + w[2]*no3[0]; no[1] = w[0]*no1[1] + w[1]*no2[1] + w[2]*no3[1]; no[2] = w[0]*no1[2] + w[1]*no2[2] + w[2]*no3[2]; - Normalize(no); + normalize_v3(no); /* now we can use the normal as a mask */ if (ps->is_ortho) { - angle = NormalizedVecAngle2((float *)ps->viewDir, no); + angle = angle_normalized_v3v3((float *)ps->viewDir, no); } else { /* Annoying but for the perspective view we need to get the pixels location in 3D space :/ */ @@ -1341,9 +1341,9 @@ float project_paint_uvpixel_mask( viewDirPersp[0] = (ps->viewPos[0] - (w[0]*co1[0] + w[1]*co2[0] + w[2]*co3[0])); viewDirPersp[1] = (ps->viewPos[1] - (w[0]*co1[1] + w[1]*co2[1] + w[2]*co3[1])); viewDirPersp[2] = (ps->viewPos[2] - (w[0]*co1[2] + w[1]*co2[2] + w[2]*co3[2])); - Normalize(viewDirPersp); + normalize_v3(viewDirPersp); - angle = NormalizedVecAngle2(viewDirPersp, no); + angle = angle_normalized_v3v3(viewDirPersp, no); } if (angle >= ps->normal_angle) { @@ -1463,7 +1463,7 @@ static ProjPixel *project_paint_uvpixel_init( } else { float co[2]; - Vec2Subf(co, projPixel->projCoSS, (float *)ps->cloneOffset); + sub_v2_v2v2(co, projPixel->projCoSS, (float *)ps->cloneOffset); /* no need to initialize the bucket, we're only checking buckets faces and for this * the faces are alredy initialized in project_paint_delayed_face_init(...) */ @@ -1654,20 +1654,20 @@ static void scale_quad(float insetCos[4][3], float *origCos[4], const float inse cent[1] = (origCos[0][1] + origCos[1][1] + origCos[2][1] + origCos[3][1]) / 4.0f; cent[2] = (origCos[0][2] + origCos[1][2] + origCos[2][2] + origCos[3][2]) / 4.0f; - VecSubf(insetCos[0], origCos[0], cent); - VecSubf(insetCos[1], origCos[1], cent); - VecSubf(insetCos[2], origCos[2], cent); - VecSubf(insetCos[3], origCos[3], cent); + sub_v3_v3v3(insetCos[0], origCos[0], cent); + sub_v3_v3v3(insetCos[1], origCos[1], cent); + sub_v3_v3v3(insetCos[2], origCos[2], cent); + sub_v3_v3v3(insetCos[3], origCos[3], cent); - VecMulf(insetCos[0], inset); - VecMulf(insetCos[1], inset); - VecMulf(insetCos[2], inset); - VecMulf(insetCos[3], inset); + mul_v3_fl(insetCos[0], inset); + mul_v3_fl(insetCos[1], inset); + mul_v3_fl(insetCos[2], inset); + mul_v3_fl(insetCos[3], inset); - VecAddf(insetCos[0], insetCos[0], cent); - VecAddf(insetCos[1], insetCos[1], cent); - VecAddf(insetCos[2], insetCos[2], cent); - VecAddf(insetCos[3], insetCos[3], cent); + add_v3_v3v3(insetCos[0], insetCos[0], cent); + add_v3_v3v3(insetCos[1], insetCos[1], cent); + add_v3_v3v3(insetCos[2], insetCos[2], cent); + add_v3_v3v3(insetCos[3], insetCos[3], cent); } @@ -1678,17 +1678,17 @@ static void scale_tri(float insetCos[4][3], float *origCos[4], const float inset cent[1] = (origCos[0][1] + origCos[1][1] + origCos[2][1]) / 3.0f; cent[2] = (origCos[0][2] + origCos[1][2] + origCos[2][2]) / 3.0f; - VecSubf(insetCos[0], origCos[0], cent); - VecSubf(insetCos[1], origCos[1], cent); - VecSubf(insetCos[2], origCos[2], cent); + sub_v3_v3v3(insetCos[0], origCos[0], cent); + sub_v3_v3v3(insetCos[1], origCos[1], cent); + sub_v3_v3v3(insetCos[2], origCos[2], cent); - VecMulf(insetCos[0], inset); - VecMulf(insetCos[1], inset); - VecMulf(insetCos[2], inset); + mul_v3_fl(insetCos[0], inset); + mul_v3_fl(insetCos[1], inset); + mul_v3_fl(insetCos[2], inset); - VecAddf(insetCos[0], insetCos[0], cent); - VecAddf(insetCos[1], insetCos[1], cent); - VecAddf(insetCos[2], insetCos[2], cent); + add_v3_v3v3(insetCos[0], insetCos[0], cent); + add_v3_v3v3(insetCos[1], insetCos[1], cent); + add_v3_v3v3(insetCos[2], insetCos[2], cent); } @@ -1776,22 +1776,22 @@ static void rect_to_uvspace_ortho( uv[0] = bucket_bounds->xmax; uv[1] = bucket_bounds->ymin; BarycentricWeights2f(uv, v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[flip?3:0], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[flip?3:0], uv1co, uv2co, uv3co, w); //uv[0] = bucket_bounds->xmax; // set above uv[1] = bucket_bounds->ymax; BarycentricWeights2f(uv, v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[flip?2:1], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[flip?2:1], uv1co, uv2co, uv3co, w); uv[0] = bucket_bounds->xmin; //uv[1] = bucket_bounds->ymax; // set above BarycentricWeights2f(uv, v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[flip?1:2], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[flip?1:2], uv1co, uv2co, uv3co, w); //uv[0] = bucket_bounds->xmin; // set above uv[1] = bucket_bounds->ymin; BarycentricWeights2f(uv, v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[flip?0:3], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[flip?0:3], uv1co, uv2co, uv3co, w); } /* same as above but use BarycentricWeightsPersp2f */ @@ -1810,22 +1810,22 @@ static void rect_to_uvspace_persp( uv[0] = bucket_bounds->xmax; uv[1] = bucket_bounds->ymin; BarycentricWeightsPersp2f(uv, v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[flip?3:0], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[flip?3:0], uv1co, uv2co, uv3co, w); //uv[0] = bucket_bounds->xmax; // set above uv[1] = bucket_bounds->ymax; BarycentricWeightsPersp2f(uv, v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[flip?2:1], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[flip?2:1], uv1co, uv2co, uv3co, w); uv[0] = bucket_bounds->xmin; //uv[1] = bucket_bounds->ymax; // set above BarycentricWeightsPersp2f(uv, v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[flip?1:2], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[flip?1:2], uv1co, uv2co, uv3co, w); //uv[0] = bucket_bounds->xmin; // set above uv[1] = bucket_bounds->ymin; BarycentricWeightsPersp2f(uv, v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[flip?0:3], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[flip?0:3], uv1co, uv2co, uv3co, w); } /* This works as we need it to but we can save a few steps and not use it */ @@ -1852,7 +1852,7 @@ static float angle_2d_clockwise(const float p1[2], const float p2[2], const floa /* limit must be a fraction over 1.0f */ static int IsectPT2Df_limit(float pt[2], float v1[2], float v2[2], float v3[2], float limit) { - return ((AreaF2Dfl(pt,v1,v2) + AreaF2Dfl(pt,v2,v3) + AreaF2Dfl(pt,v3,v1)) / (AreaF2Dfl(v1,v2,v3))) < limit; + return ((area_tri_v2(pt,v1,v2) + area_tri_v2(pt,v2,v3) + area_tri_v2(pt,v3,v1)) / (area_tri_v2(v1,v2,v3))) < limit; } /* Clip the face by a bucket and set the uv-space bucket_bounds_uv @@ -2069,13 +2069,13 @@ static void project_bucket_clip_face( if (is_ortho) { for(i=0; i<(*tot); i++) { BarycentricWeights2f(isectVCosSS[i], v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[i], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[i], uv1co, uv2co, uv3co, w); } } else { for(i=0; i<(*tot); i++) { BarycentricWeightsPersp2f(isectVCosSS[i], v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[i], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[i], uv1co, uv2co, uv3co, w); } } } @@ -2330,8 +2330,8 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i /* a pitty we need to get the worldspace pixel location here */ if(ps->rv3d->rflag & RV3D_CLIPPING) { - VecLerp3f(wco, ps->dm_mvert[ (*(&mf->v1 + i1)) ].co, ps->dm_mvert[ (*(&mf->v1 + i2)) ].co, ps->dm_mvert[ (*(&mf->v1 + i3)) ].co, w); - Mat4MulVecfl(ps->ob->obmat, wco); + interp_v3_v3v3v3(wco, ps->dm_mvert[ (*(&mf->v1 + i1)) ].co, ps->dm_mvert[ (*(&mf->v1 + i2)) ].co, ps->dm_mvert[ (*(&mf->v1 + i3)) ].co, w); + mul_m4_v3(ps->ob->obmat, wco); if(view3d_test_clipping(ps->rv3d, wco)) { continue; /* Watch out that no code below this needs to run */ } @@ -2452,7 +2452,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i line_clip_rect2f(bucket_bounds, vCoSS[fidx1], vCoSS[fidx2], bucket_clip_edges[0], bucket_clip_edges[1]) ) { - ftot = Vec2Lenf(vCoSS[fidx1], vCoSS[fidx2]); /* screenspace edge length */ + ftot = len_v2v2(vCoSS[fidx1], vCoSS[fidx2]); /* screenspace edge length */ if (ftot > 0.0f) { /* avoid div by zero */ if (mf->v4) { @@ -2460,19 +2460,19 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i else side= 0; } - fac1 = Vec2Lenf(vCoSS[fidx1], bucket_clip_edges[0]) / ftot; - fac2 = Vec2Lenf(vCoSS[fidx1], bucket_clip_edges[1]) / ftot; + fac1 = len_v2v2(vCoSS[fidx1], bucket_clip_edges[0]) / ftot; + fac2 = len_v2v2(vCoSS[fidx1], bucket_clip_edges[1]) / ftot; - Vec2Lerpf(seam_subsection[0], tf_uv_pxoffset[fidx1], tf_uv_pxoffset[fidx2], fac1); - Vec2Lerpf(seam_subsection[1], tf_uv_pxoffset[fidx1], tf_uv_pxoffset[fidx2], fac2); + interp_v2_v2v2(seam_subsection[0], tf_uv_pxoffset[fidx1], tf_uv_pxoffset[fidx2], fac1); + interp_v2_v2v2(seam_subsection[1], tf_uv_pxoffset[fidx1], tf_uv_pxoffset[fidx2], fac2); - Vec2Lerpf(seam_subsection[2], outset_uv[fidx1], outset_uv[fidx2], fac2); - Vec2Lerpf(seam_subsection[3], outset_uv[fidx1], outset_uv[fidx2], fac1); + interp_v2_v2v2(seam_subsection[2], outset_uv[fidx1], outset_uv[fidx2], fac2); + interp_v2_v2v2(seam_subsection[3], outset_uv[fidx1], outset_uv[fidx2], fac1); /* if the bucket_clip_edges values Z values was kept we could avoid this * Inset needs to be added so occlusion tests wont hit adjacent faces */ - VecLerpf(edge_verts_inset_clip[0], insetCos[fidx1], insetCos[fidx2], fac1); - VecLerpf(edge_verts_inset_clip[1], insetCos[fidx1], insetCos[fidx2], fac2); + interp_v3_v3v3(edge_verts_inset_clip[0], insetCos[fidx1], insetCos[fidx2], fac1); + interp_v3_v3v3(edge_verts_inset_clip[1], insetCos[fidx1], insetCos[fidx2], fac2); if (pixel_bounds_uv(seam_subsection[0], seam_subsection[1], seam_subsection[2], seam_subsection[3], &bounds_px, ibuf->x, ibuf->y, 1)) { @@ -2489,7 +2489,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i uv[0] = (float)x / ibuf_xf; /* use offset uvs instead */ /* test we're inside uvspace bucket and triangle bounds */ - if (IsectPQ2Df(uv, seam_subsection[0], seam_subsection[1], seam_subsection[2], seam_subsection[3])) { + if (isect_point_quad_v2(uv, seam_subsection[0], seam_subsection[1], seam_subsection[2], seam_subsection[3])) { /* We need to find the closest point along the face edge, * getting the screen_px_from_*** wont work because our actual location @@ -2506,11 +2506,11 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i fac = lambda_cp_line2(uv, seam_subsection[0], seam_subsection[1]); if (fac < 0.0f) { VECCOPY(pixelScreenCo, edge_verts_inset_clip[0]); } else if (fac > 1.0f) { VECCOPY(pixelScreenCo, edge_verts_inset_clip[1]); } - else { VecLerpf(pixelScreenCo, edge_verts_inset_clip[0], edge_verts_inset_clip[1], fac); } + else { interp_v3_v3v3(pixelScreenCo, edge_verts_inset_clip[0], edge_verts_inset_clip[1], fac); } if (!is_ortho) { pixelScreenCo[3] = 1.0f; - Mat4MulVec4fl((float(*)[4])ps->projectMat, pixelScreenCo); /* cast because of const */ + mul_m4_v4((float(*)[4])ps->projectMat, pixelScreenCo); /* cast because of const */ pixelScreenCo[0] = (float)(ps->ar->winx/2.0f)+(ps->ar->winx/2.0f)*pixelScreenCo[0]/pixelScreenCo[3]; pixelScreenCo[1] = (float)(ps->ar->winy/2.0f)+(ps->ar->winy/2.0f)*pixelScreenCo[1]/pixelScreenCo[3]; pixelScreenCo[2] = pixelScreenCo[2]/pixelScreenCo[3]; /* Use the depth for bucket point occlusion */ @@ -2546,10 +2546,10 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i /* a pitty we need to get the worldspace pixel location here */ if(ps->rv3d->rflag & RV3D_CLIPPING) { - if (side) VecLerp3f(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w); - else VecLerp3f(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w); + if (side) interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w); + else interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w); - Mat4MulVecfl(ps->ob->obmat, wco); + mul_m4_v3(ps->ob->obmat, wco); if(view3d_test_clipping(ps->rv3d, wco)) { continue; /* Watch out that no code below this needs to run */ } @@ -2709,23 +2709,23 @@ static int project_bucket_face_isect(ProjPaintState *ps, float min[2], float max p4[0] = bucket_bounds.xmax; p4[1] = bucket_bounds.ymin; if (mf->v4) { - if( IsectPQ2Df(p1, v1, v2, v3, v4) || IsectPQ2Df(p2, v1, v2, v3, v4) || IsectPQ2Df(p3, v1, v2, v3, v4) || IsectPQ2Df(p4, v1, v2, v3, v4) || + if( isect_point_quad_v2(p1, v1, v2, v3, v4) || isect_point_quad_v2(p2, v1, v2, v3, v4) || isect_point_quad_v2(p3, v1, v2, v3, v4) || isect_point_quad_v2(p4, v1, v2, v3, v4) || /* we can avoid testing v3,v1 because another intersection MUST exist if this intersects */ - (IsectLL2Df(p1, p2, v1, v2) || IsectLL2Df(p1, p2, v2, v3) || IsectLL2Df(p1, p2, v3, v4)) || - (IsectLL2Df(p2, p3, v1, v2) || IsectLL2Df(p2, p3, v2, v3) || IsectLL2Df(p2, p3, v3, v4)) || - (IsectLL2Df(p3, p4, v1, v2) || IsectLL2Df(p3, p4, v2, v3) || IsectLL2Df(p3, p4, v3, v4)) || - (IsectLL2Df(p4, p1, v1, v2) || IsectLL2Df(p4, p1, v2, v3) || IsectLL2Df(p4, p1, v3, v4)) + (isect_line_line_v2(p1, p2, v1, v2) || isect_line_line_v2(p1, p2, v2, v3) || isect_line_line_v2(p1, p2, v3, v4)) || + (isect_line_line_v2(p2, p3, v1, v2) || isect_line_line_v2(p2, p3, v2, v3) || isect_line_line_v2(p2, p3, v3, v4)) || + (isect_line_line_v2(p3, p4, v1, v2) || isect_line_line_v2(p3, p4, v2, v3) || isect_line_line_v2(p3, p4, v3, v4)) || + (isect_line_line_v2(p4, p1, v1, v2) || isect_line_line_v2(p4, p1, v2, v3) || isect_line_line_v2(p4, p1, v3, v4)) ) { return 1; } } else { - if( IsectPT2Df(p1, v1, v2, v3) || IsectPT2Df(p2, v1, v2, v3) || IsectPT2Df(p3, v1, v2, v3) || IsectPT2Df(p4, v1, v2, v3) || + if( isect_point_tri_v2(p1, v1, v2, v3) || isect_point_tri_v2(p2, v1, v2, v3) || isect_point_tri_v2(p3, v1, v2, v3) || isect_point_tri_v2(p4, v1, v2, v3) || /* we can avoid testing v3,v1 because another intersection MUST exist if this intersects */ - (IsectLL2Df(p1, p2, v1, v2) || IsectLL2Df(p1, p2, v2, v3)) || - (IsectLL2Df(p2, p3, v1, v2) || IsectLL2Df(p2, p3, v2, v3)) || - (IsectLL2Df(p3, p4, v1, v2) || IsectLL2Df(p3, p4, v2, v3)) || - (IsectLL2Df(p4, p1, v1, v2) || IsectLL2Df(p4, p1, v2, v3)) + (isect_line_line_v2(p1, p2, v1, v2) || isect_line_line_v2(p1, p2, v2, v3)) || + (isect_line_line_v2(p2, p3, v1, v2) || isect_line_line_v2(p2, p3, v2, v3)) || + (isect_line_line_v2(p3, p4, v1, v2) || isect_line_line_v2(p3, p4, v2, v3)) || + (isect_line_line_v2(p4, p1, v1, v2) || isect_line_line_v2(p4, p1, v2, v3)) ) { return 1; } @@ -2885,18 +2885,18 @@ static void project_paint_begin(ProjPaintState *ps) view3d_get_object_project_mat(ps->rv3d, ps->ob, ps->projectMat); /* viewDir - object relative */ - Mat4Invert(ps->ob->imat, ps->ob->obmat); - Mat3CpyMat4(mat, ps->rv3d->viewinv); - Mat3MulVecfl(mat, ps->viewDir); - Mat3CpyMat4(mat, ps->ob->imat); - Mat3MulVecfl(mat, ps->viewDir); - Normalize(ps->viewDir); + invert_m4_m4(ps->ob->imat, ps->ob->obmat); + copy_m3_m4(mat, ps->rv3d->viewinv); + mul_m3_v3(mat, ps->viewDir); + copy_m3_m4(mat, ps->ob->imat); + mul_m3_v3(mat, ps->viewDir); + normalize_v3(ps->viewDir); /* viewPos - object relative */ VECCOPY(ps->viewPos, ps->rv3d->viewinv[3]); - Mat3CpyMat4(mat, ps->ob->imat); - Mat3MulVecfl(mat, ps->viewPos); - VecAddf(ps->viewPos, ps->viewPos, ps->ob->imat[3]); + copy_m3_m4(mat, ps->ob->imat); + mul_m3_v3(mat, ps->viewPos); + add_v3_v3v3(ps->viewPos, ps->viewPos, ps->ob->imat[3]); { /* only use these for running 'get_view3d_viewplane' */ rctf viewplane; @@ -2930,7 +2930,7 @@ static void project_paint_begin(ProjPaintState *ps) if (ps->is_ortho) { for(a=0; a < ps->dm_totvert; a++, projScreenCo++) { VECCOPY((*projScreenCo), ps->dm_mvert[a].co); - Mat4MulVecfl(ps->projectMat, (*projScreenCo)); + mul_m4_v3(ps->projectMat, (*projScreenCo)); /* screen space, not clamped */ (*projScreenCo)[0] = (float)(ps->ar->winx/2.0f)+(ps->ar->winx/2.0f)*(*projScreenCo)[0]; @@ -2943,7 +2943,7 @@ static void project_paint_begin(ProjPaintState *ps) VECCOPY((*projScreenCo), ps->dm_mvert[a].co); (*projScreenCo)[3] = 1.0f; - Mat4MulVec4fl(ps->projectMat, (*projScreenCo)); + mul_m4_v4(ps->projectMat, (*projScreenCo)); if ((*projScreenCo)[3] > ps->clipsta) { @@ -3037,14 +3037,14 @@ static void project_paint_begin(ProjPaintState *ps) no[2] = (float)(v->no[2] / 32767.0f); if (ps->is_ortho) { - if (NormalizedVecAngle2(ps->viewDir, no) >= ps->normal_angle) { /* 1 vert of this face is towards us */ + if (angle_normalized_v3v3(ps->viewDir, no) >= ps->normal_angle) { /* 1 vert of this face is towards us */ ps->vertFlags[a] |= PROJ_VERT_CULL; } } else { - VecSubf(viewDirPersp, ps->viewPos, v->co); - Normalize(viewDirPersp); - if (NormalizedVecAngle2(viewDirPersp, no) >= ps->normal_angle) { /* 1 vert of this face is towards us */ + sub_v3_v3v3(viewDirPersp, ps->viewPos, v->co); + normalize_v3(viewDirPersp); + if (angle_normalized_v3v3(viewDirPersp, no) >= ps->normal_angle) { /* 1 vert of this face is towards us */ ps->vertFlags[a] |= PROJ_VERT_CULL; } } @@ -3183,10 +3183,10 @@ static void project_paint_begin_clone(ProjPaintState *ps, int mouse[2]) float projCo[4]; float *curs= give_cursor(ps->scene, ps->v3d); VECCOPY(projCo, curs); - Mat4MulVecfl(ps->ob->imat, projCo); + mul_m4_v3(ps->ob->imat, projCo); projCo[3] = 1.0f; - Mat4MulVec4fl(ps->projectMat, projCo); + mul_m4_v4(ps->projectMat, projCo); ps->cloneOffset[0] = mouse[0] - ((float)(ps->ar->winx/2.0f)+(ps->ar->winx/2.0f)*projCo[0]/projCo[3]); ps->cloneOffset[1] = mouse[1] - ((float)(ps->ar->winy/2.0f)+(ps->ar->winy/2.0f)*projCo[1]/projCo[3]); } @@ -3627,7 +3627,7 @@ static void *do_projectpaint_thread(void *ph_v) projPixel = (ProjPixel *)node->link; - /*dist = Vec2Lenf(projPixel->projCoSS, pos);*/ /* correct but uses a sqrtf */ + /*dist = len_v2v2(projPixel->projCoSS, pos);*/ /* correct but uses a sqrtf */ dist_nosqrt = Vec2Lenf_nosqrt(projPixel->projCoSS, pos); /*if (dist < s->brush->size) {*/ /* correct but uses a sqrtf */ @@ -3696,7 +3696,7 @@ static void *do_projectpaint_thread(void *ph_v) } break; case PAINT_TOOL_SMEAR: - Vec2Subf(co, projPixel->projCoSS, pos_ofs); + sub_v2_v2v2(co, projPixel->projCoSS, pos_ofs); if (is_floatbuf) do_projectpaint_smear_f(ps, projPixel, rgba, alpha, mask, smearArena, &smearPixels_f, co); else do_projectpaint_smear(ps, projPixel, rgba, alpha, mask, smearArena, &smearPixels, co); @@ -4076,14 +4076,14 @@ static int imapaint_paint_op(void *state, ImBuf *ibufb, float *lastpos, float *p static int texpaint_break_stroke(float *prevuv, float *fwuv, float *bkuv, float *uv) { float d1[2], d2[2]; - float mismatch = Vec2Lenf(fwuv, uv); - float len1 = Vec2Lenf(prevuv, fwuv); - float len2 = Vec2Lenf(bkuv, uv); + float mismatch = len_v2v2(fwuv, uv); + float len1 = len_v2v2(prevuv, fwuv); + float len2 = len_v2v2(bkuv, uv); - Vec2Subf(d1, fwuv, prevuv); - Vec2Subf(d2, uv, bkuv); + sub_v2_v2v2(d1, fwuv, prevuv); + sub_v2_v2v2(d2, uv, bkuv); - return ((Inp2f(d1, d2) < 0.0f) || (mismatch > MAX2(len1, len2)*2)); + return ((dot_v2v2(d1, d2) < 0.0f) || (mismatch > MAX2(len1, len2)*2)); } /* ImagePaint Common */ diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 6d7fd826534..35c059b6d2a 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -41,7 +41,7 @@ #include "WM_api.h" #include "WM_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "PIL_time.h" diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 210d6e0ff95..73619886b2b 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -13,7 +13,7 @@ #include "RNA_access.h" #include "RNA_define.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_brush.h" #include "BKE_context.h" @@ -43,9 +43,9 @@ static void imapaint_project(Object *ob, float *model, float *proj, float *co, f VECCOPY(pco, co); pco[3]= 1.0f; - Mat4MulVecfl(ob->obmat, pco); - Mat4MulVecfl((float(*)[4])model, pco); - Mat4MulVec4fl((float(*)[4])proj, pco); + mul_m4_v3(ob->obmat, pco); + mul_m4_v3((float(*)[4])model, pco); + mul_m4_v4((float(*)[4])proj, pco); } static void imapaint_tri_weights(Object *ob, float *v1, float *v2, float *v3, float *co, float *w) @@ -79,15 +79,15 @@ static void imapaint_tri_weights(Object *ob, float *v1, float *v2, float *v3, fl wmat[0][1]= pv1[1]; wmat[1][1]= pv2[1]; wmat[2][1]= pv3[1]; wmat[0][2]= pv1[3]; wmat[1][2]= pv2[3]; wmat[2][2]= pv3[3]; - Mat3Inv(invwmat, wmat); - Mat3MulVecfl(invwmat, h); + invert_m3_m3(invwmat, wmat); + mul_m3_v3(invwmat, h); VECCOPY(w, h); /* w is still divided by perspdiv, make it sum to one */ divw= w[0] + w[1] + w[2]; if(divw != 0.0f) - VecMulf(w, 1.0f/divw); + mul_v3_fl(w, 1.0f/divw); } /* compute uv coordinates of mouse in face */ diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 582a0c149b4..1e316072dd5 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -42,7 +42,7 @@ #include "IMB_imbuf_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_ghash.h" #include "DNA_anim_types.h" @@ -1104,12 +1104,10 @@ static int set_wpaint(bContext *C, wmOperator *op) /* toggle */ /* verify if active weight group is also active bone */ par= modifiers_isDeformedByArmature(ob); if(par && (par->mode & OB_MODE_POSE)) { - bPoseChannel *pchan; - for(pchan= par->pose->chanbase.first; pchan; pchan= pchan->next) - if(pchan->bone->flag & BONE_ACTIVE) - break; - if(pchan) - ED_vgroup_select_by_name(ob, pchan->name); + bArmature *arm= ob->data; + + if(arm->act_bone) + ED_vgroup_select_by_name(ob, arm->act_bone->name); } } else { @@ -1381,9 +1379,9 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *event) // if(ob->lay & v3d->lay); else error("Active object is not in this layer"); /* imat for normals */ - Mat4MulMat4(mat, ob->obmat, wpd->vc.rv3d->viewmat); - Mat4Invert(imat, mat); - Mat3CpyMat4(wpd->wpimat, imat); + mul_m4_m4m4(mat, ob->obmat, wpd->vc.rv3d->viewmat); + invert_m4_m4(imat, mat); + copy_m3_m4(wpd->wpimat, imat); /* if mirror painting, find the other group */ if(me->editflag & ME_EDIT_MIRROR_X) { @@ -1439,7 +1437,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P mval[0]-= vc->ar->winrct.xmin; mval[1]-= vc->ar->winrct.ymin; - Mat4SwapMat4(wpd->vc.rv3d->persmat, mat); + swap_m4m4(wpd->vc.rv3d->persmat, mat); /* which faces are involved */ if(wp->flag & VP_AREA) { @@ -1564,7 +1562,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P } } - Mat4SwapMat4(vc->rv3d->persmat, mat); + swap_m4m4(vc->rv3d->persmat, mat); DAG_id_flush_update(ob->data, OB_RECALC_DATA); ED_region_tag_redraw(vc->ar); @@ -1797,9 +1795,9 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent copy_vpaint_prev(vp, (unsigned int *)me->mcol, me->totface); /* some old cruft to sort out later */ - Mat4MulMat4(mat, ob->obmat, vpd->vc.rv3d->viewmat); - Mat4Invert(imat, mat); - Mat3CpyMat4(vpd->vpimat, imat); + mul_m4_m4m4(mat, ob->obmat, vpd->vc.rv3d->viewmat); + invert_m4_m4(imat, mat); + copy_m3_m4(vpd->vpimat, imat); return 1; } @@ -1873,14 +1871,14 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P else totindex= 0; } - Mat4SwapMat4(vc->rv3d->persmat, mat); + swap_m4m4(vc->rv3d->persmat, mat); for(index=0; index<totindex; index++) { if(indexar[index] && indexar[index]<=me->totface) vpaint_paint_face(vp, vpd, ob, indexar[index]-1, mval); } - Mat4SwapMat4(vc->rv3d->persmat, mat); + swap_m4m4(vc->rv3d->persmat, mat); /* was disabled because it is slow, but necessary for blur */ if(vp->mode == VP_BLUR) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index d307b08385b..4b63a388f76 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -32,7 +32,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" #include "BLI_ghash.h" @@ -306,9 +306,9 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) for(i=0; i<totvert; i++) { float tmp[3]; - VECCOPY(tmp, mvert[index[i]].co); - VECCOPY(mvert[index[i]].co, unode->co[i]) - VECCOPY(unode->co[i], tmp); + copy_v3_v3(tmp, mvert[index[i]].co); + copy_v3_v3(mvert[index[i]].co, unode->co[i]); + copy_v3_v3(unode->co[i], tmp); mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE; } @@ -399,8 +399,8 @@ static SculptUndoNode *sculpt_undo_push_node(SculptSession *ss, PBVHNode *node) /* copy threaded, hopefully this is the performance critical part */ memcpy(unode->index, verts, sizeof(int)*allvert); for(i=0; i<allvert; i++) { - VECCOPY(unode->co[i], ss->mvert[verts[i]].co) - VECCOPY(unode->no[i], ss->mvert[verts[i]].no) + copy_v3_v3(unode->co[i], ss->mvert[verts[i]].co); + VECCOPY(unode->no[i], ss->mvert[verts[i]].no); } return unode; @@ -449,7 +449,7 @@ static void sculpt_node_verts_init(Sculpt *sd, SculptSession *ss, PBVHNode *node, float (*origvert)[3], SculptVertexData *vd) { vd->radius_squared= ss->cache->radius*ss->cache->radius; - VecCopyf(vd->location, ss->cache->location); + copy_v3_v3(vd->location, ss->cache->location); vd->mvert= ss->mvert; vd->origvert= origvert; @@ -468,7 +468,7 @@ static int sculpt_node_verts_next(SculptVertexData *vd) vd->co= vd->mvert[vd->index].co; vd->origco= (vd->origvert)? vd->origvert[vd->i]: vd->co; vd->no= vd->mvert[vd->index].no; - VECSUB(delta, vd->origco, vd->location); + sub_v3_v3v3(delta, vd->origco, vd->location); dsq = INPR(delta, delta); if(dsq < vd->radius_squared) { @@ -603,7 +603,7 @@ static float tex_strength(SculptSession *ss, Brush *br, float *point, const floa /* If the active area is being applied for symmetry, flip it across the symmetry axis in order to project it. This insures that the brush texture will be oriented correctly. */ - VecCopyf(flip, point); + copy_v3_v3(flip, point); flip_coord(flip, flip, ss->cache->symmetry); projectf(ss->cache->mats, flip, point_2d); @@ -679,7 +679,7 @@ static int sculpt_search_sphere_cb(PBVHNode *node, void *data_v) nearest[i] = center[i]; } - VecSubf(t, center, nearest); + sub_v3_v3v3(t, center, nearest); return t[0] * t[0] + t[1] * t[1] + t[2] * t[2] < data->radius_squared; } @@ -704,12 +704,12 @@ static void add_norm_if(float view_vec[3], float out[3], float out_flip[3], cons { float fno[3] = {no[0], no[1], no[2]}; - Normalize(fno); + normalize_v3(fno); - if((Inpf(view_vec, fno)) > 0) { - VecAddf(out, out, fno); + if((dot_v3v3(view_vec, fno)) > 0) { + add_v3_v3v3(out, out, fno); } else { - VecAddf(out_flip, out_flip, fno); /* out_flip is used when out is {0,0,0} */ + add_v3_v3v3(out_flip, out_flip, fno); /* out_flip is used when out is {0,0,0} */ } } @@ -723,7 +723,7 @@ static void calc_area_normal(Sculpt *sd, SculptSession *ss, float area_normal[3] float out_dir[3]; int n; - VecCopyf(out_dir, cache->view_normal_symmetry); + copy_v3_v3(out_dir, cache->view_normal_symmetry); /* threaded loop over nodes */ #pragma omp parallel for private(n) schedule(static) @@ -750,23 +750,23 @@ static void calc_area_normal(Sculpt *sd, SculptSession *ss, float area_normal[3] { /* we sum per node and add together later for threads */ #pragma omp critical - VecAddf(out, out, nout); - VecAddf(out_flip, out_flip, nout_flip); + add_v3_v3v3(out, out, nout); + add_v3_v3v3(out_flip, out_flip, nout_flip); } } if (out[0]==0.0 && out[1]==0.0 && out[2]==0.0) { - VECCOPY(out, out_flip); + copy_v3_v3(out, out_flip); } - Normalize(out); + normalize_v3(out); out[0] = out_dir[0] * view + out[0] * (10-view); out[1] = out_dir[1] * view + out[1] * (10-view); out[2] = out_dir[2] * view + out[2] * (10-view); - Normalize(out); - VecCopyf(area_normal, out); + normalize_v3(out); + copy_v3_v3(area_normal, out); } static void do_draw_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode) @@ -821,7 +821,7 @@ static void neighbor_average(SculptSession *ss, float avg[3], const int vert) /* Don't modify corner vertices */ if(ncount==1) { - VecCopyf(avg, ss->mvert[vert].co); + copy_v3_v3(avg, ss->mvert[vert].co); return; } @@ -837,7 +837,7 @@ static void neighbor_average(SculptSession *ss, float avg[3], const int vert) for(i=0; i<(f->v4?4:3); ++i) { if(i != skip && (ncount!=2 || BLI_countlist(&ss->fmap[(&f->v1)[i]]) <= 2)) { - VecAddf(avg, avg, ss->mvert[(&f->v1)[i]].co); + add_v3_v3v3(avg, avg, ss->mvert[(&f->v1)[i]].co); ++total; } } @@ -846,9 +846,9 @@ static void neighbor_average(SculptSession *ss, float avg[3], const int vert) } if(total>0) - VecMulf(avg, 1.0f / total); + mul_v3_fl(avg, 1.0f / total); else - VecCopyf(avg, ss->mvert[vert].co); + copy_v3_v3(avg, ss->mvert[vert].co); } static void do_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode) @@ -917,7 +917,7 @@ static void do_grab_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int t float grab_delta[3]; int n; - VecCopyf(grab_delta, ss->cache->grab_delta_symmetry); + copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry); #pragma omp parallel for private(n) schedule(static) for(n=0; n<totnode; n++) { @@ -1021,11 +1021,11 @@ static void do_inflate_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, in add[0]= vd.no[0]/32767.0f; add[1]= vd.no[1]/32767.0f; add[2]= vd.no[2]/32767.0f; - VecMulf(add, fade * ss->cache->radius); + mul_v3_fl(add, fade * ss->cache->radius); add[0]*= ss->cache->scale[0]; add[1]*= ss->cache->scale[1]; add[2]*= ss->cache->scale[2]; - VecAddf(add, add, vd.co); + add_v3_v3v3(add, add, vd.co); sculpt_clip(sd, ss, vd.co, add); ss->mvert[vd.index].flag |= ME_VERT_PBVH_UPDATE; @@ -1066,8 +1066,8 @@ static void calc_flatten_center(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, co[0] = co[1] = co[2] = 0.0f; for(i = 0; i < FLATTEN_SAMPLE_SIZE; ++i) - VecAddf(co, co, ss->mvert[outer_index[i]].co); - VecMulf(co, 1.0f / FLATTEN_SAMPLE_SIZE); + add_v3_v3v3(co, co, ss->mvert[outer_index[i]].co); + mul_v3_fl(co, 1.0f / FLATTEN_SAMPLE_SIZE); } /* Projects a point onto a plane along the plane's normal */ @@ -1076,12 +1076,12 @@ static void point_plane_project(float intr[3], float co[3], float plane_normal[3 float p1[3], sub1[3], sub2[3]; /* Find the intersection between squash-plane and vertex (along the area normal) */ - VecSubf(p1, co, plane_normal); - VecSubf(sub1, plane_center, p1); - VecSubf(sub2, co, p1); - VecSubf(intr, co, p1); - VecMulf(intr, Inpf(plane_normal, sub1) / Inpf(plane_normal, sub2)); - VecAddf(intr, intr, p1); + sub_v3_v3v3(p1, co, plane_normal); + sub_v3_v3v3(sub1, plane_center, p1); + sub_v3_v3v3(sub2, co, p1); + sub_v3_v3v3(intr, co, p1); + mul_v3_fl(intr, dot_v3v3(plane_normal, sub1) / dot_v3v3(plane_normal, sub2)); + add_v3_v3v3(intr, intr, p1); } static int plane_point_side(float co[3], float plane_normal[3], float plane_center[3], int flip) @@ -1089,8 +1089,8 @@ static int plane_point_side(float co[3], float plane_normal[3], float plane_cent float delta[3]; float d; - VecSubf(delta, co, plane_center); - d = Inpf(plane_normal, delta); + sub_v3_v3v3(delta, co, plane_center); + d = dot_v3v3(plane_normal, delta); if(flip) d = -d; @@ -1135,22 +1135,22 @@ static void do_flatten_clay_brush(Sculpt *sd, SculptSession *ss, PBVHNode **node /* Find the intersection between squash-plane and vertex (along the area normal) */ point_plane_project(intr, vd.co, area_normal, cntr); - VecSubf(val, intr, vd.co); + sub_v3_v3v3(val, intr, vd.co); if(clay) { if(bstr > FLT_EPSILON) - VecMulf(val, fade / bstr); + mul_v3_fl(val, fade / bstr); else - VecMulf(val, fade); + mul_v3_fl(val, fade); /* Clay displacement */ val[0]+=area_normal[0] * ss->cache->scale[0]*fade; val[1]+=area_normal[1] * ss->cache->scale[1]*fade; val[2]+=area_normal[2] * ss->cache->scale[2]*fade; } else - VecMulf(val, fabs(fade)); + mul_v3_fl(val, fabs(fade)); - VecAddf(val, val, vd.co); + add_v3_v3v3(val, val, vd.co); sculpt_clip(sd, ss, vd.co, val); ss->mvert[vd.index].flag |= ME_VERT_PBVH_UPDATE; @@ -1184,12 +1184,12 @@ static void do_brush_action(Sculpt *sd, SculptSession *ss, StrokeCache *cache) ss->cache->grab_active_nodes[ss->cache->symmetry]= nodes; ss->cache->grab_active_totnode[ss->cache->symmetry]= totnode; - VecCopyf(ss->cache->grab_active_location[ss->cache->symmetry], ss->cache->location); + copy_v3_v3(ss->cache->grab_active_location[ss->cache->symmetry], ss->cache->location); } else { nodes= ss->cache->grab_active_nodes[ss->cache->symmetry]; totnode= ss->cache->grab_active_totnode[ss->cache->symmetry]; - VecCopyf(ss->cache->location, ss->cache->grab_active_location[ss->cache->symmetry]); + copy_v3_v3(ss->cache->location, ss->cache->grab_active_location[ss->cache->symmetry]); } } else { @@ -1239,7 +1239,7 @@ static void do_brush_action(Sculpt *sd, SculptSession *ss, StrokeCache *cache) for(; adata; adata= adata->next) if(adata->Index < keyblock->totelem) - VecCopyf(&co[adata->Index*3], me->mvert[adata->Index].co); + copy_v3_v3(&co[adata->Index*3], me->mvert[adata->Index].co); } } @@ -1272,8 +1272,8 @@ static void do_symmetrical_brush_actions(Sculpt *sd, SculptSession *ss) const char symm = sd->flags & 7; int i; - VecCopyf(cache->location, cache->true_location); - VecCopyf(cache->grab_delta_symmetry, cache->grab_delta); + copy_v3_v3(cache->location, cache->true_location); + copy_v3_v3(cache->grab_delta_symmetry, cache->grab_delta); cache->symmetry = 0; cache->bstrength = brush_strength(sd, cache); do_brush_action(sd, ss, cache); @@ -1460,7 +1460,7 @@ static float unproject_brush_radius(ViewContext *vc, float center[3], float offs initgrabz(vc->rv3d, center[0], center[1], center[2]); window_to_3d_delta(vc->ar, delta, offset, 0); - return VecLength(delta); + return len_v3(delta); } static void sculpt_cache_free(StrokeCache *cache) @@ -1515,7 +1515,7 @@ static void sculpt_update_cache_invariants(Sculpt *sd, SculptSession *ss, bConte ss->layer_co= MEM_mallocN(sizeof(float) * 3 * ss->totvert, "sculpt mesh vertices copy"); for(i = 0; i < ss->totvert; ++i) - VecCopyf(ss->layer_co[i], ss->mvert[i].co); + copy_v3_v3(ss->layer_co[i], ss->mvert[i].co); } } @@ -1525,7 +1525,7 @@ static void sculpt_update_cache_invariants(Sculpt *sd, SculptSession *ss, bConte float *fn = ss->face_normals; cache->face_norms= MEM_mallocN(sizeof(float) * 3 * ss->totface, "Sculpt face norms"); for(i = 0; i < ss->totface; ++i, fn += 3) - VecCopyf(cache->face_norms[i], fn); + copy_v3_v3(cache->face_norms[i], fn); } cache->original = 1; @@ -1602,8 +1602,8 @@ static void sculpt_update_cache_variants(Sculpt *sd, SculptSession *ss, struct P window_to_3d_delta(cache->vc->ar, grab_location, cache->mouse[0], cache->mouse[1]); if(!cache->first_time) - VecSubf(cache->grab_delta, grab_location, cache->old_grab_location); - VecCopyf(cache->old_grab_location, grab_location); + sub_v3_v3v3(cache->grab_delta, grab_location, cache->old_grab_location); + copy_v3_v3(cache->old_grab_location, grab_location); } } @@ -1619,7 +1619,7 @@ static int ray_face_intersection(float ray_start[3], float ray_normal[3], { float dist = FLT_MAX; - if(!RayIntersectsTriangle(ray_start, ray_normal, t0, t1, t2, + if(!isect_ray_tri_v3(ray_start, ray_normal, t0, t1, t2, &dist, NULL)) dist = FLT_MAX; @@ -1722,9 +1722,9 @@ int sculpt_stroke_get_location(bContext *C, struct PaintStroke *stroke, float ou BLI_pbvh_raycast(ss->tree, sculpt_raycast_cb, &srd, ray_start, ray_normal, srd.original); - VecCopyf(out, ray_normal); - VecMulf(out, srd.dist); - VecAddf(out, out, ray_start); + copy_v3_v3(out, ray_normal); + mul_v3_fl(out, srd.dist); + add_v3_v3v3(out, out, ray_start); return srd.hit != -1; } @@ -1802,7 +1802,7 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) int totvert= unode->totvert; for(i = 0; i < totvert; ++i) { - VECCOPY(ss->mvert[index[i]].co, co[i]); + copy_v3_v3(ss->mvert[index[i]].co, co[i]); VECCOPY(ss->mvert[index[i]].no, no[i]); } } @@ -1810,7 +1810,7 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) if(ss->face_normals) { float *fn = ss->face_normals; for(i = 0; i < ss->totface; ++i, fn += 3) - VecCopyf(fn, cache->face_norms[i]); + copy_v3_v3(fn, cache->face_norms[i]); } if(brush->sculpt_tool == SCULPT_TOOL_LAYER) |