Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Genrich <daniel.genrich@gmx.net>2008-06-05 17:02:17 +0400
committerDaniel Genrich <daniel.genrich@gmx.net>2008-06-05 17:02:17 +0400
commitf35289574ac8a6c96fb82652a99509406ac2368e (patch)
tree34056f446ba00e056b42cbeef668e465098c101c /source/blender/blenlib
parent4f601b478c99ef9d74086e73a9eb38c9c598791d (diff)
BLI_kdopbvh: crashed when traversing with little faces
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/intern/BLI_kdopbvh.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index 9c4238431dc..a85883f6572 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -240,17 +240,16 @@ void sort_along_axis(BVHTree *tree, int start, int end, int axis)
//after a call to this function you can expect one of:
// every node to left of a[n] are smaller or equal to it
// every node to the right of a[n] are greater or equal to it
-int partition_nth_element(BVHNode **a, int _begin, int _end, int n, int axis){
- int begin = _begin, end = _end, cut;
- int i;
- while(end-begin > 3)
- {
- cut = bvh_partition(a, begin, end, bvh_medianof3(a, begin, (begin+end)/2, end-1, axis), axis );
- if(cut <= n)
- begin = cut;
- else
- end = cut;
- }
+int partition_nth_element(BVHNode **a, int _begin, int _end, int n, int axis){
+ int begin = _begin, end = _end, cut;
+ while(end-begin > 3)
+ {
+ cut = bvh_partition(a, begin, end, bvh_medianof3(a, begin, (begin+end)/2, end-1, axis), axis );
+ if(cut <= n)
+ begin = cut;
+ else
+ end = cut;
+ }
bvh_insertionsort(a, begin, end, axis);
return n;
@@ -415,7 +414,7 @@ static void refit_kdop_hull(BVHTree *tree, BVHNode *node, int start, int end)
for (j = start; j < end; j++)
{
- // for all Axes.
+// for all Axes.
for (i = tree->start_axis; i < tree->stop_axis; i++)
{
newmin = tree->nodes[j]->bv[(2 * i)];
@@ -696,7 +695,7 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, int *result)
}
#pragma omp parallel for private(j) schedule(static)
- for(j = 0; j < tree1->tree_type; j++)
+ for(j = 0; j < MIN2(tree1->tree_type, tree1->nodes[tree1->totleaf]->totnode); j++)
{
traverse(data[j], tree1->nodes[tree1->totleaf]->children[j], tree2->nodes[tree2->totleaf]);
}