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:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-11-04 06:22:56 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-11-04 06:22:56 +0400
commitdd8e83606776d1d3c51cd8f5c89bf6d1a7e05f74 (patch)
tree710d8682910d03d019ca0f4a1cb86fcf2b268c2e /source/blender/blenlib
parent6dfa1601092b9aa4de88420ce1e60371cd6aed69 (diff)
parent2f2c0a51a5b108213004dcda3da6defda82e6e41 (diff)
Merged changes in the trunk up to revision 51853.
Conflicts resolved: source/blender/blenloader/intern/readfile.c source/blender/bmesh/operators/bmo_utils.c This commit also includes a fix of a bug identified during the merge and committed in revision 51853. Thanks Thomas (dingto) for the timely fix!
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_math_matrix.h1
-rw-r--r--source/blender/blenlib/BLI_string.h2
-rw-r--r--source/blender/blenlib/intern/BLI_kdopbvh.c2
-rw-r--r--source/blender/blenlib/intern/math_matrix.c10
-rw-r--r--source/blender/blenlib/intern/math_rotation.c6
-rw-r--r--source/blender/blenlib/intern/noise.c4
-rw-r--r--source/blender/blenlib/intern/string.c13
-rw-r--r--source/blender/blenlib/intern/string_utf8.c35
-rw-r--r--source/blender/blenlib/intern/voronoi.c2
9 files changed, 51 insertions, 24 deletions
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 8e9955beb61..9e34631d460 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -128,6 +128,7 @@ int is_orthonormal_m4(float mat[4][4]);
int is_uniform_scaled_m3(float mat[3][3]);
+void adjoint_m2_m2(float R[2][2], float A[2][2]);
void adjoint_m3_m3(float R[3][3], float A[3][3]);
void adjoint_m4_m4(float R[4][4], float A[4][4]);
diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h
index ba906e1221c..70c89773f02 100644
--- a/source/blender/blenlib/BLI_string.h
+++ b/source/blender/blenlib/BLI_string.h
@@ -162,7 +162,7 @@ __attribute__((nonnull))
#endif
;
-size_t BLI_strescape(char *__restrict dst, const char *__restrict src, const size_t maxlen)
+size_t BLI_strescape(char *__restrict dst, const char *__restrict src, const size_t maxncpy)
#ifdef __GNUC__
__attribute__((nonnull))
#endif
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index fe91f91320a..70617453eff 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -1104,7 +1104,9 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int
if (!tree_overlap(tree1->nodes[tree1->totleaf], tree2->nodes[tree2->totleaf],
min_axis(tree1->start_axis, tree2->start_axis),
min_axis(tree1->stop_axis, tree2->stop_axis)))
+ {
return NULL;
+ }
data = MEM_callocN(sizeof(BVHOverlapData *) * tree1->tree_type, "BVHOverlapData_star");
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index f4a65564fd4..2b7c23ce67e 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -945,8 +945,18 @@ void normalize_m4_m4(float rmat[][4], float mat[][4])
if (len != 0.0f) rmat[2][3] = mat[2][3] / len;
}
+void adjoint_m2_m2(float m1[][2], float m[][2])
+{
+ BLI_assert(m1 != m);
+ m1[0][0] = m[1][1];
+ m1[0][1] = -m[1][0];
+ m1[1][0] = -m[0][1];
+ m1[1][1] = m[0][0];
+}
+
void adjoint_m3_m3(float m1[][3], float m[][3])
{
+ BLI_assert(m1 != m);
m1[0][0] = m[1][1] * m[2][2] - m[1][2] * m[2][1];
m1[0][1] = -m[0][1] * m[2][2] + m[0][2] * m[2][1];
m1[0][2] = m[0][1] * m[1][2] - m[0][2] * m[1][1];
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index 70d9ef27734..589e6462f62 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -234,7 +234,7 @@ void quat_to_mat4(float m[][4], const float q[4])
double q0, q1, q2, q3, qda, qdb, qdc, qaa, qab, qac, qbb, qbc, qcc;
#ifdef DEBUG
- if (!((q0 = dot_qtqt(q, q)) == 0.0f || (fabsf(q0 - 1.0) < QUAT_EPSILON))) {
+ if (!((q0 = dot_qtqt(q, q)) == 0.0f || (fabsf(q0 - 1.0) < (float)QUAT_EPSILON))) {
fprintf(stderr, "Warning! quat_to_mat4() called with non-normalized: size %.8f *** report a bug ***\n", (float)q0);
}
#endif
@@ -1077,11 +1077,11 @@ void compatible_eul(float eul[3], const float oldrot[3])
for (i = 0; i < 3; i++) {
deul[i] = eul[i] - oldrot[i];
if (deul[i] > pi_thresh) {
- eul[i] -= floorf(( deul[i] / pi_x2) + 0.5) * pi_x2;
+ eul[i] -= floorf(( deul[i] / pi_x2) + 0.5f) * pi_x2;
deul[i] = eul[i] - oldrot[i];
}
else if (deul[i] < -pi_thresh) {
- eul[i] += floorf((-deul[i] / pi_x2) + 0.5) * pi_x2;
+ eul[i] += floorf((-deul[i] / pi_x2) + 0.5f) * pi_x2;
deul[i] = eul[i] - oldrot[i];
}
}
diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c
index 124624ca137..fb33d7ce127 100644
--- a/source/blender/blenlib/intern/noise.c
+++ b/source/blender/blenlib/intern/noise.c
@@ -301,8 +301,8 @@ static float newPerlin(float x, float y, float 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, */
+ 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 */
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index 73d88ddd259..ff589764287 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -41,6 +41,8 @@
#include "BLI_dynstr.h"
#include "BLI_string.h"
+#include "BLI_utildefines.h"
+
char *BLI_strdupn(const char *str, const size_t len)
{
char *n = MEM_mallocN(len + 1, "strdup");
@@ -71,6 +73,7 @@ char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy)
{
size_t srclen = strlen(src);
size_t cpylen = (srclen > (maxncpy - 1)) ? (maxncpy - 1) : srclen;
+ BLI_assert(maxncpy != 0);
memcpy(dst, src, cpylen);
dst[cpylen] = '\0';
@@ -130,10 +133,13 @@ char *BLI_sprintfN(const char *format, ...)
* TODO: support more fancy string escaping. current code is primitive
* this basically is an ascii version of PyUnicode_EncodeUnicodeEscape()
* which is a useful reference. */
-size_t BLI_strescape(char *dst, const char *src, const size_t maxlen)
+size_t BLI_strescape(char *dst, const char *src, const size_t maxncpy)
{
size_t len = 0;
- while (len < maxlen) {
+
+ BLI_assert(maxncpy != 0);
+
+ while (len < maxncpy) {
switch (*src) {
case '\0':
goto escape_finish;
@@ -144,7 +150,7 @@ size_t BLI_strescape(char *dst, const char *src, const size_t maxlen)
case '\t':
case '\n':
case '\r':
- if (len + 1 < maxlen) {
+ if (len + 1 < maxncpy) {
*dst++ = '\\';
len++;
}
@@ -439,4 +445,3 @@ void BLI_ascii_strtoupper(char *str, const size_t len)
if (str[i] >= 'a' && str[i] <= 'z')
str[i] -= 'a' - 'A';
}
-
diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c
index 5684b12cc8b..0b737e0eff5 100644
--- a/source/blender/blenlib/intern/string_utf8.c
+++ b/source/blender/blenlib/intern/string_utf8.c
@@ -33,8 +33,12 @@
#include <string.h>
#include <wchar.h>
#include <wctype.h>
+#include <stdio.h>
+#include <stdlib.h>
-#include "BLI_string_utf8.h"
+#include "BLI_utildefines.h"
+
+#include "BLI_string_utf8.h" /* own include */
/* from libswish3, originally called u8_isvalid(),
* modified to return the index of the bad character (byte index not utf).
@@ -153,14 +157,14 @@ int BLI_utf8_invalid_strip(char *str, int length)
* note: this looks to be at odd's with 'trailingBytesForUTF8',
* need to find out what gives here! - campbell */
static const size_t utf8_skip_data[256] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 4, 5, 5, 5, 5, 6, 6, 1, 1
};
#define BLI_STR_UTF8_CPY(dst, src, maxncpy) \
@@ -184,6 +188,8 @@ char *BLI_strncpy_utf8(char *dst, const char *src, size_t maxncpy)
{
char *dst_r = dst;
+ BLI_assert(maxncpy != 0);
+
/* note: currently we don't attempt to deal with invalid utf8 chars */
BLI_STR_UTF8_CPY(dst, src, maxncpy);
@@ -207,10 +213,13 @@ char *BLI_strncat_utf8(char *dst, const char *src, size_t maxncpy)
/* --------------------------------------------------------------------------*/
/* wchar_t / utf8 functions */
-size_t BLI_strncpy_wchar_as_utf8(char *dst, const wchar_t *src, const size_t maxcpy)
+size_t BLI_strncpy_wchar_as_utf8(char *dst, const wchar_t *src, const size_t maxncpy)
{
size_t len = 0;
- while (*src && len < maxcpy) { /* XXX can still run over the buffer because utf8 size isn't known :| */
+
+ BLI_assert(maxncpy != 0);
+
+ while (*src && len < maxncpy) { /* XXX can still run over the buffer because utf8 size isn't known :| */
len += BLI_str_utf8_from_unicode(*src++, dst + len);
}
@@ -280,7 +289,7 @@ size_t BLI_strnlen_utf8(const char *start, const size_t maxlen)
return len;
}
-size_t BLI_strncpy_wchar_from_utf8(wchar_t *dst_w, const char *src_c, const size_t maxcpy)
+size_t BLI_strncpy_wchar_from_utf8(wchar_t *dst_w, const char *src_c, const size_t maxncpy)
{
int len = 0;
@@ -288,7 +297,7 @@ size_t BLI_strncpy_wchar_from_utf8(wchar_t *dst_w, const char *src_c, const size
return 0;
}
- while (*src_c && len < maxcpy) {
+ while (*src_c && len < maxncpy) {
size_t step = 0;
unsigned int unicode = BLI_str_utf8_as_unicode_and_size(src_c, &step);
if (unicode != BLI_UTF8_ERR) {
diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c
index 9674012a73d..0d411038b3e 100644
--- a/source/blender/blenlib/intern/voronoi.c
+++ b/source/blender/blenlib/intern/voronoi.c
@@ -39,7 +39,7 @@
#include "BLI_voronoi.h"
#include "BLI_utildefines.h"
-#define VORONOI_EPS 1e-2
+#define VORONOI_EPS 1e-2f
enum {
voronoiEventType_Site = 0,