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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r--source/blender/blenlib/intern/math_color.c4
-rw-r--r--source/blender/blenlib/intern/math_geom.c48
-rw-r--r--source/blender/blenlib/intern/pbvh.c138
-rw-r--r--source/blender/blenlib/intern/string.c112
4 files changed, 151 insertions, 151 deletions
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index 85636d23f6f..512086f0e17 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -463,14 +463,14 @@ int constrain_rgb(float *r, float *g, float *b)
float w;
/* Amount of white needed is w = - min(0, *r, *g, *b) */
-
+
w = (0 < *r) ? 0 : *r;
w = (w < *g) ? w : *g;
w = (w < *b) ? w : *b;
w = -w;
/* Add just enough white to make r, g, b all positive. */
-
+
if (w > 0) {
*r += w; *g += w; *b += w;
return 1; /* Color modified to fit RGB gamut */
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 744a15f4711..42a9587596e 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -473,7 +473,7 @@ int isect_line_tri_v3(const float p1[3], const float p2[3], const float v0[3], c
cross_v3_v3v3(q, s, e1);
- v = f * dot_v3v3(d, q);
+ v = f * dot_v3v3(d, q);
if ((v < 0.0f)||((u + v) > 1.0f)) return 0;
*lambda = f * dot_v3v3(e2, q);
@@ -519,7 +519,7 @@ int isect_ray_tri_v3(const float p1[3], const float d[3], const float v0[3], con
*lambda = f * dot_v3v3(e2, q);
if ((*lambda < 0.0f)) return 0;
- if(uv) {
+ if(uv) {
uv[0]= u;
uv[1]= v;
}
@@ -529,36 +529,36 @@ int isect_ray_tri_v3(const float p1[3], const float d[3], const float v0[3], con
int isect_ray_tri_epsilon_v3(const float p1[3], const float d[3], const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2], const float epsilon)
{
- float p[3], s[3], e1[3], e2[3], q[3];
- float a, f, u, v;
+ float p[3], s[3], e1[3], e2[3], q[3];
+ float a, f, u, v;
- sub_v3_v3v3(e1, v1, v0);
- sub_v3_v3v3(e2, v2, v0);
+ sub_v3_v3v3(e1, v1, v0);
+ sub_v3_v3v3(e2, v2, v0);
- cross_v3_v3v3(p, d, e2);
- a = dot_v3v3(e1, p);
- if (a == 0.0f) return 0;
- f = 1.0f/a;
+ cross_v3_v3v3(p, d, e2);
+ a = dot_v3v3(e1, p);
+ if (a == 0.0f) return 0;
+ f = 1.0f/a;
- sub_v3_v3v3(s, p1, v0);
+ sub_v3_v3v3(s, p1, v0);
- u = f * dot_v3v3(s, p);
- if ((u < -epsilon)||(u > 1.0f+epsilon)) return 0;
+ u = f * dot_v3v3(s, p);
+ if ((u < -epsilon)||(u > 1.0f+epsilon)) return 0;
- cross_v3_v3v3(q, s, e1);
+ cross_v3_v3v3(q, s, e1);
- v = f * dot_v3v3(d, q);
- if ((v < -epsilon)||((u + v) > 1.0f+epsilon)) return 0;
+ v = f * dot_v3v3(d, q);
+ if ((v < -epsilon)||((u + v) > 1.0f+epsilon)) return 0;
- *lambda = f * dot_v3v3(e2, q);
- if ((*lambda < 0.0f)) return 0;
+ *lambda = f * dot_v3v3(e2, q);
+ if ((*lambda < 0.0f)) return 0;
- if(uv) {
- uv[0]= u;
- uv[1]= v;
- }
+ if(uv) {
+ uv[0]= u;
+ uv[1]= v;
+ }
- return 1;
+ return 1;
}
int isect_ray_tri_threshold_v3(const float p1[3], const float d[3], const float v0[3], const float v1[3], const float v2[3], float *lambda, float *uv, const float threshold)
@@ -2604,7 +2604,7 @@ static float ff_quad_form_factor(float *p, float *n, float *q0, float *q1, float
aresult = (_mm_set_ps1(n[0])*gx + _mm_set_ps1(n[1])*gy + _mm_set_ps1(n[2])*gz)*angle;
/* sum together */
- result= (fresult[0] + fresult[1] + fresult[2] + fresult[3])*(0.5f/(float)M_PI);
+ result= (fresult[0] + fresult[1] + fresult[2] + fresult[3])*(0.5f/(float)M_PI);
result= MAX2(result, 0.0f);
return result;
diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c
index a2fa69bfcd9..95a43a998d3 100644
--- a/source/blender/blenlib/intern/pbvh.c
+++ b/source/blender/blenlib/intern/pbvh.c
@@ -672,7 +672,7 @@ static PBVHNode *pbvh_iter_next(PBVHIter *iter)
parents, this order is necessary for e.g. computing bounding boxes */
while(iter->stacksize) {
- /* pop node */
+ /* pop node */
iter->stacksize--;
node= iter->stack[iter->stacksize].node;
@@ -709,30 +709,30 @@ static PBVHNode *pbvh_iter_next(PBVHIter *iter)
static PBVHNode *pbvh_iter_next_occluded(PBVHIter *iter)
{
- PBVHNode *node;
-
- while(iter->stacksize) {
- /* pop node */
- iter->stacksize--;
- node= iter->stack[iter->stacksize].node;
-
- /* on a mesh with no faces this can happen
- * can remove this check if we know meshes have at least 1 face */
- if(node==NULL) return NULL;
-
- if(iter->scb && !iter->scb(node, iter->search_data)) continue; /* don't traverse, outside of search zone */
-
- if(node->flag & PBVH_Leaf) {
- /* immediately hit leaf node */
- return node;
- }
- else {
- pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset+1, 0);
- pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset, 0);
- }
- }
-
- return NULL;
+ PBVHNode *node;
+
+ while(iter->stacksize) {
+ /* pop node */
+ iter->stacksize--;
+ node= iter->stack[iter->stacksize].node;
+
+ /* on a mesh with no faces this can happen
+ * can remove this check if we know meshes have at least 1 face */
+ if(node==NULL) return NULL;
+
+ if(iter->scb && !iter->scb(node, iter->search_data)) continue; /* don't traverse, outside of search zone */
+
+ if(node->flag & PBVH_Leaf) {
+ /* immediately hit leaf node */
+ return node;
+ }
+ else {
+ pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset+1, 0);
+ pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset, 0);
+ }
+ }
+
+ return NULL;
}
void BLI_pbvh_search_gather(PBVH *bvh,
@@ -793,59 +793,59 @@ void BLI_pbvh_search_callback(PBVH *bvh,
}
typedef struct node_tree {
- PBVHNode* data;
+ PBVHNode* data;
- struct node_tree* left;
- struct node_tree* right;
+ struct node_tree* left;
+ struct node_tree* right;
} node_tree;
static void node_tree_insert(node_tree* tree, node_tree* new_node)
{
- if (new_node->data->tmin < tree->data->tmin) {
- if (tree->left) {
- node_tree_insert(tree->left, new_node);
- }
- else {
- tree->left = new_node;
- }
- }
- else {
- if (tree->right) {
- node_tree_insert(tree->right, new_node);
- }
- else {
- tree->right = new_node;
- }
- }
+ if (new_node->data->tmin < tree->data->tmin) {
+ if (tree->left) {
+ node_tree_insert(tree->left, new_node);
+ }
+ else {
+ tree->left = new_node;
+ }
+ }
+ else {
+ if (tree->right) {
+ node_tree_insert(tree->right, new_node);
+ }
+ else {
+ tree->right = new_node;
+ }
+ }
}
static void traverse_tree(node_tree* tree, BLI_pbvh_HitOccludedCallback hcb, void* hit_data, float* tmin)
{
- if (tree->left) traverse_tree(tree->left, hcb, hit_data, tmin);
+ if (tree->left) traverse_tree(tree->left, hcb, hit_data, tmin);
- hcb(tree->data, hit_data, tmin);
+ hcb(tree->data, hit_data, tmin);
- if (tree->right) traverse_tree(tree->right, hcb, hit_data, tmin);
+ if (tree->right) traverse_tree(tree->right, hcb, hit_data, tmin);
}
static void free_tree(node_tree* tree)
{
- if (tree->left) {
- free_tree(tree->left);
- tree->left = 0;
- }
+ if (tree->left) {
+ free_tree(tree->left);
+ tree->left = 0;
+ }
- if (tree->right) {
- free_tree(tree->right);
- tree->right = 0;
- }
+ if (tree->right) {
+ free_tree(tree->right);
+ tree->right = 0;
+ }
- free(tree);
+ free(tree);
}
float BLI_pbvh_node_get_tmin(PBVHNode* node)
{
- return node->tmin;
+ return node->tmin;
}
static void BLI_pbvh_search_callback_occluded(PBVH *bvh,
@@ -1129,7 +1129,7 @@ void BLI_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *tot
GHash *map;
void *face, **faces;
unsigned i;
- int tot;
+ int tot;
map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "pbvh_get_grid_updates gh");
@@ -1318,17 +1318,17 @@ static int ray_face_intersection(float ray_start[3], float ray_normal[3],
float *t0, float *t1, float *t2, float *t3,
float *fdist)
{
- float dist;
-
- if ((isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t1, t2, &dist, NULL, 0.1f) && dist < *fdist) ||
- (t3 && isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t2, t3, &dist, NULL, 0.1f) && dist < *fdist))
- {
- *fdist = dist;
- return 1;
- }
- else {
- return 0;
- }
+ float dist;
+
+ if ((isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t1, t2, &dist, NULL, 0.1f) && dist < *fdist) ||
+ (t3 && isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t2, t3, &dist, NULL, 0.1f) && dist < *fdist))
+ {
+ *fdist = dist;
+ return 1;
+ }
+ else {
+ return 0;
+ }
}
int BLI_pbvh_node_raycast(PBVH *bvh, PBVHNode *node, float (*origco)[3],
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index d626ca4bf09..ee5bd17c901 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -381,64 +381,64 @@ static const char trailingBytesForUTF8[256] = {
int BLI_utf8_invalid_byte(const char *str, int length)
{
- const unsigned char *p, *pend = (unsigned char*)str + length;
- unsigned char c;
- int ab;
-
- for (p = (unsigned char*)str; p < pend; p++) {
- c = *p;
- if (c < 128)
- continue;
- if ((c & 0xc0) != 0xc0)
- goto utf8_error;
- ab = trailingBytesForUTF8[c];
- if (length < ab)
- goto utf8_error;
- length -= ab;
-
- p++;
- /* Check top bits in the second byte */
- if ((*p & 0xc0) != 0x80)
- goto utf8_error;
-
- /* Check for overlong sequences for each different length */
- switch (ab) {
- /* Check for xx00 000x */
- case 1:
- if ((c & 0x3e) == 0) goto utf8_error;
- continue; /* We know there aren't any more bytes to check */
-
- /* Check for 1110 0000, xx0x xxxx */
- case 2:
- if (c == 0xe0 && (*p & 0x20) == 0) goto utf8_error;
- break;
-
- /* Check for 1111 0000, xx00 xxxx */
- case 3:
- if (c == 0xf0 && (*p & 0x30) == 0) goto utf8_error;
- break;
-
- /* Check for 1111 1000, xx00 0xxx */
- case 4:
- if (c == 0xf8 && (*p & 0x38) == 0) goto utf8_error;
- break;
-
- /* Check for leading 0xfe or 0xff,
- and then for 1111 1100, xx00 00xx */
- case 5:
- if (c == 0xfe || c == 0xff ||
- (c == 0xfc && (*p & 0x3c) == 0)) goto utf8_error;
- break;
- }
-
- /* Check for valid bytes after the 2nd, if any; all must start 10 */
- while (--ab > 0) {
- if ((*(p+1) & 0xc0) != 0x80) goto utf8_error;
+ const unsigned char *p, *pend = (unsigned char*)str + length;
+ unsigned char c;
+ int ab;
+
+ for (p = (unsigned char*)str; p < pend; p++) {
+ c = *p;
+ if (c < 128)
+ continue;
+ if ((c & 0xc0) != 0xc0)
+ goto utf8_error;
+ ab = trailingBytesForUTF8[c];
+ if (length < ab)
+ goto utf8_error;
+ length -= ab;
+
+ p++;
+ /* Check top bits in the second byte */
+ if ((*p & 0xc0) != 0x80)
+ goto utf8_error;
+
+ /* Check for overlong sequences for each different length */
+ switch (ab) {
+ /* Check for xx00 000x */
+ case 1:
+ if ((c & 0x3e) == 0) goto utf8_error;
+ continue; /* We know there aren't any more bytes to check */
+
+ /* Check for 1110 0000, xx0x xxxx */
+ case 2:
+ if (c == 0xe0 && (*p & 0x20) == 0) goto utf8_error;
+ break;
+
+ /* Check for 1111 0000, xx00 xxxx */
+ case 3:
+ if (c == 0xf0 && (*p & 0x30) == 0) goto utf8_error;
+ break;
+
+ /* Check for 1111 1000, xx00 0xxx */
+ case 4:
+ if (c == 0xf8 && (*p & 0x38) == 0) goto utf8_error;
+ break;
+
+ /* Check for leading 0xfe or 0xff,
+ and then for 1111 1100, xx00 00xx */
+ case 5:
+ if (c == 0xfe || c == 0xff ||
+ (c == 0xfc && (*p & 0x3c) == 0)) goto utf8_error;
+ break;
+ }
+
+ /* Check for valid bytes after the 2nd, if any; all must start 10 */
+ while (--ab > 0) {
+ if ((*(p+1) & 0xc0) != 0x80) goto utf8_error;
p++; /* do this after so we get usable offset - campbell */
- }
- }
+ }
+ }
- return -1;
+ return -1;
utf8_error: