Cleanup: trailing space for BLI

This commit is contained in:
Campbell Barton 2018-06-17 16:32:54 +02:00
parent f19ecdeec6
commit 5513da65b2
44 changed files with 445 additions and 445 deletions

View File

@ -47,11 +47,11 @@
typedef struct DLRBT_Node {
/* ListBase capabilities */
struct DLRBT_Node *next, *prev;
/* Tree Associativity settings */
struct DLRBT_Node *left, *right;
struct DLRBT_Node *parent;
char tree_col;
/* ... for nice alignment, next item should usually be a char too... */
} DLRBT_Node;
@ -75,18 +75,18 @@ typedef struct DLRBT_Tree {
/* Callback Types --------------------------------- */
/* return -1, 0, 1 for whether the given data is less than, equal to, or greater than the given node
/* return -1, 0, 1 for whether the given data is less than, equal to, or greater than the given node
* - node: <DLRBT_Node> the node to compare to
* - data: pointer to the relevant data or values stored in the bitpattern dependent on the function
*/
typedef short (*DLRBT_Comparator_FP)(void *node, void *data);
/* return a new node instance wrapping the given data
/* return a new node instance wrapping the given data
* - data: pointer to the relevant data to create a subclass of node from
*/
typedef DLRBT_Node *(*DLRBT_NAlloc_FP)(void *data);
/* update an existing node instance accordingly to be in sync with the given data *
/* update an existing node instance accordingly to be in sync with the given data *
* - node: <DLRBT_Node> the node to update
* - data: pointer to the relevant data or values stored in the bitpattern dependent on the function
*/
@ -130,28 +130,28 @@ short BLI_dlrbTree_contains(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, void *
/* Node Operations (Managed) --------------------- */
/* These methods automate the process of adding/removing nodes from the BST,
/* These methods automate the process of adding/removing nodes from the BST,
* using the supplied data and callbacks
*/
/* Add the given data to the tree, and return the node added */
// NOTE: for duplicates, the update_cb is called (if available), and the existing node is returned
DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb,
DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb,
DLRBT_NAlloc_FP new_cb, DLRBT_NUpdate_FP update_cb, void *data);
/* Remove the given element from the tree and balance again */
// FIXME: this is not implemented yet...
// FIXME: this is not implemented yet...
// void BLI_dlrbTree_remove(DLRBT_Tree *tree, DLRBT_Node *node);
/* Node Operations (Manual) --------------------- */
/* These methods require custom code for creating BST nodes and adding them to the
/* These methods require custom code for creating BST nodes and adding them to the
* tree in special ways, such that the node can then be balanced.
*
* It is recommended that these methods are only used where the other method is too cumbersome...
*/
/* Balance the tree after the given node has been added to it
/* Balance the tree after the given node has been added to it
* (using custom code, in the Binary Tree way).
*/
void BLI_dlrbTree_insert(DLRBT_Tree *tree, DLRBT_Node *node);

View File

@ -24,7 +24,7 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BLI_DYNSTR_H__
#define __BLI_DYNSTR_H__

View File

@ -19,7 +19,7 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BLI_EDGEHASH_H__
#define __BLI_EDGEHASH_H__

View File

@ -51,9 +51,9 @@ typedef void (*AxialSymmetry)(struct BNode *root_node, struct BNode *node1, stru
typedef struct BGraph {
ListBase arcs;
ListBase nodes;
float length;
/* function pointer to deal with custom fonctionnality */
FreeArc free_arc;
FreeNode free_node;
@ -68,7 +68,7 @@ typedef struct BNode {
int degree;
struct BArc **arcs;
int subgraph_index;
int symmetry_level;
@ -114,17 +114,17 @@ typedef struct BArcIterator {
NextNFct nextN;
PreviousFct previous;
StoppedFct stopped;
float *p, *no;
float size;
int length;
int index;
} BArcIterator;
/* Helper structure for radial symmetry */
typedef struct RadialArc {
struct BArc *arc;
struct BArc *arc;
float n[3]; /* normalized vector joining the nodes of the arc */
} RadialArc;

View File

@ -17,7 +17,7 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BLI_HEAP_H__
#define __BLI_HEAP_H__

View File

@ -20,7 +20,7 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BLI_KDTREE_H__
#define __BLI_KDTREE_H__

View File

@ -24,7 +24,7 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BLI_LINKLIST_H__
#define __BLI_LINKLIST_H__

View File

@ -24,7 +24,7 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BLI_LINKLIST_STACK_H__
#define __BLI_LINKLIST_STACK_H__

View File

@ -385,7 +385,7 @@ void interp_barycentric_tri_v3(float data[3][3], float u, float v, float res[3])
/***************************** View & Projection *****************************/
void lookat_m4(float mat[4][4], float vx, float vy,
void lookat_m4(float mat[4][4], float vx, float vy,
float vz, float px, float py, float pz, float twist);
void polarview_m4(float mat[4][4], float dist, float azimuth,
float incidence, float twist);

View File

@ -17,7 +17,7 @@
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
* The Original Code is: some of this file.
*
* ***** END GPL LICENSE BLOCK *****

View File

@ -24,7 +24,7 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BLI_MEMPOOL_H__
#define __BLI_MEMPOOL_H__

View File

@ -24,7 +24,7 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BLI_RAND_H__
#define __BLI_RAND_H__

View File

@ -24,7 +24,7 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BLI_SMALLHASH_H__
#define __BLI_SMALLHASH_H__

View File

@ -87,7 +87,7 @@ typedef unsigned short ushort;
typedef unsigned long ulong;
typedef unsigned char uchar;
#ifdef __cplusplus
#ifdef __cplusplus
}
#endif

View File

@ -26,7 +26,7 @@
*/
#ifndef __BLI_THREADS_H__
#define __BLI_THREADS_H__
#define __BLI_THREADS_H__
/** \file BLI_threads.h
* \ingroup bli
@ -74,7 +74,7 @@ void BLI_threaded_malloc_end(void);
int BLI_system_thread_count(void); /* gets the number of threads the system can make use of */
void BLI_system_num_threads_override_set(int num);
int BLI_system_num_threads_override_get(void);
/* Global Mutex Locks
*
* One custom lock available now. can be extended. */
@ -155,7 +155,7 @@ void BLI_ticket_mutex_lock(TicketMutex *ticket);
void BLI_ticket_mutex_unlock(TicketMutex *ticket);
/* Condition */
typedef pthread_cond_t ThreadCondition;
void BLI_condition_init(ThreadCondition *cond);

View File

@ -552,13 +552,13 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size);
/* UNUSED macro, for function argument */
#if defined(__GNUC__) || defined(__clang__)
#if defined(__GNUC__) || defined(__clang__)
# define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
#else
# define UNUSED(x) UNUSED_ ## x
#endif
#if defined(__GNUC__) || defined(__clang__)
#if defined(__GNUC__) || defined(__clang__)
# define UNUSED_FUNCTION(x) __attribute__((__unused__)) UNUSED_ ## x
#else
# define UNUSED_FUNCTION(x) UNUSED_ ## x

View File

@ -24,7 +24,7 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BLI_WINSTUFF_H__
#define __BLI_WINSTUFF_H__

View File

@ -34,7 +34,7 @@
#define __PIL_TIME_H__
#ifdef __cplusplus
extern "C" {
extern "C" {
#endif
extern

View File

@ -30,21 +30,21 @@
struct Dial {
/* center of the dial */
float center[2];
/* threshold of the dial. Distance of current position has to be greater
/* threshold of the dial. Distance of current position has to be greater
* than the threshold to be used in any calculations */
float threshold_squared;
/* the direction of the first dial position exceeding the threshold. This
* is later used as the basis against which rotation angle is calculated */
float initial_direction[2];
/* cache the last angle to detect rotations bigger than -/+ PI */
float last_angle;
/* number of full rotations */
int rotations;
/* has initial_direction been initialized */
bool initialized;
};
@ -53,17 +53,17 @@ struct Dial {
Dial *BLI_dial_initialize(const float start_position[2], float threshold)
{
Dial *dial = MEM_callocN(sizeof(Dial), "dial");
copy_v2_v2(dial->center, start_position);
dial->threshold_squared = threshold * threshold;
return dial;
}
float BLI_dial_angle(Dial *dial, const float current_position[2])
{
float current_direction[2];
sub_v2_v2v2(current_direction, current_position, dial->center);
/* only update when we have enough precision, by having the mouse adequately away from center */
@ -77,14 +77,14 @@ float BLI_dial_angle(Dial *dial, const float current_position[2])
copy_v2_v2(dial->initial_direction, current_direction);
dial->initialized = true;
}
/* calculate mouse angle between initial and final mouse position */
cosval = dot_v2v2(current_direction, dial->initial_direction);
sinval = cross_v2v2(current_direction, dial->initial_direction);
/* clamp to avoid nans in acos */
angle = atan2f(sinval, cosval);
/* change of sign, we passed the 180 degree threshold. This means we need to add a turn.
* to distinguish between transition from 0 to -1 and -PI to +PI, use comparison with PI/2 */
if ((angle * dial->last_angle < 0.0f) &&
@ -96,9 +96,9 @@ float BLI_dial_angle(Dial *dial, const float current_position[2])
dial->rotations++;
}
dial->last_angle = angle;
return angle + 2.0f * (float)M_PI * dial->rotations;
}
return dial->last_angle;
}

View File

@ -58,7 +58,7 @@
typedef struct DynStrElem DynStrElem;
struct DynStrElem {
DynStrElem *next;
char *str;
};
@ -81,7 +81,7 @@ DynStr *BLI_dynstr_new(void)
ds->elems = ds->last = NULL;
ds->curlen = 0;
ds->memarena = NULL;
return ds;
}
@ -115,11 +115,11 @@ void BLI_dynstr_append(DynStr *__restrict ds, const char *cstr)
{
DynStrElem *dse = dynstr_alloc(ds, sizeof(*dse));
int cstrlen = strlen(cstr);
dse->str = dynstr_alloc(ds, cstrlen + 1);
memcpy(dse->str, cstr, cstrlen + 1);
dse->next = NULL;
if (!ds->last)
ds->last = ds->elems = dse;
else

View File

@ -458,10 +458,10 @@ static void partition_nth_element(BVHNode **a, int begin, int end, const int n,
static void build_skip_links(BVHTree *tree, BVHNode *node, BVHNode *left, BVHNode *right)
{
int i;
node->skip[0] = left;
node->skip[1] = right;
for (i = 0; i < node->totnode; i++) {
if (i + 1 < node->totnode)
build_skip_links(tree, node->children[i], left, node->children[i + 1]);
@ -482,7 +482,7 @@ static void create_kdop_hull(const BVHTree *tree, BVHNode *node, const float *co
float *bv = node->bv;
int k;
axis_t axis_iter;
/* don't init boudings for the moving case */
if (!moving) {
node_minmax_init(tree, node);
@ -560,7 +560,7 @@ static void node_join(BVHTree *tree, BVHNode *node)
axis_t axis_iter;
node_minmax_init(tree, node);
for (i = 0; i < tree->tree_type; i++) {
if (node->children[i]) {
for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) {
@ -631,7 +631,7 @@ static void bvhtree_info(BVHTree *tree)
static void bvhtree_verify(BVHTree *tree)
{
int i, j, check = 0;
/* check the pointer list */
for (i = 0; i < tree->totleaf; i++) {
if (tree->nodes[i]->parent == NULL) {
@ -648,7 +648,7 @@ static void bvhtree_verify(BVHTree *tree)
check = 0;
}
}
/* check the leaf list */
for (i = 0; i < tree->totleaf; i++) {
if (tree->nodearray[i].parent == NULL) {
@ -665,7 +665,7 @@ static void bvhtree_verify(BVHTree *tree)
check = 0;
}
}
printf("branches: %d, leafs: %d, total: %d\n",
tree->totbranch, tree->totleaf, tree->totbranch + tree->totleaf);
}
@ -1008,7 +1008,7 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
tree->nodebv = MEM_callocN(sizeof(float) * (size_t)(axis * numnodes), "BVHNodeBV");
tree->nodechild = MEM_callocN(sizeof(BVHNode *) * (size_t)(tree_type * numnodes), "BVHNodeBV");
tree->nodearray = MEM_callocN(sizeof(BVHNode) * (size_t)numnodes, "BVHNodeArray");
if (UNLIKELY((!tree->nodes) ||
(!tree->nodebv) ||
(!tree->nodechild) ||
@ -1022,7 +1022,7 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
tree->nodearray[i].bv = &tree->nodebv[i * axis];
tree->nodearray[i].children = &tree->nodechild[i * tree_type];
}
}
return tree;
@ -1108,18 +1108,18 @@ bool BLI_bvhtree_update_node(BVHTree *tree, int index, const float co[3], const
{
BVHNode *node = NULL;
axis_t axis_iter;
/* check if index exists */
if (index > tree->totleaf)
return false;
node = tree->nodearray + index;
create_kdop_hull(tree, node, co, numpoints, 0);
if (co_moving)
create_kdop_hull(tree, node, co_moving, numpoints, 1);
/* inflate the bv with some epsilon */
for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) {
node->bv[(2 * axis_iter)] -= tree->epsilon; /* minimum */
@ -1180,7 +1180,7 @@ static bool tree_overlap_test(const BVHNode *node1, const BVHNode *node2, axis_t
const float *bv1 = node1->bv + (start_axis << 1);
const float *bv2 = node2->bv + (start_axis << 1);
const float *bv1_end = node1->bv + (stop_axis << 1);
/* test all axis if min + max overlap */
for (; bv1 != bv1_end; bv1 += 2, bv2 += 2) {
if ((bv1[0] > bv2[1]) || (bv2[0] > bv1[1])) {
@ -1321,7 +1321,7 @@ BVHTreeOverlap *BLI_bvhtree_overlap(
BVHOverlapData_Shared data_shared;
BVHOverlapData_Thread *data = BLI_array_alloca(data, (size_t)thread_num);
axis_t start_axis, stop_axis;
/* check for compatibility of both trees (can't compare 14-DOP with 18-DOP) */
if (UNLIKELY((tree1->axis != tree2->axis) &&
(tree1->axis == 14 || tree2->axis == 14) &&
@ -1333,7 +1333,7 @@ BVHTreeOverlap *BLI_bvhtree_overlap(
start_axis = min_axis(tree1->start_axis, tree2->start_axis);
stop_axis = min_axis(tree1->stop_axis, tree2->stop_axis);
/* fast check root nodes for collision before doing big splitting + traversal */
if (!tree_overlap_test(tree1->nodes[tree1->totleaf], tree2->nodes[tree2->totleaf], start_axis, stop_axis)) {
return NULL;
@ -1365,12 +1365,12 @@ BVHTreeOverlap *BLI_bvhtree_overlap(
data,
bvhtree_overlap_task_cb,
&settings);
for (j = 0; j < thread_num; j++)
total += BLI_stack_count(data[j].overlap);
to = overlap = MEM_mallocN(sizeof(BVHTreeOverlap) * total, "BVHTreeOverlap");
for (j = 0; j < thread_num; j++) {
uint count = (uint)BLI_stack_count(data[j].overlap);
BLI_stack_pop_n(data[j].overlap, to, count);
@ -1403,7 +1403,7 @@ static float calc_nearest_point_squared(const float proj[3], BVHNode *node, floa
else if (bv[1] < proj[i])
nearest[i] = bv[1];
else
nearest[i] = proj[i];
nearest[i] = proj[i];
}
#if 0
@ -1548,7 +1548,7 @@ static void bfs_find_nearest(BVHNearestData *data, BVHNode *node)
push_heaps++;
}
}
if (heap_size == 0) break;
current = heap[0];
@ -1645,7 +1645,7 @@ static float ray_nearest_hit(const BVHRayCastData *data, const float bv[6])
if (lu > low) low = lu;
if (ll < upper) upper = ll;
}
if (low > upper) return FLT_MAX;
}
}
@ -1661,7 +1661,7 @@ static float ray_nearest_hit(const BVHRayCastData *data, const float bv[6])
static float fast_ray_nearest_hit(const BVHRayCastData *data, const BVHNode *node)
{
const float *bv = node->bv;
float t1x = (bv[data->index[0]] - data->ray.origin[0]) * data->idot_axis[0];
float t2x = (bv[data->index[1]] - data->ray.origin[0]) * data->idot_axis[0];
float t1y = (bv[data->index[2]] - data->ray.origin[1]) * data->idot_axis[1];
@ -1773,7 +1773,7 @@ static void iterative_raycast(BVHRayCastData *data, BVHNode *node)
data->hit.dist = dist;
madd_v3_v3v3fl(data->hit.co, data->ray.origin, data->ray.direction, dist);
}
node = node->skip[1];
}
else {
@ -1867,23 +1867,23 @@ float BLI_bvhtree_bb_raycast(const float bv[6], const float light_start[3], cons
float dist;
data.hit.dist = BVH_RAYCAST_DIST_MAX;
/* get light direction */
sub_v3_v3v3(data.ray.direction, light_end, light_start);
data.ray.radius = 0.0;
copy_v3_v3(data.ray.origin, light_start);
normalize_v3(data.ray.direction);
copy_v3_v3(data.ray_dot_axis, data.ray.direction);
dist = ray_nearest_hit(&data, bv);
madd_v3_v3v3fl(pos, light_start, data.ray.direction, dist);
return dist;
}
/**

View File

@ -123,7 +123,7 @@ static uint kdtree_balance(KDTreeNode *nodes, uint totnode, uint axis, const uin
return KD_NODE_UNSET;
else if (totnode == 1)
return 0 + ofs;
/* quicksort style sorting around median */
left = 0;
right = totnode - 1;
@ -238,7 +238,7 @@ int BLI_kdtree_find_nearest(
if (root->right != KD_NODE_UNSET)
stack[cur++] = root->right;
}
while (cur--) {
const KDTreeNode *node = &nodes[stack[cur]];
@ -448,7 +448,7 @@ int BLI_kdtree_find_nearest_n__normal(
cur_dist = squared_distance(root->co, co, nor);
add_nearest(r_nearest, &found, n, root->index, cur_dist, root->co);
if (co[root->d] < root->co[root->d]) {
if (root->right != KD_NODE_UNSET)
stack[cur++] = root->right;

View File

@ -58,18 +58,18 @@ int BLI_linklist_count(const LinkNode *list)
int BLI_linklist_index(const LinkNode *list, void *ptr)
{
int index;
for (index = 0; list; list = list->next, index++)
if (list->link == ptr)
return index;
return -1;
}
LinkNode *BLI_linklist_find(LinkNode *list, int index)
{
int i;
for (i = 0; list; list = list->next, i++)
if (i == index)
return list;
@ -80,16 +80,16 @@ LinkNode *BLI_linklist_find(LinkNode *list, int index)
void BLI_linklist_reverse(LinkNode **listp)
{
LinkNode *rhead = NULL, *cur = *listp;
while (cur) {
LinkNode *next = cur->next;
cur->next = rhead;
rhead = cur;
cur = next;
}
*listp = rhead;
}
@ -199,7 +199,7 @@ void BLI_linklist_append_nlink(LinkNodePair *list_pair, void *ptr, LinkNode *nli
{
nlink->link = ptr;
nlink->next = NULL;
if (list_pair->list) {
BLI_assert((list_pair->last_node != NULL) && (list_pair->last_node->next == NULL));
list_pair->last_node->next = nlink;
@ -275,11 +275,11 @@ void BLI_linklist_free(LinkNode *list, LinkNodeFreeFP freefunc)
{
while (list) {
LinkNode *next = list->next;
if (freefunc)
freefunc(list->link);
MEM_freeN(list);
list = next;
}
}

View File

@ -48,7 +48,7 @@ void BLI_dlrbTree_init(DLRBT_Tree *tree)
{
if (tree == NULL)
return;
tree->first = tree->last = tree->root = NULL;
}
@ -58,11 +58,11 @@ static void recursive_tree_free_nodes(DLRBT_Node *node)
/* sanity check */
if (node == NULL)
return;
/* free child nodes + subtrees */
recursive_tree_free_nodes(node->left);
recursive_tree_free_nodes(node->right);
/* free self */
MEM_freeN(node);
}
@ -72,8 +72,8 @@ void BLI_dlrbTree_free(DLRBT_Tree *tree)
{
if (tree == NULL)
return;
/* if the list-base stuff is set, just use that (and assume its set),
/* if the list-base stuff is set, just use that (and assume its set),
* otherwise, we'll need to traverse the tree...
*/
if (tree->first) {
@ -84,7 +84,7 @@ void BLI_dlrbTree_free(DLRBT_Tree *tree)
/* traverse tree, freeing sub-nodes */
recursive_tree_free_nodes(tree->root);
}
/* clear pointers */
tree->first = tree->last = tree->root = NULL;
}
@ -97,17 +97,17 @@ static void linkedlist_sync_add_node(DLRBT_Tree *tree, DLRBT_Node *node)
/* sanity checks */
if ((tree == NULL) || (node == NULL))
return;
/* add left-node (and its subtree) */
linkedlist_sync_add_node(tree, node->left);
/* now add self
* - must remove detach from other links first
* (for now, only clear own pointers)
*/
node->prev = node->next = NULL;
BLI_addtail((ListBase *)tree, (Link *)node);
/* finally, add right node (and its subtree) */
linkedlist_sync_add_node(tree, node->right);
}
@ -118,10 +118,10 @@ void BLI_dlrbTree_linkedlist_sync(DLRBT_Tree *tree)
/* sanity checks */
if (tree == NULL)
return;
/* clear list-base pointers so that the new list can be added properly */
tree->first = tree->last = NULL;
/* start adding items from the root */
linkedlist_sync_add_node(tree, tree->root);
}
@ -142,7 +142,7 @@ DLRBT_Node *BLI_dlrbTree_search(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, vo
/* iteratively perform this search */
while (node && found == 0) {
/* check if traverse further or not
/* check if traverse further or not
* NOTE: it is assumed that the values will be unit values only
*/
switch (cmp_cb(node, search_data)) {
@ -152,38 +152,38 @@ DLRBT_Node *BLI_dlrbTree_search(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, vo
else
found = 1;
break;
case 1: /* data greater than node */
if (node->right)
node = node->right;
else
found = 1;
break;
default: /* data equals node */
found = 1;
break;
}
}
/* return the nearest matching node */
return node;
}
}
/* Find the node which exactly matches the required data */
DLRBT_Node *BLI_dlrbTree_search_exact(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, void *search_data)
{
DLRBT_Node *node = (tree) ? tree->root : NULL;
short found = 0;
/* check that there is a comparator to use */
/* TODO: if no comparator is supplied, try using the one supplied with the tree... */
if (cmp_cb == NULL)
return NULL;
/* iteratively perform this search */
while (node && found == 0) {
/* check if traverse further or not
/* check if traverse further or not
* NOTE: it is assumed that the values will be unit values only
*/
switch (cmp_cb(node, search_data)) {
@ -193,20 +193,20 @@ DLRBT_Node *BLI_dlrbTree_search_exact(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_
else
found = -1;
break;
case 1: /* data greater than node */
if (node->right)
node = node->right;
else
found = -1;
break;
default: /* data equals node */
found = 1;
break;
}
}
/* return the exactly matching node */
return (found == 1) ? (node) : (NULL);
}
@ -215,25 +215,25 @@ DLRBT_Node *BLI_dlrbTree_search_exact(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_
DLRBT_Node *BLI_dlrbTree_search_prev(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, void *search_data)
{
DLRBT_Node *node;
/* check that there is a comparator to use */
/* TODO: if no comparator is supplied, try using the one supplied with the tree... */
if (cmp_cb == NULL)
return NULL;
/* get the node which best matches this description */
node = BLI_dlrbTree_search(tree, cmp_cb, search_data);
if (node) {
/* if the item we're searching for is greater than the node found, we've found the match */
if (cmp_cb(node, search_data) > 0)
return node;
/* return the previous node otherwise */
/* NOTE: what happens if there is no previous node? */
return node->prev;
}
/* nothing matching was found */
return NULL;
}
@ -247,20 +247,20 @@ DLRBT_Node *BLI_dlrbTree_search_next(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_c
/* TODO: if no comparator is supplied, try using the one supplied with the tree... */
if (cmp_cb == NULL)
return NULL;
/* get the node which best matches this description */
node = BLI_dlrbTree_search(tree, cmp_cb, search_data);
if (node) {
/* if the item we're searching for is less than the node found, we've found the match */
if (cmp_cb(node, search_data) < 0)
return node;
/* return the previous node otherwise */
/* NOTE: what happens if there is no previous node? */
return node->next;
}
/* nothing matching was found */
return NULL;
}
@ -305,7 +305,7 @@ static DLRBT_Node *get_uncle(DLRBT_Node *node)
if (node)
/* return the child of the grandparent which isn't the node's parent */
return get_sibling(node->parent);
/* uncle not found */
return NULL;
}
@ -317,12 +317,12 @@ static DLRBT_Node *get_uncle(DLRBT_Node *node)
static void rotate_left(DLRBT_Tree *tree, DLRBT_Node *root)
{
DLRBT_Node **root_slot, *pivot;
/* pivot is simply the root's right child, to become the root's parent */
pivot = root->right;
if (pivot == NULL)
return;
if (root->parent) {
if (root == root->parent->left)
root_slot = &root->parent->left;
@ -331,17 +331,17 @@ static void rotate_left(DLRBT_Tree *tree, DLRBT_Node *root)
}
else
root_slot = ((DLRBT_Node **)&tree->root); /* &((DLRBT_Node *)tree->root); */
/* - pivot's left child becomes root's right child
* - root now becomes pivot's left child
* - root now becomes pivot's left child
*/
root->right = pivot->left;
if (pivot->left) pivot->left->parent = root;
pivot->left = root;
pivot->parent = root->parent;
root->parent = pivot;
/* make the pivot the new root */
if (root_slot)
*root_slot = pivot;
@ -351,12 +351,12 @@ static void rotate_left(DLRBT_Tree *tree, DLRBT_Node *root)
static void rotate_right(DLRBT_Tree *tree, DLRBT_Node *root)
{
DLRBT_Node **root_slot, *pivot;
/* pivot is simply the root's left child, to become the root's parent */
pivot = root->left;
if (pivot == NULL)
return;
if (root->parent) {
if (root == root->parent->left)
root_slot = &root->parent->left;
@ -365,17 +365,17 @@ static void rotate_right(DLRBT_Tree *tree, DLRBT_Node *root)
}
else
root_slot = ((DLRBT_Node **)&tree->root); /* &((DLRBT_Node *)tree->root); */
/* - pivot's right child becomes root's left child
* - root now becomes pivot's right child
* - root now becomes pivot's right child
*/
root->left = pivot->right;
if (pivot->right) pivot->right->parent = root;
pivot->right = root;
pivot->parent = root->parent;
root->parent = pivot;
/* make the pivot the new root */
if (root_slot)
*root_slot = pivot;
@ -409,20 +409,20 @@ static void insert_check_2(DLRBT_Tree *tree, DLRBT_Node *node)
/* if the parent is not black, we need to change that... */
if (node && node->parent && node->parent->tree_col) {
DLRBT_Node *unc = get_uncle(node);
/* if uncle and parent are both red, need to change them to black and make
/* if uncle and parent are both red, need to change them to black and make
* the parent black in order to satisfy the criteria of each node having the
* same number of black nodes to its leaves
*/
if (unc && unc->tree_col) {
DLRBT_Node *gp = get_grandparent(node);
/* make the n-1 generation nodes black */
node->parent->tree_col = unc->tree_col = DLRBT_BLACK;
/* - make the grandparent red, so that we maintain alternating red/black property
/* - make the grandparent red, so that we maintain alternating red/black property
* (it must exist, so no need to check for NULL here),
* - as the grandparent may now cause inconsistencies with the rest of the tree,
* - as the grandparent may now cause inconsistencies with the rest of the tree,
* we must flush up the tree and perform checks/re-balancing/re-painting, using the
* grandparent as the node of interest
*/
@ -442,7 +442,7 @@ static void insert_check_2(DLRBT_Tree *tree, DLRBT_Node *node)
static void insert_check_3(DLRBT_Tree *tree, DLRBT_Node *node)
{
DLRBT_Node *gp = get_grandparent(node);
/* check that grandparent and node->parent exist (jut in case... really shouldn't happen on a good tree) */
if (node && node->parent && gp) {
/* a left rotation will switch the roles of node and its parent, assuming that
@ -454,22 +454,22 @@ static void insert_check_3(DLRBT_Tree *tree, DLRBT_Node *node)
node = node->left;
}
else if ((node == node->parent->left) && (node->parent == gp->right)) {
rotate_right(tree, node);
rotate_right(tree, node);
node = node->right;
}
/* fix old parent's color-tagging, and perform rotation on the old parent in the
/* fix old parent's color-tagging, and perform rotation on the old parent in the
* opposite direction if needed for the current situation
* NOTE: in the code above, node pointer is changed to point to the old parent
* NOTE: in the code above, node pointer is changed to point to the old parent
*/
if (node) {
/* get 'new' grandparent (i.e. grandparent for old-parent (node)) */
gp = get_grandparent(node);
/* modify the coloring of the grandparent and parent so that they still satisfy the constraints */
node->parent->tree_col = DLRBT_BLACK;
gp->tree_col = DLRBT_RED;
/* if there are several nodes that all form a left chain, do a right rotation to correct this
* (or a rotation in the opposite direction if they all form a right chain)
*/
@ -483,7 +483,7 @@ static void insert_check_3(DLRBT_Tree *tree, DLRBT_Node *node)
/* ----- */
/* Balance the tree after the given element has been added to it
/* Balance the tree after the given element has been added to it
* (using custom code, in the Binary Tree way).
*/
void BLI_dlrbTree_insert(DLRBT_Tree *tree, DLRBT_Node *node)
@ -491,10 +491,10 @@ void BLI_dlrbTree_insert(DLRBT_Tree *tree, DLRBT_Node *node)
/* sanity checks */
if ((tree == NULL) || (node == NULL))
return;
/* firstly, the node we just added should be red by default */
node->tree_col = DLRBT_RED;
/* start from case 1, an trek through the tail-recursive insertion checks */
insert_check_1(tree, node);
}
@ -503,12 +503,12 @@ void BLI_dlrbTree_insert(DLRBT_Tree *tree, DLRBT_Node *node)
/* Add the given data to the tree, and return the node added */
/* NOTE: for duplicates, the update_cb is called (if available), and the existing node is returned */
DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb,
DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb,
DLRBT_NAlloc_FP new_cb, DLRBT_NUpdate_FP update_cb, void *data)
{
DLRBT_Node *parNode, *node = NULL;
short new_node = 0;
/* sanity checks */
if (tree == NULL)
return NULL;
@ -524,11 +524,11 @@ DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb,
/* try to find the nearest node to this one */
parNode = BLI_dlrbTree_search(tree, cmp_cb, data);
/* add new node to the BST in the 'standard way' as appropriate
/* add new node to the BST in the 'standard way' as appropriate
* NOTE: we do not support duplicates in our tree...
*/
if (parNode) {
/* check how this new node compares with the existing ones
/* check how this new node compares with the existing ones
* NOTE: it is assumed that the values will be unit values only
*/
switch (cmp_cb(parNode, data)) {
@ -536,7 +536,7 @@ DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb,
{
node = new_cb(data);
new_node = 1;
parNode->left = node;
node->parent = parNode;
break;
@ -545,7 +545,7 @@ DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb,
{
node = new_cb(data);
new_node = 1;
parNode->right = node;
node->parent = parNode;
break;
@ -562,21 +562,21 @@ DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb,
/* no nodes in the tree yet... add a new node as the root */
node = new_cb(data);
new_node = 1;
tree->root = node;
}
/* if a new node was added, it should be tagged as red, and then balanced as appropriate */
if (new_node) {
/* tag this new node as being 'red' */
node->tree_col = DLRBT_RED;
/* perform BST balancing steps:
* start from case 1, an trek through the tail-recursive insertion checks
*/
insert_check_1(tree, node);
}
/* return the node added */
return node;
}

View File

@ -317,7 +317,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r
vert->used = false;
vert->index = i++;
box->v[BL] = vert++;
vert->trb = vert->brb = vert->tlb =
vert->isect_cache[0] = vert->isect_cache[1] =
vert->isect_cache[2] = vert->isect_cache[3] = NULL;
@ -326,7 +326,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r
vert->used = false;
vert->index = i++;
box->v[TR] = vert++;
vert->trb = vert->blb = vert->tlb =
vert->isect_cache[0] = vert->isect_cache[1] =
vert->isect_cache[2] = vert->isect_cache[3] = NULL;
@ -335,7 +335,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r
vert->used = false;
vert->index = i++;
box->v[TL] = vert++;
vert->trb = vert->blb = vert->brb =
vert->isect_cache[0] = vert->isect_cache[1] =
vert->isect_cache[2] = vert->isect_cache[3] = NULL;
@ -406,7 +406,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r
/* This vert has a free quadrant
* Test if we can place the box here
* vert->free & quad_flags[j] - Checks
* vert->free & quad_flags[j] - Checks
* */
for (j = 0; (j < 4) && isect; j++) {
@ -434,7 +434,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r
* with any other boxes
* Assume no intersection... */
isect = false;
if ( /* Constrain boxes to positive X/Y values */
box_xmin_get(box) < 0.0f || box_ymin_get(box) < 0.0f ||
/* check for last intersected */
@ -494,8 +494,8 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r
/* Mask free flags for verts that are
* on the bottom or side so we don't get
* boxes outside the given rectangle ares
*
* We can do an else/if here because only the first
*
* We can do an else/if here because only the first
* box can be at the very bottom left corner */
if (box_xmin_get(box) <= 0) {
box->v[TL]->free &= ~(TLF | BLF);
@ -508,7 +508,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r
/* The following block of code does a logical
* check with 2 adjacent boxes, its possible to
* flag verts on one or both of the boxes
* flag verts on one or both of the boxes
* as being used by checking the width or
* height of both boxes */
if (vert->tlb && vert->trb && (box == vert->tlb || box == vert->trb)) {

View File

@ -64,7 +64,7 @@ DynamicLibrary *BLI_dynlib_open(const char *name)
lib = MEM_callocN(sizeof(*lib), "Dynamic Library");
lib->handle = handle;
return lib;
}
@ -92,7 +92,7 @@ char *BLI_dynlib_get_error_as_string(DynamicLibrary *lib)
return buf;
}
}
return NULL;
}
@ -116,7 +116,7 @@ DynamicLibrary *BLI_dynlib_open(const char *name)
lib = MEM_callocN(sizeof(*lib), "Dynamic Library");
lib->handle = handle;
return lib;
}
@ -130,7 +130,7 @@ char *BLI_dynlib_get_error_as_string(DynamicLibrary *lib)
(void)lib; /* unused */
return dlerror();
}
void BLI_dynlib_close(DynamicLibrary *lib)
{
dlclose(lib->handle);

View File

@ -64,7 +64,7 @@
#include "BLI_sys_types.h" // for intptr_t support
#if 0 /* UNUSED */
/* gzip the file in from and write it to "to".
/* gzip the file in from and write it to "to".
* return -1 if zlib fails, -2 if the originating file does not exist
* note: will remove the "from" file
*/
@ -95,14 +95,14 @@ int BLI_file_gzip(const char *from, const char *to)
}
else if (readsize == 0)
break; /* done reading */
if (gzwrite(gzfile, buffer, readsize) <= 0) {
rval = -1; /* error happened in writing */
fprintf(stderr, "Error writing gz file %s: %s.\n", to, gzerror(gzfile, &err));
break;
}
}
gzclose(gzfile);
close(file);
@ -141,7 +141,7 @@ char *BLI_file_ungzip_to_mem(const char *from_file, int *r_size)
break;
}
}
gzclose(gzfile);
if (size == 0) {
@ -389,7 +389,7 @@ int BLI_move(const char *file, const char *to)
strcat(str, BLI_last_slash(file) + 1);
}
}
UTF16_ENCODE(file);
UTF16_ENCODE(str);
err = !MoveFileW(file_16, str_16);
@ -500,7 +500,7 @@ int BLI_rename(const char *from, const char *to)
/* make sure the filenames are different (case insensitive) before removing */
if (BLI_exists(to) && BLI_strcasecmp(from, to))
if (BLI_delete(to, false, false)) return 1;
return urename(from, to);
}
@ -1033,7 +1033,7 @@ bool BLI_dir_create_recursive(const char *dirname)
#endif
BLI_strncpy(tmp, dirname, size);
/* Avoids one useless recursion in case of '/foo/bar/' path... */
BLI_del_slash(tmp);
@ -1064,7 +1064,7 @@ int BLI_rename(const char *from, const char *to)
if (!BLI_exists(from)) {
return 1;
}
if (BLI_exists(to))
if (BLI_delete(to, false, false)) return 1;

View File

@ -445,7 +445,7 @@ static int check_freetypefont(PackedFile *pf)
}
}
}
return success;
}
@ -470,14 +470,14 @@ VFontData *BLI_vfontdata_from_freetypefont(PackedFile *pf)
}
success = check_freetypefont(pf);
if (success) {
vfd = objfnt_to_ftvfontdata(pf);
}
/* free Freetype */
FT_Done_FreeType(library);
return vfd;
}

View File

@ -47,7 +47,7 @@ void BLI_freeNode(BGraph *graph, BNode *node)
if (node->arcs) {
MEM_freeN(node->arcs);
}
if (graph->free_node) {
graph->free_node(node);
}
@ -76,7 +76,7 @@ void BLI_removeArc(BGraph *graph, BArc *arc)
void BLI_flagNodes(BGraph *graph, int flag)
{
BNode *node;
for (node = graph->nodes.first; node; node = node->next) {
node->flag = flag;
}
@ -85,7 +85,7 @@ void BLI_flagNodes(BGraph *graph, int flag)
void BLI_flagArcs(BGraph *graph, int flag)
{
BArc *arc;
for (arc = graph->arcs.first; arc; arc = arc->next) {
arc->flag = flag;
}
@ -106,9 +106,9 @@ void BLI_buildAdjacencyList(BGraph *graph)
if (node->arcs != NULL) {
MEM_freeN(node->arcs);
}
node->arcs = MEM_callocN((node->degree) * sizeof(BArc *), "adjacency list");
/* temporary use to indicate the first index available in the lists */
node->flag = 0;
}
@ -132,9 +132,9 @@ void BLI_rebuildAdjacencyListForNode(BGraph *graph, BNode *node)
if (node->arcs != NULL) {
MEM_freeN(node->arcs);
}
node->arcs = MEM_callocN((node->degree) * sizeof(BArc *), "adjacency list");
/* temporary use to indicate the first index available in the lists */
node->flag = 0;
@ -167,13 +167,13 @@ void BLI_freeAdjacencyList(BGraph *graph)
bool BLI_hasAdjacencyList(BGraph *graph)
{
BNode *node;
for (node = graph->nodes.first; node; node = node->next) {
if (node->arcs == NULL) {
return false;
}
}
return true;
}
@ -188,10 +188,10 @@ void BLI_replaceNodeInArc(BGraph *graph, BArc *arc, BNode *node_src, BNode *node
arc->tail = node_src;
node_src->degree++;
}
if (arc->head == arc->tail) {
node_src->degree -= 2;
graph->free_arc(arc);
BLI_freelinkN(&graph->arcs, arc);
}
@ -204,10 +204,10 @@ void BLI_replaceNodeInArc(BGraph *graph, BArc *arc, BNode *node_src, BNode *node
void BLI_replaceNode(BGraph *graph, BNode *node_src, BNode *node_replaced)
{
BArc *arc, *next_arc;
for (arc = graph->arcs.first; arc; arc = next_arc) {
next_arc = arc->next;
if (arc->head == node_replaced) {
arc->head = node_src;
node_replaced->degree--;
@ -219,15 +219,15 @@ void BLI_replaceNode(BGraph *graph, BNode *node_src, BNode *node_replaced)
node_replaced->degree--;
node_src->degree++;
}
if (arc->head == arc->tail) {
node_src->degree -= 2;
graph->free_arc(arc);
BLI_freelinkN(&graph->arcs, arc);
}
}
if (node_replaced->degree == 0) {
BLI_removeNode(graph, node_replaced);
}
@ -237,7 +237,7 @@ void BLI_removeDoubleNodes(BGraph *graph, float limit)
{
const float limit_sq = limit * limit;
BNode *node_src, *node_replaced;
for (node_src = graph->nodes.first; node_src; node_src = node_src->next) {
for (node_replaced = graph->nodes.first; node_replaced; node_replaced = node_replaced->next) {
if (node_replaced != node_src && len_squared_v3v3(node_replaced->p, node_src->p) <= limit_sq) {
@ -245,7 +245,7 @@ void BLI_removeDoubleNodes(BGraph *graph, float limit)
}
}
}
}
BNode *BLI_FindNodeByPosition(BGraph *graph, const float p[3], const float limit)
@ -253,7 +253,7 @@ BNode *BLI_FindNodeByPosition(BGraph *graph, const float p[3], const float limit
const float limit_sq = limit * limit;
BNode *closest_node = NULL, *node;
float min_distance = 0.0f;
for (node = graph->nodes.first; node; node = node->next) {
float distance = len_squared_v3v3(p, node->p);
if (distance <= limit_sq && (closest_node == NULL || distance < min_distance)) {
@ -261,7 +261,7 @@ BNode *BLI_FindNodeByPosition(BGraph *graph, const float p[3], const float limit
min_distance = distance;
}
}
return closest_node;
}
/************************************* SUBGRAPH DETECTION **********************************************/
@ -271,15 +271,15 @@ static void flagSubgraph(BNode *node, int subgraph)
if (node->subgraph_index == 0) {
BArc *arc;
int i;
node->subgraph_index = subgraph;
for (i = 0; i < node->degree; i++) {
arc = node->arcs[i];
flagSubgraph(BLI_otherNode(arc, node), subgraph);
}
}
}
}
int BLI_FlagSubgraphs(BGraph *graph)
{
@ -289,18 +289,18 @@ int BLI_FlagSubgraphs(BGraph *graph)
if (BLI_hasAdjacencyList(graph) == 0) {
BLI_buildAdjacencyList(graph);
}
for (node = graph->nodes.first; node; node = node->next) {
node->subgraph_index = 0;
}
for (node = graph->nodes.first; node; node = node->next) {
if (node->subgraph_index == 0) {
subgraph++;
flagSubgraph(node, subgraph);
}
}
return subgraph;
}
@ -320,7 +320,7 @@ void BLI_ReflagSubgraph(BGraph *graph, int old_subgraph, int new_subgraph)
static bool detectCycle(BNode *node, BArc *src_arc)
{
bool value = false;
if (node->flag == 0) {
int i;
@ -329,7 +329,7 @@ static bool detectCycle(BNode *node, BArc *src_arc)
for (i = 0; i < node->degree && value == 0; i++) {
BArc *arc = node->arcs[i];
/* don't go back on the source arc */
if (arc != src_arc) {
value = detectCycle(BLI_otherNode(arc, node), arc);
@ -339,7 +339,7 @@ static bool detectCycle(BNode *node, BArc *src_arc)
else {
value = true;
}
return value;
}
@ -347,9 +347,9 @@ bool BLI_isGraphCyclic(BGraph *graph)
{
BNode *node;
bool value = false;
/* NEED TO CHECK IF ADJACENCY LIST EXIST */
/* Mark all nodes as not visited */
BLI_flagNodes(graph, 0);
@ -360,20 +360,20 @@ bool BLI_isGraphCyclic(BGraph *graph)
value = value || detectCycle(node, NULL);
}
}
return value;
}
BArc *BLI_findConnectedArc(BGraph *graph, BArc *arc, BNode *v)
{
BArc *nextArc;
for (nextArc = graph->arcs.first; nextArc; nextArc = nextArc->next) {
if (arc != nextArc && (nextArc->head == v || nextArc->tail == v)) {
break;
}
}
return nextArc;
}
@ -382,9 +382,9 @@ BArc *BLI_findConnectedArc(BGraph *graph, BArc *arc, BNode *v)
static int subtreeShape(BNode *node, BArc *rootArc, int include_root)
{
int depth = 0;
node->flag = 1;
if (include_root) {
BNode *newNode = BLI_otherNode(rootArc, node);
return subtreeShape(newNode, rootArc, 0);
@ -396,18 +396,18 @@ static int subtreeShape(BNode *node, BArc *rootArc, int include_root)
}
else {
int i;
for (i = 0; i < node->degree; i++) {
BArc *arc = node->arcs[i];
BNode *newNode = BLI_otherNode(arc, node);
/* stop immediate and cyclic backtracking */
if (arc != rootArc && newNode->flag == 0) {
depth += subtreeShape(newNode, arc, 0);
}
}
}
return SHAPE_RADIX * depth + 1;
}
}
@ -428,13 +428,13 @@ float BLI_subtreeLength(BNode *node)
for (i = 0; i < node->degree; i++) {
BArc *arc = node->arcs[i];
BNode *other_node = BLI_otherNode(arc, node);
if (other_node->flag != 0) {
float subgraph_length = arc->length + BLI_subtreeLength(other_node);
float subgraph_length = arc->length + BLI_subtreeLength(other_node);
length = MAX2(length, subgraph_length);
}
}
return length;
}
@ -443,12 +443,12 @@ void BLI_calcGraphLength(BGraph *graph)
float length = 0;
int nb_subgraphs;
int i;
nb_subgraphs = BLI_FlagSubgraphs(graph);
for (i = 1; i <= nb_subgraphs; i++) {
BNode *node;
for (node = graph->nodes.first; node; node = node->next) {
/* start on an external node of the subgraph */
if (node->subgraph_index == i && node->degree == 1) {
@ -458,7 +458,7 @@ void BLI_calcGraphLength(BGraph *graph)
}
}
}
graph->length = length;
}
@ -469,7 +469,7 @@ static void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level
void BLI_mirrorAlongAxis(float v[3], float center[3], float axis[3])
{
float dv[3], pv[3];
sub_v3_v3v3(dv, v, center);
project_v3_v3v3(pv, dv, axis);
mul_v3_fl(pv, -2);
@ -481,7 +481,7 @@ static void testRadialSymmetry(BGraph *graph, BNode *root_node, RadialArc *ring,
const float limit_sq = limit * limit;
int symmetric = 1;
int i;
/* sort ring by angle */
for (i = 0; i < total - 1; i++) {
float minAngle = FLT_MAX;
@ -520,13 +520,13 @@ static void testRadialSymmetry(BGraph *graph, BNode *root_node, RadialArc *ring,
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);
copy_v3_v3(p, node2->p);
BLI_mirrorAlongAxis(p, root_node->p, normal);
/* check if it's within limit before continuing */
if (len_squared_v3v3(node1->p, p) > limit_sq) {
symmetric = 0;
@ -539,7 +539,7 @@ static void testRadialSymmetry(BGraph *graph, BNode *root_node, RadialArc *ring,
copy_v3_v3(root_node->symmetry_axis, axis);
root_node->symmetry_flag |= SYM_PHYSICAL;
root_node->symmetry_flag |= SYM_RADIAL;
/* FLAG SYMMETRY GROUP */
for (i = 0; i < total; i++) {
ring[i].arc->symmetry_group = group;
@ -567,7 +567,7 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo
/* total the number of arcs in the symmetry ring */
for (i = 0; i < root_node->degree; i++) {
BArc *connectedArc = root_node->arcs[i];
/* depth is store as a negative in flag. symmetry level is positive */
if (connectedArc->symmetry_level == -depth) {
total++;
@ -580,7 +580,7 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo
/* fill in the ring */
for (i = 0; i < root_node->degree; i++) {
BArc *connectedArc = root_node->arcs[i];
/* depth is store as a negative in flag. symmetry level is positive */
if (connectedArc->symmetry_level == -depth) {
BNode *otherNode = BLI_otherNode(connectedArc, root_node);
@ -608,14 +608,14 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo
for (j = i - 1; j >= 0; j--) {
BArc *arc1, *arc2;
arc1 = ring[j].arc;
arc2 = ring[j + 1].arc;
if (arc1->length > arc2->length) {
/* swap with smaller */
RadialArc tmp;
tmp = ring[j + 1];
ring[j + 1] = ring[j];
ring[j] = tmp;
@ -629,11 +629,11 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo
/* Dispatch to specific symmetry tests */
first = 0;
group = 0;
for (i = 1; i < total; i++) {
int dispatch = 0;
int last = i - 1;
if (fabsf(ring[first].arc->length - ring[i].arc->length) > limit) {
dispatch = 1;
}
@ -645,9 +645,9 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo
last = i;
dispatch = 1;
}
if (dispatch) {
int sub_total = last - first + 1;
int sub_total = last - first + 1;
group += 1;
@ -658,32 +658,32 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo
else if (sub_total == 2) {
BArc *arc1, *arc2;
BNode *node1, *node2;
arc1 = ring[first].arc;
arc2 = ring[last].arc;
node1 = BLI_otherNode(arc1, root_node);
node2 = BLI_otherNode(arc2, root_node);
testAxialSymmetry(graph, root_node, node1, node2, arc1, arc2, axis, limit, group);
}
else if (sub_total != total) /* allocate a new sub ring if needed */ {
RadialArc *sub_ring = MEM_callocN(sizeof(RadialArc) * sub_total, "radial symmetry ring");
int sub_i;
/* fill in the sub ring */
for (sub_i = 0; sub_i < sub_total; sub_i++) {
sub_ring[sub_i] = ring[first + sub_i];
}
testRadialSymmetry(graph, root_node, sub_ring, sub_total, axis, limit, group);
MEM_freeN(sub_ring);
}
else if (sub_total == total) {
testRadialSymmetry(graph, root_node, ring, total, axis, limit, group);
}
first = i;
}
}
@ -695,11 +695,11 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo
static void flagAxialSymmetry(BNode *root_node, BNode *end_node, BArc *arc, int group)
{
float vec[3];
arc->symmetry_group = group;
sub_v3_v3v3(vec, end_node->p, root_node->p);
if (dot_v3v3(vec, root_node->symmetry_axis) < 0) {
arc->symmetry_flag |= SYM_SIDE_NEGATIVE;
}
@ -719,9 +719,9 @@ static void testAxialSymmetry(BGraph *graph, BNode *root_node, BNode *node1, BNo
sub_v3_v3v3(p, root_node->p, node2->p);
cross_v3_v3v3(vec, p, axis);
add_v3_v3(vec, nor);
cross_v3_v3v3(nor, vec, axis);
if (fabsf(nor[0]) > fabsf(nor[1]) && fabsf(nor[0]) > fabsf(nor[2]) && nor[0] < 0) {
negate_v3(nor);
}
@ -731,11 +731,11 @@ static void testAxialSymmetry(BGraph *graph, BNode *root_node, BNode *node1, BNo
else if (fabsf(nor[2]) > fabsf(nor[1]) && fabsf(nor[2]) > fabsf(nor[0]) && nor[2] < 0) {
negate_v3(nor);
}
/* mirror node2 along axis */
copy_v3_v3(p, node2->p);
BLI_mirrorAlongAxis(p, root_node->p, nor);
/* check if it's within limit before continuing */
if (len_squared_v3v3(node1->p, p) <= limit_sq) {
/* mark node as symmetric physically */
@ -746,7 +746,7 @@ static void testAxialSymmetry(BGraph *graph, BNode *root_node, BNode *node1, BNo
/* flag side on arcs */
flagAxialSymmetry(root_node, node1, arc1, group);
flagAxialSymmetry(root_node, node2, arc2, group);
if (graph->axial_symmetry) {
graph->axial_symmetry(root_node, node1, node2, arc1, arc2);
}
@ -761,13 +761,13 @@ static void handleAxialSymmetry(BGraph *graph, BNode *root_node, int depth, floa
BArc *arc1 = NULL, *arc2 = NULL;
BNode *node1 = NULL, *node2 = NULL;
int i;
/* mark topological symmetry */
root_node->symmetry_flag |= SYM_TOPOLOGICAL;
for (i = 0; i < root_node->degree; i++) {
BArc *connectedArc = root_node->arcs[i];
/* depth is store as a negative in flag. symmetry level is positive */
if (connectedArc->symmetry_level == -depth) {
if (arc1 == NULL) {
@ -781,12 +781,12 @@ static void handleAxialSymmetry(BGraph *graph, BNode *root_node, int depth, floa
}
}
}
/* shouldn't happen, but just to be sure */
if (node1 == NULL || node2 == NULL) {
return;
}
testAxialSymmetry(graph, root_node, node1, node2, arc1, arc2, axis, limit, 1);
}
@ -795,13 +795,13 @@ static void markdownSecondarySymmetry(BGraph *graph, BNode *node, int depth, int
float axis[3] = {0, 0, 0};
int count = 0;
int i;
/* count the number of branches in this symmetry group
* and determinate the axis of symmetry
*/
for (i = 0; i < node->degree; i++) {
BArc *connectedArc = node->arcs[i];
/* depth is store as a negative in flag. symmetry level is positive */
if (connectedArc->symmetry_level == -depth) {
count++;
@ -822,11 +822,11 @@ static void markdownSecondarySymmetry(BGraph *graph, BNode *node, int depth, int
else {
handleRadialSymmetry(graph, node, depth, axis, limit);
}
/* markdown secondary symetries */
for (i = 0; i < node->degree; i++) {
BArc *connectedArc = node->arcs[i];
if (connectedArc->symmetry_level == -depth) {
/* markdown symmetry for branches corresponding to the depth */
markdownSymmetryArc(graph, connectedArc, node, level + 1, limit);
@ -841,16 +841,16 @@ static void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level
/* if arc is null, we start straight from a node */
if (arc) {
arc->symmetry_level = level;
node = BLI_otherNode(arc, node);
}
for (i = 0; i < node->degree; i++) {
BArc *connectedArc = node->arcs[i];
if (connectedArc != arc) {
BNode *connectedNode = BLI_otherNode(connectedArc, node);
/* symmetry level is positive value, negative values is subtree depth */
connectedArc->symmetry_level = -BLI_subtreeShape(graph, connectedNode, connectedArc, 0);
}
@ -861,17 +861,17 @@ static void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level
for (i = 0; i < node->degree; i++) {
int issymmetryAxis = 0;
BArc *connectedArc = node->arcs[i];
/* only arcs not already marked as symetric */
if (connectedArc->symmetry_level < 0) {
int j;
/* true by default */
issymmetryAxis = 1;
for (j = 0; j < node->degree; j++) {
BArc *otherArc = node->arcs[j];
/* different arc, same depth */
if (otherArc != connectedArc && otherArc->symmetry_level == connectedArc->symmetry_level) {
/* not on the symmetry axis */
@ -880,7 +880,7 @@ static void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level
}
}
}
/* arc could be on the symmetry axis */
if (issymmetryAxis == 1) {
/* no arc as been marked previously, keep this one */
@ -893,17 +893,17 @@ static void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level
}
}
}
/* go down the arc continuing the symmetry axis */
if (arc) {
markdownSymmetryArc(graph, arc, node, level, limit);
}
/* secondary symmetry */
for (i = 0; i < node->degree; i++) {
BArc *connectedArc = node->arcs[i];
/* only arcs not already marked as symetric and is not the next arc on the symmetry axis */
if (connectedArc->symmetry_level < 0) {
/* subtree depth is store as a negative value in the symmetry */
@ -916,34 +916,34 @@ void BLI_markdownSymmetry(BGraph *graph, BNode *root_node, float limit)
{
BNode *node;
BArc *arc;
if (root_node == NULL) {
return;
}
if (BLI_isGraphCyclic(graph)) {
return;
}
/* mark down all arcs as non-symetric */
BLI_flagArcs(graph, 0);
/* mark down all nodes as not on the symmetry axis */
BLI_flagNodes(graph, 0);
node = root_node;
/* sanity check REMOVE ME */
if (node->degree > 0) {
arc = node->arcs[0];
if (node->degree == 1) {
markdownSymmetryArc(graph, arc, node, 1, limit);
}
else {
markdownSymmetryArc(graph, NULL, node, 1, limit);
}
/* mark down non-symetric arcs */
@ -973,13 +973,13 @@ void *IT_head(void *arg)
void *IT_tail(void *arg)
{
BArcIterator *iter = (BArcIterator *)arg;
return iter->tail(iter);
return iter->tail(iter);
}
void *IT_peek(void *arg, int n)
{
BArcIterator *iter = (BArcIterator *)arg;
if (iter->index + n < 0) {
return iter->head(iter);
}

View File

@ -66,7 +66,7 @@ GSQueue *BLI_gsqueue_new(size_t elem_size)
GSQueue *gq = MEM_mallocN(sizeof(*gq), "gqueue_new");
gq->head = gq->tail = NULL;
gq->elem_size = elem_size;
return gq;
}
@ -82,13 +82,13 @@ bool BLI_gsqueue_is_empty(GSQueue *gq)
* Query number elements in the queue
*/
int BLI_gsqueue_len(GSQueue *gq)
{
{
GSQueueElem *elem;
int size = 0;
for (elem = gq->head; elem; elem = elem->next)
size++;
return size;
}
@ -121,7 +121,7 @@ void BLI_gsqueue_pop(GSQueue *gq, void *r_item)
else {
gq->head = gq->head->next;
}
if (r_item) {
memcpy(r_item, elem->data, gq->elem_size);
}
@ -137,7 +137,7 @@ void BLI_gsqueue_pop(GSQueue *gq, void *r_item)
void BLI_gsqueue_push(GSQueue *gq, const void *item)
{
GSQueueElem *elem;
/* compare: prevent events added double in row */
if (!BLI_gsqueue_is_empty(gq)) {
if (0 == memcmp(item, gq->head->data, gq->elem_size))
@ -146,7 +146,7 @@ void BLI_gsqueue_push(GSQueue *gq, const void *item)
elem = MEM_mallocN(sizeof(*elem) + gq->elem_size, "gqueue_push");
memcpy(elem->data, item, gq->elem_size);
elem->next = NULL;
if (BLI_gsqueue_is_empty(gq)) {
gq->tail = gq->head = elem;
}

View File

@ -177,7 +177,7 @@ void BLI_jitter_init(float (*jitarr)[2], int num)
}
MEM_freeN(jit2);
/* finally, move jittertab to be centered around (0, 0) */
for (i = 0; i < num; i++) {
jitarr[i][0] -= 0.5f;

View File

@ -308,7 +308,7 @@ void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink)
listbase->last = newlink;
return;
}
/* insert at head of list */
if (prevlink == NULL) {
newlink->prev = NULL;
@ -349,7 +349,7 @@ void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink)
listbase->last = newlink;
return;
}
/* insert at end of list */
if (nextlink == NULL) {
newlink->prev = listbase->last;
@ -451,7 +451,7 @@ bool BLI_listbase_link_move(ListBase *listbase, void *vlink, int step)
void BLI_freelist(ListBase *listbase)
{
Link *link, *next;
link = listbase->first;
while (link) {
next = link->next;
@ -468,7 +468,7 @@ void BLI_freelist(ListBase *listbase)
void BLI_freelistN(ListBase *listbase)
{
Link *link, *next;
link = listbase->first;
while (link) {
next = link->next;
@ -556,16 +556,16 @@ int BLI_findindex(const ListBase *listbase, const void *vlink)
int number = 0;
if (vlink == NULL) return -1;
link = listbase->first;
while (link) {
if (link == vlink)
return number;
number++;
link = link->next;
}
return -1;
}
@ -830,13 +830,13 @@ void BLI_listbase_rotate_last(ListBase *lb, void *vlink)
LinkData *BLI_genericNodeN(void *data)
{
LinkData *ld;
if (data == NULL)
return NULL;
/* create new link, and make it hold the given data */
ld = MEM_callocN(sizeof(LinkData), __func__);
ld->data = data;
return ld;
}
}

View File

@ -3665,11 +3665,11 @@ void resolve_quad_uv_v2_deriv(float r_uv[2], float r_deriv[2][2],
if (r_deriv) {
float tmp1[2], tmp2[2], s[2], t[2];
/* clear outputs */
zero_v2(r_deriv[0]);
zero_v2(r_deriv[1]);
sub_v2_v2v2(tmp1, st1, st0);
sub_v2_v2v2(tmp2, st2, st3);
interp_v2_v2v2(s, tmp1, tmp2, r_uv[1]);
@ -4958,7 +4958,7 @@ float cubic_tangent_factor_circle_v3(const float tan_l[3], const float tan_r[3])
/* -7f causes instability/glitches with Bendy Bones + Custom Refs */
const float eps = 1e-5f;
const float tan_dot = dot_v3v3(tan_l, tan_r);
if (tan_dot > 1.0f - eps) {
/* no angle difference (use fallback, length wont make any difference) */

View File

@ -421,9 +421,9 @@ float BLI_turbulence(float noisesize, float x, float y, float z, int nr)
float s, d = 0.5, div = 1.0;
s = BLI_hnoise(noisesize, x, y, z);
while (nr > 0) {
s += d * BLI_hnoise(noisesize * d, x, y, z);
div += d;
d *= 0.5f;
@ -438,13 +438,13 @@ float BLI_turbulence1(float noisesize, float x, float y, float z, int nr)
float s, d = 0.5, div = 1.0;
s = fabsf((-1.0f + 2.0f * BLI_hnoise(noisesize, x, y, z)));
while (nr > 0) {
s += fabsf(d * (-1.0f + 2.0f * BLI_hnoise(noisesize * d, x, y, z)));
div += d;
d *= 0.5f;
nr--;
}
return s / div;
@ -1486,7 +1486,7 @@ float BLI_gNoise(float noisesize, float x, float y, float z, int hard, int noise
y *= noisesize;
z *= noisesize;
}
if (hard) return fabsf(2.0f * noisefunc(x, y, z) - 1.0f);
return noisefunc(x, y, z);
}
@ -1497,7 +1497,7 @@ float BLI_gTurbulence(float noisesize, float x, float y, float z, int oct, int h
float (*noisefunc)(float, float, float);
float sum, t, amp = 1, fscale = 1;
int i;
switch (noisebasis) {
case 1:
noisefunc = orgPerlinNoiseU;
@ -1548,7 +1548,7 @@ float BLI_gTurbulence(float noisesize, float x, float y, float z, int oct, int h
if (hard) t = fabsf(2.0f * t - 1.0f);
sum += t * amp;
}
sum *= ((float)(1 << oct) / (float)((1 << (oct + 1)) - 1));
return sum;
@ -1610,7 +1610,7 @@ float mg_fBm(float x, float y, float z, float H, float lacunarity, float octaves
break;
}
}
for (i = 0; i < (int)octaves; i++) {
value += noisefunc(x, y, z) * pwr;
pwr *= pwHL;
@ -1865,7 +1865,7 @@ float mg_RidgedMultiFractal(float x, float y, float z, float H, float lacunarity
int i;
float pwHL = powf(lacunarity, -H);
float pwr = pwHL; /* starts with i=1 instead of 0 */
float (*noisefunc)(float, float, float);
switch (noisebasis) {
case 1:

View File

@ -188,7 +188,7 @@ void BLI_cleanup_path(const char *relabase, char *path)
path = path + 2; /* leave the initial "//" untouched */
}
}
/* Note
* memmove(start, eind, strlen(eind) + 1);
* is the same as
@ -196,7 +196,7 @@ void BLI_cleanup_path(const char *relabase, char *path)
* except strcpy should not be used because there is overlap,
* so use memmove's slightly more obscure syntax - Campbell
*/
#ifdef WIN32
while ( (start = strstr(path, "\\..\\")) ) {
eind = start + strlen("\\..\\") - 1;
@ -523,12 +523,12 @@ void BLI_path_rel(char *file, const char *relfile)
const char *lslash;
char temp[FILE_MAX];
char res[FILE_MAX];
/* if file is already relative, bail out */
if (BLI_path_is_rel(file)) {
return;
}
/* also bail out if relative path is not set */
if (relfile[0] == '\0') {
return;
@ -580,11 +580,11 @@ void BLI_path_rel(char *file, const char *relfile)
BLI_str_replace_char(temp + BLI_path_unc_prefix_len(temp), '\\', '/');
BLI_str_replace_char(file + BLI_path_unc_prefix_len(file), '\\', '/');
/* remove /./ which confuse the following slash counting... */
BLI_cleanup_path(NULL, file);
BLI_cleanup_path(NULL, temp);
/* the last slash in the file indicates where the path part ends */
lslash = BLI_last_slash(temp);
@ -611,7 +611,7 @@ void BLI_path_rel(char *file, const char *relfile)
}
}
/* we might have passed the slash when the beginning of a dir matches
/* we might have passed the slash when the beginning of a dir matches
* so we rewind. Only check on the actual filename
*/
if (*q != '/') {
@ -620,11 +620,11 @@ void BLI_path_rel(char *file, const char *relfile)
else if (*p != '/') {
while ( (p >= temp) && (*p != '/') ) { --p; --q; }
}
r += BLI_strcpy_rlen(r, "//");
/* p now points to the slash that is at the beginning of the part
* where the path is different from the relative path.
* where the path is different from the relative path.
* We count the number of directories we need to go up in the
* hierarchy to arrive at the common 'prefix' of the path
*/
@ -638,7 +638,7 @@ void BLI_path_rel(char *file, const char *relfile)
/* don't copy the slash at the beginning */
r += BLI_strcpy_rlen(r, q + 1);
#ifdef WIN32
BLI_str_replace_char(res + 2, '/', '\\');
#endif
@ -733,7 +733,7 @@ static bool stringframe_chars(const char *path, int *char_start, int *char_end)
ch_end++;
}
i = ch_end - 1; /* keep searching */
/* don't break, there may be a slash after this that invalidates the previous #'s */
}
}
@ -950,7 +950,7 @@ bool BLI_path_abs(char *path, const char *basepath)
}
/* we are checking here if we have an absolute path that is not in the current
* blend file as a lib main - we are basically checking for the case that a
* blend file as a lib main - we are basically checking for the case that a
* UNIX root '/' is passed.
*/
if (!wasrelative && !BLI_path_is_abs(path)) {
@ -967,20 +967,20 @@ bool BLI_path_abs(char *path, const char *basepath)
}
#else
BLI_strncpy(tmp, path, sizeof(tmp));
/* Check for loading a windows path on a posix system
* in this case, there is no use in trying C:/ since it
* in this case, there is no use in trying C:/ since it
* will never exist on a unix os.
*
*
* Add a / prefix and lowercase the driveletter, remove the :
* C:\foo.JPG -> /c/foo.JPG */
if (isalpha(tmp[0]) && tmp[1] == ':' && (tmp[2] == '\\' || tmp[2] == '/') ) {
tmp[1] = tolower(tmp[0]); /* replace ':' with driveletter */
tmp[0] = '/';
tmp[0] = '/';
/* '\' the slash will be converted later */
}
#endif
/* push slashes into unix mode - strings entering this part are
@ -1009,7 +1009,7 @@ bool BLI_path_abs(char *path, const char *basepath)
const int baselen = (int) (lslash - base) + 1; /* length up to and including last "/" */
/* use path for temp storage here, we copy back over it right away */
BLI_strncpy(path, tmp + 2, FILE_MAX); /* strip "//" */
memcpy(tmp, base, baselen); /* prefix with base up to last "/" */
BLI_strncpy(tmp + baselen, path, sizeof(tmp) - baselen); /* append path after "//" */
BLI_strncpy(path, tmp, FILE_MAX); /* return as result */
@ -1055,7 +1055,7 @@ bool BLI_path_cwd(char *path, const size_t maxlen)
#endif
bool wasrelative = true;
const int filelen = strlen(path);
#ifdef WIN32
if ((filelen >= 3 && BLI_path_is_abs(path)) || BLI_path_is_unc(path))
wasrelative = false;
@ -1063,7 +1063,7 @@ bool BLI_path_cwd(char *path, const size_t maxlen)
if (filelen >= 2 && path[0] == '/')
wasrelative = false;
#endif
if (wasrelative) {
char cwd[FILE_MAX];
/* in case the full path to the blend isn't used */
@ -1076,7 +1076,7 @@ bool BLI_path_cwd(char *path, const size_t maxlen)
printf("Could not get the current working directory - $PWD for an unknown reason.\n");
}
}
return wasrelative;
}
@ -1297,10 +1297,10 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir, c
/* Resolve relative references */
if (relabase && dir[0] == '/' && dir[1] == '/') {
char *lslash;
/* Get the file name, chop everything past the last slash (ie. the filename) */
strcpy(string, relabase);
lslash = (char *)BLI_last_slash(string);
if (lslash) *(lslash + 1) = 0;
@ -1325,7 +1325,7 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir, c
else { /* we're out of luck here, guessing the first valid drive, usually c:\ */
get_default_root(string);
}
/* ignore leading slashes */
while (*dir == '/' || *dir == '\\') dir++;
}
@ -1343,12 +1343,12 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir, c
}
/* since we've now removed all slashes, put back one slash at the end. */
strcat(string, "/");
while (*file && (*file == '/' || *file == '\\')) /* Trim slashes from the front of file */
file++;
strcat(string, file);
/* Push all slashes to the system preferred direction */
BLI_path_native_slash(string);
}
@ -1539,7 +1539,7 @@ void BLI_split_dirfile(const char *string, char *dir, char *file, const size_t d
dir[0] = '\0';
}
}
if (file) {
BLI_strncpy(file, string + lslash, filelen);
}
@ -1792,10 +1792,10 @@ const char *BLI_first_slash(const char *string)
{
const char * const ffslash = strchr(string, '/');
const char * const fbslash = strchr(string, '\\');
if (!ffslash) return fbslash;
else if (!fbslash) return ffslash;
return (ffslash < fbslash) ? ffslash : fbslash;
}
@ -1807,9 +1807,9 @@ const char *BLI_last_slash(const char *string)
const char * const lfslash = strrchr(string, '/');
const char * const lbslash = strrchr(string, '\\');
if (!lfslash) return lbslash;
if (!lfslash) return lbslash;
else if (!lbslash) return lfslash;
return (lfslash > lbslash) ? lfslash : lbslash;
}

View File

@ -312,7 +312,7 @@ void BLI_thread_srandom(int thread, unsigned int seed)
{
if (thread >= BLENDER_MAX_THREADS)
thread = 0;
BLI_rng_seed(&rng_tab[thread], seed + hash[seed & 255]);
seed = BLI_rng_get_uint(&rng_tab[thread]);
BLI_rng_seed(&rng_tab[thread], seed + hash[seed & 255]);
@ -338,11 +338,11 @@ RNG_THREAD_ARRAY *BLI_rng_threaded_new(void)
{
unsigned int i;
RNG_THREAD_ARRAY *rngarr = MEM_mallocN(sizeof(RNG_THREAD_ARRAY), "random_array");
for (i = 0; i < BLENDER_MAX_THREADS; i++) {
BLI_rng_srandom(&rngarr->rng_tab[i], (unsigned int)clock());
}
return rngarr;
}

View File

@ -100,7 +100,7 @@ typedef struct ScanFillVertLink {
static int vergscdata(const void *a1, const void *a2)
{
const ScanFillVertLink *x1 = a1, *x2 = a2;
if (x1->vert->xy[1] < x2->vert->xy[1]) return 1;
else if (x1->vert->xy[1] > x2->vert->xy[1]) return -1;
else if (x1->vert->xy[0] > x2->vert->xy[0]) return 1;
@ -117,7 +117,7 @@ static int vergpoly(const void *a1, const void *a2)
else if (x1->min_xy[0] < x2->min_xy[0]) return -1;
else if (x1->min_xy[1] > x2->min_xy[1]) return 1;
else if (x1->min_xy[1] < x2->min_xy[1]) return -1;
return 0;
}
@ -126,7 +126,7 @@ static int vergpoly(const void *a1, const void *a2)
ScanFillVert *BLI_scanfill_vert_add(ScanFillContext *sf_ctx, const float vec[3])
{
ScanFillVert *sf_v;
sf_v = BLI_memarena_alloc(sf_ctx->arena, sizeof(ScanFillVert));
BLI_addtail(&sf_ctx->fillvertbase, sf_v);
@ -151,7 +151,7 @@ ScanFillEdge *BLI_scanfill_edge_add(ScanFillContext *sf_ctx, ScanFillVert *v1, S
sf_ed = BLI_memarena_alloc(sf_ctx->arena, sizeof(ScanFillEdge));
BLI_addtail(&sf_ctx->filledgebase, sf_ed);
sf_ed->v1 = v1;
sf_ed->v2 = v2;
@ -171,7 +171,7 @@ static void addfillface(ScanFillContext *sf_ctx, ScanFillVert *v1, ScanFillVert
sf_tri = BLI_memarena_alloc(sf_ctx->arena, sizeof(ScanFillFace));
BLI_addtail(&sf_ctx->fillfacebase, sf_tri);
sf_tri->v1 = v1;
sf_tri->v2 = v2;
sf_tri->v3 = v3;
@ -402,7 +402,7 @@ static void testvertexnearedge(ScanFillContext *sf_ctx)
if (dist < SF_EPSILON_SQ) {
/* new edge */
ed1 = BLI_scanfill_edge_add(sf_ctx, eed->v1, eve);
/* printf("fill: vertex near edge %x\n", eve); */
ed1->poly_nr = eed->poly_nr;
eed->v1 = eve;
@ -435,7 +435,7 @@ static void splitlist(ScanFillContext *sf_ctx, ListBase *tempve, ListBase *tempe
}
}
for (eed = temped->first; eed; eed = eed_next) {
eed_next = eed->next;
if (eed->poly_nr == nr) {
@ -592,7 +592,7 @@ static unsigned int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int fl
while (sc->edge_first) { /* for as long there are edges */
ed1 = sc->edge_first;
ed2 = ed1->next;
/* commented out... the ESC here delivers corrupted memory (and doesnt work during grab) */
/* if (callLocalInterruptCallBack()) break; */
if (totface >= maxface) {
@ -614,14 +614,14 @@ static unsigned int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int fl
float angle_best_cos = -1.0f;
float miny;
bool firsttime = false;
v1 = ed1->v2;
v2 = ed1->v1;
v3 = ed2->v2;
/* this happens with a serial of overlapping edges */
if (v1 == v2 || v2 == v3) break;
/* printf("test verts %d %d %d\n", v1->tmp.u, v2->tmp.u, v3->tmp.u); */
miny = min_ff(v1->xy[1], v3->xy[1]);
sc1 = sc + 1;
@ -633,10 +633,10 @@ static unsigned int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int fl
if (testedgeside(v2->xy, v3->xy, sc1->vert->xy)) {
if (testedgeside(v3->xy, v1->xy, sc1->vert->xy)) {
/* point is in triangle */
/* because multiple points can be inside triangle (concave holes) */
/* we continue searching and pick the one with sharpest corner */
if (best_sc == NULL) {
/* even without holes we need to keep checking [#35861] */
best_sc = sc1;
@ -659,7 +659,7 @@ static unsigned int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int fl
}
}
}
if (best_sc) {
/* make new edge, and start over */
/* printf("add new edge %d %d and start again\n", v2->tmp.u, best_sc->vert->tmp.u); */
@ -697,10 +697,10 @@ static unsigned int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int fl
ed3->f = SF_EDGE_INTERNAL;
ed3->v1->edge_tot++;
ed3->v2->edge_tot++;
/* printf("add new edge %x %x\n", v1, v3); */
sc1 = addedgetoscanlist(scdata, ed3, verts);
if (sc1) { /* ed3 already exists: remove if a boundary */
/* printf("Edge exists\n"); */
ed3->v1->edge_tot--;
@ -1033,7 +1033,7 @@ unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const
* - eve->poly_nr :polynumber
* - eve->edge_tot :amount of edges connected to vertex
* - eve->tmp.v :store! original vertex number
*
*
* - eed->f :1 = boundary edge (optionally set by caller)
* - eed->poly_nr :poly number
*/
@ -1069,10 +1069,10 @@ unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const
}
/* STEP 4: FIND HOLES OR BOUNDS, JOIN THEM
* ( bounds just to divide it in pieces for optimization,
* ( bounds just to divide it in pieces for optimization,
* the edgefill itself has good auto-hole detection)
* WATCH IT: ONLY WORKS WITH SORTED POLYS!!! */
if ((flag & BLI_SCANFILL_CALC_HOLES) && (poly > 1)) {
unsigned short *polycache, *pc;
@ -1092,7 +1092,7 @@ unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const
pf = pflist;
for (a = 0; a < poly; a++, pf++) {
for (c = (unsigned short)(a + 1); c < poly; c++) {
/* if 'a' inside 'c': join (bbox too)
* Careful: 'a' can also be inside another poly.
*/
@ -1102,7 +1102,7 @@ unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const
}
/* only for optimize! */
/* else if (pf->max_xy[0] < (pflist+c)->min[cox]) break; */
}
while (pc != polycache) {
pc--;

View File

@ -63,7 +63,7 @@ char *BLI_strdupn(const char *str, const size_t len)
char *n = MEM_mallocN(len + 1, "strdup");
memcpy(n, str, len);
n[len] = '\0';
return n;
}
@ -91,7 +91,7 @@ char *BLI_strdupcat(const char *__restrict str1, const char *__restrict str2)
const size_t str1_len = strlen(str1);
const size_t str2_len = strlen(str2) + 1;
char *str, *s;
str = MEM_mallocN(str1_len + str2_len, "strdupcat");
s = str;
@ -425,55 +425,55 @@ char *BLI_str_replaceN(const char *__restrict str, const char *__restrict substr
BLI_assert(substr_old[0] != '\0');
/* while we can still find a match for the old substring that we're searching for,
/* while we can still find a match for the old substring that we're searching for,
* keep dicing and replacing
*/
while ((match = strstr(str, substr_old))) {
/* the assembly buffer only gets created when we actually need to rebuild the string */
if (ds == NULL)
ds = BLI_dynstr_new();
/* if the match position does not match the current position in the string,
/* if the match position does not match the current position in the string,
* copy the text up to this position and advance the current position in the string
*/
if (str != match) {
/* add the segment of the string from str to match to the buffer, then restore the value at match
*/
BLI_dynstr_nappend(ds, str, (match - str));
/* now our current position should be set on the start of the match */
str = match;
}
/* add the replacement text to the accumulation buffer */
BLI_dynstr_append(ds, substr_new);
/* advance the current position of the string up to the end of the replaced segment */
str += len_old;
}
/* finish off and return a new string that has had all occurrences of */
if (ds) {
char *str_new;
/* add what's left of the string to the assembly buffer
/* add what's left of the string to the assembly buffer
* - we've been adjusting str to point at the end of the replaced segments
*/
BLI_dynstr_append(ds, str);
/* convert to new c-string (MEM_malloc'd), and free the buffer */
str_new = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
return str_new;
}
else {
/* just create a new copy of the entire string - we avoid going through the assembly buffer
/* just create a new copy of the entire string - we avoid going through the assembly buffer
* for what should be a bit more efficiency...
*/
return BLI_strdup(str);
}
}
}
/**
* In-place replace every \a src to \a dst in \a str.
@ -497,7 +497,7 @@ void BLI_str_replace_char(char *str, char src, char dst)
*
* \retval True if the strings are equal, false otherwise.
*/
int BLI_strcaseeq(const char *a, const char *b)
int BLI_strcaseeq(const char *a, const char *b)
{
return (BLI_strcasecmp(a, b) == 0);
}
@ -509,7 +509,7 @@ char *BLI_strcasestr(const char *s, const char *find)
{
register char c, sc;
register size_t len;
if ((c = *find++) != 0) {
c = tolower(c);
len = strlen(find);
@ -654,16 +654,16 @@ int BLI_natstrcmp(const char *s1, const char *s2)
int tiebreaker = 0;
/* if both chars are numeric, to a left_number_strcmp().
* then increase string deltas as long they are
* then increase string deltas as long they are
* numeric, else do a tolower and char compare */
while (1) {
c1 = tolower(s1[d1]);
c2 = tolower(s2[d2]);
if (isdigit(c1) && isdigit(c2)) {
int numcompare = left_number_strcmp(s1 + d1, s2 + d2, &tiebreaker);
if (numcompare != 0)
return numcompare;
@ -673,11 +673,11 @@ int BLI_natstrcmp(const char *s1, const char *s2)
d2++;
while (isdigit(s2[d2]))
d2++;
c1 = tolower(s1[d1]);
c2 = tolower(s2[d2]);
}
/* first check for '.' so "foo.bar" comes before "foo 1.bar" */
if (c1 == '.' && c2 != '.')
return -1;
@ -698,7 +698,7 @@ int BLI_natstrcmp(const char *s1, const char *s2)
if (tiebreaker)
return tiebreaker;
/* we might still have a different string because of lower/upper case, in
* that case fall back to regular string comparison */
return strcmp(s1, s2);
@ -851,7 +851,7 @@ int BLI_str_index_in_array(const char *__restrict str, const char **__restrict s
bool BLI_strn_endswith(const char *__restrict str, const char *__restrict end, size_t slength)
{
size_t elength = strlen(end);
if (elength < slength) {
const char *iter = &str[slength - elength];
while (*iter) {

View File

@ -404,7 +404,7 @@ char *BLI_string_join_arrayN(
for (uint i = 0; i < strings_len; i++) {
total_len += strlen(strings[i]);
}
char *result = MEM_mallocN(sizeof(char) * total_len, __func__);
char *result = MEM_mallocN(sizeof(char) * total_len, __func__);
char *c = result;
for (uint i = 0; i < strings_len; i++) {
c += BLI_strcpy_rlen(c, strings[i]);
@ -426,7 +426,7 @@ char *BLI_string_join_array_by_sep_charN(
total_len = 1;
}
char *result = MEM_mallocN(sizeof(char) * total_len, __func__);
char *result = MEM_mallocN(sizeof(char) * total_len, __func__);
char *c = result;
if (strings_len != 0) {
for (uint i = 0; i < strings_len; i++) {
@ -455,7 +455,7 @@ char *BLI_string_join_array_by_sep_char_with_tableN(
total_len = 1;
}
char *result = MEM_mallocN(sizeof(char) * total_len, __func__);
char *result = MEM_mallocN(sizeof(char) * total_len, __func__);
char *c = result;
if (strings_len != 0) {
for (uint i = 0; i < strings_len; i++) {

View File

@ -69,7 +69,7 @@ static void *thread_tls_data;
/* We're using one global task scheduler for all kind of tasks. */
static TaskScheduler *task_scheduler = NULL;
/* ********** basic thread control API ************
/* ********** basic thread control API ************
*
* Many thread cases have an X amount of jobs, and only an Y amount of
* threads are useful (typically amount of cpus)
@ -189,10 +189,10 @@ void BLI_threadpool_init(ListBase *threadbase, void *(*do_thread)(void *), int t
if (threadbase != NULL && tot > 0) {
BLI_listbase_clear(threadbase);
if (tot > RE_MAX_THREAD) tot = RE_MAX_THREAD;
else if (tot < 1) tot = 1;
for (a = 0; a < tot; a++) {
ThreadSlot *tslot = MEM_callocN(sizeof(ThreadSlot), "threadslot");
BLI_addtail(threadbase, tslot);
@ -219,7 +219,7 @@ int BLI_available_threads(ListBase *threadbase)
{
ThreadSlot *tslot;
int counter = 0;
for (tslot = threadbase->first; tslot; tslot = tslot->next) {
if (tslot->avail)
counter++;
@ -232,7 +232,7 @@ int BLI_threadpool_available_thread_index(ListBase *threadbase)
{
ThreadSlot *tslot;
int counter = 0;
for (tslot = threadbase->first; tslot; tslot = tslot->next, counter++) {
if (tslot->avail)
return counter;
@ -261,7 +261,7 @@ int BLI_thread_is_main(void)
void BLI_threadpool_insert(ListBase *threadbase, void *callerdata)
{
ThreadSlot *tslot;
for (tslot = threadbase->first; tslot; tslot = tslot->next) {
if (tslot->avail) {
tslot->avail = 0;
@ -276,7 +276,7 @@ void BLI_threadpool_insert(ListBase *threadbase, void *callerdata)
void BLI_threadpool_remove(ListBase *threadbase, void *callerdata)
{
ThreadSlot *tslot;
for (tslot = threadbase->first; tslot; tslot = tslot->next) {
if (tslot->callerdata == callerdata) {
pthread_join(tslot->pthread, NULL);
@ -290,7 +290,7 @@ void BLI_threadpool_remove_index(ListBase *threadbase, int index)
{
ThreadSlot *tslot;
int counter = 0;
for (tslot = threadbase->first; tslot; tslot = tslot->next, counter++) {
if (counter == index && tslot->avail == 0) {
pthread_join(tslot->pthread, NULL);
@ -304,7 +304,7 @@ void BLI_threadpool_remove_index(ListBase *threadbase, int index)
void BLI_threadpool_clear(ListBase *threadbase)
{
ThreadSlot *tslot;
for (tslot = threadbase->first; tslot; tslot = tslot->next) {
if (tslot->avail == 0) {
pthread_join(tslot->pthread, NULL);
@ -317,9 +317,9 @@ void BLI_threadpool_clear(ListBase *threadbase)
void BLI_threadpool_end(ListBase *threadbase)
{
ThreadSlot *tslot;
/* only needed if there's actually some stuff to end
* this way we don't end up decrementing thread_levels on an empty threadbase
* this way we don't end up decrementing thread_levels on an empty threadbase
* */
if (threadbase && (BLI_listbase_is_empty(threadbase) == false)) {
for (tslot = threadbase->first; tslot; tslot = tslot->next) {
@ -355,7 +355,7 @@ int BLI_system_thread_count(void)
SYSTEM_INFO info;
GetSystemInfo(&info);
t = (int) info.dwNumberOfProcessors;
#else
#else
# ifdef __APPLE__
int mib[2];
size_t len;
@ -694,11 +694,11 @@ void *BLI_thread_queue_pop(ThreadQueue *queue)
pthread_mutex_lock(&queue->mutex);
while (BLI_gsqueue_is_empty(queue->queue) && !queue->nowait)
pthread_cond_wait(&queue->push_cond, &queue->mutex);
/* if we have something, pop it */
if (!BLI_gsqueue_is_empty(queue->queue)) {
BLI_gsqueue_pop(queue->queue, &work);
if (BLI_gsqueue_is_empty(queue->queue))
pthread_cond_broadcast(&queue->finish_cond);
}
@ -764,11 +764,11 @@ void *BLI_thread_queue_pop_timeout(ThreadQueue *queue, int ms)
/* if we have something, pop it */
if (!BLI_gsqueue_is_empty(queue->queue)) {
BLI_gsqueue_pop(queue->queue, &work);
if (BLI_gsqueue_is_empty(queue->queue))
pthread_cond_broadcast(&queue->finish_cond);
}
pthread_mutex_unlock(&queue->mutex);
return work;

View File

@ -39,7 +39,7 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
double PIL_check_seconds_timer(void)
double PIL_check_seconds_timer(void)
{
static int hasperfcounter = -1; /* (-1 == unknown) */
static double perffreq;
@ -89,7 +89,7 @@ void PIL_sleep_ms(int ms)
#include <unistd.h>
#include <sys/time.h>
double PIL_check_seconds_timer(void)
double PIL_check_seconds_timer(void)
{
struct timeval tv;
struct timezone tz;
@ -115,7 +115,7 @@ void PIL_sleep_ms(int ms)
sleep(ms / 1000);
ms = (ms % 1000);
}
usleep(ms * 1000);
}

View File

@ -48,11 +48,11 @@ BLI_INLINE float D(float *data, const int res[3], int x, int y, int z)
float BLI_voxel_sample_nearest(float *data, const int res[3], const float co[3])
{
int xi, yi, zi;
xi = (int)(co[0] * (float)res[0]);
yi = (int)(co[1] * (float)res[1]);
zi = (int)(co[2] * (float)res[2]);
return D(data, res, xi, yi, zi);
}
@ -76,13 +76,13 @@ BLI_INLINE int64_t _clamp(int a, int b, int c)
float BLI_voxel_sample_trilinear(float *data, const int res[3], const float co[3])
{
if (data) {
const float xf = co[0] * (float)res[0] - 0.5f;
const float yf = co[1] * (float)res[1] - 0.5f;
const float zf = co[2] * (float)res[2] - 0.5f;
const int x = FLOORI(xf), y = FLOORI(yf), z = FLOORI(zf);
const int64_t xc[2] = {
_clamp(x, 0, res[0] - 1),
_clamp(x + 1, 0, res[0] - 1),
@ -95,20 +95,20 @@ float BLI_voxel_sample_trilinear(float *data, const int res[3], const float co[3
_clamp(z, 0, res[2] - 1) * res[0] * res[1],
_clamp(z + 1, 0, res[2] - 1) * res[0] * res[1],
};
const float dx = xf - (float)x;
const float dy = yf - (float)y;
const float dz = zf - (float)z;
const float u[2] = {1.f - dx, dx};
const float v[2] = {1.f - dy, dy};
const float w[2] = {1.f - dz, dz};
return w[0] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[0]] + u[1] * data[xc[1] + yc[0] + zc[0]] )
+ v[1] * ( u[0] * data[xc[0] + yc[1] + zc[0]] + u[1] * data[xc[1] + yc[1] + zc[0]] ) )
+ w[1] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[1]] + u[1] * data[xc[1] + yc[0] + zc[1]] )
+ v[1] * ( u[0] * data[xc[0] + yc[1] + zc[1]] + u[1] * data[xc[1] + yc[1] + zc[1]] ) );
}
return 0.f;
}

View File

@ -61,9 +61,9 @@ int BLI_getInstallationDir(char *str)
BLI_split_dir_part(str, dir, sizeof(dir)); /* shouldn't be relative */
a = strlen(dir);
if (dir[a - 1] == '\\') dir[a - 1] = 0;
strcpy(str, dir);
return 1;
}
@ -155,7 +155,7 @@ void RegisterBlendExtension(void)
}
if (lresult != ERROR_SUCCESS)
RegisterBlendExtension_Fail(root);
BLI_getInstallationDir(InstallDir);
GetSystemDirectory(SysDir, FILE_MAXDIR);
#ifdef _WIN64
@ -182,8 +182,8 @@ void RegisterBlendExtension(void)
void get_default_root(char *root)
{
char str[MAX_PATH + 1];
/* the default drive to resolve a directory without a specified drive
/* the default drive to resolve a directory without a specified drive
* should be the Windows installation drive, since this was what the OS
* assumes. */
if (GetWindowsDirectory(str, MAX_PATH + 1)) {
@ -193,7 +193,7 @@ void get_default_root(char *root)
root[3] = '\0';
}
else {
/* if GetWindowsDirectory fails, something has probably gone wrong,
/* if GetWindowsDirectory fails, something has probably gone wrong,
* we are trying the blender install dir though */
if (GetModuleFileName(NULL, str, MAX_PATH + 1)) {
printf("Error! Could not get the Windows Directory - "

View File

@ -119,16 +119,16 @@ struct dirent *readdir(DIR *dp)
MEM_freeN(dp->direntry.d_name);
dp->direntry.d_name = NULL;
}
if (dp->handle == INVALID_HANDLE_VALUE) {
wchar_t *path_16 = alloc_utf16_from_8(dp->path, 0);
dp->handle = FindFirstFileW(path_16, &(dp->data));
free(path_16);
if (dp->handle == INVALID_HANDLE_VALUE)
return NULL;
dp->direntry.d_name = BLI_alloc_utf_8_from_16(dp->data.cFileName, 0);
return &dp->direntry;
}
else if (FindNextFileW(dp->handle, &(dp->data))) {
@ -147,7 +147,7 @@ int closedir(DIR *dp)
if (dp->handle != INVALID_HANDLE_VALUE) FindClose(dp->handle);
MEM_freeN(dp);
return 0;
}