From 40ad1cf0b1203848508cf6389e4337eb5071edf6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 14 Nov 2017 16:10:48 +1100 Subject: BLI: sync changes from 2.8 --- source/blender/blenlib/BLI_listbase.h | 1 + source/blender/blenlib/BLI_math_color.h | 4 + source/blender/blenlib/BLI_math_matrix.h | 1 + source/blender/blenlib/BLI_math_vector.h | 3 + source/blender/blenlib/BLI_rand.h | 12 +++ source/blender/blenlib/BLI_utildefines.h | 3 + source/blender/blenlib/intern/listbase.c | 28 ++++++ source/blender/blenlib/intern/math_color_inline.c | 8 ++ source/blender/blenlib/intern/math_matrix.c | 10 ++ source/blender/blenlib/intern/math_vector.c | 14 +++ source/blender/blenlib/intern/math_vector_inline.c | 14 +++ source/blender/blenlib/intern/rand.c | 101 +++++++++++++++++++++ 12 files changed, 199 insertions(+) diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h index b06944e4985..c1e28d5ebc3 100644 --- a/source/blender/blenlib/BLI_listbase.h +++ b/source/blender/blenlib/BLI_listbase.h @@ -77,6 +77,7 @@ int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1); void BLI_listbase_swaplinks(struct ListBase *listbase, void *vlinka, void *vlinkb) ATTR_NONNULL(1, 2); +void BLI_listbases_swaplinks(struct ListBase *listbasea, struct ListBase *listbaseb, void *vlinka, void *vlinkb) ATTR_NONNULL(2, 3); void BLI_movelisttolist(struct ListBase *dst, struct ListBase *src) ATTR_NONNULL(1, 2); void BLI_duplicatelist(struct ListBase *dst, const struct ListBase *src) ATTR_NONNULL(1, 2); diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h index 5e6b1256d30..34fc52c12c0 100644 --- a/source/blender/blenlib/BLI_math_color.h +++ b/source/blender/blenlib/BLI_math_color.h @@ -141,7 +141,11 @@ MINLINE void float_to_byte_dither_v3(unsigned char b[3], const float f[3], float #define rgba_char_args_set_fl(col, r, g, b, a) \ rgba_char_args_set(col, (r) * 255, (g) * 255, (b) * 255, (a) * 255) +#define rgba_float_args_set_ch(col, r, g, b, a) \ + rgba_float_args_set(col, (r) / 255.0f, (g) / 255.0f, (b) / 255.0f, (a) / 255.0f) + MINLINE void rgba_char_args_set(char col[4], const char r, const char g, const char b, const char a); +MINLINE void rgba_float_args_set(float col[4], const float r, const float g, const float b, const float a); MINLINE void rgba_char_args_test_set(char col[4], const char r, const char g, const char b, const char a); MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack); diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index d0dfad2a02f..173ef6861e6 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -210,6 +210,7 @@ void scale_m4_fl(float R[4][4], float scale); float mat3_to_scale(float M[3][3]); float mat4_to_scale(float M[4][4]); +float mat4_to_xy_scale(float M[4][4]); void size_to_mat3(float R[3][3], const float size[3]); void size_to_mat4(float R[4][4], const float size[3]); diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 4fdb33926a2..3f603311530 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -151,6 +151,7 @@ MINLINE void negate_v3_short(short r[3]); MINLINE void negate_v3_db(double r[3]); MINLINE void invert_v2(float r[2]); +MINLINE void invert_v3(float r[3]); MINLINE void abs_v2(float r[2]); MINLINE void abs_v2_v2(float r[2], const float a[2]); @@ -311,6 +312,7 @@ void ortho_basis_v3v3_v3(float r_n1[3], float r_n2[3], const float n[3]); void ortho_v3_v3(float out[3], const float v[3]); void ortho_v2_v2(float out[2], const float v[2]); void bisect_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3]); +void rotate_v2_v2fl(float r[2], const float p[2], const float angle); void rotate_v3_v3v3fl(float v[3], const float p[3], const float axis[3], const float angle); void rotate_normalized_v3_v3v3fl(float out[3], const float p[3], const float axis[3], const float angle); @@ -326,6 +328,7 @@ void print_vn(const char *str, const float v[], const int n); #define print_v4_id(v) print_v4(STRINGIFY(v), v) #define print_vn_id(v, n) print_vn(STRINGIFY(v), v, n) +MINLINE void normal_float_to_short_v2(short r[2], const float n[2]); MINLINE void normal_short_to_float_v3(float r[3], const short n[3]); MINLINE void normal_float_to_short_v3(short r[3], const float n[3]); diff --git a/source/blender/blenlib/BLI_rand.h b/source/blender/blenlib/BLI_rand.h index f36d2faa1b8..69b23b2473f 100644 --- a/source/blender/blenlib/BLI_rand.h +++ b/source/blender/blenlib/BLI_rand.h @@ -101,4 +101,16 @@ RNG_THREAD_ARRAY *BLI_rng_threaded_new(void); void BLI_rng_threaded_free(struct RNG_THREAD_ARRAY *rngarr) ATTR_NONNULL(1); int BLI_rng_thread_rand(RNG_THREAD_ARRAY *rngarr, int thread) ATTR_WARN_UNUSED_RESULT; +/** Low-discrepancy sequences **/ + +/** Return the _n_th number of the given low-discrepancy sequence. */ +void BLI_halton_1D(unsigned int prime, double offset, int n, double *r); +void BLI_halton_2D(unsigned int prime[2], double offset[2], int n, double *r); +void BLI_halton_3D(unsigned int prime[3], double offset[3], int n, double *r); +void BLI_hammersley_1D(unsigned int n, double *r); + +/** Return the whole low-discrepancy sequence up to _n_. */ +void BLI_halton_2D_sequence(unsigned int prime[2], double offset[2], int n, double *r); +void BLI_hammersley_2D_sequence(unsigned int n, double *r); + #endif /* __BLI_RAND_H__ */ diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 66c7f247f61..1186e4a0713 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -651,6 +651,9 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size); # define BLI_STATIC_ASSERT(a, msg) #endif +#define BLI_STATIC_ASSERT_ALIGN(st, align) \ + BLI_STATIC_ASSERT((sizeof(st) % (align) == 0), "Structure must be strictly aligned") + /* hints for branch prediction, only use in code that runs a _lot_ where */ #ifdef __GNUC__ # define LIKELY(x) __builtin_expect(!!(x), 1) diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c index 46dcee48eda..0a6d575c7d6 100644 --- a/source/blender/blenlib/intern/listbase.c +++ b/source/blender/blenlib/intern/listbase.c @@ -169,6 +169,34 @@ void BLI_listbase_swaplinks(ListBase *listbase, void *vlinka, void *vlinkb) else if (listbase->first == linkb) listbase->first = linka; } +/** + * Swaps \a vlinka and \a vlinkb from their respective lists. Assumes they are both already in their lista! + */ +void BLI_listbases_swaplinks(ListBase *listbasea, ListBase *listbaseb, void *vlinka, void *vlinkb) +{ + Link *linka = vlinka; + Link *linkb = vlinkb; + Link linkc = {NULL}; + + if (!linka || !linkb) { + return; + } + + /* Temporary link to use as placeholder of the links positions */ + BLI_insertlinkafter(listbasea, linka, &linkc); + + /* Bring linka into linkb position */ + BLI_remlink(listbasea, linka); + BLI_insertlinkafter(listbaseb, linkb, linka); + + /* Bring linkb into linka position */ + BLI_remlink(listbaseb, linkb); + BLI_insertlinkafter(listbasea, &linkc, linkb); + + /* Remove temporary link */ + BLI_remlink(listbasea, &linkc); +} + /** * Removes the head from \a listbase and returns it. */ diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c index 01a805a09b6..bc3a1ee3e90 100644 --- a/source/blender/blenlib/intern/math_color_inline.c +++ b/source/blender/blenlib/intern/math_color_inline.c @@ -239,6 +239,14 @@ MINLINE void rgba_char_args_set(char col[4], const char r, const char g, const c col[3] = a; } +MINLINE void rgba_float_args_set(float col[4], const float r, const float g, const float b, const float a) +{ + col[0] = r; + col[1] = g; + col[2] = b; + col[3] = a; +} + MINLINE void rgba_char_args_test_set(char col[4], const char r, const char g, const char b, const char a) { if (col[3] == 0) { diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index d1a219c196a..311d963f64d 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -1523,6 +1523,15 @@ float mat4_to_scale(float mat[4][4]) return len_v3(unit_vec); } +/** Return 2D scale (in XY plane) of given mat4. */ +float mat4_to_xy_scale(float M[4][4]) +{ + /* unit length vector in xy plane */ + float unit_vec[3] = {(float)M_SQRT1_2, (float)M_SQRT1_2, 0.0f}; + mul_mat3_m4_v3(M, unit_vec); + return len_v3(unit_vec); +} + void mat3_to_rot_size(float rot[3][3], float size[3], float mat3[3][3]) { /* keep rot as a 3x3 matrix, the caller can convert into a quat or euler */ @@ -1625,6 +1634,7 @@ void translate_m4(float mat[4][4], float Tx, float Ty, float Tz) mat[3][2] += (Tx * mat[0][2] + Ty * mat[1][2] + Tz * mat[2][2]); } +/* TODO: enum for axis? */ /** * Rotate a matrix in-place. * diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index 5f44c93e169..05562502278 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -849,6 +849,20 @@ void ortho_v2_v2(float out[2], const float v[2]) out[1] = v[0]; } +/** + * Rotate a point \a p by \a angle around origin (0, 0) + */ +void rotate_v2_v2fl(float r[2], const float p[2], const float angle) +{ + const float co = cosf(angle); + const float si = sinf(angle); + + BLI_assert(r != p); + + r[0] = co * p[0] - si * p[1]; + r[1] = si * p[0] + co * p[1]; +} + /** * Rotate a point \a p by \a angle around an arbitrary unit length \a axis. * http://local.wasp.uwa.edu.au/~pbourke/geometry/ diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index ee5e8651bd3..08687a1ab47 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -658,6 +658,14 @@ MINLINE void invert_v2(float r[2]) r[1] = 1.0f / r[1]; } +MINLINE void invert_v3(float r[3]) +{ + BLI_assert(!ELEM(0.0f, r[0], r[1], r[2])); + r[0] = 1.0f / r[0]; + r[1] = 1.0f / r[1]; + r[2] = 1.0f / r[2]; +} + MINLINE void abs_v2(float r[2]) { r[0] = fabsf(r[0]); @@ -960,6 +968,12 @@ MINLINE float normalize_v3(float n[3]) return normalize_v3_v3(n, n); } +MINLINE void normal_float_to_short_v2(short out[2], const float in[2]) +{ + out[0] = (short) (in[0] * 32767.0f); + out[1] = (short) (in[1] * 32767.0f); +} + MINLINE void normal_short_to_float_v3(float out[3], const short in[3]) { out[0] = in[0] * (1.0f / 32767.0f); diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c index 40d9a3da3d9..1a178db1413 100644 --- a/source/blender/blenlib/intern/rand.c +++ b/source/blender/blenlib/intern/rand.c @@ -41,6 +41,9 @@ #include "BLI_rand.h" #include "BLI_math.h" +/* defines BLI_INLINE */ +#include "BLI_utildefines.h" + #include "BLI_sys_types.h" #include "BLI_strict_flags.h" @@ -353,3 +356,101 @@ int BLI_rng_thread_rand(RNG_THREAD_ARRAY *rngarr, int thread) return BLI_rng_get_int(&rngarr->rng_tab[thread]); } +/* ********* Low-discrepancy sequences ************** */ + +/* incremental halton sequence generator, from: + * "Instant Radiosity", Keller A. */ +BLI_INLINE double halton_ex(double invprimes, double *offset) +{ + double e = fabs((1.0 - *offset) - 1e-10); + + if (invprimes >= e) { + double lasth; + double h = invprimes; + + do { + lasth = h; + h *= invprimes; + } while (h >= e); + + *offset += ((lasth + h) - 1.0); + } + else { + *offset += invprimes; + } + + return *offset; +} + +void BLI_halton_1D(unsigned int prime, double offset, int n, double *r) +{ + const double invprime = 1.0 / (double)prime; + + for (int s = 0; s < n; s++) { + *r = halton_ex(invprime, &offset); + } +} + +void BLI_halton_2D(unsigned int prime[2], double offset[2], int n, double *r) +{ + const double invprimes[2] = {1.0 / (double)prime[0], 1.0 / (double)prime[1]}; + + for (int s = 0; s < n; s++) { + for (int i = 0; i < 2; i++) { + r[i] = halton_ex(invprimes[i], &offset[i]); + } + } +} + +void BLI_halton_3D(unsigned int prime[3], double offset[3], int n, double *r) +{ + const double invprimes[3] = {1.0 / (double)prime[0], 1.0 / (double)prime[1], 1.0 / (double)prime[2]}; + + for (int s = 0; s < n; s++) { + for (int i = 0; i < 3; i++) { + r[i] = halton_ex(invprimes[i], &offset[i]); + } + } +} + +void BLI_halton_2D_sequence(unsigned int prime[2], double offset[2], int n, double *r) +{ + const double invprimes[2] = {1.0 / (double)prime[0], 1.0 / (double)prime[1]}; + + for (int s = 0; s < n; s++) { + for (int i = 0; i < 2; i++) { + r[s * 2 + i] = halton_ex(invprimes[i], &offset[i]); + } + } +} + + +/* From "Sampling with Hammersley and Halton Points" TT Wong + * Appendix: Source Code 1 */ +BLI_INLINE double radical_inverse(unsigned int n) +{ + double u = 0; + + /* This reverse the bitwise representation + * around the decimal point. */ + for (double p = 0.5; n; p *= 0.5, n >>= 1) { + if (n & 1) { + u += p; + } + } + + return u; +} + +void BLI_hammersley_1D(unsigned int n, double *r) +{ + *r = radical_inverse(n); +} + +void BLI_hammersley_2D_sequence(unsigned int n, double *r) +{ + for (unsigned int s = 0; s < n; s++) { + r[s * 2 + 0] = (double)(s + 0.5) / (double)n; + r[s * 2 + 1] = radical_inverse(s); + } +} -- cgit v1.2.3 From 7adc698eedfc325dc8485aa52d56730f87bbb586 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 14 Nov 2017 17:23:40 +1100 Subject: Cleanup: order BLI before BKE headers This was done nearly everywhere already --- source/blender/blenkernel/intern/bmfont.c | 5 ++--- source/blender/blenkernel/intern/freestyle.c | 8 ++++---- source/blender/blenkernel/intern/outliner_treehash.c | 4 ++-- source/blender/editors/animation/anim_channels_edit.c | 4 ++-- source/blender/editors/sculpt_paint/paint_curve.c | 6 +++--- source/blender/makesrna/intern/rna_cachefile.c | 4 ++-- source/blender/makesrna/intern/rna_mask.c | 4 ++-- source/blender/makesrna/intern/rna_sculpt_paint.c | 3 ++- source/blender/makesrna/intern/rna_smoke.c | 5 +++-- source/blender/python/intern/bpy_rna_array.c | 5 +++-- source/blender/render/intern/source/render_result.c | 2 +- 11 files changed, 26 insertions(+), 24 deletions(-) diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index 79b3f89da20..8018629ef2a 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -52,11 +52,10 @@ #include "MEM_guardedalloc.h" #include "IMB_imbuf_types.h" -#include "BKE_bmfont.h" -#include "BKE_bmfont_types.h" - #include "BLI_utildefines.h" +#include "BKE_bmfont.h" +#include "BKE_bmfont_types.h" #include "BKE_global.h" void printfGlyph(bmGlyph *glyph) diff --git a/source/blender/blenkernel/intern/freestyle.c b/source/blender/blenkernel/intern/freestyle.c index e45a938a4fc..686fe3bda93 100644 --- a/source/blender/blenkernel/intern/freestyle.c +++ b/source/blender/blenkernel/intern/freestyle.c @@ -34,14 +34,14 @@ #include "DNA_freestyle_types.h" #include "DNA_group_types.h" -#include "BKE_freestyle.h" -#include "BKE_library.h" -#include "BKE_linestyle.h" - #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_string_utils.h" +#include "BKE_freestyle.h" +#include "BKE_library.h" +#include "BKE_linestyle.h" + // function declarations static FreestyleLineSet *alloc_lineset(void); static void copy_lineset(FreestyleLineSet *new_lineset, FreestyleLineSet *lineset, const int flag); diff --git a/source/blender/blenkernel/intern/outliner_treehash.c b/source/blender/blenkernel/intern/outliner_treehash.c index f31ba34a984..4d97121e2a3 100644 --- a/source/blender/blenkernel/intern/outliner_treehash.c +++ b/source/blender/blenkernel/intern/outliner_treehash.c @@ -28,14 +28,14 @@ #include -#include "BKE_outliner_treehash.h" - #include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BLI_mempool.h" #include "DNA_outliner_types.h" +#include "BKE_outliner_treehash.h" + #include "MEM_guardedalloc.h" typedef struct TseGroup { diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 25f1e206be5..82f24c91df1 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -34,11 +34,9 @@ #include "MEM_guardedalloc.h" -#include "BKE_depsgraph.h" #include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "BLI_listbase.h" -#include "BKE_library.h" #include "DNA_anim_types.h" #include "DNA_object_types.h" @@ -52,11 +50,13 @@ #include "BKE_animsys.h" #include "BKE_action.h" +#include "BKE_depsgraph.h" #include "BKE_fcurve.h" #include "BKE_gpencil.h" #include "BKE_context.h" #include "BKE_mask.h" #include "BKE_global.h" +#include "BKE_library.h" #include "UI_view2d.h" diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c index 0ee78d61fb8..337f7a1ef2b 100644 --- a/source/blender/editors/sculpt_paint/paint_curve.c +++ b/source/blender/editors/sculpt_paint/paint_curve.c @@ -33,13 +33,13 @@ #include "DNA_space_types.h" #include "DNA_view3d_types.h" +#include "BLI_math_vector.h" +#include "BLI_string.h" + #include "BKE_context.h" #include "BKE_main.h" #include "BKE_paint.h" -#include "BLI_math_vector.h" -#include "BLI_string.h" - #include "ED_paint.h" #include "ED_view3d.h" diff --git a/source/blender/makesrna/intern/rna_cachefile.c b/source/blender/makesrna/intern/rna_cachefile.c index 81b0c539e33..73928d377f1 100644 --- a/source/blender/makesrna/intern/rna_cachefile.c +++ b/source/blender/makesrna/intern/rna_cachefile.c @@ -34,11 +34,11 @@ #ifdef RNA_RUNTIME +#include "BLI_string.h" + #include "BKE_cachefile.h" #include "BKE_depsgraph.h" -#include "BLI_string.h" - #include "DEG_depsgraph.h" #include "WM_api.h" diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c index f4f4685d1bf..c266e0e7f31 100644 --- a/source/blender/makesrna/intern/rna_mask.c +++ b/source/blender/makesrna/intern/rna_mask.c @@ -52,13 +52,13 @@ #ifdef RNA_RUNTIME +#include "BLI_math.h" + #include "DNA_movieclip_types.h" #include "BKE_depsgraph.h" #include "BKE_mask.h" -#include "BLI_math.h" - #include "RNA_access.h" #include "WM_api.h" diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 28bd0f1b07f..9da27233e0e 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -27,6 +27,8 @@ #include +#include "BLI_utildefines.h" + #include "RNA_define.h" #include "RNA_enum_types.h" @@ -46,7 +48,6 @@ #include "WM_api.h" #include "WM_types.h" -#include "BLI_utildefines.h" #include "bmesh.h" static const EnumPropertyItem particle_edit_hair_brush_items[] = { diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index 8e54c708c05..77d7f7833c6 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -29,6 +29,9 @@ #include #include +#include "BLI_sys_types.h" +#include "BLI_threads.h" + #include "RNA_define.h" #include "RNA_enum_types.h" @@ -38,8 +41,6 @@ #include "BKE_smoke.h" #include "BKE_pointcache.h" -#include "BLI_threads.h" - #include "DNA_modifier_types.h" #include "DNA_object_force.h" #include "DNA_object_types.h" diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c index 3e147d29c90..e0ca3634261 100644 --- a/source/blender/python/intern/bpy_rna_array.c +++ b/source/blender/python/intern/bpy_rna_array.c @@ -28,13 +28,14 @@ #include +#include "BLI_utildefines.h" + #include "RNA_types.h" #include "bpy_rna.h" #include "BKE_global.h" -#include "MEM_guardedalloc.h" -#include "BLI_utildefines.h" +#include "MEM_guardedalloc.h" #include "RNA_access.h" diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index 631503bdad5..9ad5d73fc55 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -36,7 +36,6 @@ #include "MEM_guardedalloc.h" -#include "BKE_appdir.h" #include "BLI_utildefines.h" #include "BLI_listbase.h" #include "BLI_hash_md5.h" @@ -45,6 +44,7 @@ #include "BLI_string.h" #include "BLI_threads.h" +#include "BKE_appdir.h" #include "BKE_image.h" #include "BKE_global.h" #include "BKE_main.h" -- cgit v1.2.3 From 55696b56d98411b6eeadfa1a7349bdb2bca47e38 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 14 Nov 2017 12:21:15 +0100 Subject: Fix T53068: AMD Threadripper not working well with Blender The issue was caused by SpinLock implementation in old pthreads we ar eusing on Windows. Using newer one (2.10-rc) demonstrates same exact behavior. But likely using own atomics and memory barrier based implementation solves the issue. A bit annoying that we need to change such a core part of Blender just to make specific CPU happy, but it's better to have artists happy on all computers. There is no expected downsides of this change, but it is so called "works for me" category. Let's see how it all goes. --- source/blender/blenlib/BLI_threads.h | 6 ++++-- source/blender/blenlib/intern/threads.c | 27 ++++++++++++++++++--------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h index 0b1b4d8ee8c..9d672b1ce88 100644 --- a/source/blender/blenlib/BLI_threads.h +++ b/source/blender/blenlib/BLI_threads.h @@ -111,8 +111,10 @@ void BLI_mutex_unlock(ThreadMutex *mutex); /* Spin Lock */ -#ifdef __APPLE__ -typedef OSSpinLock SpinLock; +#if defined(__APPLE__) +typedef OSSpinLock ; +#elif defined(_MSC_VER) +typedef volatile int SpinLock; #else typedef pthread_spinlock_t SpinLock; #endif diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index abf611d1245..fbb64f3ece2 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -472,8 +472,10 @@ void BLI_mutex_free(ThreadMutex *mutex) void BLI_spin_init(SpinLock *spin) { -#ifdef __APPLE__ +#if defined(__APPLE__) *spin = OS_SPINLOCK_INIT; +#elif defined(_MSC_VER) + *spin = 0; #else pthread_spin_init(spin, 0); #endif @@ -481,8 +483,14 @@ void BLI_spin_init(SpinLock *spin) void BLI_spin_lock(SpinLock *spin) { -#ifdef __APPLE__ +#if defined(__APPLE__) OSSpinLockLock(spin); +#elif defined(_MSC_VER) + while (InterlockedExchangeAcquire(spin, 1)) { + while (*spin) { + /* pass */ + } + } #else pthread_spin_lock(spin); #endif @@ -490,23 +498,24 @@ void BLI_spin_lock(SpinLock *spin) void BLI_spin_unlock(SpinLock *spin) { -#ifdef __APPLE__ +#if defined(__APPLE__) OSSpinLockUnlock(spin); +#elif defined(_MSC_VER) + _ReadWriteBarrier(); + *spin = 0; #else pthread_spin_unlock(spin); #endif } -#ifndef __APPLE__ void BLI_spin_end(SpinLock *spin) { - pthread_spin_destroy(spin); -} +#if defined(__APPLE__) +#elif defined(_MSC_VER) #else -void BLI_spin_end(SpinLock *UNUSED(spin)) -{ -} + pthread_spin_destroy(spin); #endif +} /* Read/Write Mutex Lock */ -- cgit v1.2.3 From 0a3fa9c25c920d787bf7f32fb5f922509427deaf Mon Sep 17 00:00:00 2001 From: Arto Kitula Date: Tue, 14 Nov 2017 16:51:34 +0200 Subject: Fix missing SpinLock typedef on macOS --- source/blender/blenlib/BLI_threads.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h index 9d672b1ce88..60da6b39cbe 100644 --- a/source/blender/blenlib/BLI_threads.h +++ b/source/blender/blenlib/BLI_threads.h @@ -112,7 +112,7 @@ void BLI_mutex_unlock(ThreadMutex *mutex); /* Spin Lock */ #if defined(__APPLE__) -typedef OSSpinLock ; +typedef OSSpinLock SpinLock; #elif defined(_MSC_VER) typedef volatile int SpinLock; #else -- cgit v1.2.3 From 6f15554af32dc5df0711e0057526b946f37cb353 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 14 Nov 2017 16:50:19 +0100 Subject: Alembic: Fix mismatch in forward declaration with definition --- source/blender/alembic/intern/abc_mball.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/alembic/intern/abc_mball.h b/source/blender/alembic/intern/abc_mball.h index 46b61151216..9b943698416 100644 --- a/source/blender/alembic/intern/abc_mball.h +++ b/source/blender/alembic/intern/abc_mball.h @@ -25,7 +25,7 @@ #include "abc_object.h" -struct AbcMeshWriter; +class AbcMeshWriter; struct Main; struct MetaBall; struct Object; -- cgit v1.2.3 From 2868dcbe2bc4eb64e2667239aed7e7b18fa8c96c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 14 Nov 2017 17:00:54 +0100 Subject: Fix compilation error with clang-5 --- intern/eigen/intern/eigenvalues.cc | 2 +- intern/eigen/intern/svd.cc | 2 +- source/blender/physics/intern/eigen_utils.h | 2 +- source/blender/physics/intern/implicit_eigen.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/intern/eigen/intern/eigenvalues.cc b/intern/eigen/intern/eigenvalues.cc index 57942a4dc55..b516443c421 100644 --- a/intern/eigen/intern/eigenvalues.cc +++ b/intern/eigen/intern/eigenvalues.cc @@ -28,7 +28,7 @@ #define __EIGEN3_EIGENVALUES_C_API_CC__ /* Eigen gives annoying huge amount of warnings here, silence them! */ -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(__clang__) # pragma GCC diagnostic ignored "-Wlogical-op" #endif diff --git a/intern/eigen/intern/svd.cc b/intern/eigen/intern/svd.cc index 04929cff798..7c331d25aa7 100644 --- a/intern/eigen/intern/svd.cc +++ b/intern/eigen/intern/svd.cc @@ -28,7 +28,7 @@ #define __EIGEN3_SVD_C_API_CC__ /* Eigen gives annoying huge amount of warnings here, silence them! */ -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(__clang__) # pragma GCC diagnostic ignored "-Wlogical-op" #endif diff --git a/source/blender/physics/intern/eigen_utils.h b/source/blender/physics/intern/eigen_utils.h index e4a4f306aeb..8a5a9dbf5e9 100644 --- a/source/blender/physics/intern/eigen_utils.h +++ b/source/blender/physics/intern/eigen_utils.h @@ -32,7 +32,7 @@ * \ingroup bph */ -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(__clang__) # pragma GCC diagnostic push /* XXX suppress verbose warnings in eigen */ # pragma GCC diagnostic ignored "-Wlogical-op" diff --git a/source/blender/physics/intern/implicit_eigen.cpp b/source/blender/physics/intern/implicit_eigen.cpp index ff4c705ed61..afe1b441632 100644 --- a/source/blender/physics/intern/implicit_eigen.cpp +++ b/source/blender/physics/intern/implicit_eigen.cpp @@ -39,7 +39,7 @@ #ifdef __GNUC__ # pragma GCC diagnostic push /* XXX suppress verbose warnings in eigen */ -# pragma GCC diagnostic ignored "-Wlogical-op" +//# pragma GCC diagnostic ignored "-Wlogical-op" #endif #ifndef IMPLICIT_ENABLE_EIGEN_DEBUG -- cgit v1.2.3 From 67ddc280552fea5687c84f4559216f557d81a425 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 14 Nov 2017 17:11:25 +0100 Subject: Smoke: Pass non-trivial arguments by const reference --- intern/smoke/intern/IMAGE.h | 10 +++++----- intern/smoke/intern/WTURBULENCE.cpp | 8 ++++---- intern/smoke/intern/WTURBULENCE.h | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/intern/smoke/intern/IMAGE.h b/intern/smoke/intern/IMAGE.h index a606fcddf72..79f71c6402a 100644 --- a/intern/smoke/intern/IMAGE.h +++ b/intern/smoke/intern/IMAGE.h @@ -48,27 +48,27 @@ template < class T > inline void CLAMP( T &a, T b=0., T c=1.) { if(a>c) { a=c; return; } } -template < class T > inline T MIN( T a, T b) { +template < class T > inline T MIN( const T& a, const T& b) { return (a < b) ? a : b; } -template < class T > inline T MAX( T a, T b) { +template < class T > inline T MAX( const T& a, const T& b) { return (a > b) ? a : b; } -template < class T > inline T MAX3( T a, T b, T c) { +template < class T > inline T MAX3( const T& a, const T& b, const T& c) { T max = (a > b) ? a : b; max = (max > c) ? max : c; return max; } -template < class T > inline float MAX3V( T vec) { +template < class T > inline float MAX3V( const T& vec) { float max = (vec[0] > vec[1]) ? vec[0] : vec[1]; max = (max > vec[2]) ? max : vec[2]; return max; } -template < class T > inline float MIN3V( T vec) { +template < class T > inline float MIN3V( const T& vec) { float min = (vec[0] < vec[1]) ? vec[0] : vec[1]; min = (min < vec[2]) ? min : vec[2]; return min; diff --git a/intern/smoke/intern/WTURBULENCE.cpp b/intern/smoke/intern/WTURBULENCE.cpp index 3d712d2124a..61389201796 100644 --- a/intern/smoke/intern/WTURBULENCE.cpp +++ b/intern/smoke/intern/WTURBULENCE.cpp @@ -245,7 +245,7 @@ void WTURBULENCE::initBlenderRNA(float *strength) // Takes the one-sided finite difference in both directions and // selects the smaller of the two ////////////////////////////////////////////////////////////////////// -static float minDx(int x, int y, int z, float* input, Vec3Int res) +static float minDx(int x, int y, int z, float* input, const Vec3Int& res) { const int index = x + y * res[0] + z * res[0] * res[1]; const int maxx = res[0]-2; @@ -280,7 +280,7 @@ static float minDx(int x, int y, int z, float* input, Vec3Int res) // Takes the one-sided finite difference in both directions and // selects the smaller of the two ////////////////////////////////////////////////////////////////////// -static float minDy(int x, int y, int z, float* input, Vec3Int res) +static float minDy(int x, int y, int z, float* input, const Vec3Int& res) { const int index = x + y * res[0] + z * res[0] * res[1]; const int maxy = res[1]-2; @@ -314,7 +314,7 @@ static float minDy(int x, int y, int z, float* input, Vec3Int res) // Takes the one-sided finite difference in both directions and // selects the smaller of the two ////////////////////////////////////////////////////////////////////// -static float minDz(int x, int y, int z, float* input, Vec3Int res) +static float minDz(int x, int y, int z, float* input, const Vec3Int& res) { const int slab = res[0]*res[1]; const int index = x + y * res[0] + z * slab; @@ -605,7 +605,7 @@ Vec3 WTURBULENCE::WVelocity(Vec3 orgPos) ////////////////////////////////////////////////////////////////////////////////////////// // Evaluate derivatives with Jacobian ////////////////////////////////////////////////////////////////////////////////////////// -Vec3 WTURBULENCE::WVelocityWithJacobian(Vec3 orgPos, float* xUnwarped, float* yUnwarped, float* zUnwarped) +Vec3 WTURBULENCE::WVelocityWithJacobian(const Vec3& orgPos, float* xUnwarped, float* yUnwarped, float* zUnwarped) { // arbitrarily offset evaluation points const Vec3 p1 = orgPos + Vec3(NOISE_TILE_SIZE/2.0,0,0); diff --git a/intern/smoke/intern/WTURBULENCE.h b/intern/smoke/intern/WTURBULENCE.h index 36635325f62..a00a818527a 100644 --- a/intern/smoke/intern/WTURBULENCE.h +++ b/intern/smoke/intern/WTURBULENCE.h @@ -62,7 +62,7 @@ struct WTURBULENCE // evaluate wavelet noise function Vec3 WVelocity(Vec3 p); - Vec3 WVelocityWithJacobian(Vec3 p, float* xUnwarped, float* yUnwarped, float* zUnwarped); + Vec3 WVelocityWithJacobian(const Vec3& p, float* xUnwarped, float* yUnwarped, float* zUnwarped); // access functions inline float* getDensityBig() { return _densityBig; } -- cgit v1.2.3 From 556b13f03e561b54d4f0186e207f080c786f8b66 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 14 Nov 2017 22:47:42 +0100 Subject: Fix T53309: Remove default 'Clear loc/rot/scale delta transform' shortcuts. The loc one (shift-alt-G) was same as 'remove selected from active group' action... Clear delta transform is not a common operation, so we can live without a default shortcut for it. Note that using same key (G) in same space for two completely different kind of operations is probably a rather bad thing, nice topic for future keymap work. ;) Probably nice to have in 2.79a. --- release/datafiles/locale | 2 +- release/scripts/addons | 2 +- release/scripts/addons_contrib | 2 +- source/blender/editors/object/object_ops.c | 7 ------- source/tools | 2 +- 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/release/datafiles/locale b/release/datafiles/locale index c93ed11a47b..b3d9c97f487 160000 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit c93ed11a47b3016cf59711ec16de2e2e94c30e99 +Subproject commit b3d9c97f487bff8b2423c903c14204ba5ca21a83 diff --git a/release/scripts/addons b/release/scripts/addons index 371960484a3..5b02e6e1acc 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 371960484a38fc64e0a2635170a41a0d8ab2f6bd +Subproject commit 5b02e6e1acc4c3cf4822607ab33f48d7cffecbd3 diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib index a8515cfdfe9..c3991195ad6 160000 --- a/release/scripts/addons_contrib +++ b/release/scripts/addons_contrib @@ -1 +1 @@ -Subproject commit a8515cfdfe9a98127b592f36fcbe51b7e23b969a +Subproject commit c3991195ad6eac741db27dc9e8905efb224f219d diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 5fe5a884354..9b9f77a1dbb 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -374,13 +374,6 @@ void ED_keymap_object(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "OBJECT_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "clear_delta", false); - kmi = WM_keymap_add_item(keymap, "OBJECT_OT_location_clear", GKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "clear_delta", true); - kmi = WM_keymap_add_item(keymap, "OBJECT_OT_rotation_clear", RKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "clear_delta", true); - kmi = WM_keymap_add_item(keymap, "OBJECT_OT_scale_clear", SKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "clear_delta", true); - WM_keymap_verify_item(keymap, "OBJECT_OT_origin_clear", OKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_clear", HKEY, KM_PRESS, KM_ALT, 0); diff --git a/source/tools b/source/tools index b11375e8906..9ea62ef860c 160000 --- a/source/tools +++ b/source/tools @@ -1 +1 @@ -Subproject commit b11375e89061303401376f7aeae42ac2fd64692a +Subproject commit 9ea62ef860cde8eb313b74cd1b23ca5a0734eefe -- cgit v1.2.3