diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-08 02:51:57 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-08 02:51:57 +0400 |
commit | cfb7aee017d95137e19b7b006d9393b5d6a935d4 (patch) | |
tree | 005a1981af6c5a0f36959d73479cc69137842eb4 /source/blender/blenlib/intern | |
parent | d58ce290e1e4dcb8d0b96259fdf29c854bfaef49 (diff) |
style cleanup
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/BLI_ghash.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_kdopbvh.c | 243 | ||||
-rw-r--r-- | source/blender/blenlib/intern/DLRB_tree.c | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/fileops.c | 16 | ||||
-rw-r--r-- | source/blender/blenlib/intern/freetypefont.c | 124 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 92 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_rotation.c | 12 | ||||
-rw-r--r-- | source/blender/blenlib/intern/noise.c | 30 | ||||
-rw-r--r-- | source/blender/blenlib/intern/string.c | 9 | ||||
-rw-r--r-- | source/blender/blenlib/intern/voxel.c | 9 | ||||
-rw-r--r-- | source/blender/blenlib/intern/winstuff.c | 4 |
11 files changed, 275 insertions, 270 deletions
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 4bcedb06fb0..844407f9e06 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -35,8 +35,6 @@ #include "MEM_guardedalloc.h" -// #include "BLI_blenlib.h" - #include "BLI_utildefines.h" #include "BLI_mempool.h" #include "BLI_ghash.h" diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index 6a4ee64ebcd..046e5c3587c 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -52,7 +52,7 @@ typedef struct BVHNode { struct BVHNode **children; - struct BVHNode *parent; // some user defined traversed need that + struct BVHNode *parent; /* some user defined traversed need that */ struct BVHNode *skip[2]; float *bv; /* Bounding volume of all nodes, max 13 axis */ int index; /* face, edge, vertex index */ @@ -104,16 +104,15 @@ typedef struct BVHRayCastData { BVHTreeRayHit hit; } BVHRayCastData; -////////////////////////////////////////m -//////////////////////////////////////////////////////////////////////// -// Bounding Volume Hierarchy Definition -// -// Notes: From OBB until 26-DOP --> all bounding volumes possible, just choose type below -// Notes: You have to choose the type at compile time ITM -// Notes: You can choose the tree type --> binary, quad, octree, choose below -//////////////////////////////////////////////////////////////////////// +/* + * Bounding Volume Hierarchy Definition + * + * Notes: From OBB until 26-DOP --> all bounding volumes possible, just choose type below + * Notes: You have to choose the type at compile time ITM + * Notes: You can choose the tree type --> binary, quad, octree, choose below + */ static float KDOP_AXES[13][3] = { {1.0, 0, 0}, {0, 1.0, 0}, {0, 0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, @@ -188,13 +187,15 @@ static int ADJUST_MEMORY(void *local_memblock, void **memblock, int new_size, in } #endif -////////////////////////////////////////////////////////////////////////////////////////////////////// -// Introsort -// with permission deriven from the following Java code: -// http://ralphunden.net/content/tutorials/a-guide-to-introsort/ -// and he derived it from the SUN STL -////////////////////////////////////////////////////////////////////////////////////////////////////// +/* + * Introsort + * with permission deriven from the following Java code: + * http://ralphunden.net/content/tutorials/a-guide-to-introsort/ + * and he derived it from the SUN STL + */ + //static int size_threshold = 16; + /* * Common methods for all algorithms */ @@ -336,9 +337,9 @@ static void sort_along_axis(BVHTree *tree, int start, int end, int axis) } #endif -//after a call to this function you can expect one of: -// every node to left of a[n] are smaller or equal to it -// every node to the right of a[n] are greater or equal to it +/* after a call to this function you can expect one of: + * - every node to left of a[n] are smaller or equal to it + * - every node to the right of a[n] are greater or equal to it */ static int partition_nth_element(BVHNode **a, int _begin, int _end, int n, int axis) { int begin = _begin, end = _end, cut; @@ -354,7 +355,7 @@ static int partition_nth_element(BVHNode **a, int _begin, int _end, int n, int a return n; } -////////////////////////////////////////////////////////////////////////////////////////////////////// +/* --- */ static void build_skip_links(BVHTree *tree, BVHNode *node, BVHNode *left, BVHNode *right) { int i; @@ -381,8 +382,8 @@ static void create_kdop_hull(BVHTree *tree, BVHNode *node, const float *co, int float *bv = node->bv; int i, k; - // don't init boudings for the moving case - if (!moving) { + /* don't init boudings for the moving case */ + if (!moving) { for (i = tree->start_axis; i < tree->stop_axis; i++) { bv[2 * i] = FLT_MAX; bv[2 * i + 1] = -FLT_MAX; @@ -401,7 +402,7 @@ static void create_kdop_hull(BVHTree *tree, BVHNode *node, const float *co, int } } -// depends on the fact that the BVH's for each face is already build +/* depends on the fact that the BVH's for each face is already build */ static void refit_kdop_hull(BVHTree *tree, BVHNode *node, int start, int end) { float newmin, newmax; @@ -429,31 +430,31 @@ static void refit_kdop_hull(BVHTree *tree, BVHNode *node, int start, int end) } -// only supports x,y,z axis in the moment -// but we should use a plain and simple function here for speed sake +/* only supports x,y,z axis in the moment + * but we should use a plain and simple function here for speed sake */ static char get_largest_axis(float *bv) { float middle_point[3]; - middle_point[0] = (bv[1]) - (bv[0]); // x axis - middle_point[1] = (bv[3]) - (bv[2]); // y axis - middle_point[2] = (bv[5]) - (bv[4]); // z axis + middle_point[0] = (bv[1]) - (bv[0]); /* x axis */ + middle_point[1] = (bv[3]) - (bv[2]); /* y axis */ + middle_point[2] = (bv[5]) - (bv[4]); /* z axis */ if (middle_point[0] > middle_point[1]) { if (middle_point[0] > middle_point[2]) - return 1; // max x axis + return 1; /* max x axis */ else - return 5; // max z axis + return 5; /* max z axis */ } else { if (middle_point[1] > middle_point[2]) - return 3; // max y axis + return 3; /* max y axis */ else - return 5; // max z axis + return 5; /* max z axis */ } } -// bottom-up update of bvh node BV -// join the children on the parent BV +/* bottom-up update of bvh node BV + * join the children on the parent BV */ static void node_join(BVHTree *tree, BVHNode *node) { int i, j; @@ -466,11 +467,11 @@ static void node_join(BVHTree *tree, BVHNode *node) for (i = 0; i < tree->tree_type; i++) { if (node->children[i]) { for (j = tree->start_axis; j < tree->stop_axis; j++) { - // update minimum - if (node->children[i]->bv[(2 * j)] < node->bv[(2 * j)]) + /* update minimum */ + if (node->children[i]->bv[(2 * j)] < node->bv[(2 * j)]) node->bv[(2 * j)] = node->children[i]->bv[(2 * j)]; - - // update maximum + + /* update maximum */ if (node->children[i]->bv[(2 * j) + 1] > node->bv[(2 * j) + 1]) node->bv[(2 * j) + 1] = node->children[i]->bv[(2 * j) + 1]; } @@ -523,7 +524,7 @@ static void verify_tree(BVHTree *tree) { int i, j, check = 0; - // check the pointer list + /* check the pointer list */ for (i = 0; i < tree->totleaf; i++) { if (tree->nodes[i]->parent == NULL) { @@ -543,7 +544,7 @@ static void verify_tree(BVHTree *tree) } } - // check the leaf list + /* check the leaf list */ for (i = 0; i < tree->totleaf; i++) { if (tree->nodearray[i].parent == NULL) { @@ -567,8 +568,8 @@ static void verify_tree(BVHTree *tree) } #endif -//Helper data and structures to build a min-leaf generalized implicit tree -//This code can be easily reduced (basicly this is only method to calculate pow(k, n) in O(1).. and stuff like that) +/* Helper data and structures to build a min-leaf generalized implicit tree + * This code can be easily reduced (basicly this is only method to calculate pow(k, n) in O(1).. and stuff like that) */ typedef struct BVHBuildHelper { int tree_type; /* */ int totleafs; /* */ @@ -589,7 +590,7 @@ static void build_implicit_tree_helper(BVHTree *tree, BVHBuildHelper *data) data->totleafs = tree->totleaf; data->tree_type = tree->tree_type; - //Calculate the smallest tree_type^n such that tree_type^n >= num_leafs + /* Calculate the smallest tree_type^n such that tree_type^n >= num_leafs */ for (data->leafs_per_child[0] = 1; data->leafs_per_child[0] < data->totleafs; data->leafs_per_child[0] *= data->tree_type) @@ -599,7 +600,7 @@ static void build_implicit_tree_helper(BVHTree *tree, BVHBuildHelper *data) data->branches_on_level[0] = 1; - //We could stop the loop first (but I am lazy to find out when) + /* We could stop the loop first (but I am lazy to find out when) */ for (depth = 1; depth < 32; depth++) { data->branches_on_level[depth] = data->branches_on_level[depth - 1] * data->tree_type; data->leafs_per_child[depth] = data->leafs_per_child[depth - 1] / data->tree_type; @@ -700,18 +701,18 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array, int i; const int tree_type = tree->tree_type; - const int tree_offset = 2 - tree->tree_type; //this value is 0 (on binary trees) and negative on the others + const int tree_offset = 2 - tree->tree_type; /* this value is 0 (on binary trees) and negative on the others */ const int num_branches = implicit_needed_branches(tree_type, num_leafs); BVHBuildHelper data; int depth; - // set parent from root node to NULL + /* set parent from root node to NULL */ BVHNode *tmp = branches_array + 0; tmp->parent = NULL; - //Most of bvhtree code relies on 1-leaf trees having at least one branch - //We handle that special case here + /*Most of bvhtree code relies on 1-leaf trees having at least one branch + *We handle that special case here */ if (num_leafs == 1) { BVHNode *root = branches_array + 0; refit_kdop_hull(tree, root, 0, num_leafs); @@ -722,17 +723,17 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array, return; } - branches_array--; //Implicit trees use 1-based indexs - + branches_array--; /* Implicit trees use 1-based indexs */ + build_implicit_tree_helper(tree, &data); - //Loop tree levels (log N) loops + /* Loop tree levels (log N) loops */ for (i = 1, depth = 1; i <= num_branches; i = i * tree_type + tree_offset, depth++) { const int first_of_next_level = i * tree_type + tree_offset; - const int end_j = MIN2(first_of_next_level, num_branches + 1); //index of last branch on this level + const int end_j = MIN2(first_of_next_level, num_branches + 1); /* index of last branch on this level */ int j; - //Loop all branches on this level + /* Loop all branches on this level */ #pragma omp parallel for private(j) schedule(static) for (j = i; j < end_j; j++) { int k; @@ -744,34 +745,34 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array, int parent_leafs_begin = implicit_leafs_index(&data, depth, parent_level_index); int parent_leafs_end = implicit_leafs_index(&data, depth, parent_level_index + 1); - //This calculates the bounding box of this branch - //and chooses the largest axis as the axis to divide leafs + /* This calculates the bounding box of this branch + * and chooses the largest axis as the axis to divide leafs */ refit_kdop_hull(tree, parent, parent_leafs_begin, parent_leafs_end); split_axis = get_largest_axis(parent->bv); - //Save split axis (this can be used on raytracing to speedup the query time) + /* Save split axis (this can be used on raytracing to speedup the query time) */ parent->main_axis = split_axis / 2; - //Split the childs along the split_axis, note: its not needed to sort the whole leafs array - //Only to assure that the elements are partioned on a way that each child takes the elements - //it would take in case the whole array was sorted. - //Split_leafs takes care of that "sort" problem. + /* Split the childs along the split_axis, note: its not needed to sort the whole leafs array + * Only to assure that the elements are partioned on a way that each child takes the elements + * it would take in case the whole array was sorted. + * Split_leafs takes care of that "sort" problem. */ nth_positions[0] = parent_leafs_begin; nth_positions[tree_type] = parent_leafs_end; for (k = 1; k < tree_type; k++) { int child_index = j * tree_type + tree_offset + k; - int child_level_index = child_index - first_of_next_level; //child level index + int child_level_index = child_index - first_of_next_level; /* child level index */ nth_positions[k] = implicit_leafs_index(&data, depth + 1, child_level_index); } split_leafs(leafs_array, nth_positions, tree_type, split_axis); - //Setup children and totnode counters - //Not really needed but currently most of BVH code relies on having an explicit children structure + /* Setup children and totnode counters + * Not really needed but currently most of BVH code relies on having an explicit children structure */ for (k = 0; k < tree_type; k++) { int child_index = j * tree_type + tree_offset + k; - int child_level_index = child_index - first_of_next_level; //child level index + int child_level_index = child_index - first_of_next_level; /* child level index */ int child_leafs_begin = implicit_leafs_index(&data, depth + 1, child_level_index); int child_leafs_end = implicit_leafs_index(&data, depth + 1, child_level_index + 1); @@ -803,20 +804,20 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis) BVHTree *tree; int numnodes, i; - // theres not support for trees below binary-trees :P + /* theres not support for trees below binary-trees :P */ if (tree_type < 2) return NULL; - + if (tree_type > MAX_TREETYPE) return NULL; tree = (BVHTree *)MEM_callocN(sizeof(BVHTree), "BVHTree"); - //tree epsilon must be >= FLT_EPSILON - //so that tangent rays can still hit a bounding volume.. - //this bug would show up when casting a ray aligned with a kdop-axis and with an edge of 2 faces + /* tree epsilon must be >= FLT_EPSILON + * so that tangent rays can still hit a bounding volume.. + * this bug would show up when casting a ray aligned with a kdop-axis and with an edge of 2 faces */ epsilon = MAX2(FLT_EPSILON, epsilon); - + if (tree) { tree->epsilon = epsilon; tree->tree_type = tree_type; @@ -910,59 +911,59 @@ void BLI_bvhtree_balance(BVHTree *tree) BVHNode *branches_array = tree->nodearray + tree->totleaf; BVHNode **leafs_array = tree->nodes; - //This function should only be called once (some big bug goes here if its being called more than once per tree) + /* This function should only be called once (some big bug goes here if its being called more than once per tree) */ assert(tree->totbranch == 0); - //Build the implicit tree + /* Build the implicit tree */ non_recursive_bvh_div_nodes(tree, branches_array, leafs_array, tree->totleaf); - //current code expects the branches to be linked to the nodes array - //we perform that linkage here + /*current code expects the branches to be linked to the nodes array + *we perform that linkage here */ tree->totbranch = implicit_needed_branches(tree->tree_type, tree->totleaf); for (i = 0; i < tree->totbranch; i++) tree->nodes[tree->totleaf + i] = branches_array + i; build_skip_links(tree, tree->nodes[tree->totleaf], NULL, NULL); - //bvhtree_info(tree); + /* bvhtree_info(tree); */ } int BLI_bvhtree_insert(BVHTree *tree, int index, const float *co, int numpoints) { int i; BVHNode *node = NULL; - - // insert should only possible as long as tree->totbranch is 0 + + /* insert should only possible as long as tree->totbranch is 0 */ if (tree->totbranch > 0) return 0; - + if (tree->totleaf + 1 >= MEM_allocN_len(tree->nodes) / sizeof(*(tree->nodes))) return 0; - - // TODO check if have enough nodes in array - + + /* TODO check if have enough nodes in array */ + node = tree->nodes[tree->totleaf] = &(tree->nodearray[tree->totleaf]); tree->totleaf++; - + create_kdop_hull(tree, node, co, numpoints, 0); node->index = index; - - // inflate the bv with some epsilon + + /* inflate the bv with some epsilon */ for (i = tree->start_axis; i < tree->stop_axis; i++) { - node->bv[(2 * i)] -= tree->epsilon; // minimum - node->bv[(2 * i) + 1] += tree->epsilon; // maximum + node->bv[(2 * i)] -= tree->epsilon; /* minimum */ + node->bv[(2 * i) + 1] += tree->epsilon; /* maximum */ } return 1; } -// call before BLI_bvhtree_update_tree() +/* call before BLI_bvhtree_update_tree() */ int BLI_bvhtree_update_node(BVHTree *tree, int index, const float *co, const float *co_moving, int numpoints) { int i; BVHNode *node = NULL; - // check if index exists + /* check if index exists */ if (index > tree->totleaf) return 0; @@ -982,12 +983,12 @@ int BLI_bvhtree_update_node(BVHTree *tree, int index, const float *co, const flo return 1; } -// call BLI_bvhtree_update_node() first for every node/point/triangle +/* call BLI_bvhtree_update_node() first for every node/point/triangle */ void BLI_bvhtree_update_tree(BVHTree *tree) { - //Update bottom=>top - //TRICKY: the way we build the tree all the childs have an index greater than the parent - //This allows us todo a bottom up update by starting on the biger numbered branch + /* Update bottom=>top + * TRICKY: the way we build the tree all the childs have an index greater than the parent + * This allows us todo a bottom up update by starting on the biger numbered branch */ BVHNode **root = tree->nodes + tree->totleaf; BVHNode **index = tree->nodes + tree->totleaf + tree->totbranch - 1; @@ -1004,8 +1005,8 @@ float BLI_bvhtree_getepsilon(BVHTree *tree) /* * BLI_bvhtree_overlap - */ -// overlap - is it possbile for 2 bv's to collide ? + * + * overlap - is it possbile for 2 bv's to collide ? */ static int tree_overlap(BVHNode *node1, BVHNode *node2, int start_axis, int stop_axis) { float *bv1 = node1->bv; @@ -1016,31 +1017,31 @@ static int tree_overlap(BVHNode *node1, BVHNode *node2, int start_axis, int stop bv1 += start_axis << 1; bv2 += start_axis << 1; - // test all axis if min + max overlap + /* test all axis if min + max overlap */ for (; bv1 != bv1_end; bv1 += 2, bv2 += 2) { - if ((*(bv1) > *(bv2 + 1)) || (*(bv2) > *(bv1 + 1))) + if ((*(bv1) > *(bv2 + 1)) || (*(bv2) > *(bv1 + 1))) return 0; } - + return 1; } static void traverse(BVHOverlapData *data, BVHNode *node1, BVHNode *node2) { int j; - + if (tree_overlap(node1, node2, data->start_axis, data->stop_axis)) { - // check if node1 is a leaf + /* check if node1 is a leaf */ if (!node1->totnode) { - // check if node2 is a leaf + /* check if node2 is a leaf */ if (!node2->totnode) { - + if (node1 == node2) { return; } - + if (data->i >= data->max_overlap) { - // try to make alloc'ed memory bigger + /* try to make alloc'ed memory bigger */ data->overlap = realloc(data->overlap, sizeof(BVHTreeOverlap) * data->max_overlap * 2); if (!data->overlap) { @@ -1222,14 +1223,14 @@ PUSH_HEAP_BODY(NodeDistance, NodeDistance_priority, heap, heap_size) static void NodeDistance_pop_heap(NodeDistance *heap, int heap_size) POP_HEAP_BODY(NodeDistance, NodeDistance_priority, heap, heap_size) -//NN function that uses an heap.. this functions leads to an optimal number of min-distance -//but for normal tri-faces and BV 6-dop.. a simple dfs with local heuristics (as implemented -//in source/blender/blenkernel/intern/shrinkwrap.c) works faster. -// -//It may make sense to use this function if the callback queries are very slow.. or if its impossible -//to get a nice heuristic -// -//this function uses "malloc/free" instead of the MEM_* because it intends to be openmp safe +/* NN function that uses an heap.. this functions leads to an optimal number of min-distance + * but for normal tri-faces and BV 6-dop.. a simple dfs with local heuristics (as implemented + * in source/blender/blenkernel/intern/shrinkwrap.c) works faster. + * + * It may make sense to use this function if the callback queries are very slow.. or if its impossible + * to get a nice heuristic + * + * this function uses "malloc/free" instead of the MEM_* because it intends to be openmp safe */ static void bfs_find_nearest(BVHNearestData *data, BVHNode *node) { int i; @@ -1327,11 +1328,11 @@ int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *n data.nearest.dist = FLT_MAX; } - //dfs search + /* dfs search */ if (root) dfs_find_nearest_begin(&data, root); - //copy back results + /* copy back results */ if (nearest) { memcpy(nearest, &data.nearest, sizeof(*nearest)); } @@ -1347,7 +1348,7 @@ int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *n */ -//Determines the distance that the ray must travel to hit the bounding volume of the given node +/* Determines the distance that the ray must travel to hit the bounding volume of the given node */ static float ray_nearest_hit(BVHRayCastData *data, float *bv) { int i; @@ -1382,11 +1383,11 @@ static float ray_nearest_hit(BVHRayCastData *data, float *bv) return low; } -//Determines the distance that the ray must travel to hit the bounding volume of the given node -//Based on Tactical Optimization of Ray/Box Intersection, by Graham Fyffe -//[http://tog.acm.org/resources/RTNews/html/rtnv21n1.html#art9] -// -//TODO this doens't has data->ray.radius in consideration +/* Determines the distance that the ray must travel to hit the bounding volume of the given node + * Based on Tactical Optimization of Ray/Box Intersection, by Graham Fyffe + * [http://tog.acm.org/resources/RTNews/html/rtnv21n1.html#art9] + * + * TODO this doens't has data->ray.radius in consideration */ static float fast_ray_nearest_hit(const BVHRayCastData *data, const BVHNode *node) { const float *bv = node->bv; @@ -1413,8 +1414,8 @@ static void dfs_raycast(BVHRayCastData *data, BVHNode *node) { int i; - //ray-bv is really fast.. and simple tests revealed its worth to test it - //before calling the ray-primitive functions + /* ray-bv is really fast.. and simple tests revealed its worth to test it + * before calling the ray-primitive functions */ /* XXX: temporary solution for particles until fast_ray_nearest_hit supports ray.radius */ float dist = (data->ray.radius > 0.0f) ? ray_nearest_hit(data, node->bv) : fast_ray_nearest_hit(data, node); if (dist >= data->hit.dist) return; @@ -1430,7 +1431,7 @@ static void dfs_raycast(BVHRayCastData *data, BVHNode *node) } } else { - //pick loop direction to dive into the tree (based on ray direction and split axis) + /* pick loop direction to dive into the tree (based on ray direction and split axis) */ if (data->ray_dot_axis[(int)node->main_axis] > 0.0f) { for (i = 0; i != node->totnode; i++) { dfs_raycast(data, node->children[i]); diff --git a/source/blender/blenlib/intern/DLRB_tree.c b/source/blender/blenlib/intern/DLRB_tree.c index 62d3b4e448c..c8c2ad35380 100644 --- a/source/blender/blenlib/intern/DLRB_tree.c +++ b/source/blender/blenlib/intern/DLRB_tree.c @@ -230,7 +230,7 @@ DLRBT_Node *BLI_dlrbTree_search_prev(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_c return node; /* return the previous node otherwise */ - // NOTE: what happens if there is no previous node? + /* NOTE: what happens if there is no previous node? */ return node->prev; } @@ -257,7 +257,7 @@ DLRBT_Node *BLI_dlrbTree_search_next(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_c return node; /* return the previous node otherwise */ - // NOTE: what happens if there is no previous node? + /* NOTE: what happens if there is no previous node? */ return node->next; } diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 5f564f71646..7aa956a0548 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -274,12 +274,12 @@ int BLI_move(const char *file, const char *to) { int err; - // windows doesn't support moveing to a directory - // it has to be 'mv filename filename' and not - // 'mv filename destdir' + /* windows doesn't support moveing to a directory + * it has to be 'mv filename filename' and not + * 'mv filename destdir' */ BLI_strncpy(str, to, sizeof(str)); - // points 'to' to a directory ? + /* points 'to' to a directory ? */ if (BLI_last_slash(str) == (str + strlen(str) - 1)) { if (BLI_last_slash(file) != NULL) { strcat(str, BLI_last_slash(file) + 1); @@ -305,12 +305,12 @@ int BLI_copy(const char *file, const char *to) { int err; - // windows doesn't support copying to a directory - // it has to be 'cp filename filename' and not - // 'cp filename destdir' + /* windows doesn't support copying to a directory + * it has to be 'cp filename filename' and not + * 'cp filename destdir' */ BLI_strncpy(str, to, sizeof(str)); - // points 'to' to a directory ? + /* points 'to' to a directory ? */ if (BLI_last_slash(str) == (str + strlen(str) - 1)) { if (BLI_last_slash(file) != NULL) { strcat(str, BLI_last_slash(file) + 1); diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index 10eeda96b5d..a499f9a81ea 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -71,55 +71,55 @@ static FT_Error err; static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vfd) { - // Blender + /* Blender */ struct Nurb *nu; struct VChar *che; struct BezTriple *bezt; - - // Freetype2 + + /* Freetype2 */ FT_GlyphSlot glyph; FT_UInt glyph_index; FT_Outline ftoutline; float scale, height; float dx, dy; int j, k, l, m = 0; - - // adjust font size + + /* adjust font size */ height = ((double) face->bbox.yMax - (double) face->bbox.yMin); if (height != 0.0f) scale = 1.0f / height; else scale = 1.0f / 1000.0f; - - // - // Generate the character 3D data - // - // Get the FT Glyph index and load the Glyph + + /* + * Generate the character 3D data + * + * Get the FT Glyph index and load the Glyph */ glyph_index = FT_Get_Char_Index(face, charcode); err = FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP); - - // If loading succeeded, convert the FT glyph to the internal format + + /* If loading succeeded, convert the FT glyph to the internal format */ if (!err) { int *npoints; int *onpoints; - - // First we create entry for the new character to the character list + + /* First we create entry for the new character to the character list */ che = (VChar *) MEM_callocN(sizeof(struct VChar), "objfnt_char"); BLI_addtail(&vfd->characters, che); - - // Take some data for modifying purposes + + /* Take some data for modifying purposes */ glyph = face->glyph; ftoutline = glyph->outline; - - // Set the width and character code + + /* Set the width and character code */ che->index = charcode; che->width = glyph->advance.x * scale; - - // Start converting the FT data + + /* Start converting the FT data */ npoints = (int *)MEM_callocN((ftoutline.n_contours) * sizeof(int), "endpoints"); onpoints = (int *)MEM_callocN((ftoutline.n_contours) * sizeof(int), "onpoints"); - // calculate total points of each contour + /* calculate total points of each contour */ for (j = 0; j < ftoutline.n_contours; j++) { if (j == 0) npoints[j] = ftoutline.contours[j] + 1; @@ -127,7 +127,7 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf npoints[j] = ftoutline.contours[j] - ftoutline.contours[j - 1]; } - // get number of on-curve points for beziertriples (including conic virtual on-points) + /* get number of on-curve points for beziertriples (including conic virtual on-points) */ for (j = 0; j < ftoutline.n_contours; j++) { for (k = 0; k < npoints[j]; k++) { l = (j > 0) ? (k + ftoutline.contours[j - 1] + 1) : k; @@ -145,9 +145,9 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf } } - //contour loop, bezier & conic styles merged + /* contour loop, bezier & conic styles merged */ for (j = 0; j < ftoutline.n_contours; j++) { - // add new curve + /* add new curve */ nu = (Nurb *)MEM_callocN(sizeof(struct Nurb), "objfnt_nurb"); bezt = (BezTriple *)MEM_callocN((onpoints[j]) * sizeof(BezTriple), "objfnt_bezt"); BLI_addtail(&che->nurbsbase, nu); @@ -159,26 +159,26 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf nu->flagu = CU_NURB_CYCLIC; nu->bezt = bezt; - //individual curve loop, start-end + /* individual curve loop, start-end */ for (k = 0; k < npoints[j]; k++) { if (j > 0) l = k + ftoutline.contours[j - 1] + 1; else l = k; if (k == 0) m = l; - - //virtual conic on-curve points + + /* virtual conic on-curve points */ if (k < npoints[j] - 1) { if (ftoutline.tags[l] == FT_Curve_Tag_Conic && ftoutline.tags[l + 1] == FT_Curve_Tag_Conic) { dx = (ftoutline.points[l].x + ftoutline.points[l + 1].x) * scale / 2.0f; dy = (ftoutline.points[l].y + ftoutline.points[l + 1].y) * scale / 2.0f; - //left handle + /* left handle */ bezt->vec[0][0] = (dx + (2 * ftoutline.points[l].x) * scale) / 3.0f; bezt->vec[0][1] = (dy + (2 * ftoutline.points[l].y) * scale) / 3.0f; - //midpoint (virtual on-curve point) + /* midpoint (virtual on-curve point) */ bezt->vec[1][0] = dx; bezt->vec[1][1] = dy; - //right handle + /* right handle */ bezt->vec[2][0] = (dx + (2 * ftoutline.points[l + 1].x) * scale) / 3.0f; bezt->vec[2][1] = (dy + (2 * ftoutline.points[l + 1].y) * scale) / 3.0f; @@ -188,9 +188,9 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf } } - //on-curve points + /* on-curve points */ if (ftoutline.tags[l] == FT_Curve_Tag_On) { - //left handle + /* left handle */ if (k > 0) { if (ftoutline.tags[l - 1] == FT_Curve_Tag_Cubic) { bezt->vec[0][0] = ftoutline.points[l - 1].x * scale; @@ -208,7 +208,7 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf bezt->h1 = HD_VECT; } } - else { //first point on curve + else { /* first point on curve */ if (ftoutline.tags[ftoutline.contours[j]] == FT_Curve_Tag_Cubic) { bezt->vec[0][0] = ftoutline.points[ftoutline.contours[j]].x * scale; bezt->vec[0][1] = ftoutline.points[ftoutline.contours[j]].y * scale; @@ -226,11 +226,11 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf } } - //midpoint (on-curve point) + /* midpoint (on-curve point) */ bezt->vec[1][0] = ftoutline.points[l].x * scale; bezt->vec[1][1] = ftoutline.points[l].y * scale; - //right handle + /* right handle */ if (k < (npoints[j] - 1)) { if (ftoutline.tags[l + 1] == FT_Curve_Tag_Cubic) { bezt->vec[2][0] = ftoutline.points[l + 1].x * scale; @@ -248,7 +248,7 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf bezt->h2 = HD_VECT; } } - else { //last point on curve + else { /* last point on curve */ if (ftoutline.tags[m] == FT_Curve_Tag_Cubic) { bezt->vec[2][0] = ftoutline.points[m].x * scale; bezt->vec[2][1] = ftoutline.points[m].y * scale; @@ -294,17 +294,17 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf static int objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode) { - // Freetype2 + /* Freetype2 */ FT_Face face; struct TmpFont *tf; - - // Find the correct FreeType font + + /* Find the correct FreeType font */ tf = BKE_vfont_find_tmpfont(vfont); - - // What, no font found. Something strange here + + /* What, no font found. Something strange here */ if (!tf) return FALSE; - - // Load the font to memory + + /* Load the font to memory */ if (tf->pf) { err = FT_New_Memory_Face(library, tf->pf->data, @@ -318,17 +318,17 @@ static int objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode) return FALSE; } - // Read the char + /* Read the char */ freetypechar_to_vchar(face, charcode, vfont->data); - // And everything went ok + /* And everything went ok */ return TRUE; } static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) { - // Variables + /* Variables */ FT_Face face; FT_ULong charcode = 0, lcode; FT_UInt glyph_index; @@ -343,7 +343,7 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) int n; #endif - // load the freetype font + /* load the freetype font */ err = FT_New_Memory_Face(library, pf->data, pf->size, @@ -366,22 +366,22 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) if (!found) { return NULL; } - // now, select the charmap for the face object + /* now, select the charmap for the face object */ err = FT_Set_Charmap(face, found); if (err) { return NULL; } #endif - // allocate blender font + /* allocate blender font */ vfd = MEM_callocN(sizeof(*vfd), "FTVFontData"); - // get the name + /* get the name */ fontname = FT_Get_Postscript_Name(face); BLI_strncpy(vfd->name, (fontname == NULL) ? "" : fontname, sizeof(vfd->name)); - // Extract the first 256 character from TTF + /* Extract the first 256 character from TTF */ lcode = charcode = FT_Get_First_Char(face, &glyph_index); - // No charmap found from the ttf so we need to figure it out + /* No charmap found from the ttf so we need to figure it out */ if (glyph_index == 0) { FT_CharMap found = NULL; FT_CharMap charmap; @@ -403,15 +403,15 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) lcode = charcode = FT_Get_First_Char(face, &glyph_index); } - // Load characters + /* Load characters */ while (charcode < 256) { - // Generate the font data + /* Generate the font data */ freetypechar_to_vchar(face, charcode, vfd); - // Next glyph + /* Next glyph */ charcode = FT_Get_Next_Char(face, charcode, &glyph_index); - // Check that we won't start infinite loop + /* Check that we won't start infinite loop */ if (charcode <= lcode) break; lcode = charcode; @@ -457,7 +457,7 @@ static int check_freetypefont(PackedFile *pf) if (!found) { return 0; } - // now, select the charmap for the face object + /* now, select the charmap for the face object */ err = FT_Set_Charmap(face, found); if (err) { return 0; } #endif @@ -511,21 +511,21 @@ int BLI_vfontchar_from_freetypefont(VFont *vfont, unsigned long character) if (!vfont) return FALSE; - // Init Freetype + /* Init Freetype */ err = FT_Init_FreeType(&library); if (err) { - //XXX error("Failed to load the Freetype font library"); + /* XXX error("Failed to load the Freetype font library"); */ return 0; } - // Load the character + /* Load the character */ success = objchr_to_ftvfontdata(vfont, character); if (success == FALSE) return FALSE; - // Free Freetype + /* Free Freetype */ FT_Done_FreeType(library); - // Ahh everything ok + /* Ahh everything ok */ return TRUE; } diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 402aacf369a..a7ffb95172e 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -554,29 +554,29 @@ static short IsectLLPt2Df(const float x0, const float y0, const float x1, const * compute slopes, note the cludge for infinity, however, this will * be close enough */ - if (fabs(x1 - x0) > 0.000001) + if (fabs(x1 - x0) > 0.000001f) m1 = (y1 - y0) / (x1 - x0); else - return -1; /*m1 = (float)1e+10;*/ // close enough to infinity + return -1; /*m1 = (float)1e+10;*/ /* close enough to infinity */ - if (fabs(x3 - x2) > 0.000001) + if (fabs(x3 - x2) > 0.000001f) m2 = (y3 - y2) / (x3 - x2); else - return -1; /*m2 = (float)1e+10;*/ // close enough to infinity + return -1; /*m2 = (float)1e+10;*/ /* close enough to infinity */ - if (fabs(m1 - m2) < 0.000001) + if (fabs(m1 - m2) < 0.000001f) return -1; /* parallel lines */ - // compute constants + /* compute constants */ c1 = (y0 - m1 * x0); c2 = (y2 - m2 * x2); - // compute the inverse of the determinate + /* compute the inverse of the determinate */ det_inv = 1.0f / (-m1 + m2); - // use Kramers rule to compute xi and yi + /* use Kramers rule to compute xi and yi */ *xi = ((-c2 + c1) * det_inv); *yi = ((m2 * c1 - m1 * c2) * det_inv); @@ -1123,15 +1123,17 @@ int isect_axial_line_tri_v3(const int axis, const float p1[3], const float p2[3] float u, v, f; int a0 = axis, a1 = (axis + 1) % 3, a2 = (axis + 2) % 3; - //return isect_line_tri_v3(p1,p2,v0,v1,v2,lambda); +#if 0 + return isect_line_tri_v3(p1,p2,v0,v1,v2,lambda); - ///* first a simple bounding box test */ - //if (MIN3(v0[a1],v1[a1],v2[a1]) > p1[a1]) return 0; - //if (MIN3(v0[a2],v1[a2],v2[a2]) > p1[a2]) return 0; - //if (MAX3(v0[a1],v1[a1],v2[a1]) < p1[a1]) return 0; - //if (MAX3(v0[a2],v1[a2],v2[a2]) < p1[a2]) return 0; + /* first a simple bounding box test */ + if (MIN3(v0[a1],v1[a1],v2[a1]) > p1[a1]) return 0; + if (MIN3(v0[a2],v1[a2],v2[a2]) > p1[a2]) return 0; + if (MAX3(v0[a1],v1[a1],v2[a1]) < p1[a1]) return 0; + if (MAX3(v0[a2],v1[a2],v2[a2]) < p1[a2]) return 0; - ///* then a full intersection test */ + /* then a full intersection test */ +#endif sub_v3_v3v3(e1, v1, v0); sub_v3_v3v3(e2, v2, v0); @@ -1331,9 +1333,9 @@ int isect_ray_aabb(const IsectRayAABBData *data, const float bb_min[3], if (tzmin > tmin) tmin = tzmin; - // XXX jwilkins: tmax does not need to be updated since we don't use it - // keeping this here for future reference - //if (tzmax < tmax) tmax = tzmax; + /* XXX jwilkins: tmax does not need to be updated since we don't use it + * keeping this here for future reference */ + //if (tzmax < tmax) tmax = tzmax; if (tmin_out) (*tmin_out) = tmin; @@ -2803,21 +2805,21 @@ static int ff_visible_quad(const float p[3], const float n[3], if (sd[0] > 0) { if (sd[1] > 0) { if (sd[2] > 0) { - // +++ + /* +++ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // ++- + /* ++- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); vec_add_dir(q3, v0, v2, (sd[0] / (sd[0] - sd[2]))); } else { - // ++0 + /* ++0 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -2826,21 +2828,21 @@ static int ff_visible_quad(const float p[3], const float n[3], } else if (sd[1] < 0) { if (sd[2] > 0) { - // +-+ + /* +-+ */ copy_v3_v3(q0, v0); vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, v2); } else if (sd[2] < 0) { - // +-- + /* +-- */ copy_v3_v3(q0, v0); vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); vec_add_dir(q2, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q3, q2); } else { - // +-0 + /* +-0 */ copy_v3_v3(q0, v0); vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q2, v2); @@ -2849,21 +2851,21 @@ static int ff_visible_quad(const float p[3], const float n[3], } else { if (sd[2] > 0) { - // +0+ + /* +0+ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // +0- + /* +0- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); vec_add_dir(q2, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q3, q2); } else { - // +00 + /* +00 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -2874,21 +2876,21 @@ static int ff_visible_quad(const float p[3], const float n[3], else if (sd[0] < 0) { if (sd[1] > 0) { if (sd[2] > 0) { - // -++ + /* -++ */ vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); vec_add_dir(q3, v0, v2, (sd[0] / (sd[0] - sd[2]))); } else if (sd[2] < 0) { - // -+- + /* -+- */ vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, q2); } else { - // -+0 + /* -+0 */ vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -2897,35 +2899,35 @@ static int ff_visible_quad(const float p[3], const float n[3], } else if (sd[1] < 0) { if (sd[2] > 0) { - // --+ + /* --+ */ vec_add_dir(q0, v0, v2, (sd[0] / (sd[0] - sd[2]))); vec_add_dir(q1, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // --- + /* --- */ return 0; } else { - // --0 + /* --0 */ return 0; } } else { if (sd[2] > 0) { - // -0+ + /* -0+ */ vec_add_dir(q0, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // -0- + /* -0- */ return 0; } else { - // -00 + /* -00 */ return 0; } } @@ -2933,21 +2935,21 @@ static int ff_visible_quad(const float p[3], const float n[3], else { if (sd[1] > 0) { if (sd[2] > 0) { - // 0++ + /* 0++ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 0+- + /* 0+- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, q2); } else { - // 0+0 + /* 0+0 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -2956,35 +2958,35 @@ static int ff_visible_quad(const float p[3], const float n[3], } else if (sd[1] < 0) { if (sd[2] > 0) { - // 0-+ + /* 0-+ */ copy_v3_v3(q0, v0); vec_add_dir(q1, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 0-- + /* 0-- */ return 0; } else { - // 0-0 + /* 0-0 */ return 0; } } else { if (sd[2] > 0) { - // 00+ + /* 00+ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 00- + /* 00- */ return 0; } else { - // 000 + /* 000 */ return 0; } } diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index f1e08993825..ab5601fc2dc 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -1199,12 +1199,12 @@ typedef struct RotOrderInfo { */ static RotOrderInfo rotOrders[] = { /* i, j, k, n */ - {{0, 1, 2}, 0}, // XYZ - {{0, 2, 1}, 1}, // XZY - {{1, 0, 2}, 1}, // YXZ - {{1, 2, 0}, 0}, // YZX - {{2, 0, 1}, 0}, // ZXY - {{2, 1, 0}, 1} // ZYX + {{0, 1, 2}, 0}, /* XYZ */ + {{0, 2, 1}, 1}, /* XZY */ + {{1, 0, 2}, 1}, /* YXZ */ + {{1, 2, 0}, 0}, /* YZX */ + {{2, 0, 1}, 0}, /* ZXY */ + {{2, 1, 0}, 1} /* ZYX */ }; /* Get relevant pointer to rotation order set from the array diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c index 2ff0b564592..859bb66073c 100644 --- a/source/blender/blenlib/intern/noise.c +++ b/source/blender/blenlib/intern/noise.c @@ -282,8 +282,8 @@ static float npfade(float t) static float grad(int hash, float x, float y, float z) { - int h = hash & 15; // CONVERT LO 4 BITS OF HASH CODE - float u = h < 8 ? x : y, // INTO 12 GRADIENT DIRECTIONS. + int h = hash & 15; /* CONVERT LO 4 BITS OF HASH CODE */ + float u = h < 8 ? x : y, /* INTO 12 GRADIENT DIRECTIONS. */ v = h < 4 ? y : h == 12 || h == 14 ? x : z; return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v); } @@ -293,21 +293,21 @@ static float newPerlin(float x, float y, float z) { int A, AA, AB, B, BA, BB; float u = floor(x), v = floor(y), w = floor(z); - int X = ((int)u) & 255, Y = ((int)v) & 255, Z = ((int)w) & 255; // FIND UNIT CUBE THAT CONTAINS POINT - x -= u; // FIND RELATIVE X,Y,Z - y -= v; // OF POINT IN CUBE. + int X = ((int)u) & 255, Y = ((int)v) & 255, Z = ((int)w) & 255; /* FIND UNIT CUBE THAT CONTAINS POINT */ + x -= u; /* FIND RELATIVE X,Y,Z */ + y -= v; /* OF POINT IN CUBE. */ z -= w; - u = npfade(x); // COMPUTE FADE CURVES - v = npfade(y); // FOR EACH OF X,Y,Z. + u = npfade(x); /* COMPUTE FADE CURVES */ + v = npfade(y); /* FOR EACH OF X,Y,Z. */ w = npfade(z); - A = hash[X ]+Y; AA = hash[A]+Z; AB = hash[A+1]+Z; // HASH COORDINATES OF - B = hash[X+1]+Y; BA = hash[B]+Z; BB = hash[B+1]+Z; // THE 8 CUBE CORNERS, - return lerp(w, lerp(v, lerp(u, grad(hash[AA ], x, y, z ), // AND ADD - grad(hash[BA ], x - 1, y, z )), // BLENDED - lerp(u, grad(hash[AB ], x, y - 1, z ), // RESULTS - grad(hash[BB ], x - 1, y - 1, z ))), // FROM 8 - lerp(v, lerp(u, grad(hash[AA + 1], x, y, z - 1), // CORNERS - grad(hash[BA + 1], x - 1, y, z - 1)), // OF CUBE + A = hash[X ]+Y; AA = hash[A]+Z; AB = hash[A+1]+Z; /* HASH COORDINATES OF */ + B = hash[X+1]+Y; BA = hash[B]+Z; BB = hash[B+1]+Z; /* THE 8 CUBE CORNERS, */ + return lerp(w, lerp(v, lerp(u, grad(hash[AA ], x, y, z ), /* AND ADD */ + grad(hash[BA ], x - 1, y, z )), /* BLENDED */ + lerp(u, grad(hash[AB ], x, y - 1, z ), /* RESULTS */ + grad(hash[BB ], x - 1, y - 1, z ))), /* FROM 8 */ + lerp(v, lerp(u, grad(hash[AA + 1], x, y, z - 1), /* CORNERS */ + grad(hash[BA + 1], x - 1, y, z - 1)), /* OF CUBE */ lerp(u, grad(hash[AB + 1], x, y - 1, z - 1), grad(hash[BB + 1], x - 1, y - 1, z - 1)))); } diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index e73899ce929..d86d151b1ef 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -178,8 +178,8 @@ char *BLI_getQuotedStr(const char *str, const char *prefix) startMatch = strstr(str, prefix) + prefixLen + 1; /* get the end point (i.e. where the next occurance of " is after the starting point) */ - endMatch = strchr(startMatch, '"'); // " NOTE: this comment here is just so that my text editor still shows the functions ok... - + endMatch = strchr(startMatch, '"'); /* " NOTE: this comment here is just so that my text editor still shows the functions ok... */ + /* return the slice indicated */ return BLI_strdupn(startMatch, (size_t)(endMatch - startMatch)); } @@ -187,8 +187,9 @@ char *BLI_getQuotedStr(const char *str, const char *prefix) /* Replaces all occurrences of oldText with newText in str, returning a new string that doesn't * contain the 'replaced' occurrences. */ -// A rather wasteful string-replacement utility, though this shall do for now... -// Feel free to replace this with an even safe + nicer alternative + +/* A rather wasteful string-replacement utility, though this shall do for now... + * Feel free to replace this with an even safe + nicer alternative */ char *BLI_replacestr(char *str, const char *oldText, const char *newText) { DynStr *ds = NULL; diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c index 3a8705bbbba..bc775cb8f0c 100644 --- a/source/blender/blenlib/intern/voxel.c +++ b/source/blender/blenlib/intern/voxel.c @@ -56,15 +56,18 @@ float BLI_voxel_sample_nearest(float *data, const int res[3], const float co[3]) return D(data, res, xi, yi, zi); } -// returns highest integer <= x as integer (slightly faster than floor()) +/* returns highest integer <= x as integer (slightly faster than floor()) */ BLI_INLINE int FLOORI(float x) { const int r = (int)x; return ((x >= 0.f) || (float)r == x) ? r : (r - 1); } -// clamp function, cannot use the CLAMPIS macro, it sometimes returns unwanted results apparently related to gcc optimization flag -fstrict-overflow which is enabled at -O2 -// this causes the test (x + 2) < 0 with int x == 2147483647 to return false (x being an integer, x + 2 should wrap around to -2147483647 so the test < 0 should return true, which it doesn't) +/* clamp function, cannot use the CLAMPIS macro, it sometimes returns unwanted results apparently related to + * gcc optimization flag -fstrict-overflow which is enabled at -O2 + * + * this causes the test (x + 2) < 0 with int x == 2147483647 to return false (x being an integer, + * x + 2 should wrap around to -2147483647 so the test < 0 should return true, which it doesn't) */ BLI_INLINE int _clamp(int a, int b, int c) { return (a < b) ? b : ((a > c) ? c : a); diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index e34150ee4f2..0dc4d3c2db6 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -98,10 +98,10 @@ void RegisterBlendExtension(void) printf("Registering file extension..."); GetModuleFileName(0, BlPath, MAX_PATH); - // root is HKLM by default + /* root is HKLM by default */ lresult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Classes", 0, KEY_ALL_ACCESS, &root); if (lresult != ERROR_SUCCESS) { - // try HKCU on failure + /* try HKCU on failure */ usr_mode = TRUE; lresult = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Classes", 0, KEY_ALL_ACCESS, &root); if (lresult != ERROR_SUCCESS) |