correct for own regressions when refactoring select-path, was using heap popmin incor...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 19 Jun 2013 19:59:49 +0000 (19:59 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 19 Jun 2013 19:59:49 +0000 (19:59 +0000)
source/blender/blenlib/intern/BLI_heap.c
source/blender/bmesh/tools/bmesh_path.c

index a8fdcd56abb14075053db94e0b5e85afbf741f13..2da36377e55ee13f1c085e06d3676ee245acd2f1 100644 (file)
@@ -30,6 +30,7 @@
  *  \ingroup bli
  */
 
+#include <stdlib.h>
 #include <string.h>
 
 #include "MEM_guardedalloc.h"
@@ -207,6 +208,8 @@ void *BLI_heap_popmin(Heap *heap)
 {
        void *ptr = heap->tree[0]->ptr;
 
+       BLI_assert(heap->size == 0);
+
        heap->tree[0]->ptr = heap->freenodes;
        heap->freenodes = heap->tree[0];
 
index eda252f18f56dd977bcdd8b9e30672eff348cb91..9fc1996e51aa62331ed4d33c730966709640f612 100644 (file)
@@ -144,7 +144,8 @@ LinkNode *BM_mesh_calc_path_vert(
        BLI_heap_insert(heap, 0.0f, v_src);
        cost[BM_elem_index_get(v_src)] = 0.0f;
 
-       while ((v = BLI_heap_popmin(heap))) {
+       while (!BLI_heap_is_empty(heap)) {
+               v = BLI_heap_popmin(heap);
 
                if (v == v_dst)
                        break;
@@ -261,7 +262,8 @@ LinkNode *BM_mesh_calc_path_edge(
        BLI_heap_insert(heap, 0.0f, e_src);
        cost[BM_elem_index_get(e_src)] = 0.0f;
 
-       while ((e = BLI_heap_popmin(heap))) {
+       while (!BLI_heap_is_empty(heap)) {
+               e = BLI_heap_popmin(heap);
 
                if (e == e_dst)
                        break;
@@ -386,7 +388,8 @@ LinkNode *BM_mesh_calc_path_face(
        BLI_heap_insert(heap, 0.0f, f_src);
        cost[BM_elem_index_get(f_src)] = 0.0f;
 
-       while ((f = BLI_heap_popmin(heap))) {
+       while (!BLI_heap_is_empty(heap)) {
+               f = BLI_heap_popmin(heap);
 
                if (f == f_dst)
                        break;