From 5935ef004935b27fc5795349aed32f87cf637049 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Nov 2009 21:03:54 +0000 Subject: use armature active bone as a pointer rather then a flag for each bone that needs looking up. - rna vars arm.bones.active & rna.edit_bones.active - needed special undo support. - readfile.c loads. - duplicate and copy_armature support. - keep the draw flag, renamed to BONE_DRAW_ACTIVE, only use for openGL drawing. Note: it may be better to allow active/unselected as with objects. --- source/blender/editors/sculpt_paint/paint_vertex.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'source/blender/editors/sculpt_paint') diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 408f4862b6f..2045397f3c9 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -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 { -- cgit v1.2.3 From 37e4a311b0ad9da7177e50620efc3561e2dd7045 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 10 Nov 2009 20:43:45 +0000 Subject: Math Lib * Convert all code to use new functions. * Branch maintainers may want to skip this commit, and run this conversion script instead, if they use a lot of math functions in new code: http://www.pasteall.org/9052/python --- source/blender/editors/sculpt_paint/paint_image.c | 294 ++++++++++----------- source/blender/editors/sculpt_paint/paint_stroke.c | 2 +- source/blender/editors/sculpt_paint/paint_utils.c | 14 +- source/blender/editors/sculpt_paint/paint_vertex.c | 22 +- source/blender/editors/sculpt_paint/sculpt.c | 100 +++---- 5 files changed, 216 insertions(+), 216 deletions(-) (limited to 'source/blender/editors/sculpt_paint') diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 929f854242f..e34330c2e42 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" @@ -669,7 +669,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); @@ -683,7 +683,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); @@ -734,10 +734,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 */ @@ -818,7 +818,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 */ @@ -858,10 +858,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; } @@ -1162,51 +1162,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; @@ -1220,18 +1220,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; @@ -1288,7 +1288,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)); } @@ -1304,7 +1304,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 @@ -1338,7 +1338,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]) @@ -1356,7 +1356,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, w); /* use */ uvco_to_wrapped_pxco(uv_other, ibuf_other->x, ibuf_other->y, &x, &y); @@ -1432,11 +1432,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 :/ */ @@ -1456,9 +1456,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) { @@ -1578,7 +1578,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(...) */ @@ -1769,20 +1769,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); } @@ -1793,17 +1793,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); } @@ -1891,22 +1891,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 */ @@ -1925,22 +1925,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 */ @@ -1967,7 +1967,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 @@ -2184,13 +2184,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); } } } @@ -2445,8 +2445,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 */ } @@ -2567,7 +2567,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) { @@ -2575,19 +2575,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)) { @@ -2604,7 +2604,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 @@ -2621,11 +2621,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 */ @@ -2661,10 +2661,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 */ } @@ -2824,23 +2824,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; } @@ -3000,18 +3000,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; @@ -3045,7 +3045,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]; @@ -3058,7 +3058,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) { @@ -3152,14 +3152,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; } } @@ -3298,10 +3298,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]); } @@ -3742,7 +3742,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 */ @@ -3811,7 +3811,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); @@ -4200,14 +4200,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 6e256bee7f2..0b86034958f 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 15104068350..24d9e0f4bc1 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 2045397f3c9..35723769f88 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" @@ -1379,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) { @@ -1437,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) { @@ -1562,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); @@ -1795,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; } @@ -1871,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; indextotface) 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 c4c7f436f12..7575464fd57 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" @@ -256,12 +256,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} */ } } @@ -291,7 +291,7 @@ static void calc_area_normal(Sculpt *sd, SculptSession *ss, float out[3], const VECCOPY(out, out_flip); } - Normalize(out); + normalize_v3(out); if(out_dir) { out[0] = out_dir[0] * view + out[0] * (10-view); @@ -299,7 +299,7 @@ static void calc_area_normal(Sculpt *sd, SculptSession *ss, float out[3], const out[2] = out_dir[2] * view + out[2] * (10-view); } - Normalize(out); + normalize_v3(out); } static void do_draw_brush(Sculpt *sd, SculptSession *ss, const ListBase* active_verts) @@ -349,7 +349,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; } @@ -365,7 +365,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; } } @@ -374,9 +374,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 *s, SculptSession *ss, const ListBase* active_verts) @@ -443,14 +443,14 @@ static void do_grab_brush(Sculpt *sd, SculptSession *ss) float grab_delta[3]; float *buffer = ss->drawobject!=0?(float *)GPU_buffer_lock( ss->drawobject->vertices ):0; - VecCopyf(grab_delta, ss->cache->grab_delta_symmetry); + copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry); while(node) { float *co= ss->mvert[node->Index].co; - VecCopyf(add, grab_delta); - VecMulf(add, node->Fade); - VecAddf(add, add, co); + copy_v3_v3(add, grab_delta); + mul_v3_fl(add, node->Fade); + add_v3_v3v3(add, add, co); if( buffer != 0 ) { IndexLink *cur = &ss->drawobject->indices[node->Index]; @@ -526,11 +526,11 @@ static void do_inflate_brush(Sculpt *s, SculptSession *ss, const ListBase *activ add[0]= no[0]/ 32767.0f; add[1]= no[1]/ 32767.0f; add[2]= no[2]/ 32767.0f; - VecMulf(add, node->Fade * ss->cache->radius); + mul_v3_fl(add, node->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, co); + add_v3_v3v3(add, add, co); if( buffer != 0 ) { IndexLink *cur = &ss->drawobject->indices[node->Index]; @@ -567,8 +567,8 @@ static void calc_flatten_center(SculptSession *ss, ActiveData *node, float co[3] co[0] = co[1] = co[2] = 0.0f; for(i = 0; i < FLATTEN_SAMPLE_SIZE; ++i) - VecAddf(co, co, ss->mvert[outer[i]->Index].co); - VecMulf(co, 1.0f / FLATTEN_SAMPLE_SIZE); + add_v3_v3v3(co, co, ss->mvert[outer[i]->Index].co); + mul_v3_fl(co, 1.0f / FLATTEN_SAMPLE_SIZE); } /* Projects a point onto a plane along the plane's normal */ @@ -577,12 +577,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) @@ -590,8 +590,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; @@ -629,22 +629,22 @@ static void do_flatten_clay_brush(Sculpt *sd, SculptSession *ss, const ListBase /* Find the intersection between squash-plane and vertex (along the area normal) */ point_plane_project(intr, co, area_normal, cntr); - VecSubf(val, intr, co); + sub_v3_v3v3(val, intr, co); if(clay) { if(bstr > FLT_EPSILON) - VecMulf(val, node->Fade / bstr); + mul_v3_fl(val, node->Fade / bstr); else - VecMulf(val, node->Fade); + mul_v3_fl(val, node->Fade); /* Clay displacement */ val[0]+=area_normal[0] * ss->cache->scale[0]*node->Fade; val[1]+=area_normal[1] * ss->cache->scale[1]*node->Fade; val[2]+=area_normal[2] * ss->cache->scale[2]*node->Fade; } else - VecMulf(val, fabs(node->Fade)); + mul_v3_fl(val, fabs(node->Fade)); - VecAddf(val, val, co); + add_v3_v3v3(val, val, co); if( buffer != 0 ) { IndexLink *cur = &ss->drawobject->indices[node->Index]; @@ -747,7 +747,7 @@ static float tex_strength(Sculpt *sd, SculptSession *ss, float *point, const flo /* 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); @@ -852,7 +852,7 @@ static void do_brush_action(Sculpt *sd, SculptSession *ss, StrokeCache *cache) if(ss->multires || ss->projverts[i].inside) { //vert= ss->vertexcosnos ? &ss->vertexcosnos[i*6] : a->verts[i].co; vert= ss->mvert[i].co; - av_dist= VecLenf(ss->cache->location, vert); + av_dist= len_v3v3(ss->cache->location, vert); if(av_dist < cache->radius) { adata= (ActiveData*)MEM_mallocN(sizeof(ActiveData), "ActiveData"); @@ -911,7 +911,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); } } @@ -940,8 +940,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; do_brush_action(sd, ss, cache); @@ -963,15 +963,15 @@ static void add_face_normal(vec3f *norm, MVert *mvert, const MFace* face, float vec3f s1, s2; float final[3]; - VecSubf(&s1.x,&a.x,&b.x); - VecSubf(&s2.x,&c.x,&b.x); + sub_v3_v3v3(&s1.x,&a.x,&b.x); + sub_v3_v3v3(&s2.x,&c.x,&b.x); final[0] = s1.y * s2.z - s1.z * s2.y; final[1] = s1.z * s2.x - s1.x * s2.z; final[2] = s1.x * s2.y - s1.y * s2.x; if(fn) - VecCopyf(fn, final); + copy_v3_v3(fn, final); norm->x+= final[0]; norm->y+= final[1]; @@ -994,7 +994,7 @@ static void update_damaged_vert(SculptSession *ss, ListBase *lb) add_face_normal(&norm, ss->mvert, &ss->mface[face->index], fn); face= face->next; } - Normalize(&norm.x); + normalize_v3(&norm.x); ss->mvert[vert->Index].no[0]=norm.x*32767; ss->mvert[vert->Index].no[1]=norm.y*32767; @@ -1010,9 +1010,9 @@ static void update_damaged_vert(SculptSession *ss, ListBase *lb) else { float norm[3]; if( ss->mface[i].v4 ) - CalcNormFloat4(ss->mvert[ss->mface[i].v1].co, ss->mvert[ss->mface[i].v2].co, ss->mvert[ss->mface[i].v3].co, ss->mvert[ss->mface[i].v4].co, norm); + normal_quad_v3( norm,ss->mvert[ss->mface[i].v1].co, ss->mvert[ss->mface[i].v2].co, ss->mvert[ss->mface[i].v3].co, ss->mvert[ss->mface[i].v4].co); else - CalcNormFloat(ss->mvert[ss->mface[i].v1].co, ss->mvert[ss->mface[i].v2].co, ss->mvert[ss->mface[i].v3].co, norm); + normal_tri_v3( norm,ss->mvert[ss->mface[i].v1].co, ss->mvert[ss->mface[i].v2].co, ss->mvert[ss->mface[i].v3].co); VECCOPY(&buffer[(cur->element-cur->element%3)*3],norm); VECCOPY(&buffer[(cur->element-cur->element%3+1)*3],norm); VECCOPY(&buffer[(cur->element-cur->element%3+2)*3],norm); @@ -1259,7 +1259,7 @@ static float unproject_brush_radius(SculptSession *ss, float offset) view3d_unproject(ss->cache->mats, brush_edge, ss->cache->initial_mouse[0] + offset, ss->cache->initial_mouse[1], ss->cache->depth); - return VecLenf(ss->cache->true_location, brush_edge); + return len_v3v3(ss->cache->true_location, brush_edge); } static void sculpt_cache_free(StrokeCache *cache) @@ -1318,7 +1318,7 @@ static void sculpt_update_cache_invariants(Sculpt *sd, SculptSession *ss, bConte ss->mesh_co_orig= MEM_mallocN(sizeof(float) * 3 * ss->totvert, "sculpt mesh vertices copy"); for(i = 0; i < ss->totvert; ++i) - VecCopyf(ss->mesh_co_orig[i], ss->mvert[i].co); + copy_v3_v3(ss->mesh_co_orig[i], ss->mvert[i].co); } if(brush->flag & BRUSH_ANCHORED) { @@ -1333,7 +1333,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); } } } @@ -1400,8 +1400,8 @@ static void sculpt_update_cache_variants(Sculpt *sd, SculptSession *ss, PointerR if(brush->sculpt_tool == SCULPT_TOOL_GRAB) { view3d_unproject(cache->mats, grab_location, cache->mouse[0], cache->mouse[1], cache->depth); 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); } } @@ -1477,7 +1477,7 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) buffer= (float *)GPU_buffer_lock(ss->drawobject->normals); for(i = 0; i < ss->totvert; ++i) { - VecCopyf(ss->mvert[i].co, ss->mesh_co_orig[i]); + copy_v3_v3(ss->mvert[i].co, ss->mesh_co_orig[i]); ss->mvert[i].no[0] = cache->orig_norms[i][0]; ss->mvert[i].no[1] = cache->orig_norms[i][1]; ss->mvert[i].no[2] = cache->orig_norms[i][2]; @@ -1495,7 +1495,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) -- cgit v1.2.3 From 91446e9aadb756c35071e21bb4654bef2ef2ded1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 10 Nov 2009 20:50:34 +0000 Subject: Math Lib * Post-conversion commit, fixing some introduced warnings. --- source/blender/editors/sculpt_paint/paint_image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors/sculpt_paint') diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index e34330c2e42..ef036da6d7b 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1356,7 +1356,7 @@ static void project_face_pixel(const MTFace *tf_other, ImBuf *ibuf_other, const uvCo3 = (float *)tf_other->uv[2]; } - interp_v2_v2v2v2(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); -- cgit v1.2.3