diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 7780c51095f..3ed8169f260 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -106,6 +106,7 @@ void interp_v2_v2v2v2(float r[2], const float a[2], const float b[2], const floa void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t); void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3]); void interp_v3_v3v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3], const float w[4]); +void interp_v4_v4v4(float r[4], const float a[4], const float b[4], const float t); void mid_v3_v3v3(float r[3], float a[3], float b[3]); diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index 97f5ea73ea9..8032cd64de5 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -55,6 +55,16 @@ void interp_v3_v3v3(float target[3], const float a[3], const float b[3], const f target[2]= s*a[2] + t*b[2]; } +void interp_v4_v4v4(float target[4], const float a[4], const float b[4], const float t) +{ + float s = 1.0f-t; + + target[0]= s*a[0] + t*b[0]; + target[1]= s*a[1] + t*b[1]; + target[2]= s*a[2] + t*b[2]; + target[3]= s*a[3] + t*b[3]; +} + /* weight 3 vectors, * 'w' must be unit length but is not a vector, just 3 weights */ void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3]) diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 993842d34f6..189c2efc4c5 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1874,21 +1874,6 @@ void CURVE_OT_select_inverse(wmOperatorType *ot) * @param None */ -void subdivide_v3(float *v, float *v1, float *v2, float factor) -{ - v[0]= v1[0] + factor*(v2[0] - v1[0]); - v[1]= v1[1] + factor*(v2[1] - v1[1]); - v[2]= v1[2] + factor*(v2[2] - v1[2]); -} - -void subdivide_v4(float *v, float *v1, float *v2, float factor) -{ - v[0]= v1[0] + factor*(v2[0] - v1[0]); - v[1]= v1[1] + factor*(v2[1] - v1[1]); - v[2]= v1[2] + factor*(v2[2] - v1[2]); - v[3]= v1[3] + factor*(v2[3] - v1[3]); -} - static void subdividenurb(Object *obedit, int number_cuts) { Curve *cu= obedit->data; @@ -1957,18 +1942,18 @@ static void subdividenurb(Object *obedit, int number_cuts) memcpy(beztn, bezt, sizeof(BezTriple)); /* midpoint subdividing */ - subdivide_v3(vec, prevvec[1], prevvec[2], factor); - subdivide_v3(vec+3, prevvec[2], bezt->vec[0], factor); - subdivide_v3(vec+6, bezt->vec[0], bezt->vec[1], factor); + interp_v3_v3v3(vec, prevvec[1], prevvec[2], factor); + interp_v3_v3v3(vec+3, prevvec[2], bezt->vec[0], factor); + interp_v3_v3v3(vec+6, bezt->vec[0], bezt->vec[1], factor); - subdivide_v3(vec+9, vec, vec+3, factor); - subdivide_v3(vec+12, vec+3, vec+6, factor); + interp_v3_v3v3(vec+9, vec, vec+3, factor); + interp_v3_v3v3(vec+12, vec+3, vec+6, factor); /* change handle of prev beztn */ VECCOPY((beztn-1)->vec[2], vec); /* new point */ VECCOPY(beztn->vec[0], vec+9); - subdivide_v3(beztn->vec[1], vec+9, vec+12, factor); + interp_v3_v3v3(beztn->vec[1], vec+9, vec+12, factor); VECCOPY(beztn->vec[2], vec+12); /* handle of next bezt */ if(a==0 && (nu->flagu & CU_NURB_CYCLIC)) {VECCOPY(beztnew->vec[0], vec+6);} @@ -2045,7 +2030,7 @@ static void subdividenurb(Object *obedit, int number_cuts) factor = (float)(i + 1) / (number_cuts + 1); memcpy(bpn, bp, sizeof(BPoint)); - subdivide_v4(bpn->vec, prevbp->vec, bp->vec, factor); + interp_v4_v4v4(bpn->vec, prevbp->vec, bp->vec, factor); bpn++; } @@ -2147,7 +2132,7 @@ static void subdividenurb(Object *obedit, int number_cuts) for (i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); *bpn= *bp; - subdivide_v4(bpn->vec, prevbp->vec, bp->vec, factor); + interp_v4_v4v4(bpn->vec, prevbp->vec, bp->vec, factor); bpn++; } } @@ -2165,7 +2150,7 @@ static void subdividenurb(Object *obedit, int number_cuts) for (i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); *tmp= *bp; - subdivide_v4(tmp->vec, prevbp->vec, bp->vec, factor); + interp_v4_v4v4(tmp->vec, prevbp->vec, bp->vec, factor); tmp += countu; } bp++; @@ -2212,7 +2197,7 @@ static void subdividenurb(Object *obedit, int number_cuts) node. (is it?) */ *bpn= *prevbp; - subdivide_v4(bpn->vec, prevbp->vec, bp->vec, factor); + interp_v4_v4v4(bpn->vec, prevbp->vec, bp->vec, factor); bpn++; prevbp++; @@ -2256,7 +2241,7 @@ static void subdividenurb(Object *obedit, int number_cuts) factor = (float)(i + 1) / (number_cuts + 1); prevbp= bp- 1; *bpn= *prevbp; - subdivide_v4(bpn->vec, prevbp->vec, bp->vec, factor); + interp_v4_v4v4(bpn->vec, prevbp->vec, bp->vec, factor); bpn++; } }