diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-11-07 11:01:24 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-11-07 11:01:24 +0400 |
commit | 7508540c53222c289a665cb0528e2a5c984b9b99 (patch) | |
tree | 1fd3f92c4fd7ea74d23288468a1ce494350c33a7 /source/blender/blenlib | |
parent | 261c1679b484884973d485c3f21bed9e87fa5260 (diff) | |
parent | 4b3cc63f73cfe519689bdbd8482e655b72423038 (diff) |
svn merge -r41575:41602 ^/trunk/blender
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_kdopbvh.h | 12 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_math_vector.h | 9 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_kdopbvh.c | 34 | ||||
-rw-r--r-- | source/blender/blenlib/intern/graph.c | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_vector_inline.c | 44 |
5 files changed, 77 insertions, 26 deletions
diff --git a/source/blender/blenlib/BLI_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h index 4daa27a5c72..8ead7bf5f17 100644 --- a/source/blender/blenlib/BLI_kdopbvh.h +++ b/source/blender/blenlib/BLI_kdopbvh.h @@ -85,11 +85,11 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis); void BLI_bvhtree_free(BVHTree *tree); /* construct: first insert points, then call balance */ -int BLI_bvhtree_insert(BVHTree *tree, int index, float *co, int numpoints); +int BLI_bvhtree_insert(BVHTree *tree, int index, const float *co, int numpoints); void BLI_bvhtree_balance(BVHTree *tree); /* update: first update points/nodes, then call update_tree to refit the bounding volumes */ -int BLI_bvhtree_update_node(BVHTree *tree, int index, float *co, float *co_moving, int numpoints); +int BLI_bvhtree_update_node(BVHTree *tree, int index, const float *co, const float *co_moving, int numpoints); void BLI_bvhtree_update_tree(BVHTree *tree); /* collision/overlap: check two trees if they overlap, alloc's *overlap with length of the int return value */ @@ -98,14 +98,14 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int float BLI_bvhtree_getepsilon(BVHTree *tree); /* find nearest node to the given coordinates (if nearest is given it will only search nodes where square distance is smaller than nearest->dist) */ -int BLI_bvhtree_find_nearest(BVHTree *tree, const float *co, BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata); +int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata); -int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata); +int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float *dir, float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata); -float BLI_bvhtree_bb_raycast(float *bv, float *light_start, float *light_end, float *pos); +float BLI_bvhtree_bb_raycast(float *bv, const float light_start[3], const float light_end[3], float pos[3]); /* range query */ -int BLI_bvhtree_range_query(BVHTree *tree, const float *co, float radius, BVHTree_RangeQuery callback, void *userdata); +int BLI_bvhtree_range_query(BVHTree *tree, const float co[3], float radius, BVHTree_RangeQuery callback, void *userdata); #ifdef __cplusplus } diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 0c72db0742c..cb15c6a597c 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -56,11 +56,18 @@ MINLINE void swap_v2_v2(float a[2], float b[2]); MINLINE void swap_v3_v3(float a[3], float b[3]); MINLINE void swap_v4_v4(float a[4], float b[4]); +/* char */ +MINLINE void copy_v2_v2_char(char r[2], const char a[2]); +MINLINE void copy_v3_v3_char(char r[3], const char a[3]); +MINLINE void copy_v4_v4_char(char r[4], const char a[4]); /* short */ MINLINE void copy_v2_v2_short(short r[2], const short a[2]); MINLINE void copy_v3_v3_short(short r[3], const short a[3]); MINLINE void copy_v4_v4_short(short r[4], const short a[4]); - +/* int */ +MINLINE void copy_v2_v2_int(int r[2], const int a[2]); +MINLINE void copy_v3_v3_int(int r[3], const int a[3]); +MINLINE void copy_v4_v4_int(int r[4], const int a[4]); /********************************* Arithmetic ********************************/ diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index d1734151b4a..f01777bdce1 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -387,7 +387,7 @@ static void build_skip_links(BVHTree *tree, BVHNode *node, BVHNode *left, BVHNod /* * BVHTree bounding volumes functions */ -static void create_kdop_hull(BVHTree *tree, BVHNode *node, float *co, int numpoints, int moving) +static void create_kdop_hull(BVHTree *tree, BVHNode *node, const float *co, int numpoints, int moving) { float newminmax; float *bv = node->bv; @@ -973,7 +973,7 @@ void BLI_bvhtree_balance(BVHTree *tree) //bvhtree_info(tree); } -int BLI_bvhtree_insert(BVHTree *tree, int index, float *co, int numpoints) +int BLI_bvhtree_insert(BVHTree *tree, int index, const float *co, int numpoints) { int i; BVHNode *node = NULL; @@ -1005,7 +1005,7 @@ int BLI_bvhtree_insert(BVHTree *tree, int index, float *co, int numpoints) // call before BLI_bvhtree_update_tree() -int BLI_bvhtree_update_node(BVHTree *tree, int index, float *co, float *co_moving, int numpoints) +int BLI_bvhtree_update_node(BVHTree *tree, int index, const float *co, const float *co_moving, int numpoints) { int i; BVHNode *node= NULL; @@ -1194,7 +1194,7 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int } //Determines the nearest point of the given node BV. Returns the squared distance to that point. -static float calc_nearest_point(const float *proj, BVHNode *node, float *nearest) +static float calc_nearest_point(const float proj[3], BVHNode *node, float *nearest) { int i; const float *bv = node->bv; @@ -1212,7 +1212,7 @@ static float calc_nearest_point(const float *proj, BVHNode *node, float *nearest /* //nearest on a general hull - VECCOPY(nearest, data->co); + copy_v3_v3(nearest, data->co); for(i = data->tree->start_axis; i != data->tree->stop_axis; i++, bv+=2) { float proj = dot_v3v3( nearest, KDOP_AXES[i]); @@ -1221,11 +1221,11 @@ static float calc_nearest_point(const float *proj, BVHNode *node, float *nearest if(dl > 0) { - VECADDFAC(nearest, nearest, KDOP_AXES[i], dl); + madd_v3_v3fl(nearest, KDOP_AXES[i], dl); } else if(du < 0) { - VECADDFAC(nearest, nearest, KDOP_AXES[i], du); + madd_v3_v3fl(nearest, KDOP_AXES[i], du); } } */ @@ -1377,7 +1377,7 @@ static void bfs_find_nearest(BVHNearestData *data, BVHNode *node) #endif -int BLI_bvhtree_find_nearest(BVHTree *tree, const float *co, BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata) +int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata) { int i; @@ -1510,7 +1510,7 @@ static void dfs_raycast(BVHRayCastData *data, BVHNode *node) { data->hit.index = node->index; data->hit.dist = dist; - VECADDFAC(data->hit.co, data->ray.origin, data->ray.direction, dist); + madd_v3_v3v3fl(data->hit.co, data->ray.origin, data->ray.direction, dist); } } else @@ -1553,7 +1553,7 @@ static void iterative_raycast(BVHRayCastData *data, BVHNode *node) { data->hit.index = node->index; data->hit.dist = dist; - VECADDFAC(data->hit.co, data->ray.origin, data->ray.direction, dist); + madd_v3_v3v3fl(data->hit.co, data->ray.origin, data->ray.direction, dist); } node = node->skip[1]; @@ -1566,7 +1566,7 @@ static void iterative_raycast(BVHRayCastData *data, BVHNode *node) } #endif -int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata) +int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata) { int i; BVHRayCastData data; @@ -1577,8 +1577,8 @@ int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, float data.callback = callback; data.userdata = userdata; - VECCOPY(data.ray.origin, co); - VECCOPY(data.ray.direction, dir); + copy_v3_v3(data.ray.origin, co); + copy_v3_v3(data.ray.direction, dir); data.ray.radius = radius; normalize_v3(data.ray.direction); @@ -1620,7 +1620,7 @@ int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, float return data.hit.index; } -float BLI_bvhtree_bb_raycast(float *bv, float *light_start, float *light_end, float *pos) +float BLI_bvhtree_bb_raycast(float *bv, const float light_start[3], const float light_end[3], float pos[3]) { BVHRayCastData data; float dist = 0.0; @@ -1639,13 +1639,13 @@ float BLI_bvhtree_bb_raycast(float *bv, float *light_start, float *light_end, fl data.ray.origin[2] = light_start[2]; normalize_v3(data.ray.direction); - VECCOPY(data.ray_dot_axis, data.ray.direction); + copy_v3_v3(data.ray_dot_axis, data.ray.direction); dist = ray_nearest_hit(&data, bv); if(dist > 0.0f) { - VECADDFAC(pos, light_start, data.ray.direction, dist); + madd_v3_v3v3fl(pos, light_start, data.ray.direction, dist); } return dist; @@ -1706,7 +1706,7 @@ static void dfs_range_query(RangeQueryData *data, BVHNode *node) } } -int BLI_bvhtree_range_query(BVHTree *tree, const float *co, float radius, BVHTree_RangeQuery callback, void *userdata) +int BLI_bvhtree_range_query(BVHTree *tree, const float co[3], float radius, BVHTree_RangeQuery callback, void *userdata) { BVHNode * root = tree->nodes[tree->totleaf]; diff --git a/source/blender/blenlib/intern/graph.c b/source/blender/blenlib/intern/graph.c index 6dd278ed777..d0d3d0e137e 100644 --- a/source/blender/blenlib/intern/graph.c +++ b/source/blender/blenlib/intern/graph.c @@ -823,14 +823,14 @@ static void testAxialSymmetry(BGraph *graph, BNode* root_node, BNode* node1, BNo } /* mirror node2 along axis */ - VECCOPY(p, node2->p); + copy_v3_v3(p, node2->p); BLI_mirrorAlongAxis(p, root_node->p, nor); /* check if it's within limit before continuing */ if (len_v3v3(node1->p, p) <= limit) { /* mark node as symmetric physically */ - VECCOPY(root_node->symmetry_axis, nor); + copy_v3_v3(root_node->symmetry_axis, nor); root_node->symmetry_flag |= SYM_PHYSICAL; root_node->symmetry_flag |= SYM_AXIAL; diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 5550a0e6b90..f6ba4ec43ad 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -78,6 +78,28 @@ MINLINE void copy_v4_v4(float r[4], const float a[4]) } /* short */ +MINLINE void copy_v2_v2_char(char r[2], const char a[2]) +{ + r[0]= a[0]; + r[1]= a[1]; +} + +MINLINE void copy_v3_v3_char(char r[3], const char a[3]) +{ + r[0]= a[0]; + r[1]= a[1]; + r[2]= a[2]; +} + +MINLINE void copy_v4_v4_char(char r[4], const char a[4]) +{ + r[0]= a[0]; + r[1]= a[1]; + r[2]= a[2]; + r[3]= a[3]; +} + +/* short */ MINLINE void copy_v2_v2_short(short r[2], const short a[2]) { r[0]= a[0]; @@ -99,6 +121,28 @@ MINLINE void copy_v4_v4_short(short r[4], const short a[4]) r[3]= a[3]; } +/* int */ +MINLINE void copy_v2_v2_int(int r[2], const int a[2]) +{ + r[0]= a[0]; + r[1]= a[1]; +} + +MINLINE void copy_v3_v3_int(int r[3], const int a[3]) +{ + r[0]= a[0]; + r[1]= a[1]; + r[2]= a[2]; +} + +MINLINE void copy_v4_v4_int(int r[4], const int a[4]) +{ + r[0]= a[0]; + r[1]= a[1]; + r[2]= a[2]; + r[3]= a[3]; +} + MINLINE void swap_v2_v2(float a[2], float b[2]) { SWAP(float, a[0], b[0]); |