[Bf-blender-cvs] [900c562b71b] blender2.8: Cleanup: rename fast-heap -> heap-simple
Campbell Barton
noreply at git.blender.org
Tue Nov 6 03:08:37 CET 2018
Commit: 900c562b71b6efcf68d649cb639cc8bc246d5899
Author: Campbell Barton
Date: Tue Nov 6 13:01:18 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB900c562b71b6efcf68d649cb639cc8bc246d5899
Cleanup: rename fast-heap -> heap-simple
In general prefer API names don't start with adjectives
since it causes grouping of unrelated API's for completion.
===================================================================
M source/blender/blenkernel/intern/pbvh_bmesh.c
M source/blender/blenlib/BLI_heap_simple.h
M source/blender/blenlib/intern/BLI_heap_simple.c
M source/blender/blenlib/intern/astar.c
M source/blender/bmesh/operators/bmo_connect_pair.c
M source/blender/bmesh/tools/bmesh_path.c
M source/blender/editors/curve/editcurve_select.c
M source/blender/editors/mesh/editmesh_tools.c
M source/blender/modifiers/intern/MOD_skin.c
===================================================================
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 35c02a250dd..3369b05ea60 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -721,7 +721,7 @@ static void pbvh_bmesh_node_drop_orig(PBVHNode *node)
struct EdgeQueue;
typedef struct EdgeQueue {
- FastHeap *heap;
+ HeapSimple *heap;
const float *center;
float center_proj[3]; /* for when we use projected coords. */
float radius_squared;
@@ -840,7 +840,7 @@ static void edge_queue_insert(
BMVert **pair = BLI_mempool_alloc(eq_ctx->pool);
pair[0] = e->v1;
pair[1] = e->v2;
- BLI_fastheap_insert(eq_ctx->q->heap, priority, pair);
+ BLI_heapsimple_insert(eq_ctx->q->heap, priority, pair);
#ifdef USE_EDGEQUEUE_TAG
BLI_assert(EDGE_QUEUE_TEST(e) == false);
EDGE_QUEUE_ENABLE(e);
@@ -1008,7 +1008,7 @@ static void long_edge_queue_create(
PBVH *bvh, const float center[3], const float view_normal[3],
float radius, const bool use_frontface, const bool use_projected)
{
- eq_ctx->q->heap = BLI_fastheap_new();
+ eq_ctx->q->heap = BLI_heapsimple_new();
eq_ctx->q->center = center;
eq_ctx->q->radius_squared = radius * radius;
eq_ctx->q->limit_len_squared = bvh->bm_max_edge_len * bvh->bm_max_edge_len;
@@ -1070,7 +1070,7 @@ static void short_edge_queue_create(
PBVH *bvh, const float center[3], const float view_normal[3],
float radius, const bool use_frontface, const bool use_projected)
{
- eq_ctx->q->heap = BLI_fastheap_new();
+ eq_ctx->q->heap = BLI_heapsimple_new();
eq_ctx->q->center = center;
eq_ctx->q->radius_squared = radius * radius;
eq_ctx->q->limit_len_squared = bvh->bm_min_edge_len * bvh->bm_min_edge_len;
@@ -1237,8 +1237,8 @@ static bool pbvh_bmesh_subdivide_long_edges(
{
bool any_subdivided = false;
- while (!BLI_fastheap_is_empty(eq_ctx->q->heap)) {
- BMVert **pair = BLI_fastheap_pop_min(eq_ctx->q->heap);
+ while (!BLI_heapsimple_is_empty(eq_ctx->q->heap)) {
+ BMVert **pair = BLI_heapsimple_pop_min(eq_ctx->q->heap);
BMVert *v1 = pair[0], *v2 = pair[1];
BMEdge *e;
@@ -1454,8 +1454,8 @@ static bool pbvh_bmesh_collapse_short_edges(
/* deleted verts point to vertices they were merged into, or NULL when removed. */
GHash *deleted_verts = BLI_ghash_ptr_new("deleted_verts");
- while (!BLI_fastheap_is_empty(eq_ctx->q->heap)) {
- BMVert **pair = BLI_fastheap_pop_min(eq_ctx->q->heap);
+ while (!BLI_heapsimple_is_empty(eq_ctx->q->heap)) {
+ BMVert **pair = BLI_heapsimple_pop_min(eq_ctx->q->heap);
BMVert *v1 = pair[0], *v2 = pair[1];
BLI_mempool_free(eq_ctx->pool, pair);
pair = NULL;
@@ -1961,7 +1961,7 @@ bool BKE_pbvh_bmesh_update_topology(
short_edge_queue_create(&eq_ctx, bvh, center, view_normal, radius, use_frontface, use_projected);
modified |= pbvh_bmesh_collapse_short_edges(
&eq_ctx, bvh, &deleted_faces);
- BLI_fastheap_free(q.heap, NULL);
+ BLI_heapsimple_free(q.heap, NULL);
BLI_mempool_destroy(queue_pool);
}
@@ -1976,7 +1976,7 @@ bool BKE_pbvh_bmesh_update_topology(
long_edge_queue_create(&eq_ctx, bvh, center, view_normal, radius, use_frontface, use_projected);
modified |= pbvh_bmesh_subdivide_long_edges(
&eq_ctx, bvh, &edge_loops);
- BLI_fastheap_free(q.heap, NULL);
+ BLI_heapsimple_free(q.heap, NULL);
BLI_mempool_destroy(queue_pool);
}
diff --git a/source/blender/blenlib/BLI_heap_simple.h b/source/blender/blenlib/BLI_heap_simple.h
index 077c8cc1bb9..eed33558d84 100644
--- a/source/blender/blenlib/BLI_heap_simple.h
+++ b/source/blender/blenlib/BLI_heap_simple.h
@@ -26,20 +26,19 @@
* \brief A min-heap / priority queue ADT
*/
-
-struct FastHeap;
-typedef struct FastHeap FastHeap;
+struct HeapSimple;
+typedef struct HeapSimple HeapSimple;
typedef void (*HeapSimpleFreeFP)(void *ptr);
-FastHeap *BLI_fastheap_new_ex(unsigned int tot_reserve) ATTR_WARN_UNUSED_RESULT;
-FastHeap *BLI_fastheap_new(void) ATTR_WARN_UNUSED_RESULT;
-void BLI_fastheap_clear(FastHeap *heap, HeapSimpleFreeFP ptrfreefp) ATTR_NONNULL(1);
-void BLI_fastheap_free(FastHeap *heap, HeapSimpleFreeFP ptrfreefp) ATTR_NONNULL(1);
-void BLI_fastheap_insert(FastHeap *heap, float value, void *ptr) ATTR_NONNULL(1);
-bool BLI_fastheap_is_empty(const FastHeap *heap) ATTR_NONNULL(1);
-uint BLI_fastheap_len(const FastHeap *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
-float BLI_fastheap_top_value(const FastHeap *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
-void *BLI_fastheap_pop_min(FastHeap *heap) ATTR_NONNULL(1);
+HeapSimple *BLI_heapsimple_new_ex(unsigned int tot_reserve) ATTR_WARN_UNUSED_RESULT;
+HeapSimple *BLI_heapsimple_new(void) ATTR_WARN_UNUSED_RESULT;
+void BLI_heapsimple_clear(HeapSimple *heap, HeapSimpleFreeFP ptrfreefp) ATTR_NONNULL(1);
+void BLI_heapsimple_free(HeapSimple *heap, HeapSimpleFreeFP ptrfreefp) ATTR_NONNULL(1);
+void BLI_heapsimple_insert(HeapSimple *heap, float value, void *ptr) ATTR_NONNULL(1);
+bool BLI_heapsimple_is_empty(const HeapSimple *heap) ATTR_NONNULL(1);
+uint BLI_heapsimple_len(const HeapSimple *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
+float BLI_heapsimple_top_value(const HeapSimple *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
+void *BLI_heapsimple_pop_min(HeapSimple *heap) ATTR_NONNULL(1);
#endif /* __BLI_HEAP_SIMPLE_H__ */
diff --git a/source/blender/blenlib/intern/BLI_heap_simple.c b/source/blender/blenlib/intern/BLI_heap_simple.c
index 66766489781..777b9c61b28 100644
--- a/source/blender/blenlib/intern/BLI_heap_simple.c
+++ b/source/blender/blenlib/intern/BLI_heap_simple.c
@@ -24,6 +24,8 @@
* A min-heap / priority queue ADT.
*
* Simplified version of the heap that only supports insertion and removal from top.
+ *
+ * See BLI_heap.c for a more full featured heap implementation.
*/
#include <stdlib.h>
@@ -38,37 +40,37 @@
#define HEAP_PARENT(i) (((i) - 1) >> 1)
/* -------------------------------------------------------------------- */
-/** \name FastHeap Internal Structs
+/** \name HeapSimple Internal Structs
* \{ */
-typedef struct FastHeapNode {
+typedef struct HeapSimpleNode {
float value;
void *ptr;
-} FastHeapNode;
+} HeapSimpleNode;
-struct FastHeap {
+struct HeapSimple {
uint size;
uint bufsize;
- FastHeapNode *tree;
+ HeapSimpleNode *tree;
};
/** \} */
/* -------------------------------------------------------------------- */
-/** \name FastHeap Internal Functions
+/** \name HeapSimple Internal Functions
* \{ */
-static void fastheap_down(FastHeap *heap, uint start_i, const FastHeapNode *init)
+static void heapsimple_down(HeapSimple *heap, uint start_i, const HeapSimpleNode *init)
{
#if 1
/* The compiler isn't smart enough to realize that all computations
* using index here can be modified to work with byte offset. */
uint8_t * const tree_buf = (uint8_t *)heap->tree;
-#define OFFSET(i) (i * (uint)sizeof(FastHeapNode))
-#define NODE(offset) (*(FastHeapNode*)(tree_buf + (offset)))
+#define OFFSET(i) (i * (uint)sizeof(HeapSimpleNode))
+#define NODE(offset) (*(HeapSimpleNode*)(tree_buf + (offset)))
#else
- FastHeapNode *const tree = heap->tree;
+ HeapSimpleNode *const tree = heap->tree;
#define OFFSET(i) (i)
#define NODE(i) tree[i]
@@ -124,9 +126,9 @@ static void fastheap_down(FastHeap *heap, uint start_i, const FastHeapNode *init
#undef HEAP_LEFT_OFFSET
}
-static void fastheap_up(FastHeap *heap, uint i, float active_val, void *active_ptr)
+static void heapsimple_up(HeapSimple *heap, uint i, float active_val, void *active_ptr)
{
- FastHeapNode *const tree = heap->tree;
+ HeapSimpleNode *const tree = heap->tree;
while (LIKELY(i > 0)) {
const uint p = HEAP_PARENT(i);
@@ -146,30 +148,30 @@ static void fastheap_up(FastHeap *heap, uint i, float active_val, void *active_p
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Public FastHeap API
+/** \name Public HeapSimple API
* \{ */
/**
- * Creates a new fast heap, which only supports insertion and removal from top.
+ * Creates a new simple heap, which only supports insertion and removal from top.
*
* \note Use when the size of the heap is known in advance.
*/
-FastHeap *BLI_fastheap_new_ex(uint tot_reserve)
+HeapSimple *BLI_heapsimple_new_ex(uint tot_reserve)
{
- FastHeap *heap = MEM_mallocN(sizeof(FastHeap), __func__);
+ HeapSimple *heap = MEM_mallocN(sizeof(HeapSimple), __func__);
/* ensure we have at least one so we can keep doubling it */
heap->size = 0;
heap->bufsize = MAX2(1u, tot_reserve);
- heap->tree = MEM_mallocN(heap->bufsize * sizeof(FastHeapNode), "BLIFastHeapTree");
+ heap->tree = MEM_mallocN(heap->bufsize * sizeof(HeapSimpleNode), "BLIHeapSimpleTree");
return heap;
}
-FastHeap *BLI_fastheap_new(void)
+HeapSimple *BLI_heapsimple_new(void)
{
- return BLI_fastheap_new_ex(1);
+ return BLI_heapsimple_new_ex(1);
}
-void BLI_fastheap_free(FastHeap *heap, HeapSimpleFreeFP ptrfreefp)
+void BLI_heapsimple_free(HeapSimple *heap, HeapSimpleFreeFP ptrfreefp)
{
if (ptrfreefp) {
for (uint i = 0; i < heap->size; i++) {
@@ -181,7 +183,7 @@ void BLI_fastheap_free(FastHeap *heap, HeapSimpleFreeFP ptrfreefp)
MEM_freeN(heap);
}
-void BLI_fastheap_clear(FastHeap *heap, HeapSimpleFreeFP ptrfreefp)
+void BLI_heapsimple_clear(HeapSimple *heap, HeapSimpleFreeFP ptrfreefp)
{
if (ptrfreefp) {
for (uint i = 0; i < heap->size; i++) {
@@ -196,22 +198,22 @@ void BLI_fastheap_clear(FastHeap *heap, HeapSimpleFreeFP ptrfreefp)
* Insert heap node with a value (often a 'cost') and pointer into the heap,
* duplicate values are allowed.
*/
-void BLI_fastheap_insert(FastHeap *heap, float value, void *ptr)
+void BLI_heapsimple_insert(HeapSimple *heap, float value, void *ptr)
{
if (UNLIKELY(heap->size >= heap->bufsize)) {
heap->bufsize *= 2;
heap->tree = MEM_reallocN(heap->tree, heap->bufsize * sizeof(*heap->tree));
}
- fastheap_up(heap, heap->size++, value, ptr);
+ heapsimple_up(heap, heap->size++, value, ptr);
}
-bool BLI_fastheap_is_empty(const FastHeap *heap)
+bool BLI_heapsimple_is_empty(const HeapSimple *hea
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list