diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-11-10 23:43:45 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-11-10 23:43:45 +0300 |
commit | 37e4a311b0ad9da7177e50620efc3561e2dd7045 (patch) | |
tree | 8aea2cc851ab828ee040d601ed4c776283fd639a /source/blender/blenlib | |
parent | 4617bb68ba4b1c5ab459673fffd98bf7203bb4f2 (diff) |
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
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/BLI_kdopbvh.c | 6 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_kdtree.c | 12 | ||||
-rw-r--r-- | source/blender/blenlib/intern/freetypefont.c | 12 | ||||
-rw-r--r-- | source/blender/blenlib/intern/graph.c | 60 | ||||
-rw-r--r-- | source/blender/blenlib/intern/jitter.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/scanfill.c | 14 |
6 files changed, 53 insertions, 53 deletions
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index eea49254a0e..75eb9b3bb28 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -37,7 +37,7 @@ #include "BKE_utildefines.h" #include "BLI_kdopbvh.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #ifdef _OPENMP #include <omp.h> @@ -1578,7 +1578,7 @@ int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, float VECCOPY(data.ray.direction, dir); data.ray.radius = radius; - Normalize(data.ray.direction); + normalize_v3(data.ray.direction); for(i=0; i<3; i++) { @@ -1635,7 +1635,7 @@ float BLI_bvhtree_bb_raycast(float *bv, float *light_start, float *light_end, fl data.ray.origin[1] = light_start[1]; data.ray.origin[2] = light_start[2]; - Normalize(data.ray.direction); + normalize_v3(data.ray.direction); VECCOPY(data.ray_dot_axis, data.ray.direction); dist = ray_nearest_hit(&data, bv); diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c index ccf79ed42dc..abf61bfb734 100644 --- a/source/blender/blenlib/intern/BLI_kdtree.c +++ b/source/blender/blenlib/intern/BLI_kdtree.c @@ -34,7 +34,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_kdtree.h" #define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; } @@ -76,8 +76,8 @@ void BLI_kdtree_insert(KDTree *tree, int index, float *co, float *nor) KDTreeNode *node= &tree->nodes[tree->totnode++]; node->index= index; - VecCopyf(node->co, co); - if(nor) VecCopyf(node->nor, nor); + copy_v3_v3(node->co, co); + if(nor) copy_v3_v3(node->nor, nor); } static KDTreeNode *kdtree_balance(KDTreeNode *nodes, int totnode, int axis) @@ -225,7 +225,7 @@ int BLI_kdtree_find_nearest(KDTree *tree, float *co, float *nor, KDTreeNearest * if(nearest) { nearest->index= min_node->index; nearest->dist= sqrt(min_dist); - VecCopyf(nearest->co, min_node->co); + copy_v3_v3(nearest->co, min_node->co); } if(stack != defaultstack) @@ -249,7 +249,7 @@ static void add_nearest(KDTreeNearest *ptn, int *found, int n, int index, float ptn[i].index= index; ptn[i].dist= dist; - VecCopyf(ptn[i].co, co); + copy_v3_v3(ptn[i].co, co); } /* finds the nearest n entries in tree to specified coordinates */ @@ -366,7 +366,7 @@ static void add_in_range(KDTreeNearest **ptn, int found, int *totfoundstack, int to->index = index; to->dist = sqrt(dist); - VecCopyf(to->co, co); + copy_v3_v3(to->co, co); } int BLI_kdtree_range_search(KDTree *tree, float range, float *co, float *nor, KDTreeNearest **nearest) { diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index cb5632df569..f2727f6f259 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -45,7 +45,7 @@ #include "BLI_vfontdata.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" //XXX #include "BIF_toolbox.h" @@ -256,11 +256,11 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf // VecLenf, see if there's a distance between the three points // VecLenf again, to check the angle between the handles // finally, check if one of them is a vector handle - if((DistVL2Dfl(bezt->vec[0],bezt->vec[1],bezt->vec[2]) < 0.001) && - (VecLenf(bezt->vec[0], bezt->vec[1]) > 0.0001) && - (VecLenf(bezt->vec[1], bezt->vec[2]) > 0.0001) && - (VecLenf(bezt->vec[0], bezt->vec[2]) > 0.0002) && - (VecLenf(bezt->vec[0], bezt->vec[2]) > MAX2(VecLenf(bezt->vec[0], bezt->vec[1]), VecLenf(bezt->vec[1], bezt->vec[2]))) && + if((dist_to_line_v2(bezt->vec[0],bezt->vec[1],bezt->vec[2]) < 0.001) && + (len_v3v3(bezt->vec[0], bezt->vec[1]) > 0.0001) && + (len_v3v3(bezt->vec[1], bezt->vec[2]) > 0.0001) && + (len_v3v3(bezt->vec[0], bezt->vec[2]) > 0.0002) && + (len_v3v3(bezt->vec[0], bezt->vec[2]) > MAX2(len_v3v3(bezt->vec[0], bezt->vec[1]), len_v3v3(bezt->vec[1], bezt->vec[2]))) && bezt->h1 != HD_VECT && bezt->h2 != HD_VECT) { bezt->h1= bezt->h2= HD_ALIGN; diff --git a/source/blender/blenlib/intern/graph.c b/source/blender/blenlib/intern/graph.c index 49a3cad53f1..fd6bb1a2014 100644 --- a/source/blender/blenlib/intern/graph.c +++ b/source/blender/blenlib/intern/graph.c @@ -30,7 +30,7 @@ #include "BLI_graph.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_utildefines.h" @@ -267,7 +267,7 @@ void BLI_removeDoubleNodes(BGraph *graph, float limit) { for(node_replaced = graph->nodes.first; node_replaced; node_replaced = node_replaced->next) { - if (node_replaced != node_src && VecLenf(node_replaced->p, node_src->p) <= limit) + if (node_replaced != node_src && len_v3v3(node_replaced->p, node_src->p) <= limit) { BLI_replaceNode(graph, node_src, node_replaced); } @@ -283,7 +283,7 @@ BNode * BLI_FindNodeByPosition(BGraph *graph, float *p, float limit) for(node = graph->nodes.first; node; node = node->next) { - float distance = VecLenf(p, node->p); + float distance = len_v3v3(p, node->p); if (distance <= limit && (closest_node == NULL || distance < min_distance)) { closest_node = node; @@ -526,10 +526,10 @@ void BLI_mirrorAlongAxis(float v[3], float center[3], float axis[3]) { float dv[3], pv[3]; - VecSubf(dv, v, center); - Projf(pv, dv, axis); - VecMulf(pv, -2); - VecAddf(v, v, pv); + sub_v3_v3v3(dv, v, center); + project_v3_v3v3(pv, dv, axis); + mul_v3_fl(pv, -2); + add_v3_v3v3(v, v, pv); } static void testRadialSymmetry(BGraph *graph, BNode* root_node, RadialArc* ring, int total, float axis[3], float limit, int group) @@ -546,7 +546,7 @@ static void testRadialSymmetry(BGraph *graph, BNode* root_node, RadialArc* ring, for (j = i + 1; j < total; j++) { - float angle = Inpf(ring[i].n, ring[j].n); + float angle = dot_v3v3(ring[i].n, ring[j].n); /* map negative values to 1..2 */ if (angle < 0) @@ -579,8 +579,8 @@ static void testRadialSymmetry(BGraph *graph, BNode* root_node, RadialArc* ring, float p[3]; int j = (i + 1) % total; /* next arc in the circular list */ - VecAddf(tangent, ring[i].n, ring[j].n); - Crossf(normal, tangent, axis); + add_v3_v3v3(tangent, ring[i].n, ring[j].n); + cross_v3_v3v3(normal, tangent, axis); node1 = BLI_otherNode(ring[i].arc, root_node); node2 = BLI_otherNode(ring[j].arc, root_node); @@ -589,7 +589,7 @@ static void testRadialSymmetry(BGraph *graph, BNode* root_node, RadialArc* ring, BLI_mirrorAlongAxis(p, root_node->p, normal); /* check if it's within limit before continuing */ - if (VecLenf(node1->p, p) > limit) + if (len_v3v3(node1->p, p) > limit) { symmetric = 0; } @@ -658,11 +658,11 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo unit->arc = connectedArc; /* project the node to node vector on the symmetry plane */ - VecSubf(unit->n, otherNode->p, root_node->p); - Projf(vec, unit->n, axis); - VecSubf(unit->n, unit->n, vec); + sub_v3_v3v3(unit->n, otherNode->p, root_node->p); + project_v3_v3v3(vec, unit->n, axis); + sub_v3_v3v3(unit->n, unit->n, vec); - Normalize(unit->n); + normalize_v3(unit->n); unit++; } @@ -780,9 +780,9 @@ static void flagAxialSymmetry(BNode *root_node, BNode *end_node, BArc *arc, int arc->symmetry_group = group; - VecSubf(vec, end_node->p, root_node->p); + sub_v3_v3v3(vec, end_node->p, root_node->p); - if (Inpf(vec, root_node->symmetry_axis) < 0) + if (dot_v3v3(vec, root_node->symmetry_axis) < 0) { arc->symmetry_flag |= SYM_SIDE_NEGATIVE; } @@ -796,26 +796,26 @@ static void testAxialSymmetry(BGraph *graph, BNode* root_node, BNode* node1, BNo { float nor[3], vec[3], p[3]; - VecSubf(p, node1->p, root_node->p); - Crossf(nor, p, axis); + sub_v3_v3v3(p, node1->p, root_node->p); + cross_v3_v3v3(nor, p, axis); - VecSubf(p, root_node->p, node2->p); - Crossf(vec, p, axis); - VecAddf(vec, vec, nor); + sub_v3_v3v3(p, root_node->p, node2->p); + cross_v3_v3v3(vec, p, axis); + add_v3_v3v3(vec, vec, nor); - Crossf(nor, vec, axis); + cross_v3_v3v3(nor, vec, axis); if (abs(nor[0]) > abs(nor[1]) && abs(nor[0]) > abs(nor[2]) && nor[0] < 0) { - VecNegf(nor); + negate_v3(nor); } else if (abs(nor[1]) > abs(nor[0]) && abs(nor[1]) > abs(nor[2]) && nor[1] < 0) { - VecNegf(nor); + negate_v3(nor); } else if (abs(nor[2]) > abs(nor[1]) && abs(nor[2]) > abs(nor[0]) && nor[2] < 0) { - VecNegf(nor); + negate_v3(nor); } /* mirror node2 along axis */ @@ -823,7 +823,7 @@ static void testAxialSymmetry(BGraph *graph, BNode* root_node, BNode* node1, BNo BLI_mirrorAlongAxis(p, root_node->p, nor); /* check if it's within limit before continuing */ - if (VecLenf(node1->p, p) <= limit) + if (len_v3v3(node1->p, p) <= limit) { /* mark node as symmetric physically */ VECCOPY(root_node->symmetry_axis, nor); @@ -905,12 +905,12 @@ static void markdownSecondarySymmetry(BGraph *graph, BNode *node, int depth, int /* If arc is on the axis */ else if (connectedArc->symmetry_level == level) { - VecAddf(axis, axis, connectedArc->head->p); - VecSubf(axis, axis, connectedArc->tail->p); + add_v3_v3v3(axis, axis, connectedArc->head->p); + sub_v3_v3v3(axis, axis, connectedArc->tail->p); } } - Normalize(axis); + normalize_v3(axis); /* Split between axial and radial symmetry */ if (count == 2) diff --git a/source/blender/blenlib/intern/jitter.c b/source/blender/blenlib/intern/jitter.c index fd658765802..e7933ee98a2 100644 --- a/source/blender/blenlib/intern/jitter.c +++ b/source/blender/blenlib/intern/jitter.c @@ -34,7 +34,7 @@ #include <string.h> #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BLI_jitter.h" diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index bd9ed85efa2..e54382c9392 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -40,7 +40,7 @@ #include "DNA_listBase.h" #include "DNA_mesh_types.h" #include "BLI_editVert.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_scanfill.h" #include "BLI_callbacks.h" @@ -432,13 +432,13 @@ static void testvertexnearedge(void) eed= filledgebase.first; while(eed) { if(eve!=eed->v1 && eve!=eed->v2 && eve->xs==eed->f1) { - if(FloatCompare(eve->co,eed->v1->co, COMPLIMIT)) { + if(compare_v3v3(eve->co,eed->v1->co, COMPLIMIT)) { ed1->v2= eed->v1; eed->v1->h++; eve->h= 0; break; } - else if(FloatCompare(eve->co,eed->v2->co, COMPLIMIT)) { + else if(compare_v3v3(eve->co,eed->v2->co, COMPLIMIT)) { ed1->v2= eed->v2; eed->v2->h++; eve->h= 0; @@ -450,7 +450,7 @@ static void testvertexnearedge(void) vec2[0]= eed->v2->co[cox]; vec2[1]= eed->v2->co[coy]; if(boundinsideEV(eed,eve)) { - dist= DistVL2Dfl(vec1,vec2,vec3); + dist= dist_to_line_v2(vec1,vec2,vec3); if(dist<COMPLIMIT) { /* new edge */ ed1= BLI_addfilledge(eed->v1, eve); @@ -819,12 +819,12 @@ int BLI_edgefill(int mode, int mat_nr) eve= fillvertbase.first; while(eve) { if(v2) { - if( FloatCompare(v2, eve->co, COMPLIMIT)==0) { - len= CalcNormFloat(v1, v2, eve->co, norm); + if( compare_v3v3(v2, eve->co, COMPLIMIT)==0) { + len= normal_tri_v3( norm,v1, v2, eve->co); if(len != 0.0) break; } } - else if(FloatCompare(v1, eve->co, COMPLIMIT)==0) { + else if(compare_v3v3(v1, eve->co, COMPLIMIT)==0) { v2= eve->co; } eve= eve->next; |