From 692aeb6fe0e4314a17cf15c7252d2bfa21a1c9c6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Apr 2018 15:39:43 +0200 Subject: Cleanup: newlines left in messages --- source/blender/python/intern/bpy_rna.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 27eb1431295..baaae066b4b 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1422,8 +1422,8 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val) /* prefer not fail silently in case of api errors, maybe disable it later */ CLOG_WARN(BPY_LOG_RNA, - "Current value \"%d\" " - "matches no enum in '%s', '%s', '%s'\n", + "current value '%d' " + "matches no enum in '%s', '%s', '%s'", val, RNA_struct_identifier(ptr->type), ptr_name, RNA_property_identifier(prop)); @@ -6600,7 +6600,7 @@ static PyObject *pyrna_srna_ExternalType(StructRNA *srna) if (bpy_types == NULL) { PyErr_Print(); PyErr_Clear(); - CLOG_ERROR(BPY_LOG_RNA, "failed to find 'bpy_types' module\n"); + CLOG_ERROR(BPY_LOG_RNA, "failed to find 'bpy_types' module"); return NULL; } bpy_types_dict = PyModule_GetDict(bpy_types); /* borrow */ @@ -6618,7 +6618,7 @@ static PyObject *pyrna_srna_ExternalType(StructRNA *srna) PyObject *tp_slots = PyDict_GetItem(((PyTypeObject *)newclass)->tp_dict, bpy_intern_str___slots__); if (tp_slots == NULL) { - CLOG_ERROR(BPY_LOG_RNA, "expected class '%s' to have __slots__ defined, see bpy_types.py\n", idname); + CLOG_ERROR(BPY_LOG_RNA, "expected class '%s' to have __slots__ defined, see bpy_types.py", idname); newclass = NULL; } else if (PyTuple_GET_SIZE(tp_bases)) { @@ -6628,12 +6628,12 @@ static PyObject *pyrna_srna_ExternalType(StructRNA *srna) char pyob_info[256]; PyC_ObSpitStr(pyob_info, sizeof(pyob_info), base_compare); CLOG_ERROR(BPY_LOG_RNA, - "incorrect subclassing of SRNA '%s', expected '%s', see bpy_types.py\n", + "incorrect subclassing of SRNA '%s', expected '%s', see bpy_types.py", idname, pyob_info); newclass = NULL; } else { - CLOG_INFO(BPY_LOG_RNA, 2, "SRNA sub-classed: '%s'\n", idname); + CLOG_INFO(BPY_LOG_RNA, 2, "SRNA sub-classed: '%s'", idname); } } } @@ -6731,7 +6731,7 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna) } else { /* this should not happen */ - CLOG_ERROR(BPY_LOG_RNA, "error registering '%s'", idname); + CLOG_ERROR(BPY_LOG_RNA, "failed to register '%s'", idname); PyErr_Print(); PyErr_Clear(); } @@ -7603,7 +7603,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param py_class = RNA_struct_py_type_get(ptr->type); /* rare case. can happen when registering subclasses */ if (py_class == NULL) { - CLOG_WARN(BPY_LOG_RNA, "unable to get Python class for rna struct '%.200s'\n", RNA_struct_identifier(ptr->type)); + CLOG_WARN(BPY_LOG_RNA, "unable to get Python class for rna struct '%.200s'", RNA_struct_identifier(ptr->type)); return -1; } -- cgit v1.2.3 From 888a04c7e4e6002ac7d757fdb6d443561de696dd Mon Sep 17 00:00:00 2001 From: Milan Jaros Date: Mon, 2 Apr 2018 16:11:11 +0200 Subject: Build: fixes for the Intel compiler versions 2016, 2017, 2018. Differential Revision: https://developer.blender.org/D3109 --- CMakeLists.txt | 4 +-- build_files/cmake/macros.cmake | 2 +- intern/cycles/CMakeLists.txt | 48 +++++++++++++++++++++++++++++ intern/cycles/util/util_types_float4.h | 1 - intern/cycles/util/util_types_float4_impl.h | 5 --- source/blender/blenkernel/intern/displist.c | 5 ++- source/blender/blenlib/BLI_utildefines.h | 2 +- 7 files changed, 56 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 212587d6d08..566754d4883 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1496,8 +1496,8 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare) # disable numbered, false positives - set(C_WARNINGS "${C_WARNINGS} -wd188,186,144,913,556") - set(CXX_WARNINGS "${CXX_WARNINGS} -wd188,186,144,913,556") + set(C_WARNINGS "${C_WARNINGS} -wd188,186,144,913,556,858,597,177,1292,167,279,592,94,2722,3199") + set(CXX_WARNINGS "${CXX_WARNINGS} -wd188,186,144,913,556,858,597,177,1292,167,279,592,94,2722,3199") elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC") # most msvc warnings are C & C++ set(_WARNINGS diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index d159bde845d..107b29e0cc8 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -807,7 +807,7 @@ macro(TEST_SSE_SUPPORT endif() elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") set(${_sse_flags} "") # icc defaults to -msse - set(${_sse2_flags} "-msse2") + set(${_sse2_flags} "") # icc defaults to -msse2 else() message(WARNING "SSE flags for this compiler: '${CMAKE_C_COMPILER_ID}' not known") set(${_sse_flags}) diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt index 9df1e91e239..c3305ac3dd8 100644 --- a/intern/cycles/CMakeLists.txt +++ b/intern/cycles/CMakeLists.txt @@ -104,6 +104,54 @@ elseif(CMAKE_COMPILER_IS_GNUCC OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CYCLES_KERNEL_FLAGS}") +elseif(WIN32 AND CMAKE_CXX_COMPILER_ID MATCHES "Intel") + check_cxx_compiler_flag(/QxSSE2 CXX_HAS_SSE) + check_cxx_compiler_flag(/arch:AVX CXX_HAS_AVX) + check_cxx_compiler_flag(/QxCORE-AVX2 CXX_HAS_AVX2) + + if(CXX_HAS_SSE) + set(CYCLES_SSE2_KERNEL_FLAGS "/QxSSE2") + set(CYCLES_SSE3_KERNEL_FLAGS "/QxSSSE3") + set(CYCLES_SSE41_KERNEL_FLAGS "/QxSSE4.1") + + if(CXX_HAS_AVX) + set(CYCLES_AVX_KERNEL_FLAGS "/arch:AVX") + endif() + + if(CXX_HAS_AVX2) + set(CYCLES_AVX2_KERNEL_FLAGS "/QxCORE-AVX2") + endif() + endif() +elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel") + if(APPLE) + # ICC does not support SSE2 flag on MacOSX + check_cxx_compiler_flag(-xssse3 CXX_HAS_SSE) + else() + check_cxx_compiler_flag(-xsse2 CXX_HAS_SSE) + endif() + + check_cxx_compiler_flag(-xavx CXX_HAS_AVX) + check_cxx_compiler_flag(-xcore-avx2 CXX_HAS_AVX2) + + if(CXX_HAS_SSE) + if(APPLE) + # ICC does not support SSE2 flag on MacOSX + set(CYCLES_SSE2_KERNEL_FLAGS "-xssse3") + else() + set(CYCLES_SSE2_KERNEL_FLAGS "-xsse2") + endif() + + set(CYCLES_SSE3_KERNEL_FLAGS "-xssse3") + set(CYCLES_SSE41_KERNEL_FLAGS "-xsse4.1") + + if(CXX_HAS_AVX) + set(CYCLES_AVX_KERNEL_FLAGS "-xavx") + endif() + + if(CXX_HAS_AVX2) + set(CYCLES_AVX2_KERNEL_FLAGS "-xcore-avx2") + endif() + endif() endif() if(CXX_HAS_SSE) diff --git a/intern/cycles/util/util_types_float4.h b/intern/cycles/util/util_types_float4.h index a7d9abe1b95..154391f6881 100644 --- a/intern/cycles/util/util_types_float4.h +++ b/intern/cycles/util/util_types_float4.h @@ -34,7 +34,6 @@ struct ccl_try_align(16) float4 { }; __forceinline float4(); - __forceinline float4(const float4& a); __forceinline explicit float4(const __m128& a); __forceinline operator const __m128&(void) const; diff --git a/intern/cycles/util/util_types_float4_impl.h b/intern/cycles/util/util_types_float4_impl.h index ff3ec4d4ecf..09f45f47d38 100644 --- a/intern/cycles/util/util_types_float4_impl.h +++ b/intern/cycles/util/util_types_float4_impl.h @@ -33,11 +33,6 @@ __forceinline float4::float4() { } -__forceinline float4::float4(const float4& a) - : m128(a.m128) -{ -} - __forceinline float4::float4(const __m128& a) : m128(a) { diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 2a300cbe47b..8433634f749 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -297,7 +297,10 @@ bool BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, i } /* ****************** make displists ********************* */ - +#ifdef __INTEL_COMPILER +/* ICC with the optimization -02 causes crashes. */ +# pragma intel optimization_level 1 +#endif static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, const bool for_render, const bool use_render_resolution) { diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 11c8a586784..46b3748c7ce 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -411,7 +411,7 @@ extern "C" { } (void)0 /* assuming a static array */ -#if defined(__GNUC__) && !defined(__cplusplus) && !defined(__clang__) +#if defined(__GNUC__) && !defined(__cplusplus) && !defined(__clang__) && !defined(__INTEL_COMPILER) # define ARRAY_SIZE(arr) \ ((sizeof(struct {int isnt_array : ((const void *)&(arr) == &(arr)[0]);}) * 0) + \ (sizeof(arr) / sizeof(*(arr)))) -- cgit v1.2.3 From 4041385ddd68460d4dd04825431c4e2495c0c2a9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Apr 2018 17:30:35 +0200 Subject: Cleanup: remove redundant imbuf return values Some functions always returned the input argument which was never used. This made code read as if there might be a leak. Now return a boolean (true the imbuf is modified). --- source/blender/imbuf/IMB_imbuf.h | 6 ++--- source/blender/imbuf/intern/scaling.c | 40 +++++++++++++++++++------------- source/blender/imbuf/intern/writeimage.c | 19 +++++++-------- 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index a7f793b5b11..a0fc273a746 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -380,13 +380,13 @@ struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1); * * \attention Defined in scaling.c */ -struct ImBuf *IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy); +bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy); /** * * \attention Defined in scaling.c */ -struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy); +bool IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy); /** * @@ -399,7 +399,7 @@ void IMB_scaleImBuf_threaded(struct ImBuf *ibuf, unsigned int newx, unsigned int * \attention Defined in writeimage.c */ short IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags); -struct ImBuf *IMB_prepare_write_ImBuf(const bool isfloat, struct ImBuf *ibuf); +bool IMB_prepare_write_ImBuf(const bool isfloat, struct ImBuf *ibuf); /** * diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index 504b59b2b1d..ff92ce15811 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -1550,12 +1550,17 @@ static void scalefast_Z_ImBuf(ImBuf *ibuf, int newx, int newy) } } -struct ImBuf *IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy) +/** + * Return true if \a ibuf is modified. + */ +bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy) { - if (ibuf == NULL) return (NULL); - if (ibuf->rect == NULL && ibuf->rect_float == NULL) return (ibuf); + if (ibuf == NULL) return false; + if (ibuf->rect == NULL && ibuf->rect_float == NULL) return false; - if (newx == ibuf->x && newy == ibuf->y) { return ibuf; } + if (newx == ibuf->x && newy == ibuf->y) { + return false; + } /* scaleup / scaledown functions below change ibuf->x and ibuf->y * so we first scale the Z-buffer (if any) */ @@ -1564,7 +1569,7 @@ struct ImBuf *IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int /* try to scale common cases in a fast way */ /* disabled, quality loss is unacceptable, see report #18609 (ton) */ if (0 && q_scale_linear_interpolation(ibuf, newx, newy)) { - return ibuf; + return true; } if (newx && (newx < ibuf->x)) scaledownx(ibuf, newx); @@ -1572,14 +1577,17 @@ struct ImBuf *IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int if (newx && (newx > ibuf->x)) scaleupx(ibuf, newx); if (newy && (newy > ibuf->y)) scaleupy(ibuf, newy); - return(ibuf); + return true; } struct imbufRGBA { float r, g, b, a; }; -struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy) +/** + * Return true if \a ibuf is modified. + */ +bool IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy) { unsigned int *rect, *_newrect, *newrect; struct imbufRGBA *rectf, *_newrectf, *newrectf; @@ -1590,16 +1598,16 @@ struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned rect = NULL; _newrect = NULL; newrect = NULL; rectf = NULL; _newrectf = NULL; newrectf = NULL; - if (ibuf == NULL) return(NULL); + if (ibuf == NULL) return false; if (ibuf->rect) do_rect = true; if (ibuf->rect_float) do_float = true; - if (do_rect == false && do_float == false) return(ibuf); + if (do_rect == false && do_float == false) return false; - if (newx == ibuf->x && newy == ibuf->y) return(ibuf); + if (newx == ibuf->x && newy == ibuf->y) return false; if (do_rect) { _newrect = MEM_mallocN(newx * newy * sizeof(int), "scalefastimbuf"); - if (_newrect == NULL) return(ibuf); + if (_newrect == NULL) return false; newrect = _newrect; } @@ -1607,7 +1615,7 @@ struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned _newrectf = MEM_mallocN(newx * newy * sizeof(float) * 4, "scalefastimbuf f"); if (_newrectf == NULL) { if (_newrect) MEM_freeN(_newrect); - return(ibuf); + return false; } newrectf = _newrectf; } @@ -1643,18 +1651,18 @@ struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned ibuf->mall |= IB_rect; ibuf->rect = _newrect; } - + if (do_float) { imb_freerectfloatImBuf(ibuf); ibuf->mall |= IB_rectfloat; ibuf->rect_float = (float *)_newrectf; } - + scalefast_Z_ImBuf(ibuf, newx, newy); - + ibuf->x = newx; ibuf->y = newy; - return(ibuf); + return true; } /* ******** threaded scaling ******** */ diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c index 84ec2534e7f..c019b0b1363 100644 --- a/source/blender/imbuf/intern/writeimage.c +++ b/source/blender/imbuf/intern/writeimage.c @@ -46,7 +46,7 @@ #include "IMB_colormanagement.h" #include "IMB_colormanagement_intern.h" -static ImBuf *prepare_write_imbuf(const ImFileType *type, ImBuf *ibuf) +static bool prepare_write_imbuf(const ImFileType *type, ImBuf *ibuf) { return IMB_prepare_write_ImBuf((type->flag & IM_FTYPE_FLOAT), ibuf); } @@ -64,15 +64,11 @@ short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags) for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) { if (type->save && type->ftype(type, ibuf)) { - ImBuf *write_ibuf; short result = false; - write_ibuf = prepare_write_imbuf(type, ibuf); + prepare_write_imbuf(type, ibuf); - result = type->save(write_ibuf, name, flags); - - if (write_ibuf != ibuf) - IMB_freeImBuf(write_ibuf); + result = type->save(ibuf, name, flags); return result; } @@ -83,9 +79,9 @@ short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags) return false; } -ImBuf *IMB_prepare_write_ImBuf(const bool isfloat, ImBuf *ibuf) +bool IMB_prepare_write_ImBuf(const bool isfloat, ImBuf *ibuf) { - ImBuf *write_ibuf = ibuf; + bool changed = false; if (isfloat) { /* pass */ @@ -94,8 +90,11 @@ ImBuf *IMB_prepare_write_ImBuf(const bool isfloat, ImBuf *ibuf) if (ibuf->rect == NULL && ibuf->rect_float) { ibuf->rect_colorspace = colormanage_colorspace_get_roled(COLOR_ROLE_DEFAULT_BYTE); IMB_rect_from_float(ibuf); + if (ibuf->rect != NULL) { + changed = true; + } } } - return write_ibuf; + return changed; } -- cgit v1.2.3 From 71d7d6cd8c431b7f4fac8d65a4eaedf3cff6c8f6 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 2 Apr 2018 18:55:10 +0200 Subject: Build: add WITH_OPENVDB_3_ABI_COMPATIBLE option. Better fix for T54457. It seems Debian compiles OpenVDB without ABI 3 compatibility, while Arch does enable it as is the default in the OpeVDB CMake build system. So now there's an option that the distribution can set depending on how they compile their OpenVDB package. --- CMakeLists.txt | 2 ++ intern/openvdb/CMakeLists.txt | 7 ++++++- intern/openvdb/intern/openvdb_writer.cc | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 566754d4883..f0930866d64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -251,6 +251,8 @@ option(WITH_OPENSUBDIV "Enable OpenSubdiv for surface subdivision" _init_OPEN option(WITH_OPENVDB "Enable features relying on OpenVDB" OFF) option(WITH_OPENVDB_BLOSC "Enable blosc compression for OpenVDB, only enable if OpenVDB was built with blosc support" OFF) +option(WITH_OPENVDB_3_ABI_COMPATIBLE "Assume OpenVDB library has been compiled with version 3 ABI compatibility" OFF) +mark_as_advanced(WITH_OPENVDB_3_ABI_COMPATIBLE) # GHOST Windowing Library Options option(WITH_GHOST_DEBUG "Enable debugging output for the GHOST library" OFF) diff --git a/intern/openvdb/CMakeLists.txt b/intern/openvdb/CMakeLists.txt index 4b872f25d45..f666dc78e75 100644 --- a/intern/openvdb/CMakeLists.txt +++ b/intern/openvdb/CMakeLists.txt @@ -38,9 +38,14 @@ set(SRC if(WITH_OPENVDB) add_definitions( -DWITH_OPENVDB - -DOPENVDB_3_ABI_COMPATIBLE ) + if(WITH_OPENVDB_3_ABI_COMPATIBLE) + add_definitions( + -DOPENVDB_3_ABI_COMPATIBLE + ) + endif() + list(APPEND INC_SYS ${BOOST_INCLUDE_DIR} ${TBB_INCLUDE_DIRS} diff --git a/intern/openvdb/intern/openvdb_writer.cc b/intern/openvdb/intern/openvdb_writer.cc index b83691ac7de..bedcfe65552 100644 --- a/intern/openvdb/intern/openvdb_writer.cc +++ b/intern/openvdb/intern/openvdb_writer.cc @@ -45,7 +45,7 @@ void OpenVDBWriter::insert(const openvdb::GridBase::Ptr &grid) void OpenVDBWriter::insert(const openvdb::GridBase &grid) { -#if (OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER >= 3) +#if (OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER <= 3) || defined(OPENVDB_3_ABI_COMPATIBLE) m_grids->push_back(grid.copyGrid()); #else m_grids->push_back(grid.copyGridWithNewTree()); -- cgit v1.2.3 From 31f2a6755db5bf9439e51701eddcadfca773459a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Apr 2018 19:48:34 +0200 Subject: PyAPI: Add PyC_Tuple_Pack_F64 utility --- source/blender/python/generic/py_capi_utils.c | 9 +++++++++ source/blender/python/generic/py_capi_utils.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index 62ef1b773c7..6f265b2ae87 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -146,6 +146,15 @@ PyObject *PyC_Tuple_PackArray_F32(const float *array, uint len) return tuple; } +PyObject *PyC_Tuple_PackArray_F64(const double *array, uint len) +{ + PyObject *tuple = PyTuple_New(len); + for (uint i = 0; i < len; i++) { + PyTuple_SET_ITEM(tuple, i, PyFloat_FromDouble(array[i])); + } + return tuple; +} + PyObject *PyC_Tuple_PackArray_I32(const int *array, uint len) { PyObject *tuple = PyTuple_New(len); diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h index e4d6d3fe557..fe7a046d99c 100644 --- a/source/blender/python/generic/py_capi_utils.h +++ b/source/blender/python/generic/py_capi_utils.h @@ -51,12 +51,15 @@ int PyC_AsArray( const PyTypeObject *type, const bool is_double, const char *error_prefix); PyObject *PyC_Tuple_PackArray_F32(const float *array, uint len); +PyObject *PyC_Tuple_PackArray_F64(const double *array, uint len); PyObject *PyC_Tuple_PackArray_I32(const int *array, uint len); PyObject *PyC_Tuple_PackArray_I32FromBool(const int *array, uint len); PyObject *PyC_Tuple_PackArray_Bool(const bool *array, uint len); #define PyC_Tuple_Pack_F32(...) \ PyC_Tuple_PackArray_F32(((const float []){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__)) +#define PyC_Tuple_Pack_F64(...) \ + PyC_Tuple_PackArray_F64(((const double []){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__)) #define PyC_Tuple_Pack_I32(...) \ PyC_Tuple_PackArray_I32(((const int []){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__)) #define PyC_Tuple_Pack_I32FromBool(...) \ -- cgit v1.2.3 From a0eb54142f244641041b0cb317cd09171105ad72 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Apr 2018 08:35:42 +0200 Subject: Undo: replace global access w/ ED_undo_stack_get While I'd like to avoid using this too much since the operator system should handle. It's less trouble than accessing it inline each time. --- source/blender/editors/include/ED_undo.h | 2 ++ source/blender/editors/physics/particle_edit_undo.c | 7 +++---- source/blender/editors/sculpt_paint/paint_curve_undo.c | 11 +++++------ source/blender/editors/sculpt_paint/paint_image_undo.c | 14 +++++++------- source/blender/editors/sculpt_paint/sculpt_undo.c | 15 +++++++-------- source/blender/editors/undo/ed_undo.c | 14 ++++++++++++++ 6 files changed, 38 insertions(+), 25 deletions(-) diff --git a/source/blender/editors/include/ED_undo.h b/source/blender/editors/include/ED_undo.h index 044d69cfced..b3814ab5899 100644 --- a/source/blender/editors/include/ED_undo.h +++ b/source/blender/editors/include/ED_undo.h @@ -51,6 +51,8 @@ void ED_undo_operator_repeat_cb_evt(struct bContext *C, void *arg_op, int arg bool ED_undo_is_valid(const struct bContext *C, const char *undoname); +struct UndoStack *ED_undo_stack_get(void); + /* undo_system_types.c */ void ED_undosys_type_init(void); void ED_undosys_type_free(void); diff --git a/source/blender/editors/physics/particle_edit_undo.c b/source/blender/editors/physics/particle_edit_undo.c index 329658a56e1..6e212174f39 100644 --- a/source/blender/editors/physics/particle_edit_undo.c +++ b/source/blender/editors/physics/particle_edit_undo.c @@ -45,16 +45,15 @@ #include "BLI_utildefines.h" #include "BKE_depsgraph.h" -#include "BKE_global.h" #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_context.h" -#include "BKE_main.h" #include "BKE_undo_system.h" #include "ED_object.h" #include "ED_particle.h" #include "ED_physics.h" +#include "ED_undo.h" #include "particle_edit_utildefines.h" @@ -304,10 +303,10 @@ void ED_particle_undosys_type(UndoType *ut) void PE_undo_push(struct Scene *scene, const char *str) { - wmWindowManager *wm = G.main->wm.first; + UndoStack *ustack = ED_undo_stack_get(); bContext *C_temp = CTX_create(); CTX_data_scene_set(C_temp, scene); - BKE_undosys_step_push_with_type(wm->undo_stack, C_temp, str, BKE_UNDOSYS_TYPE_PARTICLE); + BKE_undosys_step_push_with_type(ustack, C_temp, str, BKE_UNDOSYS_TYPE_PARTICLE); CTX_free(C_temp); } diff --git a/source/blender/editors/sculpt_paint/paint_curve_undo.c b/source/blender/editors/sculpt_paint/paint_curve_undo.c index d5b7496fa3e..77f06180df6 100644 --- a/source/blender/editors/sculpt_paint/paint_curve_undo.c +++ b/source/blender/editors/sculpt_paint/paint_curve_undo.c @@ -34,11 +34,10 @@ #include "BKE_context.h" #include "BKE_paint.h" -#include "BKE_global.h" -#include "BKE_main.h" #include "BKE_undo_system.h" #include "ED_paint.h" +#include "ED_undo.h" #include "WM_api.h" #include "WM_types.h" @@ -155,15 +154,15 @@ void ED_paintcurve_undosys_type(UndoType *ut) void ED_paintcurve_undo_push_begin(const char *name) { + UndoStack *ustack = ED_undo_stack_get(); bContext *C = NULL; /* special case, we never read from this. */ - wmWindowManager *wm = G.main->wm.first; - BKE_undosys_step_push_init_with_type(wm->undo_stack, C, name, BKE_UNDOSYS_TYPE_PAINTCURVE); + BKE_undosys_step_push_init_with_type(ustack, C, name, BKE_UNDOSYS_TYPE_PAINTCURVE); } void ED_paintcurve_undo_push_end(void) { - wmWindowManager *wm = G.main->wm.first; /* XXX, avoids adding extra arg. */ - BKE_undosys_step_push(wm->undo_stack, NULL, NULL); + UndoStack *ustack = ED_undo_stack_get(); + BKE_undosys_step_push(ustack, NULL, NULL); } /** \} */ diff --git a/source/blender/editors/sculpt_paint/paint_image_undo.c b/source/blender/editors/sculpt_paint/paint_image_undo.c index 9d1987943a5..554ddf92150 100644 --- a/source/blender/editors/sculpt_paint/paint_image_undo.c +++ b/source/blender/editors/sculpt_paint/paint_image_undo.c @@ -41,10 +41,10 @@ #include "BKE_depsgraph.h" #include "BKE_image.h" #include "BKE_main.h" -#include "BKE_global.h" #include "BKE_undo_system.h" #include "ED_paint.h" +#include "ED_undo.h" #include "GPU_draw.h" @@ -358,15 +358,15 @@ static void image_undo_free_list(ListBase *lb) void ED_image_undo_push_begin(const char *name) { + UndoStack *ustack = ED_undo_stack_get(); bContext *C = NULL; /* special case, we never read from this. */ - wmWindowManager *wm = G.main->wm.first; - BKE_undosys_step_push_init_with_type(wm->undo_stack, C, name, BKE_UNDOSYS_TYPE_IMAGE); + BKE_undosys_step_push_init_with_type(ustack, C, name, BKE_UNDOSYS_TYPE_IMAGE); } void ED_image_undo_push_end(void) { - wmWindowManager *wm = G.main->wm.first; /* XXX, avoids adding extra arg. */ - BKE_undosys_step_push(wm->undo_stack, NULL, NULL); + UndoStack *ustack = ED_undo_stack_get(); + BKE_undosys_step_push(ustack, NULL, NULL); } static void image_undo_invalidate(void) @@ -486,8 +486,8 @@ ListBase *ED_image_undosys_step_get_tiles(UndoStep *us_p) ListBase *ED_image_undo_get_tiles(void) { - wmWindowManager *wm = G.main->wm.first; /* XXX, avoids adding extra arg. */ - UndoStep *us = BKE_undosys_stack_init_or_active_with_type(wm->undo_stack, BKE_UNDOSYS_TYPE_IMAGE); + UndoStack *ustack = ED_undo_stack_get(); + UndoStep *us = BKE_undosys_stack_init_or_active_with_type(ustack, BKE_UNDOSYS_TYPE_IMAGE); return ED_image_undosys_step_get_tiles(us); } diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 4e2bcab9f36..e90d2b58c0c 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -59,8 +59,6 @@ #include "BKE_key.h" #include "BKE_mesh.h" #include "BKE_subsurf.h" -#include "BKE_global.h" -#include "BKE_main.h" #include "BKE_undo_system.h" #include "WM_api.h" @@ -71,6 +69,7 @@ #include "ED_paint.h" #include "ED_object.h" #include "ED_sculpt.h" +#include "ED_undo.h" #include "bmesh.h" #include "paint_intern.h" @@ -974,9 +973,9 @@ SculptUndoNode *sculpt_undo_push_node( void sculpt_undo_push_begin(const char *name) { + UndoStack *ustack = ED_undo_stack_get(); bContext *C = NULL; /* special case, we never read from this. */ - wmWindowManager *wm = G.main->wm.first; - BKE_undosys_step_push_init_with_type(wm->undo_stack, C, name, BKE_UNDOSYS_TYPE_SCULPT); + BKE_undosys_step_push_init_with_type(ustack, C, name, BKE_UNDOSYS_TYPE_SCULPT); } void sculpt_undo_push_end(void) @@ -995,8 +994,8 @@ void sculpt_undo_push_end(void) BKE_pbvh_node_layer_disp_free(unode->node); } - wmWindowManager *wm = G.main->wm.first; /* XXX, avoids adding extra arg. */ - BKE_undosys_step_push(wm->undo_stack, NULL, NULL); + UndoStack *ustack = ED_undo_stack_get(); + BKE_undosys_step_push(ustack, NULL, NULL); } /* -------------------------------------------------------------------- */ @@ -1083,8 +1082,8 @@ static UndoSculpt *sculpt_undosys_step_get_nodes(UndoStep *us_p) static UndoSculpt *sculpt_undo_get_nodes(void) { - wmWindowManager *wm = G.main->wm.first; /* XXX, avoids adding extra arg. */ - UndoStep *us = BKE_undosys_stack_init_or_active_with_type(wm->undo_stack, BKE_UNDOSYS_TYPE_SCULPT); + UndoStack *ustack = ED_undo_stack_get(); + UndoStep *us = BKE_undosys_stack_init_or_active_with_type(ustack, BKE_UNDOSYS_TYPE_SCULPT); return sculpt_undosys_step_get_nodes(us); } diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c index 691ba066bf9..4f62e38dc0b 100644 --- a/source/blender/editors/undo/ed_undo.c +++ b/source/blender/editors/undo/ed_undo.c @@ -42,6 +42,7 @@ #include "BKE_blender_undo.h" #include "BKE_context.h" #include "BKE_global.h" +#include "BKE_main.h" #include "BKE_screen.h" #include "BKE_undo_system.h" @@ -190,6 +191,19 @@ bool ED_undo_is_valid(const bContext *C, const char *undoname) return BKE_undosys_stack_has_undo(wm->undo_stack, undoname); } +/** + * Ideally we wont access the stack directly, + * this is needed for modes which handle undo themselves (bypassing #ED_undo_push). + * + * Using global isn't great, this just avoids doing inline, + * causing 'BKE_global.h' & 'BKE_main.h' includes. + */ +UndoStack *ED_undo_stack_get(void) +{ + wmWindowManager *wm = G.main->wm.first; + return wm->undo_stack; +} + /** \} */ /* -------------------------------------------------------------------- */ -- cgit v1.2.3 From 72ae0e1b6d3057d92420f7ccff88592946e61937 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Apr 2018 08:42:12 +0200 Subject: Cleanup: editor BKE_main includes --- source/blender/editors/gpencil/gpencil_paint.c | 1 - source/blender/editors/gpencil/gpencil_undo.c | 1 - source/blender/editors/mesh/editmesh_extrude.c | 1 - source/blender/editors/mesh/editmesh_utils.c | 1 - source/blender/editors/physics/physics_fluid.c | 1 - source/blender/editors/space_action/action_buttons.c | 1 - source/blender/editors/space_action/action_data.c | 1 - source/blender/editors/space_action/action_edit.c | 1 - source/blender/editors/space_text/text_undo.c | 1 - 9 files changed, 9 deletions(-) diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index f54356dfed3..84b3ddccf77 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -46,7 +46,6 @@ #include "PIL_time.h" -#include "BKE_main.h" #include "BKE_paint.h" #include "BKE_gpencil.h" #include "BKE_context.h" diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c index 7a9ad2b32c0..202d7630ae0 100644 --- a/source/blender/editors/gpencil/gpencil_undo.c +++ b/source/blender/editors/gpencil/gpencil_undo.c @@ -45,7 +45,6 @@ #include "BKE_context.h" #include "BKE_global.h" #include "BKE_gpencil.h" -#include "BKE_main.h" #include "ED_gpencil.h" diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index 93049528146..78bc361b222 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -36,7 +36,6 @@ #include "BLI_listbase.h" #include "BKE_context.h" -#include "BKE_main.h" #include "BKE_object.h" #include "BKE_report.h" #include "BKE_editmesh.h" diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index dceffd462ff..41e8a963383 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -44,7 +44,6 @@ #include "BKE_DerivedMesh.h" #include "BKE_context.h" #include "BKE_depsgraph.h" -#include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_mesh_mapping.h" #include "BKE_report.h" diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 56551a08641..ce1e9d5cf6a 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -48,7 +48,6 @@ #include "BKE_context.h" #include "BKE_customdata.h" #include "BKE_fluidsim.h" -#include "BKE_main.h" #include "BKE_modifier.h" #include "BKE_object.h" #include "BKE_report.h" diff --git a/source/blender/editors/space_action/action_buttons.c b/source/blender/editors/space_action/action_buttons.c index 0dec95d4340..ba6cef38acd 100644 --- a/source/blender/editors/space_action/action_buttons.c +++ b/source/blender/editors/space_action/action_buttons.c @@ -50,7 +50,6 @@ #include "BKE_curve.h" #include "BKE_depsgraph.h" #include "BKE_fcurve.h" -#include "BKE_main.h" #include "BKE_screen.h" #include "BKE_unit.h" diff --git a/source/blender/editors/space_action/action_data.c b/source/blender/editors/space_action/action_data.c index ca8dbbce1a1..f1153b5bed0 100644 --- a/source/blender/editors/space_action/action_data.c +++ b/source/blender/editors/space_action/action_data.c @@ -56,7 +56,6 @@ #include "BKE_fcurve.h" #include "BKE_library.h" #include "BKE_key.h" -#include "BKE_main.h" #include "BKE_nla.h" #include "BKE_scene.h" #include "BKE_context.h" diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 72b1245ca8a..1c15a7c5950 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -59,7 +59,6 @@ #include "BKE_global.h" #include "BKE_library.h" #include "BKE_key.h" -#include "BKE_main.h" #include "BKE_nla.h" #include "BKE_context.h" #include "BKE_report.h" diff --git a/source/blender/editors/space_text/text_undo.c b/source/blender/editors/space_text/text_undo.c index 4f62c409d58..ef9cfccdc1c 100644 --- a/source/blender/editors/space_text/text_undo.c +++ b/source/blender/editors/space_text/text_undo.c @@ -38,7 +38,6 @@ #include "BKE_context.h" #include "BKE_library.h" -#include "BKE_main.h" #include "BKE_report.h" #include "BKE_text.h" #include "BKE_undo_system.h" -- cgit v1.2.3 From b3004d30f5d5060035c5f8ac4cb6338463872877 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Apr 2018 08:57:01 +0200 Subject: Undo: remove particle undo push Was only called on copy particle system which is already doing an undo push. --- source/blender/editors/include/ED_particle.h | 2 -- source/blender/editors/physics/particle_edit.c | 6 ------ source/blender/editors/physics/particle_edit_undo.c | 16 ---------------- source/blender/editors/physics/particle_object.c | 2 -- 4 files changed, 26 deletions(-) diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h index fa5abb8e1dd..4f6aa1cc702 100644 --- a/source/blender/editors/include/ED_particle.h +++ b/source/blender/editors/include/ED_particle.h @@ -65,7 +65,5 @@ void PE_deselect_all_visible(struct PTCacheEdit *edit); /* particle_edit_undo.c */ void ED_particle_undosys_type(struct UndoType *ut); -void PE_undo_push(struct Scene *scene, const char *str); - #endif /* __ED_PARTICLE_H__ */ diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index fce43fa6425..bdffaf31384 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -4377,12 +4377,6 @@ void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache, Partic if (psys && !cache) recalc_emitter_field(ob, psys); PE_update_object(scene, ob, 1); - - /* Causes issues, adding undo pushes while performing undo history. - * Seems not to like this isn't needed anyway - Campbell. */ -#if 0 - PE_undo_push(scene, "Original"); -#endif } } diff --git a/source/blender/editors/physics/particle_edit_undo.c b/source/blender/editors/physics/particle_edit_undo.c index 6e212174f39..ef0a2711fdd 100644 --- a/source/blender/editors/physics/particle_edit_undo.c +++ b/source/blender/editors/physics/particle_edit_undo.c @@ -53,7 +53,6 @@ #include "ED_object.h" #include "ED_particle.h" #include "ED_physics.h" -#include "ED_undo.h" #include "particle_edit_utildefines.h" @@ -296,18 +295,3 @@ void ED_particle_undosys_type(UndoType *ut) } /** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Utilities - * \{ */ - -void PE_undo_push(struct Scene *scene, const char *str) -{ - UndoStack *ustack = ED_undo_stack_get(); - bContext *C_temp = CTX_create(); - CTX_data_scene_set(C_temp, scene); - BKE_undosys_step_push_with_type(ustack, C_temp, str, BKE_UNDOSYS_TYPE_PARTICLE); - CTX_free(C_temp); -} - -/** \} */ diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 63b84df9fce..53a70abca05 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -940,8 +940,6 @@ static void copy_particle_edit(Scene *scene, Object *ob, ParticleSystem *psys, P recalc_lengths(edit); recalc_emitter_field(ob, psys); PE_update_object(scene, ob, true); - - PE_undo_push(scene, "Original"); } static void remove_particle_systems_from_object(Object *ob_to) -- cgit v1.2.3