From ebdb5490b3a63e37ac5638f8a06737cf34ba36d3 Mon Sep 17 00:00:00 2001 From: Antonioya Date: Wed, 10 Aug 2016 15:51:40 +0200 Subject: GPencil: Avoid segment fault if new stroke function is called without colorname --- source/blender/makesrna/intern/rna_gpencil.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 7424c190501..9476c964b40 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -482,7 +482,9 @@ static void rna_GPencil_stroke_point_pop(bGPDstroke *stroke, ReportList *reports static bGPDstroke *rna_GPencil_stroke_new(bGPDframe *frame, const char *colorname) { bGPDstroke *stroke = MEM_callocN(sizeof(bGPDstroke), "gp_stroke"); - strcpy(stroke->colorname, colorname); + if (colorname) { + strcpy(stroke->colorname, colorname); + } stroke->palcolor = NULL; stroke->flag |= GP_STROKE_RECALC_COLOR; BLI_addtail(&frame->strokes, stroke); -- cgit v1.2.3 From bbbc079a6c03b0df863ab0aae8b7838d4eb41cbb Mon Sep 17 00:00:00 2001 From: Lukas Stockner Date: Wed, 10 Aug 2016 17:17:46 +0200 Subject: Cycles: Correct maximum number of textures on pre-Kepler CUDA cards Commit c96ae81160ad added three data textures and therefore removed three image texture slots, but the value in util_textures.h wasn't updated. --- intern/cycles/util/util_texture.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/util/util_texture.h b/intern/cycles/util/util_texture.h index 2ef47283029..0cecfe91ea9 100644 --- a/intern/cycles/util/util_texture.h +++ b/intern/cycles/util/util_texture.h @@ -37,7 +37,7 @@ CCL_NAMESPACE_BEGIN /* CUDA (Geforce 4xx and 5xx) */ #define TEX_NUM_FLOAT4_CUDA 5 -#define TEX_NUM_BYTE4_CUDA 88 +#define TEX_NUM_BYTE4_CUDA 85 #define TEX_NUM_FLOAT_CUDA 0 #define TEX_NUM_BYTE_CUDA 0 #define TEX_NUM_HALF4_CUDA 0 -- cgit v1.2.3 From ef27d8ec5a7ce0370468171720d91426ea87d9d7 Mon Sep 17 00:00:00 2001 From: Lukas Stockner Date: Mon, 8 Aug 2016 21:09:12 +0200 Subject: Cycles Standalone: Add option to set the tile size from the command line Since the optimal values depend on the device used, this option doesn't make much sense in the XML. Therefore, it's now specified via the command line, just like the device itself. --- intern/cycles/app/cycles_standalone.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/intern/cycles/app/cycles_standalone.cpp b/intern/cycles/app/cycles_standalone.cpp index 726e9a51744..e8168bc15ff 100644 --- a/intern/cycles/app/cycles_standalone.cpp +++ b/intern/cycles/app/cycles_standalone.cpp @@ -375,6 +375,8 @@ static void options_parse(int argc, const char **argv) "--threads %d", &options.session_params.threads, "CPU Rendering Threads", "--width %d", &options.width, "Window width in pixel", "--height %d", &options.height, "Window height in pixel", + "--tile-width %d", &options.session_params.tile_size.x, "Tile width in pixels", + "--tile-height %d", &options.session_params.tile_size.y, "Tile height in pixels", "--list-devices", &list, "List information about all available devices", #ifdef WITH_CYCLES_LOGGING "--debug", &debug, "Enable debug logging", -- cgit v1.2.3 From 498b7bd7ce3411dff79b5acfd550c2126fe0b7ac Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 10 Aug 2016 19:18:53 +0200 Subject: Updated install_deps.sh to OSD 3.0.5 (and switch from git repo to download archive of sources). --- build_files/build_environment/install_deps.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index 7230fc47105..51928b82d8c 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -337,7 +337,7 @@ OSL_FORCE_REBUILD=false OSL_SKIP=false # OpenSubdiv needs to be compiled for now -OSD_VERSION="3.0.2" +OSD_VERSION="3.0.5" OSD_VERSION_MIN=$OSD_VERSION OSD_FORCE_BUILD=false OSD_FORCE_REBUILD=false @@ -739,7 +739,7 @@ OSL_SOURCE_REPO=( "https://github.com/Nazg-Gul/OpenShadingLanguage.git" ) OSL_SOURCE_REPO_UID="7d40ff5fe8e47b030042afb92d0e955f5aa96f48" OSL_SOURCE_REPO_BRANCH="blender-fixes" -OSD_USE_REPO=true +OSD_USE_REPO=false # Script foo to make the version string compliant with the archive name: # ${Varname//SearchForThisChar/ReplaceWithThisChar} OSD_SOURCE=( "https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v${OSD_VERSION//./_}.tar.gz" ) @@ -1907,7 +1907,7 @@ compile_OSD() { fi # To be changed each time we make edits that would modify the compiled result! - osd_magic=1 + osd_magic=2 _init_osd # Clean install if needed! -- cgit v1.2.3 From 82e65abfef34ea422299c0a40a6dab84813db556 Mon Sep 17 00:00:00 2001 From: Lukas Stockner Date: Wed, 10 Aug 2016 20:02:08 +0200 Subject: Cycles: Fix KernelIntegrator padding to 16-byte boundary --- intern/cycles/kernel/kernel_types.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index f3b10c21b9d..2ae42a83dc9 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -1120,7 +1120,8 @@ typedef struct KernelIntegrator { float volume_step_size; int volume_samples; - int pad; + int pad1; + int pad2; } KernelIntegrator; typedef struct KernelBVH { -- cgit v1.2.3 From 4d1bf1472ec6306bc405dc6ff322928e5cab6241 Mon Sep 17 00:00:00 2001 From: Mai Lavelle Date: Wed, 10 Aug 2016 14:06:43 -0400 Subject: Cycles Standalone: Fix building after microdisp changes --- intern/cycles/app/CMakeLists.txt | 3 +++ intern/cycles/app/cycles_xml.cpp | 14 +------------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/intern/cycles/app/CMakeLists.txt b/intern/cycles/app/CMakeLists.txt index 73dbf16a3d3..8cd499b7ca6 100644 --- a/intern/cycles/app/CMakeLists.txt +++ b/intern/cycles/app/CMakeLists.txt @@ -88,6 +88,9 @@ macro(cycles_target_link_libraries target) if(WITH_CYCLES_OSL) target_link_libraries(${target} ${OSL_LIBRARIES} ${LLVM_LIBRARIES}) endif() + if(WITH_CYCLES_OPENSUBDIV) + target_link_libraries(${target} ${OPENSUBDIV_LIBRARIES}) + endif() target_link_libraries( ${target} ${OPENIMAGEIO_LIBRARIES} diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp index 3d3aca33881..a54022268bb 100644 --- a/intern/cycles/app/cycles_xml.cpp +++ b/intern/cycles/app/cycles_xml.cpp @@ -57,14 +57,12 @@ struct XMLReadState : public XMLReader { Shader *shader; /* current shader */ string base; /* base path to current file*/ float dicing_rate; /* current dicing rate */ - Mesh::DisplacementMethod displacement_method; XMLReadState() : scene(NULL), smooth(false), shader(NULL), - dicing_rate(0.0f), - displacement_method(Mesh::DISPLACE_BUMP) + dicing_rate(0.0f) { tfm = transform_identity(); } @@ -405,8 +403,6 @@ static void xml_read_mesh(const XMLReadState& state, pugi::xml_node node) int shader = 0; bool smooth = state.smooth; - mesh->displacement_method = state.displacement_method; - /* read vertices and polygons, RIB style */ vector P; vector UV; @@ -653,14 +649,6 @@ static void xml_read_state(XMLReadState& state, pugi::xml_node node) state.smooth = true; else if(xml_equal_string(node, "interpolation", "flat")) state.smooth = false; - - /* read displacement method */ - if(xml_equal_string(node, "displacement_method", "true")) - state.displacement_method = Mesh::DISPLACE_TRUE; - else if(xml_equal_string(node, "displacement_method", "bump")) - state.displacement_method = Mesh::DISPLACE_BUMP; - else if(xml_equal_string(node, "displacement_method", "both")) - state.displacement_method = Mesh::DISPLACE_BOTH; } /* Scene */ -- cgit v1.2.3 From 7c3a06c34918567e6b0ab67bded60725ff63073b Mon Sep 17 00:00:00 2001 From: Lukas Stockner Date: Wed, 10 Aug 2016 20:48:35 +0200 Subject: Cycles Tests: Add test for correct 16 byte alignment of KernelData structs --- intern/cycles/test/CMakeLists.txt | 1 + intern/cycles/test/kernel_struct_align_test.cpp | 60 +++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 intern/cycles/test/kernel_struct_align_test.cpp diff --git a/intern/cycles/test/CMakeLists.txt b/intern/cycles/test/CMakeLists.txt index 9af777fb9dd..e97332392a0 100644 --- a/intern/cycles/test/CMakeLists.txt +++ b/intern/cycles/test/CMakeLists.txt @@ -69,3 +69,4 @@ CYCLES_TEST(util_aligned_malloc "cycles_util") CYCLES_TEST(util_path "cycles_util;${BOOST_LIBRARIES};${OPENIMAGEIO_LIBRARIES}") CYCLES_TEST(util_string "cycles_util;${BOOST_LIBRARIES}") CYCLES_TEST(util_task "cycles_util;${BOOST_LIBRARIES}") +CYCLES_TEST(kernel_struct_align "") diff --git a/intern/cycles/test/kernel_struct_align_test.cpp b/intern/cycles/test/kernel_struct_align_test.cpp new file mode 100644 index 00000000000..d078b8d0524 --- /dev/null +++ b/intern/cycles/test/kernel_struct_align_test.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2011-2016 Blender Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "testing/testing.h" + +#include "kernel/kernel_types.h" + +CCL_NAMESPACE_BEGIN + +#define TEST_IS_ALIGNED(name) ((sizeof(name) % 16) == 0) + +TEST(kernel_struct_align, KernelCamera) +{ + EXPECT_TRUE(TEST_IS_ALIGNED(KernelCamera)); +} + +TEST(kernel_struct_align, KernelFilm) +{ + EXPECT_TRUE(TEST_IS_ALIGNED(KernelFilm)); +} + +TEST(kernel_struct_align, KernelBackground) +{ + EXPECT_TRUE(TEST_IS_ALIGNED(KernelBackground)); +} + +TEST(kernel_struct_align, KernelIntegrator) +{ + EXPECT_TRUE(TEST_IS_ALIGNED(KernelIntegrator)); +} + +TEST(kernel_struct_align, KernelBVH) +{ + EXPECT_TRUE(TEST_IS_ALIGNED(KernelBVH)); +} + +TEST(kernel_struct_align, KernelCurves) +{ + EXPECT_TRUE(TEST_IS_ALIGNED(KernelCurves)); +} + +TEST(kernel_struct_align, KernelTables) +{ + EXPECT_TRUE(TEST_IS_ALIGNED(KernelTables)); +} + +CCL_NAMESPACE_END -- cgit v1.2.3 From a501668cc5f11f15af9fb47ea3c8c7fc910e8722 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 11 Aug 2016 10:08:23 +0200 Subject: Revert "Cycles Tests: Add test for correct 16 byte alignment of KernelData structs" Using unit tests is a wrong way to control static behavior of the application. They should only be used for checking dynamic behavior, all the rest is easily controllable at compile time. Doing tests at ocmpile time are actually more robust approach since we don't have strict policy of runnign unit tests before accepting any change. Proper alignment control is coming shortly. This reverts commit 7c3a06c34918567e6b0ab67bded60725ff63073b. --- intern/cycles/test/CMakeLists.txt | 1 - intern/cycles/test/kernel_struct_align_test.cpp | 60 ------------------------- 2 files changed, 61 deletions(-) delete mode 100644 intern/cycles/test/kernel_struct_align_test.cpp diff --git a/intern/cycles/test/CMakeLists.txt b/intern/cycles/test/CMakeLists.txt index e97332392a0..9af777fb9dd 100644 --- a/intern/cycles/test/CMakeLists.txt +++ b/intern/cycles/test/CMakeLists.txt @@ -69,4 +69,3 @@ CYCLES_TEST(util_aligned_malloc "cycles_util") CYCLES_TEST(util_path "cycles_util;${BOOST_LIBRARIES};${OPENIMAGEIO_LIBRARIES}") CYCLES_TEST(util_string "cycles_util;${BOOST_LIBRARIES}") CYCLES_TEST(util_task "cycles_util;${BOOST_LIBRARIES}") -CYCLES_TEST(kernel_struct_align "") diff --git a/intern/cycles/test/kernel_struct_align_test.cpp b/intern/cycles/test/kernel_struct_align_test.cpp deleted file mode 100644 index d078b8d0524..00000000000 --- a/intern/cycles/test/kernel_struct_align_test.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2011-2016 Blender Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "testing/testing.h" - -#include "kernel/kernel_types.h" - -CCL_NAMESPACE_BEGIN - -#define TEST_IS_ALIGNED(name) ((sizeof(name) % 16) == 0) - -TEST(kernel_struct_align, KernelCamera) -{ - EXPECT_TRUE(TEST_IS_ALIGNED(KernelCamera)); -} - -TEST(kernel_struct_align, KernelFilm) -{ - EXPECT_TRUE(TEST_IS_ALIGNED(KernelFilm)); -} - -TEST(kernel_struct_align, KernelBackground) -{ - EXPECT_TRUE(TEST_IS_ALIGNED(KernelBackground)); -} - -TEST(kernel_struct_align, KernelIntegrator) -{ - EXPECT_TRUE(TEST_IS_ALIGNED(KernelIntegrator)); -} - -TEST(kernel_struct_align, KernelBVH) -{ - EXPECT_TRUE(TEST_IS_ALIGNED(KernelBVH)); -} - -TEST(kernel_struct_align, KernelCurves) -{ - EXPECT_TRUE(TEST_IS_ALIGNED(KernelCurves)); -} - -TEST(kernel_struct_align, KernelTables) -{ - EXPECT_TRUE(TEST_IS_ALIGNED(KernelTables)); -} - -CCL_NAMESPACE_END -- cgit v1.2.3 From fdc43f993da8e89a08bc018315aaa4468b29a456 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 11 Aug 2016 09:52:39 +0200 Subject: Cycles: Use static assert to control structures alignment --- intern/cycles/kernel/CMakeLists.txt | 1 + intern/cycles/kernel/kernel_types.h | 12 +++++++ intern/cycles/util/CMakeLists.txt | 1 + intern/cycles/util/util_debug.h | 2 ++ intern/cycles/util/util_static_assert.h | 64 +++++++++++++++++++++++++++++++++ 5 files changed, 80 insertions(+) create mode 100644 intern/cycles/util/util_static_assert.h diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index 7bef247d3bd..9317bfbb703 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -176,6 +176,7 @@ set(SRC_UTIL_HEADERS ../util/util_half.h ../util/util_math.h ../util/util_math_fast.h + ../util/util_static_assert.h ../util/util_transform.h ../util/util_texture.h ../util/util_types.h diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 2ae42a83dc9..a94d544b873 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -19,6 +19,7 @@ #include "kernel_math.h" #include "svm/svm_types.h" +#include "util_static_assert.h" #ifndef __KERNEL_GPU__ # define __KERNEL_CPU__ @@ -986,6 +987,7 @@ typedef struct KernelCamera { int pad; } KernelCamera; +static_assert_align(KernelCamera, 16); typedef struct KernelFilm { float exposure; @@ -1040,6 +1042,7 @@ typedef struct KernelFilm { int pass_pad3; #endif } KernelFilm; +static_assert_align(KernelFilm, 16); typedef struct KernelBackground { /* only shader index */ @@ -1053,6 +1056,7 @@ typedef struct KernelBackground { float ao_distance; float ao_pad1, ao_pad2; } KernelBackground; +static_assert_align(KernelBackground, 16); typedef struct KernelIntegrator { /* emission */ @@ -1123,6 +1127,7 @@ typedef struct KernelIntegrator { int pad1; int pad2; } KernelIntegrator; +static_assert_align(KernelIntegrator, 16); typedef struct KernelBVH { /* root node */ @@ -1134,6 +1139,7 @@ typedef struct KernelBVH { int use_qbvh; int pad1, pad2; } KernelBVH; +static_assert_align(KernelBVH, 16); typedef enum CurveFlag { /* runtime flags */ @@ -1153,11 +1159,13 @@ typedef struct KernelCurves { float minimum_width; float maximum_width; } KernelCurves; +static_assert_align(KernelCurves, 16); typedef struct KernelTables { int beckmann_offset; int pad1, pad2, pad3; } KernelTables; +static_assert_align(KernelTables, 16); typedef struct KernelData { KernelCamera cam; @@ -1168,8 +1176,12 @@ typedef struct KernelData { KernelCurves curve; KernelTables tables; } KernelData; +static_assert_align(KernelData, 16); #ifdef __KERNEL_DEBUG__ +/* NOTE: This is a runtime-only struct, alignment is not + * really important here. + */ typedef ccl_addr_space struct DebugData { // Total number of BVH node traversal steps and primitives intersections // for the camera rays. diff --git a/intern/cycles/util/CMakeLists.txt b/intern/cycles/util/CMakeLists.txt index e6140b3ed09..7eb5a9c7c64 100644 --- a/intern/cycles/util/CMakeLists.txt +++ b/intern/cycles/util/CMakeLists.txt @@ -71,6 +71,7 @@ set(SRC_HEADERS util_ssef.h util_ssei.h util_stack_allocator.h + util_static_assert.h util_stats.h util_string.h util_system.h diff --git a/intern/cycles/util/util_debug.h b/intern/cycles/util/util_debug.h index 1787ff648ee..73fd228b5d9 100644 --- a/intern/cycles/util/util_debug.h +++ b/intern/cycles/util/util_debug.h @@ -20,6 +20,8 @@ #include #include +#include "util_static_assert.h" + CCL_NAMESPACE_BEGIN /* Global storage for all sort of flags used to fine-tune behavior of particular diff --git a/intern/cycles/util/util_static_assert.h b/intern/cycles/util/util_static_assert.h new file mode 100644 index 00000000000..1b945705145 --- /dev/null +++ b/intern/cycles/util/util_static_assert.h @@ -0,0 +1,64 @@ +/* + * Copyright 2011-2016 Blender Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __UTIL_STATIC_ASSERT_H__ +#define __UTIL_STATIC_ASSERT_H__ + +CCL_NAMESPACE_BEGIN + +/* TODO(sergey): In theory CUDA might work with own static assert + * implementation since it's just pure C++. + */ +#ifndef __KERNEL_GPU__ +# if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) +/* C++11 has built-in static_assert() */ +# else /* C++11 or MSVC2015 */ +template class StaticAssertFailure; +template <> class StaticAssertFailure {}; +# define _static_assert_private_glue_impl(A, B) A ## B +# define _static_assert_glue(A, B) _static_assert_private_glue_impl(A, B) +# ifdef __COUNTER__ +# define static_assert(condition, message) \ + enum {_static_assert_glue(q_static_assert_result, __COUNTER__) = sizeof(StaticAssertFailure)} // NOLINT +# else /* __COUNTER__ */ +# define static_assert(condition, message) \ + enum {_static_assert_glue(q_static_assert_result, __LINE__) = sizeof(StaticAssertFailure)} // NOLINT +# endif /* __COUNTER__ */ +# endif /* C++11 or MSVC2015 */ +#else /* __KERNEL_GPU__ */ +# define static_assert(statement, message) +#endif /* __KERNEL_GPU__ */ + +/* TODO(sergey): For until C++11 is a bare minimum for us, + * we do a bit of a trickery to show meaningful message so + * it's more or less clear what's wrong when building without + * C++11. + * + * The thing here is: our non-C++11 implementation doesn't + * have a way to print any message after preprocessor + * substitution so we rely on the message which is passed to + * static_assert() since that's the only message visible when + * compilation fails. + * + * After C++11 bump it should be possible to glue structure + * name to the error message, + */ +# define static_assert_align(st, align) \ + static_assert((sizeof(st) % (align) == 0), "Structure must be strictly aligned") // NOLINT + +CCL_NAMESPACE_END + +#endif /* __UTIL_STATIC_ASSERT_H__ */ -- cgit v1.2.3 From 1fe9d671cf19f339917a78cb3ab0b6148ab1ceff Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Thu, 11 Aug 2016 13:36:29 +0300 Subject: Fix T49004 and motion blur of cloth, softbody, etc past the end frame. Point cache read code contains checks designed to prevent it reading stale data when the relevant simulation code should instead compute the next frame from the previous one. However in some situations like motion blur subframes the simulation can't possibly do it and just exits. This causes completely incorrect motion blur at or after the last cached frame. To fix, add a parameter that tells the cache code whether it should apply the checks and exit, or read what it can even if stale (true means exactly same as old behavior). Doing this in cache rather than clamping the frame number better in the caller lets it handle the case of incomplete cache that stops before the official last frame. Reviewed By: mont29, lukastoenne Maniphest Tasks: T49004 Differential Revision: https://developer.blender.org/D2144 --- source/blender/blenkernel/BKE_pointcache.h | 2 +- source/blender/blenkernel/intern/cloth.c | 9 ++++++--- source/blender/blenkernel/intern/dynamicpaint.c | 6 ++++-- source/blender/blenkernel/intern/particle_system.c | 2 +- source/blender/blenkernel/intern/pointcache.c | 17 ++++++++++++----- source/blender/blenkernel/intern/rigidbody.c | 6 ++++-- source/blender/blenkernel/intern/smoke.c | 13 ++++++------- source/blender/blenkernel/intern/softbody.c | 9 ++++++--- 8 files changed, 40 insertions(+), 24 deletions(-) diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index 8238ea64242..02f6c435ee2 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -304,7 +304,7 @@ void BKE_ptcache_mem_pointers_incr(struct PTCacheMem *pm); int BKE_ptcache_mem_pointers_seek(int point_index, struct PTCacheMem *pm); /* Main cache reading call. */ -int BKE_ptcache_read(PTCacheID *pid, float cfra); +int BKE_ptcache_read(PTCacheID *pid, float cfra, bool no_extrapolate_old); /* Main cache writing call. */ int BKE_ptcache_write(PTCacheID *pid, unsigned int cfra); diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 681b93172b2..445be5277d8 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -449,9 +449,12 @@ void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, Derived } /* try to read from cache */ - cache_result = BKE_ptcache_read(&pid, (float)framenr+scene->r.subframe); + bool can_simulate = (framenr == clmd->clothObject->last_frame+1) && !(cache->flag & PTCACHE_BAKED); - if (cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) { + cache_result = BKE_ptcache_read(&pid, (float)framenr+scene->r.subframe, can_simulate); + + if (cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED || + (!can_simulate && cache_result == PTCACHE_READ_OLD)) { BKE_cloth_solver_set_positions(clmd); cloth_to_object (ob, clmd, vertexCos); @@ -473,7 +476,7 @@ void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, Derived return; } - if (framenr!=clmd->clothObject->last_frame+1) + if (!can_simulate) return; /* if on second frame, write cache for first frame */ diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index d35de6fc5d3..24425720bd2 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -2015,11 +2015,13 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene } /* try to read from cache */ - if (BKE_ptcache_read(&pid, (float)scene->r.cfra)) { + bool can_simulate = ((int)scene->r.cfra == current_frame) && !(cache->flag & PTCACHE_BAKED); + + if (BKE_ptcache_read(&pid, (float)scene->r.cfra, can_simulate)) { BKE_ptcache_validate(cache, (int)scene->r.cfra); } /* if read failed and we're on surface range do recalculate */ - else if ((int)scene->r.cfra == current_frame && !(cache->flag & PTCACHE_BAKED)) { + else if (can_simulate) { /* calculate surface frame */ canvas->flags |= MOD_DPAINT_BAKING; dynamicPaint_calculateFrame(surface, scene, ob, current_frame); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 0728fef2a32..b4e951ce04a 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3925,7 +3925,7 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_ /* 2. try to read from the cache */ if (pid) { - int cache_result = BKE_ptcache_read(pid, cache_cfra); + int cache_result = BKE_ptcache_read(pid, cache_cfra, true); if (ELEM(cache_result, PTCACHE_READ_EXACT, PTCACHE_READ_INTERPOLATED)) { cached_step(sim, cfra); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 69a98c06000..d08814e3373 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2632,7 +2632,7 @@ static int ptcache_interpolate(PTCacheID *pid, float cfra, int cfra1, int cfra2) } /* reads cache from disk or memory */ /* possible to get old or interpolated result */ -int BKE_ptcache_read(PTCacheID *pid, float cfra) +int BKE_ptcache_read(PTCacheID *pid, float cfra, bool no_extrapolate_old) { int cfrai = (int)floor(cfra), cfra1=0, cfra2=0; int ret = 0; @@ -2658,10 +2658,17 @@ int BKE_ptcache_read(PTCacheID *pid, float cfra) return 0; /* don't read old cache if already simulated past cached frame */ - if (cfra1 == 0 && cfra2 && cfra2 <= pid->cache->simframe) - return 0; - if (cfra1 && cfra1 == cfra2) - return 0; + if (no_extrapolate_old) { + if (cfra1 == 0 && cfra2 && cfra2 <= pid->cache->simframe) + return 0; + if (cfra1 && cfra1 == cfra2) + return 0; + } + else { + /* avoid calling interpolate between the same frame values */ + if (cfra1 && cfra1 == cfra2) + cfra1 = 0; + } if (cfra1) { if (pid->file_type == PTCACHE_FILE_OPENVDB && pid->read_openvdb_stream) { diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index 0f1f9b4bdf7..c3ae5736aa9 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -1560,14 +1560,16 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime) /* try to read from cache */ // RB_TODO deal with interpolated, old and baked results - if (BKE_ptcache_read(&pid, ctime)) { + bool can_simulate = (ctime == rbw->ltime + 1) && !(cache->flag & PTCACHE_BAKED); + + if (BKE_ptcache_read(&pid, ctime, can_simulate)) { BKE_ptcache_validate(cache, (int)ctime); rbw->ltime = ctime; return; } /* advance simulation, we can only step one frame forward */ - if (ctime == rbw->ltime + 1 && !(cache->flag & PTCACHE_BAKED)) { + if (can_simulate) { /* write cache for first frame when on second frame */ if (rbw->ltime == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0)) { BKE_ptcache_write(&pid, startframe); diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 43569f9ded2..3fc72628c97 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -2737,19 +2737,18 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object * return; } + /* only calculate something when we advanced a single frame */ + /* don't simulate if viewing start frame, but scene frame is not real start frame */ + bool can_simulate = (framenr == (int)smd->time + 1) && (framenr == scene->r.cfra); + /* try to read from cache */ - if (BKE_ptcache_read(&pid, (float)framenr) == PTCACHE_READ_EXACT) { + if (BKE_ptcache_read(&pid, (float)framenr, can_simulate) == PTCACHE_READ_EXACT) { BKE_ptcache_validate(cache, framenr); smd->time = framenr; return; } - /* only calculate something when we advanced a single frame */ - if (framenr != (int)smd->time + 1) - return; - - /* don't simulate if viewing start frame, but scene frame is not real start frame */ - if (framenr != scene->r.cfra) + if (!can_simulate) return; #ifdef DEBUG_TIME diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 901926dd8d4..03cf33083da 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -3719,9 +3719,12 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i } /* try to read from cache */ - cache_result = BKE_ptcache_read(&pid, (float)framenr+scene->r.subframe); + bool can_simulate = (framenr == sb->last_frame+1) && !(cache->flag & PTCACHE_BAKED); - if (cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) { + cache_result = BKE_ptcache_read(&pid, (float)framenr+scene->r.subframe, can_simulate); + + if (cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED || + (!can_simulate && cache_result == PTCACHE_READ_OLD)) { softbody_to_object(ob, vertexCos, numVerts, sb->local); BKE_ptcache_validate(cache, framenr); @@ -3742,7 +3745,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i return; } - if (framenr!=sb->last_frame+1) + if (!can_simulate) return; /* if on second frame, write cache for first frame */ -- cgit v1.2.3 From 013a5c27a5ae31fb5efda1213a94d3a89a24f263 Mon Sep 17 00:00:00 2001 From: Mai Lavelle Date: Thu, 11 Aug 2016 14:35:43 -0400 Subject: Cycles: Remove odd definition from CMake file This was causing Cycles standalone to fail to build from Blender repo. Hopefully nothing breaks from removing this. --- intern/cycles/util/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/intern/cycles/util/CMakeLists.txt b/intern/cycles/util/CMakeLists.txt index 7eb5a9c7c64..f5674bdc15c 100644 --- a/intern/cycles/util/CMakeLists.txt +++ b/intern/cycles/util/CMakeLists.txt @@ -25,10 +25,6 @@ set(SRC util_windows.cpp ) -if(NOT CYCLES_STANDALONE_REPOSITORY) - add_definitions(-DWITH_GLEW_MX) -endif() - if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI) list(APPEND SRC util_view.cpp -- cgit v1.2.3 From 3aed54dbd517f6c99b512ffa842bee75dea48fc7 Mon Sep 17 00:00:00 2001 From: Mai Lavelle Date: Thu, 11 Aug 2016 15:09:58 -0400 Subject: Cycles: Fix change of sign warning --- intern/cycles/kernel/kernel_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index a94d544b873..bb26570455b 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -1266,7 +1266,7 @@ enum RayState { /* Patch map node flags */ #define PATCH_MAP_NODE_IS_SET (1 << 30) -#define PATCH_MAP_NODE_IS_LEAF (1 << 31) +#define PATCH_MAP_NODE_IS_LEAF (1u << 31) #define PATCH_MAP_NODE_INDEX_MASK (~(PATCH_MAP_NODE_IS_SET | PATCH_MAP_NODE_IS_LEAF)) CCL_NAMESPACE_END -- cgit v1.2.3 From 5ac7ef873b7b5895b3482387ba05168e694c6525 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Thu, 11 Aug 2016 22:30:03 +0200 Subject: Cycles: Change code order for Image Data Types. Now we have the 4 component ones first (float4, byte4, half4) followed by the 1 component ones (float, byte, half). Makes code a bit more consistent and also reduces code a bit when enabling half support on GPU in next commit. This also exposed a typo in half CPU images for 3D textures, which wasn't used yet, but good to have that one fixed anyway. --- .../cycles/kernel/kernels/cpu/kernel_cpu_image.h | 14 ++++---- intern/cycles/kernel/svm/svm_image.h | 2 +- intern/cycles/render/image.cpp | 10 +++--- intern/cycles/render/image.h | 6 ++-- intern/cycles/util/util_texture.h | 40 +++++++++++----------- 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h b/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h index 47383140170..af68907a5c2 100644 --- a/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h +++ b/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h @@ -25,12 +25,12 @@ ccl_device float4 kernel_tex_image_interp_impl(KernelGlobals *kg, int tex, float { if(tex >= TEX_START_HALF_CPU) return kg->texture_half_images[tex - TEX_START_HALF_CPU].interp(x, y); - else if(tex >= TEX_START_HALF4_CPU) - return kg->texture_half4_images[tex - TEX_START_HALF4_CPU].interp(x, y); else if(tex >= TEX_START_BYTE_CPU) return kg->texture_byte_images[tex - TEX_START_BYTE_CPU].interp(x, y); else if(tex >= TEX_START_FLOAT_CPU) return kg->texture_float_images[tex - TEX_START_FLOAT_CPU].interp(x, y); + else if(tex >= TEX_START_HALF4_CPU) + return kg->texture_half4_images[tex - TEX_START_HALF4_CPU].interp(x, y); else if(tex >= TEX_START_BYTE4_CPU) return kg->texture_byte4_images[tex - TEX_START_BYTE4_CPU].interp(x, y); else @@ -41,12 +41,12 @@ ccl_device float4 kernel_tex_image_interp_3d_impl(KernelGlobals *kg, int tex, fl { if(tex >= TEX_START_HALF_CPU) return kg->texture_half_images[tex - TEX_START_HALF_CPU].interp_3d(x, y, z); - else if(tex >= TEX_START_HALF4_CPU) - return kg->texture_half4_images[tex - TEX_START_HALF4_CPU].interp_3d(x, y, z); else if(tex >= TEX_START_BYTE_CPU) return kg->texture_byte_images[tex - TEX_START_BYTE_CPU].interp_3d(x, y, z); else if(tex >= TEX_START_FLOAT_CPU) return kg->texture_float_images[tex - TEX_START_FLOAT_CPU].interp_3d(x, y, z); + else if(tex >= TEX_START_HALF4_CPU) + return kg->texture_half4_images[tex - TEX_START_HALF4_CPU].interp_3d(x, y, z); else if(tex >= TEX_START_BYTE4_CPU) return kg->texture_byte4_images[tex - TEX_START_BYTE4_CPU].interp_3d(x, y, z); else @@ -57,13 +57,13 @@ ccl_device float4 kernel_tex_image_interp_3d_impl(KernelGlobals *kg, int tex, fl ccl_device float4 kernel_tex_image_interp_3d_ex_impl(KernelGlobals *kg, int tex, float x, float y, float z, int interpolation) { if(tex >= TEX_START_HALF_CPU) - return kg->texture_half4_images[tex - TEX_START_HALF_CPU].interp_3d_ex(x, y, z, interpolation); - else if(tex >= TEX_START_HALF4_CPU) - return kg->texture_half_images[tex - TEX_START_HALF4_CPU].interp_3d_ex(x, y, z, interpolation); + return kg->texture_half_images[tex - TEX_START_HALF_CPU].interp_3d_ex(x, y, z, interpolation); else if(tex >= TEX_START_BYTE_CPU) return kg->texture_byte_images[tex - TEX_START_BYTE_CPU].interp_3d_ex(x, y, z, interpolation); else if(tex >= TEX_START_FLOAT_CPU) return kg->texture_float_images[tex - TEX_START_FLOAT_CPU].interp_3d_ex(x, y, z, interpolation); + else if(tex >= TEX_START_HALF4_CPU) + return kg->texture_half4_images[tex - TEX_START_HALF4_CPU].interp_3d_ex(x, y, z, interpolation); else if(tex >= TEX_START_BYTE4_CPU) return kg->texture_byte4_images[tex - TEX_START_BYTE4_CPU].interp_3d_ex(x, y, z, interpolation); else diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h index b6b90dfff81..f359829374d 100644 --- a/intern/cycles/kernel/svm/svm_image.h +++ b/intern/cycles/kernel/svm/svm_image.h @@ -277,7 +277,7 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, } # else CUtexObject tex = kernel_tex_fetch(__bindless_mapping, id); - if(id < 2048) /* TODO(dingto): Make this a variable */ + if(id < TEX_START_FLOAT_CUDA_KEPLER) r = kernel_tex_image_interp_float4(tex, x, y); else { float f = kernel_tex_image_interp_float(tex, x, y); diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index 614620c14af..284af5f90f7 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -52,15 +52,15 @@ ImageManager::ImageManager(const DeviceInfo& info) { \ tex_num_images[IMAGE_DATA_TYPE_FLOAT4] = TEX_NUM_FLOAT4_ ## ARCH; \ tex_num_images[IMAGE_DATA_TYPE_BYTE4] = TEX_NUM_BYTE4_ ## ARCH; \ + tex_num_images[IMAGE_DATA_TYPE_HALF4] = TEX_NUM_HALF4_ ## ARCH; \ tex_num_images[IMAGE_DATA_TYPE_FLOAT] = TEX_NUM_FLOAT_ ## ARCH; \ tex_num_images[IMAGE_DATA_TYPE_BYTE] = TEX_NUM_BYTE_ ## ARCH; \ - tex_num_images[IMAGE_DATA_TYPE_HALF4] = TEX_NUM_HALF4_ ## ARCH; \ tex_num_images[IMAGE_DATA_TYPE_HALF] = TEX_NUM_HALF_ ## ARCH; \ tex_start_images[IMAGE_DATA_TYPE_FLOAT4] = TEX_START_FLOAT4_ ## ARCH; \ tex_start_images[IMAGE_DATA_TYPE_BYTE4] = TEX_START_BYTE4_ ## ARCH; \ + tex_start_images[IMAGE_DATA_TYPE_HALF4] = TEX_START_HALF4_ ## ARCH; \ tex_start_images[IMAGE_DATA_TYPE_FLOAT] = TEX_START_FLOAT_ ## ARCH; \ tex_start_images[IMAGE_DATA_TYPE_BYTE] = TEX_START_BYTE_ ## ARCH; \ - tex_start_images[IMAGE_DATA_TYPE_HALF4] = TEX_START_HALF4_ ## ARCH; \ tex_start_images[IMAGE_DATA_TYPE_HALF] = TEX_START_HALF_ ## ARCH; \ } @@ -82,15 +82,15 @@ ImageManager::ImageManager(const DeviceInfo& info) /* Should not happen. */ tex_num_images[IMAGE_DATA_TYPE_FLOAT4] = 0; tex_num_images[IMAGE_DATA_TYPE_BYTE4] = 0; + tex_num_images[IMAGE_DATA_TYPE_HALF4] = 0; tex_num_images[IMAGE_DATA_TYPE_FLOAT] = 0; tex_num_images[IMAGE_DATA_TYPE_BYTE] = 0; - tex_num_images[IMAGE_DATA_TYPE_HALF4] = 0; tex_num_images[IMAGE_DATA_TYPE_HALF] = 0; tex_start_images[IMAGE_DATA_TYPE_FLOAT4] = 0; tex_start_images[IMAGE_DATA_TYPE_BYTE4] = 0; + tex_start_images[IMAGE_DATA_TYPE_HALF4] = 0; tex_start_images[IMAGE_DATA_TYPE_FLOAT] = 0; tex_start_images[IMAGE_DATA_TYPE_BYTE] = 0; - tex_start_images[IMAGE_DATA_TYPE_HALF4] = 0; tex_start_images[IMAGE_DATA_TYPE_HALF] = 0; assert(0); } @@ -216,7 +216,7 @@ ImageManager::ImageDataType ImageManager::get_image_metadata(const string& filen } /* We use a consecutive slot counting scheme on the devices, in order - * float4, byte4, float, byte. + * float4, byte4, half4, float, byte, half. * These functions convert the slot ids from ImageManager "images" ones * to device ones and vice versa. */ int ImageManager::type_index_to_flattened_slot(int slot, ImageDataType type) diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h index 07998684b23..cca71a6bb93 100644 --- a/intern/cycles/render/image.h +++ b/intern/cycles/render/image.h @@ -39,9 +39,9 @@ public: enum ImageDataType { IMAGE_DATA_TYPE_FLOAT4 = 0, IMAGE_DATA_TYPE_BYTE4 = 1, - IMAGE_DATA_TYPE_FLOAT = 2, - IMAGE_DATA_TYPE_BYTE = 3, - IMAGE_DATA_TYPE_HALF4 = 4, + IMAGE_DATA_TYPE_HALF4 = 2, + IMAGE_DATA_TYPE_FLOAT = 3, + IMAGE_DATA_TYPE_BYTE = 4, IMAGE_DATA_TYPE_HALF = 5, IMAGE_DATA_NUM_TYPES diff --git a/intern/cycles/util/util_texture.h b/intern/cycles/util/util_texture.h index 0cecfe91ea9..ec3ee2b8191 100644 --- a/intern/cycles/util/util_texture.h +++ b/intern/cycles/util/util_texture.h @@ -24,58 +24,58 @@ CCL_NAMESPACE_BEGIN /* CPU */ #define TEX_NUM_FLOAT4_CPU 1024 #define TEX_NUM_BYTE4_CPU 1024 +#define TEX_NUM_HALF4_CPU 1024 #define TEX_NUM_FLOAT_CPU 1024 #define TEX_NUM_BYTE_CPU 1024 -#define TEX_NUM_HALF4_CPU 1024 #define TEX_NUM_HALF_CPU 1024 #define TEX_START_FLOAT4_CPU 0 #define TEX_START_BYTE4_CPU TEX_NUM_FLOAT4_CPU -#define TEX_START_FLOAT_CPU (TEX_NUM_FLOAT4_CPU + TEX_NUM_BYTE4_CPU) -#define TEX_START_BYTE_CPU (TEX_NUM_FLOAT4_CPU + TEX_NUM_BYTE4_CPU + TEX_NUM_FLOAT_CPU) -#define TEX_START_HALF4_CPU (TEX_NUM_FLOAT4_CPU + TEX_NUM_BYTE4_CPU + TEX_NUM_FLOAT_CPU + TEX_NUM_BYTE_CPU) -#define TEX_START_HALF_CPU (TEX_NUM_FLOAT4_CPU + TEX_NUM_BYTE4_CPU + TEX_NUM_FLOAT_CPU + TEX_NUM_BYTE_CPU + TEX_NUM_HALF4_CPU) +#define TEX_START_HALF4_CPU (TEX_NUM_FLOAT4_CPU + TEX_NUM_BYTE4_CPU) +#define TEX_START_FLOAT_CPU (TEX_NUM_FLOAT4_CPU + TEX_NUM_BYTE4_CPU + TEX_NUM_HALF4_CPU) +#define TEX_START_BYTE_CPU (TEX_NUM_FLOAT4_CPU + TEX_NUM_BYTE4_CPU + TEX_NUM_HALF4_CPU + TEX_NUM_FLOAT_CPU) +#define TEX_START_HALF_CPU (TEX_NUM_FLOAT4_CPU + TEX_NUM_BYTE4_CPU + TEX_NUM_HALF4_CPU + TEX_NUM_FLOAT_CPU + TEX_NUM_BYTE_CPU) /* CUDA (Geforce 4xx and 5xx) */ #define TEX_NUM_FLOAT4_CUDA 5 #define TEX_NUM_BYTE4_CUDA 85 +#define TEX_NUM_HALF4_CUDA 0 #define TEX_NUM_FLOAT_CUDA 0 #define TEX_NUM_BYTE_CUDA 0 -#define TEX_NUM_HALF4_CUDA 0 #define TEX_NUM_HALF_CUDA 0 #define TEX_START_FLOAT4_CUDA 0 #define TEX_START_BYTE4_CUDA TEX_NUM_FLOAT4_CUDA -#define TEX_START_FLOAT_CUDA (TEX_NUM_FLOAT4_CUDA + TEX_NUM_BYTE4_CUDA) -#define TEX_START_BYTE_CUDA (TEX_NUM_FLOAT4_CUDA + TEX_NUM_BYTE4_CUDA + TEX_NUM_FLOAT_CUDA) -#define TEX_START_HALF4_CUDA (TEX_NUM_FLOAT4_CUDA + TEX_NUM_BYTE4_CUDA + TEX_NUM_FLOAT_CUDA + TEX_NUM_BYTE_CUDA) -#define TEX_START_HALF_CUDA (TEX_NUM_FLOAT4_CUDA + TEX_NUM_BYTE4_CUDA + TEX_NUM_FLOAT_CUDA + TEX_NUM_BYTE_CUDA + TEX_NUM_HALF4_CUDA) +#define TEX_START_HALF4_CUDA (TEX_NUM_FLOAT4_CUDA + TEX_NUM_BYTE4_CUDA) +#define TEX_START_FLOAT_CUDA (TEX_NUM_FLOAT4_CUDA + TEX_NUM_BYTE4_CUDA + TEX_NUM_HALF4_CUDA) +#define TEX_START_BYTE_CUDA (TEX_NUM_FLOAT4_CUDA + TEX_NUM_BYTE4_CUDA + TEX_NUM_HALF4_CUDA + TEX_NUM_FLOAT_CUDA) +#define TEX_START_HALF_CUDA (TEX_NUM_FLOAT4_CUDA + TEX_NUM_BYTE4_CUDA + TEX_NUM_HALF4_CUDA + TEX_NUM_FLOAT_CUDA + TEX_NUM_BYTE_CUDA) /* CUDA (Kepler, Geforce 6xx and above) */ #define TEX_NUM_FLOAT4_CUDA_KEPLER 1024 #define TEX_NUM_BYTE4_CUDA_KEPLER 1024 +#define TEX_NUM_HALF4_CUDA_KEPLER 0 #define TEX_NUM_FLOAT_CUDA_KEPLER 1024 #define TEX_NUM_BYTE_CUDA_KEPLER 1024 -#define TEX_NUM_HALF4_CUDA_KEPLER 0 #define TEX_NUM_HALF_CUDA_KEPLER 0 #define TEX_START_FLOAT4_CUDA_KEPLER 0 #define TEX_START_BYTE4_CUDA_KEPLER TEX_NUM_FLOAT4_CUDA_KEPLER -#define TEX_START_FLOAT_CUDA_KEPLER (TEX_NUM_FLOAT4_CUDA_KEPLER + TEX_NUM_BYTE4_CUDA_KEPLER) -#define TEX_START_BYTE_CUDA_KEPLER (TEX_NUM_FLOAT4_CUDA_KEPLER + TEX_NUM_BYTE4_CUDA_KEPLER + TEX_NUM_FLOAT_CUDA_KEPLER) -#define TEX_START_HALF4_CUDA_KEPLER (TEX_NUM_FLOAT4_CUDA_KEPLER + TEX_NUM_BYTE4_CUDA_KEPLER + TEX_NUM_FLOAT_CUDA_KEPLER + TEX_NUM_BYTE_CUDA_KEPLER) -#define TEX_START_HALF_CUDA_KEPLER (TEX_NUM_FLOAT4_CUDA_KEPLER + TEX_NUM_BYTE4_CUDA_KEPLER + TEX_NUM_FLOAT_CUDA_KEPLER + TEX_NUM_BYTE_CUDA_KEPLER + TEX_NUM_HALF4_CUDA_KEPLER) +#define TEX_START_HALF4_CUDA_KEPLER (TEX_NUM_FLOAT4_CUDA_KEPLER + TEX_NUM_BYTE4_CUDA_KEPLER) +#define TEX_START_FLOAT_CUDA_KEPLER (TEX_NUM_FLOAT4_CUDA_KEPLER + TEX_NUM_BYTE4_CUDA_KEPLER + TEX_NUM_HALF4_CUDA_KEPLER) +#define TEX_START_BYTE_CUDA_KEPLER (TEX_NUM_FLOAT4_CUDA_KEPLER + TEX_NUM_BYTE4_CUDA_KEPLER + TEX_NUM_HALF4_CUDA_KEPLER + TEX_NUM_FLOAT_CUDA_KEPLER) +#define TEX_START_HALF_CUDA_KEPLER (TEX_NUM_FLOAT4_CUDA_KEPLER + TEX_NUM_BYTE4_CUDA_KEPLER + TEX_NUM_HALF4_CUDA_KEPLER + TEX_NUM_FLOAT_CUDA_KEPLER + TEX_NUM_BYTE_CUDA_KEPLER) /* OpenCL */ #define TEX_NUM_FLOAT4_OPENCL 1024 #define TEX_NUM_BYTE4_OPENCL 1024 +#define TEX_NUM_HALF4_OPENCL 0 #define TEX_NUM_FLOAT_OPENCL 0 #define TEX_NUM_BYTE_OPENCL 0 -#define TEX_NUM_HALF4_OPENCL 0 #define TEX_NUM_HALF_OPENCL 0 #define TEX_START_FLOAT4_OPENCL 0 #define TEX_START_BYTE4_OPENCL TEX_NUM_FLOAT4_OPENCL -#define TEX_START_FLOAT_OPENCL (TEX_NUM_FLOAT4_OPENCL + TEX_NUM_BYTE4_OPENCL) -#define TEX_START_BYTE_OPENCL (TEX_NUM_FLOAT4_OPENCL + TEX_NUM_BYTE4_OPENCL + TEX_NUM_FLOAT_OPENCL) -#define TEX_START_HALF4_OPENCL (TEX_NUM_FLOAT4_OPENCL + TEX_NUM_BYTE4_OPENCL + TEX_NUM_FLOAT_OPENCL + TEX_NUM_BYTE_OPENCL) -#define TEX_START_HALF_OPENCL (TEX_NUM_FLOAT4_OPENCL + TEX_NUM_BYTE4_OPENCL + TEX_NUM_FLOAT_OPENCL + TEX_NUM_BYTE_OPENCL + TEX_NUM_HALF4_OPENCL) +#define TEX_START_HALF4_OPENCL (TEX_NUM_FLOAT4_OPENCL + TEX_NUM_BYTE4_OPENCL) +#define TEX_START_FLOAT_OPENCL (TEX_NUM_FLOAT4_OPENCL + TEX_NUM_BYTE4_OPENCL + TEX_NUM_HALF4_OPENCL) +#define TEX_START_BYTE_OPENCL (TEX_NUM_FLOAT4_OPENCL + TEX_NUM_BYTE4_OPENCL + TEX_NUM_HALF4_OPENCL + TEX_NUM_FLOAT_OPENCL) +#define TEX_START_HALF_OPENCL (TEX_NUM_FLOAT4_OPENCL + TEX_NUM_BYTE4_OPENCL + TEX_NUM_HALF4_OPENCL + TEX_NUM_FLOAT_OPENCL + TEX_NUM_BYTE_OPENCL) /* Color to use when textures are not found. */ -- cgit v1.2.3 From 9d236ac06c2b6511365eb53f84bbe366c76acc72 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Thu, 11 Aug 2016 22:47:53 +0200 Subject: Cycles: Enable half float support (4 channels and 1 channel) on CUDA. Atm OpenEXR half files benefit from this and will use only 1/2 of the memory now. More space for HDRs! Part of my GSoC 2016. --- intern/cycles/device/device_cuda.cpp | 9 +++++++-- intern/cycles/kernel/kernel_compat_cuda.h | 1 + intern/cycles/kernel/svm/svm_image.h | 4 +++- intern/cycles/util/util_half.h | 12 ++++++++---- intern/cycles/util/util_texture.h | 4 ++-- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index a85f34082db..76e52498b42 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -576,6 +576,7 @@ public: case TYPE_UINT: format = CU_AD_FORMAT_UNSIGNED_INT32; break; case TYPE_INT: format = CU_AD_FORMAT_SIGNED_INT32; break; case TYPE_FLOAT: format = CU_AD_FORMAT_FLOAT; break; + case TYPE_HALF: format = CU_AD_FORMAT_HALF; break; default: assert(0); return; } @@ -747,8 +748,12 @@ public: } /* Resize once */ - if(flat_slot >= bindless_mapping.size()) - bindless_mapping.resize(4096); /*TODO(dingto): Make this a variable */ + if(flat_slot >= bindless_mapping.size()) { + /* Allocate some slots in advance, to reduce amount + * of re-allocations. + */ + bindless_mapping.resize(flat_slot + 128); + } /* Set Mapping and tag that we need to (re-)upload to device */ bindless_mapping.get_data()[flat_slot] = (uint)tex; diff --git a/intern/cycles/kernel/kernel_compat_cuda.h b/intern/cycles/kernel/kernel_compat_cuda.h index 063220b542e..d656fac81e6 100644 --- a/intern/cycles/kernel/kernel_compat_cuda.h +++ b/intern/cycles/kernel/kernel_compat_cuda.h @@ -31,6 +31,7 @@ #endif #include +#include #include /* Qualifier wrappers for different names on different devices */ diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h index f359829374d..9050ce93951 100644 --- a/intern/cycles/kernel/svm/svm_image.h +++ b/intern/cycles/kernel/svm/svm_image.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Float4 textures on various devices. */ #if defined(__KERNEL_CPU__) -# define TEX_NUM_FLOAT4_IMAGES TEX_NUM_FLOAT4_CPU +# define TEX_NUM_FLOAT4_IMAGES TEX_NUM_FLOAT4_CPU #elif defined(__KERNEL_CUDA__) # if __CUDA_ARCH__ < 300 # define TEX_NUM_FLOAT4_IMAGES TEX_NUM_FLOAT4_CUDA @@ -277,8 +277,10 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, } # else CUtexObject tex = kernel_tex_fetch(__bindless_mapping, id); + /* float4, byte4 and half4 */ if(id < TEX_START_FLOAT_CUDA_KEPLER) r = kernel_tex_image_interp_float4(tex, x, y); + /* float, byte and half */ else { float f = kernel_tex_image_interp_float(tex, x, y); r = make_float4(f, f, f, 1.0); diff --git a/intern/cycles/util/util_half.h b/intern/cycles/util/util_half.h index ae85ab3a915..5db3384cda4 100644 --- a/intern/cycles/util/util_half.h +++ b/intern/cycles/util/util_half.h @@ -33,17 +33,21 @@ CCL_NAMESPACE_BEGIN #else +/* CUDA has its own half data type, no need to define then */ +#ifndef __KERNEL_CUDA__ typedef unsigned short half; +#endif + struct half4 { half x, y, z, w; }; #ifdef __KERNEL_CUDA__ ccl_device_inline void float4_store_half(half *h, float4 f, float scale) { - h[0] = __float2half_rn(f.x * scale); - h[1] = __float2half_rn(f.y * scale); - h[2] = __float2half_rn(f.z * scale); - h[3] = __float2half_rn(f.w * scale); + h[0] = __float2half(f.x * scale); + h[1] = __float2half(f.y * scale); + h[2] = __float2half(f.z * scale); + h[3] = __float2half(f.w * scale); } #else diff --git a/intern/cycles/util/util_texture.h b/intern/cycles/util/util_texture.h index ec3ee2b8191..be1177d3be9 100644 --- a/intern/cycles/util/util_texture.h +++ b/intern/cycles/util/util_texture.h @@ -52,10 +52,10 @@ CCL_NAMESPACE_BEGIN /* CUDA (Kepler, Geforce 6xx and above) */ #define TEX_NUM_FLOAT4_CUDA_KEPLER 1024 #define TEX_NUM_BYTE4_CUDA_KEPLER 1024 -#define TEX_NUM_HALF4_CUDA_KEPLER 0 +#define TEX_NUM_HALF4_CUDA_KEPLER 1024 #define TEX_NUM_FLOAT_CUDA_KEPLER 1024 #define TEX_NUM_BYTE_CUDA_KEPLER 1024 -#define TEX_NUM_HALF_CUDA_KEPLER 0 +#define TEX_NUM_HALF_CUDA_KEPLER 1024 #define TEX_START_FLOAT4_CUDA_KEPLER 0 #define TEX_START_BYTE4_CUDA_KEPLER TEX_NUM_FLOAT4_CUDA_KEPLER #define TEX_START_HALF4_CUDA_KEPLER (TEX_NUM_FLOAT4_CUDA_KEPLER + TEX_NUM_BYTE4_CUDA_KEPLER) -- cgit v1.2.3 From f3bff6a1a1cb05bcc6a540461f7a282da7bb3dae Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 12 Aug 2016 01:01:09 +0200 Subject: Fix T49071: Cycles OSL build problem with oslc compilers that can't find their own stdosl.h. --- intern/cycles/kernel/shaders/node_rgb_curves.osl | 1 + intern/cycles/kernel/shaders/node_rgb_ramp.osl | 1 + intern/cycles/kernel/shaders/node_vector_curves.osl | 1 + 3 files changed, 3 insertions(+) diff --git a/intern/cycles/kernel/shaders/node_rgb_curves.osl b/intern/cycles/kernel/shaders/node_rgb_curves.osl index c8e7e4f175b..984b7d47e8f 100644 --- a/intern/cycles/kernel/shaders/node_rgb_curves.osl +++ b/intern/cycles/kernel/shaders/node_rgb_curves.osl @@ -14,6 +14,7 @@ * limitations under the License. */ +#include "stdosl.h" #include "node_ramp_util.h" shader node_rgb_curves( diff --git a/intern/cycles/kernel/shaders/node_rgb_ramp.osl b/intern/cycles/kernel/shaders/node_rgb_ramp.osl index 24b8728b999..4e7d8fdcf65 100644 --- a/intern/cycles/kernel/shaders/node_rgb_ramp.osl +++ b/intern/cycles/kernel/shaders/node_rgb_ramp.osl @@ -14,6 +14,7 @@ * limitations under the License. */ +#include "stdosl.h" #include "node_ramp_util.h" shader node_rgb_ramp( diff --git a/intern/cycles/kernel/shaders/node_vector_curves.osl b/intern/cycles/kernel/shaders/node_vector_curves.osl index d92fa11d439..ff284c48e0a 100644 --- a/intern/cycles/kernel/shaders/node_vector_curves.osl +++ b/intern/cycles/kernel/shaders/node_vector_curves.osl @@ -14,6 +14,7 @@ * limitations under the License. */ +#include "stdosl.h" #include "node_ramp_util.h" shader node_vector_curves( -- cgit v1.2.3 From bac1279b031f9b3996c4691e948d941e4dcfaea1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 12 Aug 2016 01:19:22 +0200 Subject: Fix T49045: splash not working correctly on OS X, after recent bugfix. --- source/blender/windowmanager/intern/wm_window.c | 29 ++++++++++++++----------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 425287993d9..2d43c47679d 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -1197,23 +1197,26 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr } case GHOST_kEventNativeResolutionChange: { - // printf("change, pixel size %f\n", GHOST_GetNativePixelSize(win->ghostwin)); - + // only update if the actual pixel size changes + float prev_pixelsize = U.pixelsize; U.pixelsize = wm_window_pixelsize(win); - BKE_blender_userdef_refresh(); - // close all popups since they are positioned with the pixel - // size baked in and it's difficult to correct them - wmWindow *oldWindow = CTX_wm_window(C); - CTX_wm_window_set(C, win); - UI_popup_handlers_remove_all(C, &win->modalhandlers); - CTX_wm_window_set(C, oldWindow); + if (U.pixelsize != prev_pixelsize) { + BKE_blender_userdef_refresh(); - wm_window_make_drawable(wm, win); - wm_draw_window_clear(win); + // close all popups since they are positioned with the pixel + // size baked in and it's difficult to correct them + wmWindow *oldWindow = CTX_wm_window(C); + CTX_wm_window_set(C, win); + UI_popup_handlers_remove_all(C, &win->modalhandlers); + CTX_wm_window_set(C, oldWindow); + + wm_window_make_drawable(wm, win); + wm_draw_window_clear(win); - WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); - WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL); + } break; } -- cgit v1.2.3 From 82268fa1009dadb526dd6dc2ebc81763aedb2c18 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 12 Aug 2016 13:58:48 +0200 Subject: Depsgraph: Tag relations for update when making datablocks single user This is mainly required for the new dependency graph where non-object datablocks are a part of dependency graph. This solves issue when making mesh shared by multiple objects a single user one. --- source/blender/editors/interface/interface_templates.c | 2 ++ source/blender/editors/object/object_relations.c | 1 + 2 files changed, 3 insertions(+) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 241da5decc6..50dd219b53c 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -326,7 +326,9 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) } else { if (id) { + Main *bmain = CTX_data_main(C); id_single_user(C, id, &template->ptr, template->prop); + DAG_relations_tag_update(bmain); } } } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index d5c7632765f..067a5ad2b49 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -2106,6 +2106,7 @@ void ED_object_single_users(Main *bmain, Scene *scene, const bool full, const bo } BKE_main_id_clear_newpoins(bmain); + DAG_relations_tag_update(bmain); } /******************************* Make Local ***********************************/ -- cgit v1.2.3 From 04c7d9d56674f97d14c393488439c93a343823b4 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 12 Aug 2016 14:59:11 +0200 Subject: Depsgraph: tag relations for update when aterial slots changes New dependency graph puts materials to the graph in order to deal with animation assigned to them and things like that. This leads us to a requirement to update relations when slots changes. This fixes: T49075 Assignment of a keyframed material using the frame_change_pre handler doesn't update the keyframe using the new dependency graph --- source/blender/blenkernel/BKE_material.h | 10 +++++----- source/blender/blenkernel/intern/material.c | 30 ++++++++++++++++++---------- source/blender/blenloader/intern/readfile.c | 2 +- source/blender/editors/mesh/editmesh_tools.c | 18 ++++++++--------- source/blender/makesrna/intern/rna_ID.c | 13 ++++++------ 5 files changed, 42 insertions(+), 31 deletions(-) diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h index df739996c54..8ae5c2b3c45 100644 --- a/source/blender/blenkernel/BKE_material.h +++ b/source/blender/blenkernel/BKE_material.h @@ -49,7 +49,7 @@ void BKE_material_free(struct Material *ma); void BKE_material_free_ex(struct Material *ma, bool do_id_user); void test_object_materials(struct Object *ob, struct ID *id); void test_all_objects_materials(struct Main *bmain, struct ID *id); -void BKE_material_resize_object(struct Object *ob, const short totcol, bool do_id_user); +void BKE_material_resize_object(struct Main *bmain, struct Object *ob, const short totcol, bool do_id_user); void BKE_material_init(struct Material *ma); void BKE_material_remap_object(struct Object *ob, const unsigned int *remap); void BKE_material_remap_object_calc(struct Object *ob_dst, struct Object *ob_src, short *remap_src_to_dst); @@ -90,10 +90,10 @@ void BKE_texpaint_slot_refresh_cache(struct Scene *scene, struct Material *ma); void BKE_texpaint_slots_refresh_object(struct Scene *scene, struct Object *ob); /* rna api */ -void BKE_material_resize_id(struct ID *id, short totcol, bool do_id_user); -void BKE_material_append_id(struct ID *id, struct Material *ma); -struct Material *BKE_material_pop_id(struct ID *id, int index, bool update_data); /* index is an int because of RNA */ -void BKE_material_clear_id(struct ID *id, bool update_data); +void BKE_material_resize_id(struct Main *bmain, struct ID *id, short totcol, bool do_id_user); +void BKE_material_append_id(struct Main *bmain, struct ID *id, struct Material *ma); +struct Material *BKE_material_pop_id(struct Main *bmain, struct ID *id, int index, bool update_data); /* index is an int because of RNA */ +void BKE_material_clear_id(struct Main *bmain, struct ID *id, bool update_data); /* rendering */ void init_render_material(struct Material *, int, float *); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 470108545b8..54945242fe4 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -58,6 +58,7 @@ #include "BKE_animsys.h" #include "BKE_displist.h" #include "BKE_global.h" +#include "BKE_depsgraph.h" #include "BKE_icons.h" #include "BKE_image.h" #include "BKE_library.h" @@ -398,7 +399,7 @@ static void material_data_index_clear_id(ID *id) } } -void BKE_material_resize_id(struct ID *id, short totcol, bool do_id_user) +void BKE_material_resize_id(Main *bmain, ID *id, short totcol, bool do_id_user) { Material ***matar = give_matarar_id(id); short *totcolp = give_totcolp_id(id); @@ -424,9 +425,11 @@ void BKE_material_resize_id(struct ID *id, short totcol, bool do_id_user) *matar = MEM_recallocN(*matar, sizeof(void *) * totcol); } *totcolp = totcol; + + DAG_relations_tag_update(bmain); } -void BKE_material_append_id(ID *id, Material *ma) +void BKE_material_append_id(Main *bmain, ID *id, Material *ma) { Material ***matar; if ((matar = give_matarar_id(id))) { @@ -439,11 +442,12 @@ void BKE_material_append_id(ID *id, Material *ma) (*matar)[(*totcol)++] = ma; id_us_plus((ID *)ma); - test_all_objects_materials(G.main, id); + test_all_objects_materials(bmain, id); + DAG_relations_tag_update(bmain); } } -Material *BKE_material_pop_id(ID *id, int index_i, bool update_data) +Material *BKE_material_pop_id(Main *bmain, ID *id, int index_i, bool update_data) { short index = (short)index_i; Material *ret = NULL; @@ -472,13 +476,15 @@ Material *BKE_material_pop_id(ID *id, int index_i, bool update_data) /* decrease mat_nr index */ material_data_index_remove_id(id, index); } + + DAG_relations_tag_update(bmain); } } return ret; } -void BKE_material_clear_id(struct ID *id, bool update_data) +void BKE_material_clear_id(Main *bmain, ID *id, bool update_data) { Material ***matar; if ((matar = give_matarar_id(id))) { @@ -497,6 +503,8 @@ void BKE_material_clear_id(struct ID *id, bool update_data) /* decrease mat_nr index */ material_data_index_clear_id(id); } + + DAG_relations_tag_update(bmain); } } @@ -553,7 +561,7 @@ Material *give_node_material(Material *ma) return NULL; } -void BKE_material_resize_object(Object *ob, const short totcol, bool do_id_user) +void BKE_material_resize_object(Main *bmain, Object *ob, const short totcol, bool do_id_user) { Material **newmatar; char *newmatbits; @@ -590,6 +598,8 @@ void BKE_material_resize_object(Object *ob, const short totcol, bool do_id_user) ob->totcol = totcol; if (ob->totcol && ob->actcol == 0) ob->actcol = 1; if (ob->actcol > ob->totcol) ob->actcol = ob->totcol; + + DAG_relations_tag_update(bmain); } void test_object_materials(Object *ob, ID *id) @@ -601,7 +611,7 @@ void test_object_materials(Object *ob, ID *id) return; } - BKE_material_resize_object(ob, *totcol, false); + BKE_material_resize_object(G.main, ob, *totcol, false); } void test_all_objects_materials(Main *bmain, ID *id) @@ -617,7 +627,7 @@ void test_all_objects_materials(Main *bmain, ID *id) BKE_main_lock(bmain); for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->data == id) { - BKE_material_resize_object(ob, *totcol, false); + BKE_material_resize_object(bmain, ob, *totcol, false); } } BKE_main_unlock(bmain); @@ -1881,7 +1891,7 @@ static short mesh_getmaterialnumber(Mesh *me, Material *ma) /* append material */ static short mesh_addmaterial(Mesh *me, Material *ma) { - BKE_material_append_id(&me->id, NULL); + BKE_material_append_id(G.main, &me->id, NULL); me->mat[me->totcol - 1] = ma; id_us_plus(&ma->id); @@ -2020,7 +2030,7 @@ static void convert_tfacematerial(Main *main, Material *ma) /* remove material from mesh */ for (a = 0; a < me->totcol; ) { if (me->mat[a] == ma) { - BKE_material_pop_id(&me->id, a, true); + BKE_material_pop_id(main, &me->id, a, true); } else { a++; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index eb94c91389c..161ab3a2b82 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4774,7 +4774,7 @@ static void lib_link_object(FileData *fd, Main *main) /* Only expand so as not to loose any object materials that might be set. */ if (totcol_data && (*totcol_data > ob->totcol)) { /* printf("'%s' %d -> %d\n", ob->id.name, ob->totcol, *totcol_data); */ - BKE_material_resize_object(ob, *totcol_data, false); + BKE_material_resize_object(main, ob, *totcol_data, false); } } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 1a14fad8650..999d5b278ee 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3080,7 +3080,7 @@ static void bm_mesh_hflag_flush_vert(BMesh *bm, const char hflag) * \note This could be used for split-by-material for non mesh types. * \note This could take material data from another object or args. */ -static void mesh_separate_material_assign_mat_nr(Object *ob, const short mat_nr) +static void mesh_separate_material_assign_mat_nr(Main *bmain, Object *ob, const short mat_nr) { ID *obdata = ob->data; @@ -3116,18 +3116,18 @@ static void mesh_separate_material_assign_mat_nr(Object *ob, const short mat_nr) ma_obdata = NULL; } - BKE_material_clear_id(obdata, true); - BKE_material_resize_object(ob, 1, true); - BKE_material_resize_id(obdata, 1, true); + BKE_material_clear_id(bmain, obdata, true); + BKE_material_resize_object(bmain, ob, 1, true); + BKE_material_resize_id(bmain, obdata, 1, true); ob->mat[0] = ma_ob; ob->matbits[0] = matbit; (*matarar)[0] = ma_obdata; } else { - BKE_material_clear_id(obdata, true); - BKE_material_resize_object(ob, 0, true); - BKE_material_resize_id(obdata, 0, true); + BKE_material_clear_id(bmain, obdata, true); + BKE_material_resize_object(bmain, ob, 0, true); + BKE_material_resize_id(bmain, obdata, 0, true); } } @@ -3162,7 +3162,7 @@ static bool mesh_separate_material(Main *bmain, Scene *scene, Base *base_old, BM /* leave the current object with some materials */ if (tot == bm_old->totface) { - mesh_separate_material_assign_mat_nr(base_old->object, mat_nr); + mesh_separate_material_assign_mat_nr(bmain, base_old->object, mat_nr); /* since we're in editmode, must set faces here */ BM_ITER_MESH (f, &iter, bm_old, BM_FACES_OF_MESH) { @@ -3174,7 +3174,7 @@ static bool mesh_separate_material(Main *bmain, Scene *scene, Base *base_old, BM /* Move selection into a separate object */ base_new = mesh_separate_tagged(bmain, scene, base_old, bm_old); if (base_new) { - mesh_separate_material_assign_mat_nr(base_new->object, mat_nr); + mesh_separate_material_assign_mat_nr(bmain, base_new->object, mat_nr); } result |= (base_new != NULL); diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index fdb93ac1a18..ab124b361f1 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -386,15 +386,15 @@ int rna_IDMaterials_assign_int(PointerRNA *ptr, int key, const PointerRNA *assig } } -static void rna_IDMaterials_append_id(ID *id, Material *ma) +static void rna_IDMaterials_append_id(ID *id, Main *bmain, Material *ma) { - BKE_material_append_id(id, ma); + BKE_material_append_id(bmain, id, ma); WM_main_add_notifier(NC_OBJECT | ND_DRAW, id); WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, id); } -static Material *rna_IDMaterials_pop_id(ID *id, ReportList *reports, int index_i, int remove_material_slot) +static Material *rna_IDMaterials_pop_id(ID *id, Main *bmain, ReportList *reports, int index_i, int remove_material_slot) { Material *ma; short *totcol = give_totcolp_id(id); @@ -408,7 +408,7 @@ static Material *rna_IDMaterials_pop_id(ID *id, ReportList *reports, int index_i return NULL; } - ma = BKE_material_pop_id(id, index_i, remove_material_slot); + ma = BKE_material_pop_id(bmain, id, index_i, remove_material_slot); if (*totcol == totcol_orig) { BKE_report(reports, RPT_ERROR, "No material to removed"); @@ -424,7 +424,7 @@ static Material *rna_IDMaterials_pop_id(ID *id, ReportList *reports, int index_i static void rna_IDMaterials_clear_id(ID *id, int remove_material_slot) { - BKE_material_clear_id(id, remove_material_slot); + BKE_material_clear_id(G.main, id, remove_material_slot); DAG_id_tag_update(id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_DRAW, id); @@ -820,12 +820,13 @@ static void rna_def_ID_materials(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "ID Materials", "Collection of materials"); func = RNA_def_function(srna, "append", "rna_IDMaterials_append_id"); + RNA_def_function_flag(func, FUNC_USE_MAIN); RNA_def_function_ui_description(func, "Add a new material to the data block"); parm = RNA_def_pointer(func, "material", "Material", "", "Material to add"); RNA_def_property_flag(parm, PROP_REQUIRED); func = RNA_def_function(srna, "pop", "rna_IDMaterials_pop_id"); - RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_MAIN); RNA_def_function_ui_description(func, "Remove a material from the data block"); parm = RNA_def_int(func, "index", -1, -MAXMAT, MAXMAT, "", "Index of material to remove", 0, MAXMAT); RNA_def_boolean(func, "update_data", 0, "", "Update data by re-adjusting the material slots assigned"); -- cgit v1.2.3 From 25872cae291235ec49298419a2fa141a1c98cbb9 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Sat, 13 Aug 2016 01:29:17 +0200 Subject: Fix error in GPencil V2 version patching GPencil conversion would just always run for file version 2.77.3. This wasn't an issue in master, but possibly for other branches that used the 2.77.3 block. Wasn't aware that you have to add the asterisk for pointers either, this is kinda weird. Anyway, it's running correctly now. --- source/blender/blenloader/intern/versioning_270.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index af95649a559..f41aba1b5b0 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -1246,7 +1246,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) if (!MAIN_VERSION_ATLEAST(main, 277, 3)) { /* ------- init of grease pencil initialization --------------- */ - if (!DNA_struct_elem_find(fd->filesdna, "bGPDstroke", "bGPDpalettecolor", "palcolor")) { + if (!DNA_struct_elem_find(fd->filesdna, "bGPDstroke", "bGPDpalettecolor", "*palcolor")) { for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { ToolSettings *ts = scene->toolsettings; /* initialize use position for sculpt brushes */ -- cgit v1.2.3 From fcb78f24023a6e30412ea65e8951b2a51f7f3389 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Sat, 13 Aug 2016 01:40:19 +0200 Subject: Add DNA_struct_find (useful for version patching) --- source/blender/makesdna/DNA_genfile.h | 1 + source/blender/makesdna/intern/dna_genfile.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/source/blender/makesdna/DNA_genfile.h b/source/blender/makesdna/DNA_genfile.h index a2981c0aa76..9e9ab974b01 100644 --- a/source/blender/makesdna/DNA_genfile.h +++ b/source/blender/makesdna/DNA_genfile.h @@ -100,6 +100,7 @@ void *DNA_struct_reconstruct( int DNA_elem_array_size(const char *str); int DNA_elem_offset(struct SDNA *sdna, const char *stype, const char *vartype, const char *name); +bool DNA_struct_find(const struct SDNA *sdna, const char *stype); bool DNA_struct_elem_find(const struct SDNA *sdna, const char *stype, const char *vartype, const char *name); diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 6a41591e051..96085a79eff 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -1294,6 +1294,11 @@ int DNA_elem_offset(SDNA *sdna, const char *stype, const char *vartype, const ch return (int)((intptr_t)cp); } +bool DNA_struct_find(const SDNA *sdna, const char *stype) +{ + return DNA_struct_find_nr(sdna, stype) != -1; +} + bool DNA_struct_elem_find(const SDNA *sdna, const char *stype, const char *vartype, const char *name) { const int SDNAnr = DNA_struct_find_nr(sdna, stype); -- cgit v1.2.3 From c395d044fcce02321f1689b8b025369fb2dbd6a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20T=C3=B6nne?= Date: Sat, 13 Aug 2016 16:31:46 +0200 Subject: Fix T49082: Intermediate update call when making links can change group socket layout. Node tree update calls in the middle of a socket loop are dangerous, they can change sockets on group nodes and link instances in particular. Updates should only happen after the operator has finished. Simply removed the extra convenience check for validity now. Worst case an invalid (red) link is created which can be removed by the user as well and should simply be ignored by node systems. The update system in nodes needs a complete rewrite to handle complex cases like this, where an operator may need to react to changes during its execution. --- source/blender/editors/space_node/node_relationships.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index ea3869ef387..5f592431558 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -276,25 +276,16 @@ static bNodeSocket *best_socket_input(bNodeTree *ntree, bNode *node, int num, in return NULL; } -static int snode_autoconnect_input(SpaceNode *snode, bNode *node_fr, bNodeSocket *sock_fr, bNode *node_to, bNodeSocket *sock_to, int replace) +static bool snode_autoconnect_input(SpaceNode *snode, bNode *node_fr, bNodeSocket *sock_fr, bNode *node_to, bNodeSocket *sock_to, int replace) { bNodeTree *ntree = snode->edittree; - bNodeLink *link; /* then we can connect */ if (replace) nodeRemSocketLinks(ntree, sock_to); - link = nodeAddLink(ntree, node_fr, sock_fr, node_to, sock_to); - /* validate the new link */ - ntreeUpdateTree(G.main, ntree); - if (!(link->flag & NODE_LINK_VALID)) { - nodeRemLink(ntree, link); - return 0; - } - - snode_update(snode, node_to); - return 1; + nodeAddLink(ntree, node_fr, sock_fr, node_to, sock_to); + return true; } static void snode_autoconnect(SpaceNode *snode, const bool allow_multiple, const bool replace) -- cgit v1.2.3 From 35a6e540b172cf351da34715b8ad2e0bebc92d44 Mon Sep 17 00:00:00 2001 From: Antonioya Date: Sat, 13 Aug 2016 16:59:53 +0200 Subject: GPencil: Cleanup code --- source/blender/makesdna/DNA_gpencil_types.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h index f1546053c5c..773d203bdb3 100644 --- a/source/blender/makesdna/DNA_gpencil_types.h +++ b/source/blender/makesdna/DNA_gpencil_types.h @@ -298,9 +298,8 @@ typedef struct bGPdata { char pad[6]; /* padding for compiler alignment error */ short sflag; /* settings for palette color */ - /* saved paletes and brushes */ + /* saved palettes */ ListBase palettes; - //ListBase brushes; } bGPdata; /* bGPdata->flag */ -- cgit v1.2.3 From da77d9873f1632f2ec4b624e949c0270753fa465 Mon Sep 17 00:00:00 2001 From: Luca Rood Date: Sat, 13 Aug 2016 19:40:22 +0300 Subject: Prevent max stiffness values from going under normal stiffness values in cloth stiffness scaling. When updating the max values under stiffness scaling, they clip at the normal stiffness values as expected, however when updating stiffness values, you could set them higher than the max values, and the max values weren't updated accordingly. As the stiffness scaling computes using the absolute difference between the max values and the stiffness values, you got higher stiffnesses in scaled areas even though your max is actually lower than the normal stiffness. This diff fixes that behaviour, by updating the max values to be equal to the stiffness whenever you set a higher stiffness than the max value. Also, I have initialized the max values to the same as the stiffnesses, as they were previously just set to zero, and caused the same problem described above. Reviewers: lukastoenne Reviewed By: lukastoenne Tags: #physics Differential Revision: https://developer.blender.org/D2147 --- source/blender/blenkernel/intern/cloth.c | 2 ++ source/blender/makesrna/intern/rna_cloth.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 445be5277d8..28ef3f6f248 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -81,8 +81,10 @@ void cloth_init(ClothModifierData *clmd ) clmd->sim_parms->gravity[1] = 0.0; clmd->sim_parms->gravity[2] = -9.81; clmd->sim_parms->structural = 15.0; + clmd->sim_parms->max_struct = 15.0; clmd->sim_parms->shear = 15.0; clmd->sim_parms->bending = 0.5; + clmd->sim_parms->max_bend = 0.5; clmd->sim_parms->bending_damping = 0.5; clmd->sim_parms->Cdis = 5.0; clmd->sim_parms->Cvi = 1.0; diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c index 781e44c9ed6..91cae32d054 100644 --- a/source/blender/makesrna/intern/rna_cloth.c +++ b/source/blender/makesrna/intern/rna_cloth.c @@ -68,6 +68,16 @@ static void rna_cloth_pinning_changed(Main *UNUSED(bmain), Scene *UNUSED(scene), WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob); } +static void rna_ClothSettings_bending_set(struct PointerRNA *ptr, float value) +{ + ClothSimSettings *settings = (ClothSimSettings *)ptr->data; + + settings->bending = value; + + /* check for max clipping */ + if (value > settings->max_bend) + settings->max_bend = value; +} static void rna_ClothSettings_max_bend_set(struct PointerRNA *ptr, float value) { @@ -80,6 +90,17 @@ static void rna_ClothSettings_max_bend_set(struct PointerRNA *ptr, float value) settings->max_bend = value; } +static void rna_ClothSettings_structural_set(struct PointerRNA *ptr, float value) +{ + ClothSimSettings *settings = (ClothSimSettings *)ptr->data; + + settings->structural = value; + + /* check for max clipping */ + if (value > settings->max_struct) + settings->max_struct = value; +} + static void rna_ClothSettings_max_struct_set(struct PointerRNA *ptr, float value) { ClothSimSettings *settings = (ClothSimSettings *)ptr->data; @@ -493,6 +514,7 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "structural_stiffness", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "structural"); RNA_def_property_range(prop, 0.0f, 10000.0f); + RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_structural_set", NULL); RNA_def_property_ui_text(prop, "Structural Stiffness", "Overall stiffness of structure"); RNA_def_property_update(prop, 0, "rna_cloth_update"); @@ -521,6 +543,7 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "bending_stiffness", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "bending"); RNA_def_property_range(prop, 0.0f, 10000.0f); + RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_bending_set", NULL); RNA_def_property_ui_text(prop, "Bending Stiffness", "Wrinkle coefficient (higher = less smaller but more big wrinkles)"); RNA_def_property_update(prop, 0, "rna_cloth_update"); -- cgit v1.2.3 From 5c0a67b325b2c07574ef303947d5c026ab3f55d5 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 14 Aug 2016 20:21:08 +0200 Subject: Cycles: Add single channel texture support for OpenCL. This way OpenCL devices can also benefit from a smaller memory footprint, when using e.g. bumpmaps (greyscale, 1 channel). Additional target for my GSoC 2016. --- intern/cycles/kernel/kernel_compat_cpu.h | 1 + intern/cycles/kernel/kernel_textures.h | 2 + intern/cycles/kernel/svm/svm_image.h | 17 +++++- intern/cycles/render/image.cpp | 90 +++++++++++++++++++++++++++++--- intern/cycles/render/scene.h | 2 + intern/cycles/util/util_texture.h | 4 +- 6 files changed, 105 insertions(+), 11 deletions(-) diff --git a/intern/cycles/kernel/kernel_compat_cpu.h b/intern/cycles/kernel/kernel_compat_cpu.h index c882b477c35..3775934f293 100644 --- a/intern/cycles/kernel/kernel_compat_cpu.h +++ b/intern/cycles/kernel/kernel_compat_cpu.h @@ -495,6 +495,7 @@ typedef texture texture_uint; typedef texture texture_int; typedef texture texture_uint4; typedef texture texture_uchar4; +typedef texture texture_uchar; typedef texture_image texture_image_float; typedef texture_image texture_image_uchar; typedef texture_image texture_image_half; diff --git a/intern/cycles/kernel/kernel_textures.h b/intern/cycles/kernel/kernel_textures.h index 7d6fec02331..8d5bb75a428 100644 --- a/intern/cycles/kernel/kernel_textures.h +++ b/intern/cycles/kernel/kernel_textures.h @@ -188,6 +188,8 @@ KERNEL_TEX(uint, texture_uint, __bindless_mapping) /* packed image (opencl) */ KERNEL_TEX(uchar4, texture_uchar4, __tex_image_byte4_packed) KERNEL_TEX(float4, texture_float4, __tex_image_float4_packed) +KERNEL_TEX(uchar, texture_uchar, __tex_image_byte_packed) +KERNEL_TEX(float, texture_float, __tex_image_float_packed) KERNEL_TEX(uint4, texture_uint4, __tex_image_packed_info) #undef KERNEL_TEX diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h index 9050ce93951..5d02be1fa2f 100644 --- a/intern/cycles/kernel/svm/svm_image.h +++ b/intern/cycles/kernel/svm/svm_image.h @@ -36,13 +36,26 @@ CCL_NAMESPACE_BEGIN ccl_device_inline float4 svm_image_texture_read(KernelGlobals *kg, int id, int offset) { - if(id >= TEX_NUM_FLOAT4_IMAGES) { + /* Float4 */ + if(id < TEX_START_BYTE4_OPENCL) { + return kernel_tex_fetch(__tex_image_float4_packed, offset); + } + /* Byte4 */ + else if(id < TEX_START_FLOAT_OPENCL) { uchar4 r = kernel_tex_fetch(__tex_image_byte4_packed, offset); float f = 1.0f/255.0f; return make_float4(r.x*f, r.y*f, r.z*f, r.w*f); } + /* Float */ + else if(id < TEX_START_BYTE_OPENCL) { + float f = kernel_tex_fetch(__tex_image_float_packed, offset); + return make_float4(f, f, f, 1.0f); + } + /* Byte */ else { - return kernel_tex_fetch(__tex_image_float4_packed, offset); + uchar r = kernel_tex_fetch(__tex_image_byte_packed, offset); + float f = r * (1.0f/255.0f); + return make_float4(f, f, f, 1.0f); } } diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index 284af5f90f7..24543601ef9 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -284,7 +284,7 @@ int ImageManager::add_image(const string& filename, if(type == IMAGE_DATA_TYPE_FLOAT || type == IMAGE_DATA_TYPE_FLOAT4) is_float = true; - /* No single channel and half textures on CUDA (Fermi) and OpenCL, use available slots */ + /* No single channel and half textures on CUDA (Fermi) and no half on OpenCL, use available slots */ if((type == IMAGE_DATA_TYPE_FLOAT || type == IMAGE_DATA_TYPE_HALF4 || type == IMAGE_DATA_TYPE_HALF) && @@ -1105,10 +1105,11 @@ void ImageManager::device_pack_images(Device *device, size_t size = 0, offset = 0; ImageDataType type; - int info_size = tex_num_images[IMAGE_DATA_TYPE_FLOAT4] + tex_num_images[IMAGE_DATA_TYPE_BYTE4]; + int info_size = tex_num_images[IMAGE_DATA_TYPE_FLOAT4] + tex_num_images[IMAGE_DATA_TYPE_BYTE4] + + tex_num_images[IMAGE_DATA_TYPE_FLOAT] + tex_num_images[IMAGE_DATA_TYPE_BYTE]; uint4 *info = dscene->tex_image_packed_info.resize(info_size); - /* Byte Textures*/ + /* Byte4 Textures*/ type = IMAGE_DATA_TYPE_BYTE4; for(size_t slot = 0; slot < images[type].size(); slot++) { @@ -1119,7 +1120,7 @@ void ImageManager::device_pack_images(Device *device, size += tex_img.size(); } - uchar4 *pixels_byte = dscene->tex_image_byte4_packed.resize(size); + uchar4 *pixels_byte4 = dscene->tex_image_byte4_packed.resize(size); for(size_t slot = 0; slot < images[type].size(); slot++) { if(!images[type][slot]) @@ -1131,11 +1132,11 @@ void ImageManager::device_pack_images(Device *device, info[type_index_to_flattened_slot(slot, type)] = make_uint4(tex_img.data_width, tex_img.data_height, offset, options); - memcpy(pixels_byte+offset, (void*)tex_img.data_pointer, tex_img.memory_size()); + memcpy(pixels_byte4+offset, (void*)tex_img.data_pointer, tex_img.memory_size()); offset += tex_img.size(); } - /* Float Textures*/ + /* Float4 Textures*/ type = IMAGE_DATA_TYPE_FLOAT4; size = 0, offset = 0; @@ -1147,7 +1148,7 @@ void ImageManager::device_pack_images(Device *device, size += tex_img.size(); } - float4 *pixels_float = dscene->tex_image_float4_packed.resize(size); + float4 *pixels_float4 = dscene->tex_image_float4_packed.resize(size); for(size_t slot = 0; slot < images[type].size(); slot++) { if(!images[type][slot]) @@ -1160,6 +1161,63 @@ void ImageManager::device_pack_images(Device *device, uint8_t options = pack_image_options(type, slot); info[type_index_to_flattened_slot(slot, type)] = make_uint4(tex_img.data_width, tex_img.data_height, offset, options); + memcpy(pixels_float4+offset, (void*)tex_img.data_pointer, tex_img.memory_size()); + offset += tex_img.size(); + } + + /* Byte Textures*/ + type = IMAGE_DATA_TYPE_BYTE; + size = 0, offset = 0; + + for(size_t slot = 0; slot < images[type].size(); slot++) { + if(!images[type][slot]) + continue; + + device_vector& tex_img = dscene->tex_byte_image[slot]; + size += tex_img.size(); + } + + uchar *pixels_byte = dscene->tex_image_byte_packed.resize(size); + + for(size_t slot = 0; slot < images[type].size(); slot++) { + if(!images[type][slot]) + continue; + + device_vector& tex_img = dscene->tex_byte_image[slot]; + + uint8_t options = pack_image_options(type, slot); + + info[type_index_to_flattened_slot(slot, type)] = make_uint4(tex_img.data_width, tex_img.data_height, offset, options); + + memcpy(pixels_byte+offset, (void*)tex_img.data_pointer, tex_img.memory_size()); + offset += tex_img.size(); + } + + /* Float Textures*/ + type = IMAGE_DATA_TYPE_FLOAT; + size = 0, offset = 0; + + for(size_t slot = 0; slot < images[type].size(); slot++) { + if(!images[type][slot]) + continue; + + device_vector& tex_img = dscene->tex_float_image[slot]; + size += tex_img.size(); + } + + float *pixels_float = dscene->tex_image_float_packed.resize(size); + + for(size_t slot = 0; slot < images[type].size(); slot++) { + if(!images[type][slot]) + continue; + + device_vector& tex_img = dscene->tex_float_image[slot]; + + /* todo: support 3D textures, only CPU for now */ + + uint8_t options = pack_image_options(type, slot); + info[type_index_to_flattened_slot(slot, type)] = make_uint4(tex_img.data_width, tex_img.data_height, offset, options); + memcpy(pixels_float+offset, (void*)tex_img.data_pointer, tex_img.memory_size()); offset += tex_img.size(); } @@ -1178,6 +1236,20 @@ void ImageManager::device_pack_images(Device *device, } device->tex_alloc("__tex_image_float4_packed", dscene->tex_image_float4_packed); } + if(dscene->tex_image_byte_packed.size()) { + if(dscene->tex_image_byte_packed.device_pointer) { + thread_scoped_lock device_lock(device_mutex); + device->tex_free(dscene->tex_image_byte_packed); + } + device->tex_alloc("__tex_image_byte_packed", dscene->tex_image_byte_packed); + } + if(dscene->tex_image_float_packed.size()) { + if(dscene->tex_image_float_packed.device_pointer) { + thread_scoped_lock device_lock(device_mutex); + device->tex_free(dscene->tex_image_float_packed); + } + device->tex_alloc("__tex_image_float_packed", dscene->tex_image_float_packed); + } if(dscene->tex_image_packed_info.size()) { if(dscene->tex_image_packed_info.device_pointer) { thread_scoped_lock device_lock(device_mutex); @@ -1208,10 +1280,14 @@ void ImageManager::device_free(Device *device, DeviceScene *dscene) device->tex_free(dscene->tex_image_byte4_packed); device->tex_free(dscene->tex_image_float4_packed); + device->tex_free(dscene->tex_image_byte_packed); + device->tex_free(dscene->tex_image_float_packed); device->tex_free(dscene->tex_image_packed_info); dscene->tex_image_byte4_packed.clear(); dscene->tex_image_float4_packed.clear(); + dscene->tex_image_byte_packed.clear(); + dscene->tex_image_float_packed.clear(); dscene->tex_image_packed_info.clear(); } diff --git a/intern/cycles/render/scene.h b/intern/cycles/render/scene.h index 9e72f197cce..8fec171b6fb 100644 --- a/intern/cycles/render/scene.h +++ b/intern/cycles/render/scene.h @@ -123,6 +123,8 @@ public: /* opencl images */ device_vector tex_image_byte4_packed; device_vector tex_image_float4_packed; + device_vector tex_image_byte_packed; + device_vector tex_image_float_packed; device_vector tex_image_packed_info; KernelData data; diff --git a/intern/cycles/util/util_texture.h b/intern/cycles/util/util_texture.h index be1177d3be9..aff928ea2ee 100644 --- a/intern/cycles/util/util_texture.h +++ b/intern/cycles/util/util_texture.h @@ -67,8 +67,8 @@ CCL_NAMESPACE_BEGIN #define TEX_NUM_FLOAT4_OPENCL 1024 #define TEX_NUM_BYTE4_OPENCL 1024 #define TEX_NUM_HALF4_OPENCL 0 -#define TEX_NUM_FLOAT_OPENCL 0 -#define TEX_NUM_BYTE_OPENCL 0 +#define TEX_NUM_FLOAT_OPENCL 1024 +#define TEX_NUM_BYTE_OPENCL 1024 #define TEX_NUM_HALF_OPENCL 0 #define TEX_START_FLOAT4_OPENCL 0 #define TEX_START_BYTE4_OPENCL TEX_NUM_FLOAT4_OPENCL -- cgit v1.2.3 From 9396e11180fbdc380f06dbd4c696a9c39ff32ec9 Mon Sep 17 00:00:00 2001 From: Mai Lavelle Date: Sun, 14 Aug 2016 12:41:45 -0400 Subject: Cycles microdisplacement: Move call to tessellate() from addon to Cycles By calling `tessellate()` from the mesh manager in Cycles we can do pre/post processing or even threaded tessellation without concerning client side code with the details. --- intern/cycles/blender/blender_mesh.cpp | 9 ++++---- intern/cycles/render/mesh.cpp | 42 +++++++++++++++++++++++++++++++++- intern/cycles/render/mesh.h | 3 +++ intern/cycles/subd/CMakeLists.txt | 1 + 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp index 6dc26c2981b..c33bc4c263f 100644 --- a/intern/cycles/blender/blender_mesh.cpp +++ b/intern/cycles/blender/blender_mesh.cpp @@ -806,7 +806,10 @@ static void create_subd_mesh(Scene *scene, } /* set subd params */ - SubdParams sdparams(mesh); + if(!mesh->subd_params) { + mesh->subd_params = new SubdParams(mesh); + } + SubdParams& sdparams = *mesh->subd_params; PointerRNA cobj = RNA_pointer_get(&b_ob.ptr, "cycles"); @@ -816,10 +819,6 @@ static void create_subd_mesh(Scene *scene, scene->camera->update(); sdparams.camera = scene->camera; sdparams.objecttoworld = get_transform(b_ob.matrix_world()); - - /* tesselate */ - DiagSplit dsplit(sdparams); - mesh->tessellate(&dsplit); } /* Sync */ diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp index f90c19a11c8..fcf4e69984d 100644 --- a/intern/cycles/render/mesh.cpp +++ b/intern/cycles/render/mesh.cpp @@ -30,6 +30,7 @@ #include "osl_globals.h" +#include "subd_split.h" #include "subd_patch_table.h" #include "util_foreach.h" @@ -172,6 +173,7 @@ Mesh::Mesh() num_ngons = 0; subdivision_type = SUBDIVISION_NONE; + subd_params = NULL; patch_table = NULL; } @@ -180,6 +182,7 @@ Mesh::~Mesh() { delete bvh; delete patch_table; + delete subd_params; } void Mesh::resize_mesh(int numverts, int numtris) @@ -1659,6 +1662,42 @@ void MeshManager::device_update(Device *device, DeviceScene *dscene, Scene *scen } } + /* Tessellate meshes that are using subdivision */ + size_t total_tess_needed = 0; + foreach(Mesh *mesh, scene->meshes) { + if(mesh->need_update && + mesh->subdivision_type != Mesh::SUBDIVISION_NONE && + mesh->num_subd_verts == 0 && + mesh->subd_params) + { + total_tess_needed++; + } + } + + size_t i = 0; + foreach(Mesh *mesh, scene->meshes) { + if(mesh->need_update && + mesh->subdivision_type != Mesh::SUBDIVISION_NONE && + mesh->num_subd_verts == 0 && + mesh->subd_params) + { + string msg = "Tessellating "; + if(mesh->name == "") + msg += string_printf("%u/%u", (uint)(i+1), (uint)total_tess_needed); + else + msg += string_printf("%s %u/%u", mesh->name.c_str(), (uint)(i+1), (uint)total_tess_needed); + + progress.set_status("Updating Mesh", msg); + + DiagSplit dsplit(*mesh->subd_params); + mesh->tessellate(&dsplit); + + i++; + + if(progress.get_cancel()) return; + } + } + /* Update images needed for true displacement. */ bool true_displacement_used = false; bool old_need_object_flags_update = false; @@ -1719,7 +1758,7 @@ void MeshManager::device_update(Device *device, DeviceScene *dscene, Scene *scen } /* Update bvh. */ - size_t i = 0, num_bvh = 0; + size_t num_bvh = 0; foreach(Mesh *mesh, scene->meshes) { if(mesh->need_update && mesh->need_build_bvh()) { num_bvh++; @@ -1728,6 +1767,7 @@ void MeshManager::device_update(Device *device, DeviceScene *dscene, Scene *scen TaskPool pool; + i = 0; foreach(Mesh *mesh, scene->meshes) { if(mesh->need_update) { pool.push(function_bind(&Mesh::compute_bvh, diff --git a/intern/cycles/render/mesh.h b/intern/cycles/render/mesh.h index eff5c50e635..a77e296ea4a 100644 --- a/intern/cycles/render/mesh.h +++ b/intern/cycles/render/mesh.h @@ -39,6 +39,7 @@ class Progress; class Scene; class SceneParams; class AttributeRequest; +struct SubdParams; class DiagSplit; struct PackedPatchTable; @@ -156,6 +157,8 @@ public: array subd_creases; + SubdParams *subd_params; + vector used_shaders; AttributeSet attributes; AttributeSet curve_attributes; diff --git a/intern/cycles/subd/CMakeLists.txt b/intern/cycles/subd/CMakeLists.txt index 9265299e82b..dafb807bdf3 100644 --- a/intern/cycles/subd/CMakeLists.txt +++ b/intern/cycles/subd/CMakeLists.txt @@ -22,6 +22,7 @@ set(SRC set(SRC_HEADERS subd_dice.h subd_patch.h + subd_patch_table.h subd_split.h ) -- cgit v1.2.3 From a18b2ba64366bd1a4c9a729aaafce68ab1fee5a7 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 14 Aug 2016 22:22:21 +0200 Subject: Cycles: Use half storage for 16bit files (e.g. 16bit pngs) as well. Note: This only works for textures loaded from disk via OIIO, not packed textures. That's still a ToDo. --- intern/cycles/render/image.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index 24543601ef9..fae50f4ea5e 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -176,7 +176,9 @@ ImageManager::ImageDataType ImageManager::get_image_metadata(const string& filen } /* check if it's half float */ - if(spec.format == TypeDesc::HALF) + if(spec.format == TypeDesc::HALF || + spec.format == TypeDesc::USHORT || + spec.format == TypeDesc::SHORT) is_half = true; channels = spec.nchannels; -- cgit v1.2.3 From 4d41d8be790ecee0d91ac7b08b3611ec4d14096a Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Mon, 15 Aug 2016 00:04:19 +0200 Subject: Fix CUDA compilation after OpenCL changes. --- intern/cycles/kernel/kernel_textures.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/intern/cycles/kernel/kernel_textures.h b/intern/cycles/kernel/kernel_textures.h index 8d5bb75a428..f45da39bad5 100644 --- a/intern/cycles/kernel/kernel_textures.h +++ b/intern/cycles/kernel/kernel_textures.h @@ -186,11 +186,13 @@ KERNEL_TEX(uint, texture_uint, __bindless_mapping) #endif /* packed image (opencl) */ +#ifdef __KERNEL_OPENCL__ KERNEL_TEX(uchar4, texture_uchar4, __tex_image_byte4_packed) KERNEL_TEX(float4, texture_float4, __tex_image_float4_packed) KERNEL_TEX(uchar, texture_uchar, __tex_image_byte_packed) KERNEL_TEX(float, texture_float, __tex_image_float_packed) KERNEL_TEX(uint4, texture_uint4, __tex_image_packed_info) +#endif #undef KERNEL_TEX #undef KERNEL_IMAGE_TEX -- cgit v1.2.3 From 9b0f6fa7f77972c2e1838979b2b5bfd0580423d7 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Mon, 15 Aug 2016 01:01:43 +0200 Subject: Revert "Cycles: Use half storage for 16bit files (e.g. 16bit pngs) as well." After discussion in IRC, 16bit int should not be converted to half, too much precision loss. --- intern/cycles/render/image.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index fae50f4ea5e..24543601ef9 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -176,9 +176,7 @@ ImageManager::ImageDataType ImageManager::get_image_metadata(const string& filen } /* check if it's half float */ - if(spec.format == TypeDesc::HALF || - spec.format == TypeDesc::USHORT || - spec.format == TypeDesc::SHORT) + if(spec.format == TypeDesc::HALF) is_half = true; channels = spec.nchannels; -- cgit v1.2.3 From 55eb8ce87361e968b153a3e728e6842e3069d093 Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Tue, 9 Aug 2016 01:29:58 -0400 Subject: OpenGL: enhance debug output When running blender --debug-gpu Display which debug facilities are available. One of these, in order of preference: - OpenGL 4.3 - KHR_debug - ARB_debug_output - AMD_debug_output All messages are logged now, not just errors. Will probably turn some of these off later. GL_DEBUG_OUTPUT_SYNCHRONOUS lets us break on errors and backtrace to the exact trouble spot. Callers of GPU_string_marker no longer pass in a message length, just the message itself (null terminated). Apple provides no GL debug logging features. --- source/blender/gpu/GPU_debug.h | 2 +- source/blender/gpu/intern/gpu_debug.c | 101 ++++++++++++++++++++++++++-------- 2 files changed, 79 insertions(+), 24 deletions(-) diff --git a/source/blender/gpu/GPU_debug.h b/source/blender/gpu/GPU_debug.h index 2c1728bfff1..ec0db43c38c 100644 --- a/source/blender/gpu/GPU_debug.h +++ b/source/blender/gpu/GPU_debug.h @@ -62,7 +62,7 @@ void GPU_assert_no_gl_errors(const char *file, int line, const char *str); /* inserts a debug marker message for the debug context messaging system */ -void GPU_string_marker(size_t size, const char *str); +void GPU_string_marker(const char *str); #ifdef __cplusplus } diff --git a/source/blender/gpu/intern/gpu_debug.c b/source/blender/gpu/intern/gpu_debug.c index be9285727fe..555af8b087a 100644 --- a/source/blender/gpu/intern/gpu_debug.c +++ b/source/blender/gpu/intern/gpu_debug.c @@ -159,29 +159,78 @@ const char *gpuErrorString(GLenum err) #endif +static const char* source_name(GLenum source) +{ + switch (source) { + case GL_DEBUG_SOURCE_API: return "API"; + case GL_DEBUG_SOURCE_WINDOW_SYSTEM: return "window system"; + case GL_DEBUG_SOURCE_SHADER_COMPILER: return "shader compiler"; + case GL_DEBUG_SOURCE_THIRD_PARTY: return "3rd party"; + case GL_DEBUG_SOURCE_APPLICATION: return "application"; + case GL_DEBUG_SOURCE_OTHER: return "other"; + default: return "???"; + } +} + +static const char* message_type_name(GLenum message) +{ + switch (message) { + case GL_DEBUG_TYPE_ERROR: return "error"; + case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: return "deprecated behavior"; + case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: return "undefined behavior"; + case GL_DEBUG_TYPE_PORTABILITY: return "portability"; + case GL_DEBUG_TYPE_PERFORMANCE: return "performance"; + case GL_DEBUG_TYPE_OTHER: return "other"; + case GL_DEBUG_TYPE_MARKER: return "marker"; /* KHR has this, ARB does not */ + default: return "???"; + } +} + +static const char* category_name_amd(GLenum category) +{ + switch (category) { + case GL_DEBUG_CATEGORY_API_ERROR_AMD: return "API error"; + case GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD: return "window system"; + case GL_DEBUG_CATEGORY_DEPRECATION_AMD: return "deprecated behavior"; + case GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD: return "undefined behavior"; + case GL_DEBUG_CATEGORY_PERFORMANCE_AMD: return "performance"; + case GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD: return "shader compiler"; + case GL_DEBUG_CATEGORY_APPLICATION_AMD: return "application"; + case GL_DEBUG_CATEGORY_OTHER_AMD: return "other"; + default: return "???"; + } +} + + static void APIENTRY gpu_debug_proc( GLenum source, GLenum type, GLuint UNUSED(id), - GLenum UNUSED(severity), GLsizei UNUSED(length), + GLenum severity, GLsizei UNUSED(length), const GLchar *message, const GLvoid *UNUSED(userParm)) { - if (source == GL_DEBUG_SOURCE_API && type == GL_DEBUG_TYPE_ERROR) { - fprintf(stderr, "GL: %s\n", message); - fflush(stderr); - } - else if (G.debug_value == 20) { - fprintf(stderr, "GL: %s\n", message); - fflush(stderr); + switch (severity) { + case GL_DEBUG_SEVERITY_HIGH: + case GL_DEBUG_SEVERITY_MEDIUM: + case GL_DEBUG_SEVERITY_LOW: + case GL_DEBUG_SEVERITY_NOTIFICATION: /* KHR has this, ARB does not */ + fprintf(stderr, "GL %s %s: %s\n", source_name(source), message_type_name(type), message); + fflush(stderr); } } #ifndef GLEW_ES_ONLY static void APIENTRY gpu_debug_proc_amd( - GLuint UNUSED(id), GLenum UNUSED(category), - GLenum UNUSED(severity), GLsizei UNUSED(length), + GLuint UNUSED(id), GLenum category, + GLenum severity, GLsizei UNUSED(length), const GLchar *message, GLvoid *UNUSED(userParm)) { - fprintf(stderr, "GL: %s\n", message); + switch (severity) { + case GL_DEBUG_SEVERITY_HIGH: + case GL_DEBUG_SEVERITY_MEDIUM: + case GL_DEBUG_SEVERITY_LOW: + fprintf(stderr, "GL %s: %s\n", category_name_amd(category), message); + fflush(stderr); + } } #endif @@ -194,36 +243,44 @@ void gpu_debug_init(void) #if !defined(WITH_GLEW_ES) && !defined(GLEW_ES_ONLY) if (GLEW_VERSION_4_3) { + fprintf(stderr, "Using OpenGL 4.3 debug facilities\n"); glEnable(GL_DEBUG_OUTPUT); + glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); glDebugMessageCallback((GLDEBUGPROC)gpu_debug_proc, mxGetCurrentContext()); glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE); - GPU_string_marker(sizeof(success), success); + GPU_string_marker(success); return; } #endif if (GLEW_KHR_debug) { #ifndef GLEW_ES_ONLY + fprintf(stderr, "Using KHR_debug extension\n"); + glEnable(GL_DEBUG_OUTPUT); + glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); glDebugMessageCallback((GLDEBUGPROC)gpu_debug_proc, mxGetCurrentContext()); glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE); - GPU_string_marker(sizeof(success), success); + GPU_string_marker(success); #endif return; } #ifndef GLEW_ES_ONLY if (GLEW_ARB_debug_output) { + fprintf(stderr, "Using ARB_debug_output extension\n"); + glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); glDebugMessageCallbackARB((GLDEBUGPROCARB)gpu_debug_proc, mxGetCurrentContext()); glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE); - GPU_string_marker(sizeof(success), success); + GPU_string_marker(success); return; } if (GLEW_AMD_debug_output) { + fprintf(stderr, "Using AMD_debug_output extension\n"); glDebugMessageCallbackAMD(gpu_debug_proc_amd, mxGetCurrentContext()); glDebugMessageEnableAMD(GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE); - GPU_string_marker(sizeof(success), success); + GPU_string_marker(success); return; } @@ -271,14 +328,14 @@ void gpu_debug_exit(void) return; } -void GPU_string_marker(size_t length, const char *buf) +void GPU_string_marker(const char *buf) { #ifndef WITH_GLEW_ES #ifndef GLEW_ES_ONLY if (GLEW_VERSION_4_3) { glDebugMessageInsert( GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0, - GL_DEBUG_SEVERITY_NOTIFICATION, length, buf); + GL_DEBUG_SEVERITY_NOTIFICATION, -1, buf); return; } @@ -289,7 +346,7 @@ void GPU_string_marker(size_t length, const char *buf) #ifndef GLEW_ES_ONLY glDebugMessageInsert( GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0, - GL_DEBUG_SEVERITY_NOTIFICATION, length, buf); + GL_DEBUG_SEVERITY_NOTIFICATION, -1, buf); #endif return; } @@ -298,7 +355,7 @@ void GPU_string_marker(size_t length, const char *buf) if (GLEW_ARB_debug_output) { glDebugMessageInsertARB( GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_OTHER_ARB, 0, - GL_DEBUG_SEVERITY_LOW_ARB, length, buf); + GL_DEBUG_SEVERITY_LOW_ARB, -1, buf); return; } @@ -306,19 +363,17 @@ void GPU_string_marker(size_t length, const char *buf) if (GLEW_AMD_debug_output) { glDebugMessageInsertAMD( GL_DEBUG_CATEGORY_APPLICATION_AMD, GL_DEBUG_SEVERITY_LOW_AMD, 0, - length, buf); + 0, buf); return; } if (GLEW_GREMEDY_string_marker) { - glStringMarkerGREMEDY(length, buf); + glStringMarkerGREMEDY(0, buf); return; } #endif - - return; } void GPU_print_error_debug(const char *str) -- cgit v1.2.3 From ad6e7a0be15cf6c47635987a04cd5824fb5de054 Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Mon, 15 Aug 2016 04:00:59 -0400 Subject: OpenGL: backtrace on errors (--debug-gpu) Backtrace so we can pinpoint where the GL error came from. Then fflush on severe errors in case it's severe enough to crash Blender. --- source/blender/gpu/intern/gpu_debug.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/source/blender/gpu/intern/gpu_debug.c b/source/blender/gpu/intern/gpu_debug.c index 555af8b087a..21458a22221 100644 --- a/source/blender/gpu/intern/gpu_debug.c +++ b/source/blender/gpu/intern/gpu_debug.c @@ -207,13 +207,21 @@ static void APIENTRY gpu_debug_proc( GLenum severity, GLsizei UNUSED(length), const GLchar *message, const GLvoid *UNUSED(userParm)) { + bool backtrace = false; + switch (severity) { case GL_DEBUG_SEVERITY_HIGH: + backtrace = true; + /* fall through */ case GL_DEBUG_SEVERITY_MEDIUM: case GL_DEBUG_SEVERITY_LOW: case GL_DEBUG_SEVERITY_NOTIFICATION: /* KHR has this, ARB does not */ fprintf(stderr, "GL %s %s: %s\n", source_name(source), message_type_name(type), message); - fflush(stderr); + } + + if (backtrace) { + BLI_system_backtrace(stderr); + fflush(stderr); } } @@ -224,12 +232,20 @@ static void APIENTRY gpu_debug_proc_amd( GLenum severity, GLsizei UNUSED(length), const GLchar *message, GLvoid *UNUSED(userParm)) { + bool backtrace = false; + switch (severity) { case GL_DEBUG_SEVERITY_HIGH: + backtrace = true; + /* fall through */ case GL_DEBUG_SEVERITY_MEDIUM: case GL_DEBUG_SEVERITY_LOW: fprintf(stderr, "GL %s: %s\n", category_name_amd(category), message); - fflush(stderr); + } + + if (backtrace) { + BLI_system_backtrace(stderr); + fflush(stderr); } } #endif -- cgit v1.2.3 From 2c03d0186a014e4478aecb8e2a000bf2d530db10 Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Mon, 15 Aug 2016 04:49:07 -0400 Subject: OpenGL: debug context on Windows Enable based on --debug-gpu at the command line. Linux already works this way. This commit in master (2.78 timeframe) is the smallest change that gets the desired result. I did a similar commit in blender2.8. Most ongoing GL debug work will go into 2.8, not 2.7x. In support of T49089 --- intern/ghost/intern/GHOST_WindowWin32.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 6a27d7aadf9..2aa950f8278 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -649,7 +649,7 @@ GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType ty WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 3, 2, #endif - GHOST_OPENGL_WGL_CONTEXT_FLAGS, + (m_debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0), GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY); #else # error -- cgit v1.2.3 From 988b4e2c80d85cdacc165a1ab660c5f481485c6a Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Mon, 15 Aug 2016 13:46:38 +0200 Subject: Tentative compile fix after recent gpu debug changes --- source/blender/gpu/intern/gpu_debug.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/gpu/intern/gpu_debug.c b/source/blender/gpu/intern/gpu_debug.c index 21458a22221..8d1ab43288a 100644 --- a/source/blender/gpu/intern/gpu_debug.c +++ b/source/blender/gpu/intern/gpu_debug.c @@ -43,6 +43,10 @@ #define CASE_CODE_RETURN_STR(code) case code: return #code; +#if (defined(__GNUC__) && !defined(__clang__)) && defined(NDEBUG) +# pragma GCC diagnostic ignored "-Wimplicit-function-declaration" +#endif + static const char *gpu_gl_error_symbol(GLenum err) { switch (err) { -- cgit v1.2.3 From ad4a01ec0fa72ab4626922e9d5d3dda1a46ca01b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 15 Aug 2016 15:34:41 +0200 Subject: Fix OpenGL backtrace build errors, without disabling warnings. --- source/blender/blenlib/BLI_system.h | 1 + source/blender/gpu/intern/gpu_debug.c | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/source/blender/blenlib/BLI_system.h b/source/blender/blenlib/BLI_system.h index cb8cb6f5a0d..92403eb7dea 100644 --- a/source/blender/blenlib/BLI_system.h +++ b/source/blender/blenlib/BLI_system.h @@ -28,6 +28,7 @@ int BLI_cpu_support_sse2(void); #if defined(NDEBUG) || !defined(__BLI_UTILDEFINES_H__) +#include void BLI_system_backtrace(FILE *fp); #endif diff --git a/source/blender/gpu/intern/gpu_debug.c b/source/blender/gpu/intern/gpu_debug.c index 8d1ab43288a..af69c2fca36 100644 --- a/source/blender/gpu/intern/gpu_debug.c +++ b/source/blender/gpu/intern/gpu_debug.c @@ -30,6 +30,7 @@ */ #include "BLI_sys_types.h" +#include "BLI_system.h" #include "BKE_global.h" @@ -43,10 +44,6 @@ #define CASE_CODE_RETURN_STR(code) case code: return #code; -#if (defined(__GNUC__) && !defined(__clang__)) && defined(NDEBUG) -# pragma GCC diagnostic ignored "-Wimplicit-function-declaration" -#endif - static const char *gpu_gl_error_symbol(GLenum err) { switch (err) { -- cgit v1.2.3 From 33c83a289d269986678caaf7e90ec6d5b729099a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 15 Aug 2016 16:17:47 +0200 Subject: Fix Cycles OpenCL textures after recent CUDA fix. kernel_textures.h is included in device_opencl.cpp, so we can't check __KERNEL_OPENCL__ there. --- intern/cycles/kernel/kernel_compat_cuda.h | 1 + intern/cycles/kernel/kernel_textures.h | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/intern/cycles/kernel/kernel_compat_cuda.h b/intern/cycles/kernel/kernel_compat_cuda.h index d656fac81e6..9a96cb9f438 100644 --- a/intern/cycles/kernel/kernel_compat_cuda.h +++ b/intern/cycles/kernel/kernel_compat_cuda.h @@ -67,6 +67,7 @@ typedef texture texture_float; typedef texture texture_uint; typedef texture texture_int; typedef texture texture_uint4; +typedef texture texture_uchar; typedef texture texture_uchar4; typedef texture texture_image_float4; typedef texture texture_image3d_float4; diff --git a/intern/cycles/kernel/kernel_textures.h b/intern/cycles/kernel/kernel_textures.h index f45da39bad5..8d5bb75a428 100644 --- a/intern/cycles/kernel/kernel_textures.h +++ b/intern/cycles/kernel/kernel_textures.h @@ -186,13 +186,11 @@ KERNEL_TEX(uint, texture_uint, __bindless_mapping) #endif /* packed image (opencl) */ -#ifdef __KERNEL_OPENCL__ KERNEL_TEX(uchar4, texture_uchar4, __tex_image_byte4_packed) KERNEL_TEX(float4, texture_float4, __tex_image_float4_packed) KERNEL_TEX(uchar, texture_uchar, __tex_image_byte_packed) KERNEL_TEX(float, texture_float, __tex_image_float_packed) KERNEL_TEX(uint4, texture_uint4, __tex_image_packed_info) -#endif #undef KERNEL_TEX #undef KERNEL_IMAGE_TEX -- cgit v1.2.3 From 76b6c77f2cba22a6760f0ff4e446b6ee4a7ad718 Mon Sep 17 00:00:00 2001 From: Mai Lavelle Date: Mon, 15 Aug 2016 09:08:38 -0400 Subject: Cycles microdisplacement: Allow kernels to be built without patch evaluation Kernels can now be built without patch evaluation when not needed by the scene (Catmull-Clark subdivision not in use), giving a performance boost for some devices. --- intern/cycles/device/device.cpp | 6 ++++++ intern/cycles/device/device.h | 10 +++++++++- intern/cycles/kernel/geom/geom.h | 4 +++- intern/cycles/kernel/geom/geom_subd_triangle.h | 10 ++++++++-- intern/cycles/kernel/kernel_types.h | 4 ++++ intern/cycles/render/session.cpp | 5 +++++ 6 files changed, 35 insertions(+), 4 deletions(-) diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index df01215c91a..85e736ad635 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -56,8 +56,14 @@ std::ostream& operator <<(std::ostream &os, << string_from_bool(requested_features.use_camera_motion) << std::endl; os << "Use Baking: " << string_from_bool(requested_features.use_baking) << std::endl; + os << "Use Subsurface: " + << string_from_bool(requested_features.use_subsurface) << std::endl; os << "Use Volume: " << string_from_bool(requested_features.use_volume) << std::endl; + os << "Use Branched Integrator: " + << string_from_bool(requested_features.use_integrator_branched) << std::endl; + os << "Use Patch Evaluation: " + << string_from_bool(requested_features.use_patch_evaluation) << std::endl; return os; } diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index e11bb7f76af..77dc1fa9713 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -109,6 +109,9 @@ public: /* Use branched integrator. */ bool use_integrator_branched; + /* Use OpenSubdiv patch evaluation */ + bool use_patch_evaluation; + DeviceRequestedFeatures() { /* TODO(sergey): Find more meaningful defaults. */ @@ -123,6 +126,7 @@ public: use_subsurface = false; use_volume = false; use_integrator_branched = false; + use_patch_evaluation = false; } bool modified(const DeviceRequestedFeatures& requested_features) @@ -137,7 +141,8 @@ public: use_baking == requested_features.use_baking && use_subsurface == requested_features.use_subsurface && use_volume == requested_features.use_volume && - use_integrator_branched == requested_features.use_integrator_branched); + use_integrator_branched == requested_features.use_integrator_branched && + use_patch_evaluation == requested_features.use_patch_evaluation); } /* Convert the requested features structure to a build options, @@ -175,6 +180,9 @@ public: if(!use_integrator_branched) { build_options += " -D__NO_BRANCHED_PATH__"; } + if(!use_patch_evaluation) { + build_options += " -D__NO_PATCH_EVAL__"; + } return build_options; } }; diff --git a/intern/cycles/kernel/geom/geom.h b/intern/cycles/kernel/geom/geom.h index 11548324e18..3605394f182 100644 --- a/intern/cycles/kernel/geom/geom.h +++ b/intern/cycles/kernel/geom/geom.h @@ -17,7 +17,9 @@ #include "geom_attribute.h" #include "geom_object.h" -#include "geom_patch.h" +#ifdef __PATCH_EVAL__ +# include "geom_patch.h" +#endif #include "geom_triangle.h" #include "geom_subd_triangle.h" #include "geom_triangle_intersect.h" diff --git a/intern/cycles/kernel/geom/geom_subd_triangle.h b/intern/cycles/kernel/geom/geom_subd_triangle.h index fccacf435f9..647840dc696 100644 --- a/intern/cycles/kernel/geom/geom_subd_triangle.h +++ b/intern/cycles/kernel/geom/geom_subd_triangle.h @@ -101,6 +101,7 @@ ccl_device_noinline float subd_triangle_attribute_float(KernelGlobals *kg, const { int patch = subd_triangle_patch(kg, sd); +#ifdef __PATCH_EVAL__ if(desc.flags & ATTR_SUBDIVIDED) { float2 uv[3]; subd_triangle_patch_uv(kg, sd, uv); @@ -144,7 +145,9 @@ ccl_device_noinline float subd_triangle_attribute_float(KernelGlobals *kg, const return a; } - else if(desc.element == ATTR_ELEMENT_FACE) { + else +#endif /* __PATCH_EVAL__ */ + if(desc.element == ATTR_ELEMENT_FACE) { if(dx) *dx = 0.0f; if(dy) *dy = 0.0f; @@ -217,6 +220,7 @@ ccl_device_noinline float3 subd_triangle_attribute_float3(KernelGlobals *kg, con { int patch = subd_triangle_patch(kg, sd); +#ifdef __PATCH_EVAL__ if(desc.flags & ATTR_SUBDIVIDED) { float2 uv[3]; subd_triangle_patch_uv(kg, sd, uv); @@ -266,7 +270,9 @@ ccl_device_noinline float3 subd_triangle_attribute_float3(KernelGlobals *kg, con return a; } - else if(desc.element == ATTR_ELEMENT_FACE) { + else +#endif /* __PATCH_EVAL__ */ + if(desc.element == ATTR_ELEMENT_FACE) { if(dx) *dx = make_float3(0.0f, 0.0f, 0.0f); if(dy) *dy = make_float3(0.0f, 0.0f, 0.0f); diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index bb26570455b..e29940672ca 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -148,6 +148,7 @@ CCL_NAMESPACE_BEGIN #define __CAMERA_CLIPPING__ #define __INTERSECTION_REFINE__ #define __CLAMP_SAMPLE__ +#define __PATCH_EVAL__ #ifdef __KERNEL_SHADING__ # define __SVM__ @@ -197,6 +198,9 @@ CCL_NAMESPACE_BEGIN #ifdef __NO_BRANCHED_PATH__ # undef __BRANCHED_PATH__ #endif +#ifdef __NO_PATCH_EVAL__ +# undef __PATCH_EVAL__ +#endif /* Random Numbers */ diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp index 1cd76ff2b39..9d8c9fed7af 100644 --- a/intern/cycles/render/session.cpp +++ b/intern/cycles/render/session.cpp @@ -635,6 +635,11 @@ DeviceRequestedFeatures Session::get_requested_device_features() } requested_features.use_object_motion |= object->use_motion | mesh->use_motion_blur; requested_features.use_camera_motion |= mesh->use_motion_blur; +#ifdef WITH_OPENSUBDIV + if(mesh->subdivision_type != Mesh::SUBDIVISION_NONE) { + requested_features.use_patch_evaluation = true; + } +#endif } BakeManager *bake_manager = scene->bake_manager; -- cgit v1.2.3 From c00b2d89911e20c8ace12a9256c689e9f43cc63b Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Mon, 15 Aug 2016 14:55:09 -0400 Subject: OpenGL: ignore deprecated API warnings Reduces noise from --debug-gpu so we can spot serious errors. Blender 2.7x uses OpenGL 2.1, we don't care if features are deprecated. I'll re-enable these warnings for blender2.8 after next merge. --- source/blender/gpu/intern/gpu_debug.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/blender/gpu/intern/gpu_debug.c b/source/blender/gpu/intern/gpu_debug.c index af69c2fca36..5ed51247858 100644 --- a/source/blender/gpu/intern/gpu_debug.c +++ b/source/blender/gpu/intern/gpu_debug.c @@ -208,6 +208,11 @@ static void APIENTRY gpu_debug_proc( GLenum severity, GLsizei UNUSED(length), const GLchar *message, const GLvoid *UNUSED(userParm)) { + if (type == GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR) { + /* Blender 2.7x uses OpenGL 2.1, we don't care if features are deprecated */ + return; + } + bool backtrace = false; switch (severity) { @@ -233,6 +238,11 @@ static void APIENTRY gpu_debug_proc_amd( GLenum severity, GLsizei UNUSED(length), const GLchar *message, GLvoid *UNUSED(userParm)) { + if (category == GL_DEBUG_CATEGORY_DEPRECATION_AMD) { + /* Blender 2.7x uses OpenGL 2.1, we don't care if features are deprecated */ + return; + } + bool backtrace = false; switch (severity) { -- cgit v1.2.3 From b1677201f9af7a3e5f5254817179f12384fbdc44 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 16 Aug 2016 10:32:55 +0200 Subject: Rework 2D stabilizator See this page for motivation and description of concepts: https://github.com/Ichthyostega/blender/wiki See this video for UI explanation and demonstration of usage http://vimeo.com/blenderHack/stabilizerdemo This proposal attempts to improve usability of Blender's image stabilization feature for real-world footage esp. with moving and panning camera. It builds upon the feature tracking to get a measurement of 2D image movement. - Use a weighted average of movement contributions (instead of a median). - Allow for rotation compensation and zoom (image scale) compensation. - Allow to pick a different set of tracks for translation and for rotation/zoom. - Treat translation / rotation / zoom contributions systematically in a similar way. - Improve handling of partial tracking data with gaps and varying start / end points. - Have a user definable anchor frame and interpolate / extrapolate data to avoid jumping back to "neutral" position when no tracking data is available. - Support for travelling and panning shots by including an //intended// position/rotation/zoom ("target position"). The idea is for these parameters to be //animated// by the user, in order to supply an smooth, intended camera movement. This way, we can keep the image content roughly in frame even when moving completely away from the initial view. A known shortcoming is that the pivot point for rotation compensation is set to the translation compensated image center. This can produce spurious rotation on travelling shots, which needs to be compensated manually (by animating the target rotation parameter). There are several possible ways to address that problem, yet all of them are considered beyond the scope of this improvement proposal for now. Own modifications: - Restrict line length, it's really handy for split-view editing - In motion tracking we prefer fully human-readable comments, meaning we don't use doxygen with it's weird markup and comments are supposed to start with capital and end with a full stop, - Add explicit comparison of pointer to NULL. Reviewers: sergey Subscribers: kusi, kdawg, forest-house, mardy, Samoth, plasmasolutions, willolis, sebastian_k, hype, enetheru, sunboy, jta, leon_cheung Maniphest Tasks: T49036 Differential Revision: https://developer.blender.org/D583 --- release/scripts/startup/bl_ui/space_clip.py | 92 +- source/blender/blenkernel/BKE_tracking.h | 4 +- source/blender/blenkernel/intern/movieclip.c | 6 +- source/blender/blenkernel/intern/tracking.c | 29 +- .../blender/blenkernel/intern/tracking_stabilize.c | 1447 +++++++++++++++++--- source/blender/blenloader/intern/readfile.c | 2 +- source/blender/blenloader/intern/versioning_270.c | 58 + .../blender/compositor/nodes/COM_MovieClipNode.cpp | 2 +- .../operations/COM_MovieClipAttributeOperation.cpp | 2 +- source/blender/editors/space_clip/clip_intern.h | 5 +- source/blender/editors/space_clip/clip_utils.c | 12 +- source/blender/editors/space_clip/space_clip.c | 20 +- source/blender/editors/space_clip/tracking_ops.c | 25 +- .../editors/space_clip/tracking_ops_stabilize.c | 141 +- source/blender/makesdna/DNA_tracking_types.h | 27 +- source/blender/makesrna/RNA_access.h | 1 + source/blender/makesrna/intern/rna_tracking.c | 157 ++- 17 files changed, 1698 insertions(+), 332 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 799f1e20dc6..9b1c0a16603 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -621,6 +621,7 @@ class CLIP_PT_track(CLIP_PT_tracking_panel, Panel): text="", toggle=True, icon='IMAGE_ALPHA') layout.prop(act_track, "weight") + layout.prop(act_track, "weight_stab") if act_track.has_bundle: label_text = "Average Error: %.4f" % (act_track.average_error) @@ -907,44 +908,80 @@ class CLIP_PT_stabilization(CLIP_PT_reconstruction_panel, Panel): self.layout.prop(stab, "use_2d_stabilization", text="") def draw(self, context): - layout = self.layout - tracking = context.space_data.clip.tracking stab = tracking.stabilization + layout = self.layout layout.active = stab.use_2d_stabilization - row = layout.row() - row.template_list("UI_UL_list", "stabilization_tracks", stab, "tracks", - stab, "active_track_index", rows=2) + layout.prop(stab, "anchor_frame") - sub = row.column(align=True) + box = layout.box() + row = box.row(align=True) + row.prop(stab, "show_tracks_expanded", text="", emboss=False) + + if not stab.show_tracks_expanded: + row.label(text="Tracks For Stabilization") + else: + row.label(text="Tracks For Location") + row = box.row() + row.template_list("UI_UL_list", "stabilization_tracks", stab, "tracks", + stab, "active_track_index", rows=2) - sub.operator("clip.stabilize_2d_add", icon='ZOOMIN', text="") - sub.operator("clip.stabilize_2d_remove", icon='ZOOMOUT', text="") + sub = row.column(align=True) - sub.menu('CLIP_MT_stabilize_2d_specials', text="", - icon='DOWNARROW_HLT') + sub.operator("clip.stabilize_2d_add", icon='ZOOMIN', text="") + sub.operator("clip.stabilize_2d_remove", icon='ZOOMOUT', text="") - layout.prop(stab, "influence_location") + sub.menu('CLIP_MT_stabilize_2d_specials', text="", + icon='DOWNARROW_HLT') - layout.prop(stab, "use_autoscale") - col = layout.column() - col.active = stab.use_autoscale - col.prop(stab, "scale_max") - col.prop(stab, "influence_scale") + row = box.row() + row.label(text="Tracks For Rotation / Scale") + row = box.row() + row.active = stab.use_stabilize_rotation + row.template_list("UI_UL_list", "stabilization_rotation_tracks", stab, "rotation_tracks", + stab, "active_rotation_track_index", rows=2) + + sub = row.column(align=True) + + sub.operator("clip.stabilize_2d_rotation_add", icon='ZOOMIN', text="") + sub.operator("clip.stabilize_2d_rotation_remove", icon='ZOOMOUT', text="") + + sub.menu('CLIP_MT_stabilize_2d_rotation_specials', text="", + icon='DOWNARROW_HLT') layout.prop(stab, "use_stabilize_rotation") - col = layout.column() - col.active = stab.use_stabilize_rotation + row = layout.row() + row.active = stab.use_stabilize_rotation + row.prop(stab, "use_stabilize_scale") + if stab.use_autoscale: + row = layout.row(align=True) + row.prop(stab, "use_autoscale") + row.prop(stab, "scale_max", text="Max") + else: + layout.prop(stab, "use_autoscale") - row = col.row(align=True) - row.prop_search(stab, "rotation_track", tracking, "tracks", text="") - row.operator("clip.stabilize_2d_set_rotation", text="", icon='ZOOMIN') + layout.separator() + layout.label(text="Expected Position") + layout.prop(stab, "target_pos", text="") + layout.prop(stab, "target_rot") + if stab.use_autoscale: + layout.label(text="Auto Scale Factor: %5.3f" % (1.0 / stab.target_zoom)) + else: + layout.prop(stab, "target_zoom") + layout.separator() + row = layout.row() + row.active = 0 < len(stab.tracks.values()) + row.prop(stab, "influence_location") + + col = layout.column() + col.active = stab.use_stabilize_rotation and 0 < len(stab.rotation_tracks.values()) row = col.row() - row.active = stab.rotation_track is not None row.prop(stab, "influence_rotation") + row = col.row() + row.prop(stab, "influence_scale") layout.prop(stab, "filter_type") @@ -1434,7 +1471,7 @@ class CLIP_MT_track_color_specials(Menu): class CLIP_MT_stabilize_2d_specials(Menu): - bl_label = "Track Color Specials" + bl_label = "Translation Track Specials" def draw(self, context): layout = self.layout @@ -1442,5 +1479,14 @@ class CLIP_MT_stabilize_2d_specials(Menu): layout.operator("clip.stabilize_2d_select") +class CLIP_MT_stabilize_2d_rotation_specials(Menu): + bl_label = "Rotation Track Specials" + + def draw(self, context): + layout = self.layout + + layout.operator("clip.stabilize_2d_rotation_select") + + if __name__ == "__main__": # only for live edit. bpy.utils.register_module(__name__) diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h index 1938bb08395..30873567297 100644 --- a/source/blender/blenkernel/BKE_tracking.h +++ b/source/blender/blenkernel/BKE_tracking.h @@ -277,9 +277,9 @@ void BKE_tracking_detect_harris(struct MovieTracking *tracking, struct ListBase bool place_outside_layer); /* **** 2D stabilization **** */ -void BKE_tracking_stabilization_data_get(struct MovieTracking *tracking, int framenr, int width, int height, +void BKE_tracking_stabilization_data_get(struct MovieClip *clip, int framenr, int width, int height, float translation[2], float *scale, float *angle); -struct ImBuf *BKE_tracking_stabilize_frame(struct MovieTracking *tracking, int framenr, struct ImBuf *ibuf, +struct ImBuf *BKE_tracking_stabilize_frame(struct MovieClip *clip, int framenr, struct ImBuf *ibuf, float translation[2], float *scale, float *angle); void BKE_tracking_stabilization_data_to_mat4(int width, int height, float aspect, float translation[2], float scale, float angle, float mat[4][4]); diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 0d362086134..482015d3b26 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -1033,7 +1033,7 @@ static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, ImBu stableibuf = cache->stabilized.ibuf; - BKE_tracking_stabilization_data_get(&clip->tracking, clip_framenr, stableibuf->x, stableibuf->y, tloc, &tscale, &tangle); + BKE_tracking_stabilization_data_get(clip, clip_framenr, stableibuf->x, stableibuf->y, tloc, &tscale, &tangle); /* check for stabilization parameters */ if (tscale != cache->stabilized.scale || @@ -1057,7 +1057,7 @@ static ImBuf *put_stabilized_frame_to_cache(MovieClip *clip, MovieClipUser *user float tloc[2], tscale, tangle; int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, framenr); - stableibuf = BKE_tracking_stabilize_frame(&clip->tracking, clip_framenr, ibuf, tloc, &tscale, &tangle); + stableibuf = BKE_tracking_stabilize_frame(clip, clip_framenr, ibuf, tloc, &tscale, &tangle); copy_v2_v2(cache->stabilized.loc, tloc); @@ -1270,8 +1270,6 @@ void BKE_movieclip_reload(MovieClip *clip) /* clear cache */ free_buffers(clip); - clip->tracking.stabilization.ok = false; - /* update clip source */ detect_clip_source(clip); diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index a56fc0f9abe..d5d3384bb48 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -241,13 +241,9 @@ static void tracking_reconstruction_copy( /* Copy stabilization structure. */ static void tracking_stabilization_copy( - MovieTrackingStabilization *stabilization_dst, MovieTrackingStabilization *stabilization_src, - GHash *tracks_mapping) + MovieTrackingStabilization *stabilization_dst, MovieTrackingStabilization *stabilization_src) { *stabilization_dst = *stabilization_src; - if (stabilization_src->rot_track) { - stabilization_dst->rot_track = BLI_ghash_lookup(tracks_mapping, stabilization_src->rot_track); - } } /* Copy tracking object. */ @@ -284,7 +280,7 @@ void BKE_tracking_copy(MovieTracking *tracking_dst, MovieTracking *tracking_src) tracking_tracks_copy(&tracking_dst->tracks, &tracking_src->tracks, tracks_mapping); tracking_plane_tracks_copy(&tracking_dst->plane_tracks, &tracking_src->plane_tracks, tracks_mapping); tracking_reconstruction_copy(&tracking_dst->reconstruction, &tracking_src->reconstruction); - tracking_stabilization_copy(&tracking_dst->stabilization, &tracking_src->stabilization, tracks_mapping); + tracking_stabilization_copy(&tracking_dst->stabilization, &tracking_src->stabilization); if (tracking_src->act_track) { tracking_dst->act_track = BLI_ghash_lookup(tracks_mapping, tracking_src->act_track); } @@ -316,7 +312,7 @@ void BKE_tracking_copy(MovieTracking *tracking_dst, MovieTracking *tracking_src) } /* Initialize motion tracking settings to default values, - * used when new movie clip datablock is creating. + * used when new movie clip datablock is created. */ void BKE_tracking_settings_init(MovieTracking *tracking) { @@ -333,11 +329,23 @@ void BKE_tracking_settings_init(MovieTracking *tracking) tracking->settings.dist = 1; tracking->settings.object_distance = 1; + tracking->stabilization.scaleinf = 1.0f; + tracking->stabilization.anchor_frame = MINFRAME; + zero_v2(tracking->stabilization.target_pos); + tracking->stabilization.target_rot = 0.0f; + tracking->stabilization.scale = 1.0f; + + tracking->stabilization.act_track = 0; + tracking->stabilization.act_rot_track = 0; + tracking->stabilization.tot_track = 0; + tracking->stabilization.tot_rot_track = 0; + tracking->stabilization.scaleinf = 1.0f; tracking->stabilization.locinf = 1.0f; tracking->stabilization.rotinf = 1.0f; tracking->stabilization.maxscale = 2.0f; tracking->stabilization.filter = TRACKING_FILTER_BILINEAR; + tracking->stabilization.flag |= TRACKING_SHOW_STAB_TRACKS; BKE_tracking_object_add(tracking, "Camera"); } @@ -552,6 +560,7 @@ MovieTrackingTrack *BKE_tracking_track_add(MovieTracking *tracking, ListBase *tr track->flag = settings->default_flag; track->algorithm_flag = settings->default_algorithm_flag; track->weight = settings->default_weight; + track->weight_stab = settings->default_weight; memset(&marker, 0, sizeof(marker)); marker.pos[0] = x; @@ -590,6 +599,12 @@ MovieTrackingTrack *BKE_tracking_track_duplicate(MovieTrackingTrack *track) new_track->markers = MEM_dupallocN(new_track->markers); + /* Orevent duplicate from being used for 2D stabilization. + * If necessary, it shall be added explicitly. + */ + new_track->flag &= ~TRACK_USE_2D_STAB; + new_track->flag &= ~TRACK_USE_2D_STAB_ROT; + return new_track; } diff --git a/source/blender/blenkernel/intern/tracking_stabilize.c b/source/blender/blenkernel/intern/tracking_stabilize.c index eb224020977..5642ee83fde 100644 --- a/source/blender/blenkernel/intern/tracking_stabilize.c +++ b/source/blender/blenkernel/intern/tracking_stabilize.c @@ -21,6 +21,7 @@ * Contributor(s): Blender Foundation, * Sergey Sharybin * Keir Mierle + * Ichthyostega * * ***** END GPL LICENSE BLOCK ***** */ @@ -28,292 +29,1305 @@ /** \file blender/blenkernel/intern/tracking_stabilize.c * \ingroup bke * - * This file contains implementation of 2D frame stabilization. + * This file contains implementation of 2D image stabilization. */ #include #include "DNA_movieclip_types.h" +#include "DNA_scene_types.h" +#include "DNA_anim_types.h" +#include "RNA_access.h" #include "BLI_utildefines.h" +#include "BLI_sort_utils.h" +#include "BLI_math_vector.h" #include "BLI_math.h" #include "BKE_tracking.h" +#include "BKE_movieclip.h" +#include "BKE_fcurve.h" +#include "BLI_ghash.h" +#include "MEM_guardedalloc.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" -/* Calculate median point of markers of tracks marked as used for - * 2D stabilization. - * - * NOTE: frame number should be in clip space, not scene space + +/* == Parameterization constants == */ + +/* When measuring the scale changes relative to the rotation pivot point, it + * might happen accidentally that a probe point (tracking point), which doesn't + * actually move on a circular path, gets very close to the pivot point, causing + * the measured scale contribution to go toward infinity. We damp this undesired + * effect by adding a bias (floor) to the measured distances, which will + * dominate very small distances and thus cause the corresponding track's + * contribution to diminish. + * Measurements happen in normalized (0...1) coordinates within a frame. + */ +static float SCALE_ERROR_LIMIT_BIAS = 0.01f; + +/* When to consider a track as completely faded out. + * This is used in conjunction with the "disabled" flag of the track + * to determine start positions, end positions and gaps */ -static bool stabilization_median_point_get(MovieTracking *tracking, int framenr, float median[2]) +static float EPSILON_WEIGHT = 0.005f; + + + +/* == private working data == */ + +/* Per track baseline for stabilization, defined at reference frame. + * A track's reference frame is chosen as close as possible to the (global) + * anchor_frame. Baseline holds the constant part of each track's contribution + * to the observed movement; it is calculated at initialization pass, using the + * measurement value at reference frame plus the average contribution to fill + * the gap between global anchor_frame and the reference frame for this track. + * This struct with private working data is associated to the local call context + * via `StabContext::private_track_data` + */ +typedef struct TrackStabilizationBase { + float stabilization_offset_base[2]; + + /* measured relative to translated pivot */ + float stabilization_rotation_base[2][2]; + + /* measured relative to translated pivot */ + float stabilization_scale_base; + + bool is_init_for_stabilization; + FCurve *track_weight_curve; +} TrackStabilizationBase; + +/* Tracks are reordered for initialization, starting as close as possible to + * anchor_frame + */ +typedef struct TrackInitOrder { + int sort_value; + int reference_frame; + MovieTrackingTrack *data; +} TrackInitOrder; + +/* Per frame private working data, for accessing possibly animated values. */ +typedef struct StabContext { + MovieClip *clip; + MovieTracking *tracking; + MovieTrackingStabilization *stab; + GHash *private_track_data; + FCurve *locinf; + FCurve *rotinf; + FCurve *scaleinf; + FCurve *target_pos[2]; + FCurve *target_rot; + FCurve *target_scale; + bool use_animation; +} StabContext; + + +static TrackStabilizationBase *access_stabilization_baseline_data( + StabContext *ctx, + MovieTrackingTrack *track) { - bool ok = false; - float min[2], max[2]; - MovieTrackingTrack *track; + return BLI_ghash_lookup(ctx->private_track_data, track); +} - INIT_MINMAX2(min, max); +static void attach_stabilization_baseline_data( + StabContext *ctx, + MovieTrackingTrack *track, + TrackStabilizationBase *private_data) +{ + return BLI_ghash_insert(ctx->private_track_data, track, private_data); +} - track = tracking->tracks.first; - while (track) { - if (track->flag & TRACK_USE_2D_STAB) { - MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); +static void discard_stabilization_baseline_data(void *val) +{ + if (val != NULL) { + MEM_freeN(val); + } +} - minmax_v2v2_v2(min, max, marker->pos); - ok = true; - } +/* == access animated values for given frame == */ + +static FCurve *retrieve_stab_animation(MovieClip *clip, + const char *data_path, + int idx) +{ + return id_data_find_fcurve(&clip->id, + &clip->tracking.stabilization, + &RNA_MovieTrackingStabilization, + data_path, + idx, + NULL); +} + +static FCurve *retrieve_track_weight_animation(MovieClip *clip, + MovieTrackingTrack *track) +{ + return id_data_find_fcurve(&clip->id, + track, + &RNA_MovieTrackingTrack, + "weight_stab", + 0, + NULL); +} - track = track->next; +static float fetch_from_fcurve(FCurve *animationCurve, + int framenr, + StabContext *ctx, + float default_value) +{ + if (ctx && ctx->use_animation && animationCurve) { + int scene_framenr = BKE_movieclip_remap_clip_to_scene_frame(ctx->clip, + framenr); + return evaluate_fcurve(animationCurve, scene_framenr); } + return default_value; +} - median[0] = (max[0] + min[0]) / 2.0f; - median[1] = (max[1] + min[1]) / 2.0f; - return ok; +static float get_animated_locinf(StabContext *ctx, int framenr) +{ + return fetch_from_fcurve(ctx->locinf, framenr, ctx, ctx->stab->locinf); } -/* Calculate stabilization data (translation, scale and rotation) from - * given median of first and current frame medians, tracking data and - * frame number. - * - * NOTE: frame number should be in clip space, not scene space +static float get_animated_rotinf(StabContext *ctx, int framenr) +{ + return fetch_from_fcurve(ctx->rotinf, framenr, ctx, ctx->stab->rotinf); +} + +static float get_animated_scaleinf(StabContext *ctx, int framenr) +{ + return fetch_from_fcurve(ctx->scaleinf, framenr, ctx, ctx->stab->scaleinf); +} + +static void get_animated_target_pos(StabContext *ctx, + int framenr, + float target_pos[2]) +{ + target_pos[0] = fetch_from_fcurve(ctx->target_pos[0], + framenr, + ctx, + ctx->stab->target_pos[0]); + target_pos[1] = fetch_from_fcurve(ctx->target_pos[1], + framenr, + ctx, + ctx->stab->target_pos[1]); +} + +static float get_animated_target_rot(StabContext *ctx, int framenr) +{ + return fetch_from_fcurve(ctx->target_rot, + framenr, + ctx, + ctx->stab->target_rot); +} + +static float get_animated_target_scale(StabContext *ctx, int framenr) +{ + return fetch_from_fcurve(ctx->target_scale, framenr, ctx, ctx->stab->scale); +} + +static float get_animated_weight(StabContext *ctx, + MovieTrackingTrack *track, + int framenr) +{ + TrackStabilizationBase *working_data = + access_stabilization_baseline_data(ctx, track); + if (working_data && working_data->track_weight_curve) { + int scene_framenr = BKE_movieclip_remap_clip_to_scene_frame(ctx->clip, + framenr); + return evaluate_fcurve(working_data->track_weight_curve, scene_framenr); + } + /* Use weight at global 'current frame' as fallback default. */ + return track->weight_stab; +} + +static void use_values_from_fcurves(StabContext *ctx, bool toggle) +{ + if (ctx != NULL) { + ctx->use_animation = toggle; + } +} + + +/* Prepare per call private working area. + * Used for access to possibly animated values: retrieve available F-curves. */ -static void stabilization_calculate_data(MovieTracking *tracking, int framenr, int width, int height, - const float firstmedian[2], const float median[2], - float translation[2], float *scale, float *angle) +static StabContext *initialize_stabilization_working_context(MovieClip *clip) { - MovieTrackingStabilization *stab = &tracking->stabilization; + StabContext *ctx = MEM_callocN(sizeof(StabContext), + "2D stabilization animation runtime data"); + ctx->clip = clip; + ctx->tracking = &clip->tracking; + ctx->stab = &clip->tracking.stabilization; + ctx->private_track_data = BLI_ghash_ptr_new( + "2D stabilization per track private working data"); + ctx->locinf = retrieve_stab_animation(clip, "influence_location", 0); + ctx->rotinf = retrieve_stab_animation(clip, "influence_rotation", 0); + ctx->scaleinf = retrieve_stab_animation(clip, "influence_scale", 0); + ctx->target_pos[0] = retrieve_stab_animation(clip, "target_pos", 0); + ctx->target_pos[1] = retrieve_stab_animation(clip, "target_pos", 1); + ctx->target_rot = retrieve_stab_animation(clip, "target_rot", 0); + ctx->target_scale = retrieve_stab_animation(clip, "target_zoom", 0); + ctx->use_animation = true; + return ctx; +} - *scale = (stab->scale - 1.0f) * stab->scaleinf + 1.0f; - *angle = 0.0f; +/* Discard all private working data attached to this call context. + * NOTE: We allocate the record for the per track baseline contribution + * locally for each call context (i.e. call to + * BKE_tracking_stabilization_data_get() + * Thus it is correct to discard all allocations found within the + * corresponding _local_ GHash + */ +static void discard_stabilization_working_context(StabContext *ctx) +{ + if (ctx != NULL) { + BLI_ghash_free(ctx->private_track_data, + NULL, + discard_stabilization_baseline_data); + MEM_freeN(ctx); + } +} - translation[0] = (firstmedian[0] - median[0]) * width * (*scale); - translation[1] = (firstmedian[1] - median[1]) * height * (*scale); +static bool is_init_for_stabilization(StabContext *ctx, + MovieTrackingTrack *track) +{ + TrackStabilizationBase *working_data = + access_stabilization_baseline_data(ctx, track); + return (working_data != NULL && working_data->is_init_for_stabilization); +} + +static bool is_usable_for_stabilization(StabContext *ctx, + MovieTrackingTrack *track) +{ + return (track->flag & TRACK_USE_2D_STAB) && + is_init_for_stabilization(ctx, track); +} - mul_v2_fl(translation, stab->locinf); +static bool is_effectively_disabled(StabContext *ctx, + MovieTrackingTrack *track, + MovieTrackingMarker *marker) +{ + return (marker->flag & MARKER_DISABLED) || + (EPSILON_WEIGHT > get_animated_weight(ctx, track, marker->framenr)); +} - if ((stab->flag & TRACKING_STABILIZE_ROTATION) && stab->rot_track && stab->rotinf) { - MovieTrackingMarker *marker; - float a[2], b[2]; - float x0 = (float)width / 2.0f, y0 = (float)height / 2.0f; - float x = median[0] * width, y = median[1] * height; - marker = BKE_tracking_marker_get(stab->rot_track, 1); - sub_v2_v2v2(a, marker->pos, firstmedian); - a[0] *= width; - a[1] *= height; +static int search_closest_marker_index(MovieTrackingTrack *track, + int ref_frame) +{ + MovieTrackingMarker *markers = track->markers; + int end = track->markersnr; + int i = track->last_marker; + + i = MAX2(0, i); + i = MIN2(i, end - 1); + for ( ; i < end - 1 && markers[i].framenr <= ref_frame; ++i); + for ( ; 0 < i && markers[i].framenr > ref_frame; --i); + + track->last_marker = i; + return i; +} + +static void retrieve_next_higher_usable_frame(StabContext *ctx, + MovieTrackingTrack *track, + int i, + int ref_frame, + int *next_higher) +{ + MovieTrackingMarker *markers = track->markers; + int end = track->markersnr; + BLI_assert(0 <= i && i < end); + + while (i < end && + (markers[i].framenr < ref_frame || + is_effectively_disabled(ctx, track, &markers[i]))) + { + ++i; + } + if (i < end && markers[i].framenr < *next_higher) { + BLI_assert(markers[i].framenr >= ref_frame); + *next_higher = markers[i].framenr; + } +} + +static void retrieve_next_lower_usable_frame(StabContext *ctx, + MovieTrackingTrack *track, + int i, + int ref_frame, + int *next_lower) +{ + MovieTrackingMarker *markers = track->markers; + BLI_assert(0 <= i && i < end); + while (i >= 0 && + (markers[i].framenr > ref_frame || + is_effectively_disabled(ctx, track, &markers[i]))) + { + --i; + } + if (0 <= i && markers[i].framenr > *next_lower) { + BLI_assert(markers[i].framenr <= ref_frame); + *next_lower = markers[i].framenr; + } +} + +/* Find closest frames with usable stabilization data. + * A frame counts as _usable_ when there is at least one track marked for + * translation stabilization, which has an enabled tracking marker at this very + * frame. We search both for the next lower and next higher position, to allow + * the caller to interpolate gaps and to extrapolate at the ends of the + * definition range. + * + * NOTE: Regarding performance note that the individual tracks will cache the + * last search position. + */ +static void find_next_working_frames(StabContext *ctx, + int framenr, + int *next_lower, + int *next_higher) +{ + for (MovieTrackingTrack *track = ctx->tracking->tracks.first; + track != NULL; + track = track->next) + { + if (is_usable_for_stabilization(ctx, track)) { + int startpoint = search_closest_marker_index(track, framenr); + retrieve_next_higher_usable_frame(ctx, + track, + startpoint, + framenr, + next_higher); + retrieve_next_lower_usable_frame(ctx, + track, + startpoint, + framenr, + next_lower); + } + } +} + - marker = BKE_tracking_marker_get(stab->rot_track, framenr); - sub_v2_v2v2(b, marker->pos, median); - b[0] *= width; - b[1] *= height; +/* Find active (enabled) marker closest to the reference frame. */ +static MovieTrackingMarker *get_closest_marker(StabContext *ctx, + MovieTrackingTrack *track, + int ref_frame) +{ + if (track->markersnr > 0) { + int next_lower = MINAFRAME; + int next_higher = MAXFRAME; + int i = search_closest_marker_index(track, ref_frame); + retrieve_next_higher_usable_frame(ctx, track, i, ref_frame, &next_higher); + retrieve_next_lower_usable_frame(ctx, track, i, ref_frame, &next_lower); + + if ((next_higher - ref_frame) < (ref_frame - next_lower)) { + return BKE_tracking_marker_get_exact(track, next_higher); + } + else { + return BKE_tracking_marker_get_exact(track, next_lower); + } + } + return NULL; +} - *angle = -atan2f(a[0] * b[1] - a[1] * b[0], a[0] * b[0] + a[1] * b[1]); - *angle *= stab->rotinf; - /* convert to rotation around image center */ - translation[0] -= (x0 + (x - x0) * cosf(*angle) - (y - y0) * sinf(*angle) - x) * (*scale); - translation[1] -= (y0 + (x - x0) * sinf(*angle) + (y - y0) * cosf(*angle) - y) * (*scale); +/* Retrieve tracking data, if available and applicable for this frame. + * The returned weight value signals the validity; data recorded for this + * tracking marker on the exact requested frame is output with the full weight + * of this track, while gaps in the data sequence cause the weight to go to zero. + */ +static MovieTrackingMarker *get_tracking_data_point( + StabContext *ctx, + MovieTrackingTrack *track, + int framenr, + float *weight) +{ + MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); + if (marker && marker->framenr == framenr && !(marker->flag & MARKER_DISABLED)) { + *weight = get_animated_weight(ctx, track, framenr); + return marker; + } + else { + /* no marker at this frame (=gap) or marker disabled */ + *weight = 0.0f; + return NULL; } } -/* Calculate factor of a scale, which will eliminate black areas - * appearing on the frame caused by frame translation. +/* Calculate the contribution of a single track at the time position (frame) of + * the given marker. Each track has a local reference frame, which is as close + * as possible to the global anchor_frame. Thus the translation contribution is + * comprised of the offset relative to the image position at that reference + * frame, plus a guess of the contribution for the time span between the + * anchor_frame and the local reference frame of this track. The constant part + * of this contribution is precomputed initially. At the anchor_frame, by + * definition the contribution of all tracks is zero, keeping the frame in place. + * + * track_ref is per track baseline contribution at reference frame; filled in at + * initialization + * marker is tracking data to use as contribution for current frame. + * result_offset is a total cumulated contribution of this track, + * relative to the stabilization anchor_frame, + * in normalized (0...1) coordinates. + */ +static void translation_contribution(TrackStabilizationBase *track_ref, + MovieTrackingMarker *marker, + float result_offset[2]) +{ + add_v2_v2v2(result_offset, + track_ref->stabilization_offset_base, + marker->pos); +} + +/* Similar to the ::translation_contribution(), the rotation contribution is + * comprised of the contribution by this individual track, and the averaged + * contribution from anchor_frame to the ref point of this track. + * - Contribution is in terms of angles, -pi < angle < +pi, and all averaging + * happens in this domain. + * - Yet the actual measurement happens as vector between pivot and the current + * tracking point + * - Currently we use the center of frame as approximation for the rotation pivot + * point. + * - Moreover, the pivot point has to be compensated for the already determined + * shift offset, in order to get the pure rotation around the pivot. + * To turn this into a _contribution_, the likewise corrected angle at the + * reference frame has to be subtracted, to get only the pure angle difference + * this tracking point has captured. + * - To get from vectors to angles, we have to go through an arcus tangens, + * which involves the issue of the definition range: the resulting angles will + * flip by 360deg when the measured vector passes from the 2nd to the third + * quadrant, thus messing up the average calculation. Since _any_ tracking + * point might be used, these problems are quite common in practice. + * - Thus we perform the subtraction of the reference and the addition of the + * baseline contribution in polar coordinates as simple addition of angles; + * since these parts are fixed, we can bake them into a rotation matrix. + * With this approach, the border of the arcus tangens definition range will + * be reached only, when the _whole_ contribution approaches +- 180deg, + * meaning we've already tilted the frame upside down. This situation is way + * less common and can be tolerated. + * - As an additional feature, when activated, also changes in image scale + * relative to the rotation center can be picked up. To handle those values + * in the same framework, we average the scales as logarithms. + * + * aspect is a total aspect ratio of the undistorted image (includes fame and + * pixel aspect). + */ +static void rotation_contribution(TrackStabilizationBase *track_ref, + MovieTrackingMarker *marker, + float aspect, + float target_pos[2], + float averaged_translation_contribution[2], + float *result_angle, + float *result_scale) +{ + float len; + float pos[2]; + float pivot[2]; + copy_v2_fl(pivot, 0.5f); /* Use center of frame as hard wired pivot. */ + add_v2_v2(pivot, averaged_translation_contribution); + sub_v2_v2(pivot, target_pos); + sub_v2_v2v2(pos, marker->pos, pivot); + + pos[0] *= aspect; + mul_m2v2(track_ref->stabilization_rotation_base, pos); + + *result_angle = atan2f(pos[1],pos[0]); + + len = len_v2(pos) + SCALE_ERROR_LIMIT_BIAS; + *result_scale = len * track_ref->stabilization_scale_base; + BLI_assert(0.0 < *result_scale); +} + + +/* Weighted average of the per track cumulated contributions at given frame. + * Returns truth if all desired calculations could be done and all averages are + * available. + * + * NOTE: Even if the result is not `true`, the returned translation and angle + * are always sensible and as good as can be. Especially in the + * initialization phase we might not be able to get any average (yet) or + * get only a translation value. Since initialization visits tracks in a + * specific order, starting from anchor_frame, the result is logically + * correct non the less. But under normal operation conditions, + * a result of `false` should disable the stabilization function */ -static float stabilization_calculate_autoscale_factor(MovieTracking *tracking, int width, int height) +static bool average_track_contributions(StabContext *ctx, + int framenr, + float aspect, + float r_translation[2], + float *r_angle, + float *r_scale_step) { - float firstmedian[2]; + bool ok; + float weight_sum; + MovieTrackingTrack *track; + MovieTracking *tracking = ctx->tracking; MovieTrackingStabilization *stab = &tracking->stabilization; - float aspect = tracking->camera.pixel_aspect; - - /* Early output if stabilization data is already up-to-date. */ - if (stab->ok) - return stab->scale; - - /* See comment in BKE_tracking_stabilization_data_get about first frame. */ - if (stabilization_median_point_get(tracking, 1, firstmedian)) { - int sfra = INT_MAX, efra = INT_MIN, cfra; - float scale = 1.0f; - MovieTrackingTrack *track; - - stab->scale = 1.0f; - - /* Calculate frame range of tracks used for stabilization. */ - track = tracking->tracks.first; - while (track) { - if (track->flag & TRACK_USE_2D_STAB || - ((stab->flag & TRACKING_STABILIZE_ROTATION) && track == stab->rot_track)) - { - sfra = min_ii(sfra, track->markers[0].framenr); - efra = max_ii(efra, track->markers[track->markersnr - 1].framenr); - } + BLI_assert(stab->flag & TRACKING_2D_STABILIZATION); - track = track->next; + zero_v2(r_translation); + *r_scale_step = 0.0f; /* logarithm */ + *r_angle = 0.0f; + + ok = false; + weight_sum = 0.0f; + for (track = tracking->tracks.first; track; track = track->next) { + if (!is_init_for_stabilization(ctx, track)) { + continue; + } + if (track->flag & TRACK_USE_2D_STAB) { + float weight = 0.0f; + MovieTrackingMarker *marker = get_tracking_data_point(ctx, + track, + framenr, + &weight); + if (marker) { + TrackStabilizationBase *stabilization_base = + access_stabilization_baseline_data(ctx, track); + BLI_assert(stabilization_base != NULL); + float offset[2]; + weight_sum += weight; + translation_contribution(stabilization_base, marker, offset); + mul_v2_fl(offset, weight); + add_v2_v2(r_translation, offset); + ok |= (weight_sum > EPSILON_WEIGHT); + } } + } + if (!ok) { + return false; + } - /* For every frame we calculate scale factor needed to eliminate black - * area and choose largest scale factor as final one. - */ - for (cfra = sfra; cfra <= efra; cfra++) { - float median[2]; - float translation[2], angle, tmp_scale; - int i; - float mat[4][4]; - float points[4][2] = {{0.0f, 0.0f}, {0.0f, height}, {width, height}, {width, 0.0f}}; - float si, co; + r_translation[0] /= weight_sum; + r_translation[1] /= weight_sum; - stabilization_median_point_get(tracking, cfra, median); + if (!(stab->flag & TRACKING_STABILIZE_ROTATION)) { + return ok; + } - stabilization_calculate_data(tracking, cfra, width, height, firstmedian, median, translation, - &tmp_scale, &angle); + ok = false; + weight_sum = 0.0f; + for (track = tracking->tracks.first; track; track = track->next) { + if (!is_init_for_stabilization(ctx, track)) { + continue; + } + if (track->flag & TRACK_USE_2D_STAB_ROT) { + float weight = 0.0f; + MovieTrackingMarker *marker = get_tracking_data_point(ctx, + track, + framenr, + &weight); + if (marker) { + TrackStabilizationBase *stabilization_base = + access_stabilization_baseline_data(ctx, track); + BLI_assert(stabilization_base != NULL); + float rotation, scale; + float target_pos[2]; + weight_sum += weight; + get_animated_target_pos(ctx, framenr, target_pos); + rotation_contribution(stabilization_base, + marker, + aspect, + target_pos, + r_translation, + &rotation, + &scale); + *r_angle += rotation * weight; + if (stab->flag & TRACKING_STABILIZE_SCALE) { + *r_scale_step += logf(scale) * weight; + } + else { + *r_scale_step = 0; + } + ok |= (weight_sum > EPSILON_WEIGHT); + } + } + } + if (ok) { + *r_scale_step /= weight_sum; + *r_angle /= weight_sum; + } + else { + /* We reach this point because translation could be calculated, + * but rotation/scale found no data to work on. + */ + *r_scale_step = 0.0f; + *r_angle = 0.0f; + } + return true; +} - BKE_tracking_stabilization_data_to_mat4(width, height, aspect, translation, 1.0f, angle, mat); - si = sinf(angle); - co = cosf(angle); +/* Linear interpolation of data retrieved at two measurement points. + * This function is used to fill gaps in the middle of the covered area, + * at frames without any usable tracks for stabilization. + * + * framenr is a position to interpolate for. + * frame_a is a valid measurement point below framenr + * frame_b is a valid measurement point above framenr + * Returns truth if both measurements could actually be retrieved. + * Otherwise output parameters remain unaltered + */ +static bool interpolate_averaged_track_contributions(StabContext *ctx, + int framenr, + int frame_a, + int frame_b, + float aspect, + float translation[2], + float *r_angle, + float *r_scale_step) +{ + float t, s; + float trans_a[2], trans_b[2]; + float angle_a, angle_b; + float scale_a, scale_b; + bool success = false; + + BLI_assert(frame_a <= frame_b); + BLI_assert(frame_a <= framenr); + BLI_assert(framenr <= frame_b); + + t = ((float)framenr - frame_a) / (frame_b - frame_a); + s = 1.0f - t; + + success = average_track_contributions(ctx, frame_a, aspect, trans_a, &angle_a, &scale_a); + if (!success) { + return false; + } + success = average_track_contributions(ctx, frame_b, aspect, trans_b, &angle_b, &scale_b); + if (!success) { + return false; + } - for (i = 0; i < 4; i++) { - int j; - float a[3] = {0.0f, 0.0f, 0.0f}, b[3] = {0.0f, 0.0f, 0.0f}; + interp_v2_v2v2(translation, trans_a, trans_b, t); + *r_scale_step = s * scale_a + t * scale_b; + *r_angle = s * angle_a + t * angle_b; + return true; +} - copy_v3_v3(a, points[i]); - copy_v3_v3(b, points[(i + 1) % 4]); - mul_m4_v3(mat, a); - mul_m4_v3(mat, b); +/* Reorder tracks starting with those providing a tracking data frame + * closest to the global anchor_frame. Tracks with a gap at anchor_frame or + * starting farer away from anchor_frame altogether will be visited later. + * This allows to build up baseline contributions incrementally. + * + * order is an array for sorting the tracks. Must be of suitable size to hold + * all tracks. + * Returns number of actually usable tracks, can be less than the overall number + * of tracks. + * + * NOTE: After returning, the order array holds entries up to the number of + * usable tracks, appropriately sorted starting with the closest tracks. + * Initialization includes disabled tracks, since they might be enabled + * through automation later. + */ +static int establish_track_initialization_order(StabContext *ctx, + TrackInitOrder *order) +{ + size_t tracknr = 0; + MovieTrackingTrack *track; + MovieTracking *tracking = ctx->tracking; + int anchor_frame = tracking->stabilization.anchor_frame; - for (j = 0; j < 4; j++) { - float point[3] = {points[j][0], points[j][1], 0.0f}; - float v1[3], v2[3]; + for (track = tracking->tracks.first; track != NULL; track = track->next) { + MovieTrackingMarker *marker; + order[tracknr].data = track; + marker = get_closest_marker(ctx, track, anchor_frame); + if (marker != NULL && + (track->flag & (TRACK_USE_2D_STAB | TRACK_USE_2D_STAB_ROT))) + { + order[tracknr].sort_value = abs(marker->framenr - anchor_frame); + order[tracknr].reference_frame = marker->framenr; + ++tracknr; + } + } + if (tracknr) { + qsort(order, tracknr, sizeof(TrackInitOrder), BLI_sortutil_cmp_int); + } + return tracknr; +} - sub_v3_v3v3(v1, b, a); - sub_v3_v3v3(v2, point, a); - if (cross_v2v2(v1, v2) >= 0.0f) { - const float rotDx[4][2] = {{1.0f, 0.0f}, {0.0f, -1.0f}, {-1.0f, 0.0f}, {0.0f, 1.0f}}; - const float rotDy[4][2] = {{0.0f, 1.0f}, {1.0f, 0.0f}, {0.0f, -1.0f}, {-1.0f, 0.0f}}; +/* Setup the constant part of this track's contribution to the determined frame + * movement. Tracks usually don't provide tracking data for every frame. Thus, + * for determining data at a given frame, we split up the contribution into a + * part covered by actual measurements on this track, and the initial gap + * between this track's reference frame and the global anchor_frame. + * The (missing) data for the gap can be substituted by the average offset + * observed by the other tracks covering the gap. This approximation doesn't + * introduce wrong data, but it records data with incorrect weight. A totally + * correct solution would require us to average the contribution per frame, and + * then integrate stepwise over all frames -- which of course would be way more + * expensive, especially for longer clips. To the contrary, our solution + * cumulates the total contribution per track and averages afterwards over all + * tracks; it can thus be calculated just based on the data of a single frame, + * plus the "baseline" for the reference frame, which is what we are computing + * here. + * + * Since we're averaging _contributions_, we have to calculate the _difference_ + * of the measured position at current frame and the position at the reference + * frame. But the "reference" part of this difference is constant and can thus + * be packed together with the baseline contribution into a single precomputed + * vector per track. + * + * In case of the rotation contribution, the principle is the same, but we have + * to compensate for the already determined translation and measure the pure + * rotation, simply because this is how we model the offset: shift plus rotation + * around the shifted rotation center. To circumvent problems with the + * definition range of the arcus tangens function, we perform this baseline + * addition and reference angle subtraction in polar coordinates and bake this + * operation into a precomputed rotation matrix. + * + * track is a track to be initialized to initialize + * reference_frame is a local frame for this track, the closest pick to the + * global anchor_frame. + * aspect is a total aspect ratio of the undistorted image (includes fame and + * pixel aspect). + * target_pos is a possibly animated target position as set by the user for + * the reference_frame + * average_translation is a value observed by the _other_ tracks for the gap + * between reference_frame and anchor_frame. This + * average must not contain contributions of frames + * not yet initialized + * average_angle in a similar way, the rotation value observed by the + * _other_ tracks. + * average_scale_step is an image scale factor observed on average by the other + * tracks for this frame. This value is recorded and + * averaged as logarithm. The recorded scale changes + * are damped for very small contributions, to limit + * the effect of probe points approaching the pivot + * too closely. + * + * NOTE: when done, this track is marked as initialized + */ +static void initialize_track_for_stabilization(StabContext *ctx, + MovieTrackingTrack *track, + int reference_frame, + float aspect, + const float target_pos[2], + const float average_translation[2], + float average_angle, + float average_scale_step) +{ + float pos[2], angle, len; + float pivot[2]; + TrackStabilizationBase *local_data = + access_stabilization_baseline_data(ctx, track); + MovieTrackingMarker *marker = + BKE_tracking_marker_get_exact(track, reference_frame); + /* Logic for initialization order ensures there *is* a marker on that + * very frame. + */ + BLI_assert(marker != NULL); + BLI_assert(local_data != NULL); - float dx = translation[0] * rotDx[j][0] + translation[1] * rotDx[j][1], - dy = translation[0] * rotDy[j][0] + translation[1] * rotDy[j][1]; + /* Per track baseline value for translation. */ + sub_v2_v2v2(local_data->stabilization_offset_base, + average_translation, + marker->pos); - float w, h, E, F, G, H, I, J, K, S; + /* Per track baseline value for rotation. */ + copy_v2_fl(pivot, 0.5f); /* Use center of frame as hard wired pivot. */ + add_v2_v2(pivot, average_translation); + sub_v2_v2(pivot, target_pos); + sub_v2_v2v2(pos, marker->pos, pivot); - if (j % 2) { - w = (float)height / 2.0f; - h = (float)width / 2.0f; - } - else { - w = (float)width / 2.0f; - h = (float)height / 2.0f; - } + pos[0] *= aspect; + angle = average_angle - atan2f(pos[1],pos[0]); + rotate_m2(local_data->stabilization_rotation_base, angle); - E = -w * co + h * si; - F = -h * co - w * si; + /* Per track baseline value for zoom. */ + len = len_v2(pos) + SCALE_ERROR_LIMIT_BIAS; + local_data->stabilization_scale_base = expf(average_scale_step) / len; - if ((i % 2) == (j % 2)) { - G = -w * co - h * si; - H = h * co - w * si; - } - else { - G = w * co + h * si; - H = -h * co + w * si; - } + local_data->is_init_for_stabilization = true; +} - I = F - H; - J = G - E; - K = G * F - E * H; - S = (-w * I - h * J) / (dx * I + dy * J + K); +static void initialize_all_tracks(StabContext *ctx, float aspect) +{ + size_t i, track_cnt = 0; + MovieClip *clip = ctx->clip; + MovieTracking *tracking = ctx->tracking; + MovieTrackingTrack *track; + TrackInitOrder *order; - scale = max_ff(scale, S); - } - } - } + /* Attempt to start initialization at anchor_frame. + * By definition, offset contribution is zero there. + */ + int reference_frame = tracking->stabilization.anchor_frame; + float average_angle=0, average_scale_step=0; + float average_translation[2]; + float target_pos_at_ref_frame[2]; + zero_v2(target_pos_at_ref_frame); + zero_v2(average_translation); + + /* Initialize private working data. */ + for (track = tracking->tracks.first; track != NULL; track = track->next) { + TrackStabilizationBase *local_data = + access_stabilization_baseline_data(ctx, track); + if (!local_data) { + local_data = MEM_callocN(sizeof(TrackStabilizationBase), + "2D stabilization per track baseline data"); + attach_stabilization_baseline_data(ctx, track, local_data); } + BLI_assert(local_data != NULL); + local_data->track_weight_curve = retrieve_track_weight_animation(clip, + track); + local_data->is_init_for_stabilization = false; - stab->scale = scale; + ++track_cnt; + } + if (!track_cnt) { + return; + } - if (stab->maxscale > 0.0f) - stab->scale = min_ff(stab->scale, stab->maxscale); + order = MEM_mallocN(track_cnt * sizeof(TrackInitOrder), + "stabilization track order"); + if (!order) { + return; } - else { - stab->scale = 1.0f; + + track_cnt = establish_track_initialization_order(ctx, order); + if (track_cnt == 0) { + goto cleanup; } - stab->ok = true; + for (i = 0; i < track_cnt; ++i) { + track = order[i].data; + if (reference_frame != order[i].reference_frame) { + reference_frame = order[i].reference_frame; + average_track_contributions(ctx, + reference_frame, + aspect, + average_translation, + &average_angle, + &average_scale_step); + get_animated_target_pos(ctx, + reference_frame, + target_pos_at_ref_frame); + } + initialize_track_for_stabilization(ctx, + track, + reference_frame, + aspect, + target_pos_at_ref_frame, + average_translation, + average_angle, + average_scale_step); + } - return stab->scale; +cleanup: + MEM_freeN(order); } -/* Get stabilization data (translation, scaling and angle) for a given frame. + +/* Retrieve the measurement of frame movement by averaging contributions of + * active tracks. * - * NOTE: frame number should be in clip space, not scene space + * translation is a measurement in normalized 0..1 coordinates. + * angle is a measurement in radians -pi..+pi counter clockwise relative to + * translation compensated frame center + * scale_step is a measurement of image scale changes, in logarithmic scale + * (zero means scale == 1) + * Returns calculation enabled and all data retrieved as expected for this frame. + * + * NOTE: when returning `false`, output parameters are reset to neutral values. */ -void BKE_tracking_stabilization_data_get(MovieTracking *tracking, int framenr, int width, int height, - float translation[2], float *scale, float *angle) +static bool stabilization_determine_offset_for_frame(StabContext *ctx, + int framenr, + float aspect, + float r_translation[2], + float *r_angle, + float *r_scale_step) { - float firstmedian[2], median[2]; - MovieTrackingStabilization *stab = &tracking->stabilization; + bool success = false; /* Early output if stabilization is disabled. */ - if ((stab->flag & TRACKING_2D_STABILIZATION) == 0) { - zero_v2(translation); - *scale = 1.0f; - *angle = 0.0f; + if ((ctx->stab->flag & TRACKING_2D_STABILIZATION) == 0) { + zero_v2(r_translation); + *r_scale_step = 0.0f; + *r_angle = 0.0f; + return false; + } - return; + success = average_track_contributions(ctx, + framenr, + aspect, + r_translation, + r_angle, + r_scale_step); + if (!success) { + /* Try to hold extrapolated settings beyond the definition range + * and to interpolate in gaps without any usable tracking data + * to prevent sudden jump to image zero position. + */ + int next_lower = MINAFRAME; + int next_higher = MAXFRAME; + use_values_from_fcurves(ctx, true); + find_next_working_frames(ctx, framenr, &next_lower, &next_higher); + if (next_lower >= MINFRAME && next_higher < MAXFRAME) { + success = interpolate_averaged_track_contributions(ctx, + framenr, + next_lower, + next_higher, + aspect, + r_translation, + r_angle, + r_scale_step); + } + else if (next_higher < MAXFRAME) { + /* Before start of stabilized range: extrapolate start point + * settings. + */ + success = average_track_contributions(ctx, + next_higher, + aspect, + r_translation, + r_angle, + r_scale_step); + } + else if (next_lower >= MINFRAME) { + /* After end of stabilized range: extrapolate end point settings. */ + success = average_track_contributions(ctx, + next_lower, + aspect, + r_translation, + r_angle, + r_scale_step); + } + use_values_from_fcurves(ctx, false); } + return success; +} - /* Even if tracks does not start at frame 1, their position will - * be estimated at this frame, which will give reasonable result - * in most of cases. - * - * However, it's still better to replace this with real first - * frame number at which tracks are appearing. +/* Calculate stabilization data (translation, scale and rotation) from given raw + * measurements. Result is in absolute image dimensions (expanded image, square + * pixels), includes automatic or manual scaling and compensates for a target + * frame position, if given. + * + * size is a size of the expanded image, the width in pixels is size * aspect. + * aspect is a ratio (width / height) of the effective canvas (square pixels). + * do_compensate denotes whether to actually output values necessary to + * _compensate_ the determined frame movement. + * Otherwise, the effective target movement is returned. + */ +static void stabilization_calculate_data(StabContext *ctx, + int framenr, + int size, + float aspect, + bool do_compensate, + float scale_step, + float r_translation[2], + float *r_scale, + float *r_angle) +{ + float target_pos[2]; + float scaleinf = get_animated_scaleinf(ctx, framenr); + + *r_scale = (get_animated_target_scale(ctx,framenr) - 1.0f) * scaleinf + 1.0f; + + if (ctx->stab->flag & TRACKING_STABILIZE_SCALE) { + *r_scale *= expf(scale_step * scaleinf); /* Averaged in log scale */ + } + + mul_v2_fl(r_translation, get_animated_locinf(ctx, framenr)); + *r_angle *= get_animated_rotinf(ctx, framenr); + + /* Compensate for a target frame position. + * This allows to follow tracking / panning shots in a semi manual fashion, + * when animating the settings for the target frame position. */ - if (stabilization_median_point_get(tracking, 1, firstmedian)) { - stabilization_median_point_get(tracking, framenr, median); + get_animated_target_pos(ctx, framenr, target_pos); + sub_v2_v2(r_translation, target_pos); + *r_angle -= get_animated_target_rot(ctx,framenr); - if ((stab->flag & TRACKING_AUTOSCALE) == 0) - stab->scale = 1.0f; + /* Convert from relative to absolute coordinates, square pixels. */ + r_translation[0] *= (float)size * aspect; + r_translation[1] *= (float)size; + + /* Output measured data, or inverse of the measured values for + * compensation? + */ + if (do_compensate) { + mul_v2_fl(r_translation, -1.0f); + *r_angle *= -1.0f; + if (*r_scale != 0.0f) { + *r_scale = 1.0f / *r_scale; + } + } +} - if (!stab->ok) { - if (stab->flag & TRACKING_AUTOSCALE) - stabilization_calculate_autoscale_factor(tracking, width, height); - stabilization_calculate_data(tracking, framenr, width, height, firstmedian, median, - translation, scale, angle); +/* Determine the inner part of the frame, which is always safe to use. + * When enlarging the image by the inverse of this factor, any black areas + * appearing due to frame translation and rotation will be removed. + * + * NOTE: When calling this function, basic initialization of tracks must be + * done already + */ +static void stabilization_determine_safe_image_area(StabContext *ctx, + int size, + float image_aspect) +{ + MovieTrackingStabilization *stab = ctx->stab; + float pixel_aspect = ctx->tracking->camera.pixel_aspect; - stab->ok = true; + int sfra = INT_MAX, efra = INT_MIN, cfra; + float scale = 1.0f, scale_step = 0.0f; + MovieTrackingTrack *track; + stab->scale = 1.0f; + + /* Calculate maximal frame range of tracks where stabilization is active. */ + for (track = ctx->tracking->tracks.first; track; track = track->next) { + if ((track->flag & TRACK_USE_2D_STAB) || + ((stab->flag & TRACKING_STABILIZE_ROTATION) && + (track->flag & TRACK_USE_2D_STAB_ROT))) + { + int first_frame = track->markers[0].framenr; + int last_frame = track->markers[track->markersnr - 1].framenr; + sfra = min_ii(sfra, first_frame); + efra = max_ii(efra, last_frame); } - else { - stabilization_calculate_data(tracking, framenr, width, height, firstmedian, median, - translation, scale, angle); + } + + /* For every frame we calculate scale factor needed to eliminate black border area + * and choose largest scale factor as final one. + */ + for (cfra = sfra; cfra <= efra; cfra++) { + float translation[2], angle, tmp_scale; + int i; + float mat[4][4]; + float points[4][2] = {{0.0f, 0.0f}, + {0.0f, size}, + {image_aspect * size, size}, + {image_aspect * size, 0.0f}}; + float si, co; + bool do_compensate = true; + + stabilization_determine_offset_for_frame(ctx, + cfra, + image_aspect, + translation, + &angle, + &scale_step); + stabilization_calculate_data(ctx, + cfra, + size, + image_aspect, + do_compensate, + scale_step, + translation, + &tmp_scale, + &angle); + + BKE_tracking_stabilization_data_to_mat4(size * image_aspect, + size, + pixel_aspect, + translation, + 1.0f, + angle, + mat); + + si = sinf(angle); + co = cosf(angle); + + /* Investigate the transformed border lines for this frame; + * find out, where it cuts the original frame. + */ + for (i = 0; i < 4; i++) { + int j; + float a[3] = {0.0f, 0.0f, 0.0f}, + b[3] = {0.0f, 0.0f, 0.0f}; + + copy_v2_v2(a, points[i]); + copy_v2_v2(b, points[(i + 1) % 4]); + a[2] = b[2] = 0.0f; + + mul_m4_v3(mat, a); + mul_m4_v3(mat, b); + + for (j = 0; j < 4; j++) { + float point[3] = {points[j][0], points[j][1], 0.0f}; + float v1[3], v2[3]; + + sub_v3_v3v3(v1, b, a); + sub_v3_v3v3(v2, point, a); + + if (cross_v2v2(v1, v2) >= 0.0f) { + const float rot_dx[4][2] = {{1.0f, 0.0f}, + {0.0f, -1.0f}, + {-1.0f, 0.0f}, + {0.0f, 1.0f}}; + const float rot_dy[4][2] = {{0.0f, 1.0f}, + {1.0f, 0.0f}, + {0.0f, -1.0f}, + {-1.0f, 0.0f}}; + + float dx = translation[0] * rot_dx[j][0] + + translation[1] * rot_dx[j][1], + dy = translation[0] * rot_dy[j][0] + + translation[1] * rot_dy[j][1]; + + float w, h, E, F, G, H, I, J, K, S; + + if (j % 2) { + w = (float)size / 2.0f; + h = image_aspect*size / 2.0f; + } + else { + w = image_aspect*size / 2.0f; + h = (float)size / 2.0f; + } + + E = -w * co + h * si; + F = -h * co - w * si; + + if ((i % 2) == (j % 2)) { + G = -w * co - h * si; + H = h * co - w * si; + } + else { + G = w * co + h * si; + H = -h * co + w * si; + } + + I = F - H; + J = G - E; + K = G * F - E * H; + + S = (dx * I + dy * J + K) / (-w * I - h * J); + + scale = min_ff(scale, S); + } + } } } + + stab->scale = scale; + + if (stab->maxscale > 0.0f) { + stab->scale = max_ff(stab->scale, 1.0f / stab->maxscale); + } +} + + +/* Prepare working data and determine reference point for each track. + * + * NOTE: These calculations _could_ be cached and reused for all frames of the + * same clip. However, since proper initialization depends on (weight) + * animation and setup of tracks, ensuring consistency of cached init data + * turns out to be tricky, hard to maintain and generally not worth the + * effort. Thus we'll re-initialize on every frame. + */ +static StabContext *init_stabilizer(MovieClip *clip, int width, int height) +{ + MovieTracking *tracking = &clip->tracking; + MovieTrackingStabilization *stab = &tracking->stabilization; + float pixel_aspect = tracking->camera.pixel_aspect; + float aspect = (float)width * pixel_aspect / height; + int size = height; + + StabContext *ctx = initialize_stabilization_working_context(clip); + BLI_assert(ctx != NULL); + initialize_all_tracks(ctx, aspect); + if (stab->flag & TRACKING_AUTOSCALE) { + stabilization_determine_safe_image_area(ctx, size, aspect); + } + /* By default, just use values for the global current frame. */ + use_values_from_fcurves(ctx, false); + return ctx; +} + + +/* === public interface functions === */ + +/* Get stabilization data (translation, scaling and angle) for a given frame. + * Returned data describes how to compensate the detected movement, but with any + * chosen scale factor already applied and any target frame position already + * compensated. In case stabilization fails or is disabled, neutral values are + * returned. + * + * framenr is a frame number, relative to the clip (not relative to the scene + * timeline) + * width is an effective width of the canvas (square pixels), used to scale the + * determined translation + * + * Outputs: + * - translation of the lateral shift, absolute canvas coordinates + * (square pixels). + * - scale of the scaling to apply + * - angle of the rotation angle, relative to the frame center + */ +/* TODO(sergey): Use r_ prefix for output parameters here. */ +void BKE_tracking_stabilization_data_get(MovieClip *clip, + int framenr, + int width, + int height, + float translation[2], + float *scale, + float *angle) +{ + StabContext *ctx = NULL; + MovieTracking *tracking = &clip->tracking; + bool enabled = (tracking->stabilization.flag & TRACKING_2D_STABILIZATION); + /* Might become a parameter of a stabilization compositor node. */ + bool do_compensate = true; + float scale_step = 0.0f; + float pixel_aspect = tracking->camera.pixel_aspect; + float aspect = (float)width * pixel_aspect / height; + int size = height; + + if (enabled) { + ctx = init_stabilizer(clip, width, height); + } + + if (enabled && + stabilization_determine_offset_for_frame(ctx, + framenr, + aspect, + translation, + angle, + &scale_step)) + { + stabilization_calculate_data(ctx, + framenr, + size, + aspect, + do_compensate, + scale_step, + translation, + scale, + angle); + } else { zero_v2(translation); *scale = 1.0f; *angle = 0.0f; } + discard_stabilization_working_context(ctx); } -/* Stabilize given image buffer using stabilization data for - * a specified frame number. +/* Stabilize given image buffer using stabilization data for a specified + * frame number. * - * NOTE: frame number should be in clip space, not scene space + * NOTE: frame number should be in clip space, not scene space. */ -ImBuf *BKE_tracking_stabilize_frame(MovieTracking *tracking, int framenr, ImBuf *ibuf, - float translation[2], float *scale, float *angle) +/* TODO(sergey): Use r_ prefix for output parameters here. */ +ImBuf *BKE_tracking_stabilize_frame(MovieClip *clip, + int framenr, + ImBuf *ibuf, + float translation[2], + float *scale, + float *angle) { float tloc[2], tscale, tangle; + MovieTracking *tracking = &clip->tracking; MovieTrackingStabilization *stab = &tracking->stabilization; ImBuf *tmpibuf; int width = ibuf->x, height = ibuf->y; - float aspect = tracking->camera.pixel_aspect; + float pixel_aspect = tracking->camera.pixel_aspect; float mat[4][4]; int j, filter = tracking->stabilization.filter; void (*interpolation)(struct ImBuf *, struct ImBuf *, float, float, int, int) = NULL; @@ -349,8 +1363,12 @@ ImBuf *BKE_tracking_stabilize_frame(MovieTracking *tracking, int framenr, ImBuf tmpibuf = IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->planes, ibuf_flags); /* Calculate stabilization matrix. */ - BKE_tracking_stabilization_data_get(tracking, framenr, width, height, tloc, &tscale, &tangle); - BKE_tracking_stabilization_data_to_mat4(ibuf->x, ibuf->y, aspect, tloc, tscale, tangle, mat); + BKE_tracking_stabilization_data_get(clip, framenr, width, height, tloc, &tscale, &tangle); + BKE_tracking_stabilization_data_to_mat4(ibuf->x, ibuf->y, pixel_aspect, tloc, tscale, tangle, mat); + + /* The following code visits each nominal target grid position + * and picks interpolated data "backwards" from source. + * thus we need the inverse of the transformation to apply. */ invert_m4(mat); if (filter == TRACKING_FILTER_NEAREST) @@ -397,48 +1415,61 @@ ImBuf *BKE_tracking_stabilize_frame(MovieTracking *tracking, int framenr, ImBuf return tmpibuf; } -/* Get 4x4 transformation matrix which corresponds to - * stabilization data and used for easy coordinate - * transformation. + +/* Build a 4x4 transformation matrix based on the given 2D stabilization data. + * mat is a 4x4 matrix in homogeneous coordinates, adapted to the + * final image buffer size and compensated for pixel aspect ratio, + * ready for direct OpenGL drawing. * - * NOTE: The reason it is 4x4 matrix is because it's - * used for OpenGL drawing directly. + * TODO(sergey): The signature of this function should be changed. we actually + * don't need the dimensions of the image buffer. Instead we + * should consider to provide the pivot point of the rotation as a + * further stabilization data parameter. */ -void BKE_tracking_stabilization_data_to_mat4(int width, int height, float aspect, +void BKE_tracking_stabilization_data_to_mat4(int buffer_width, + int buffer_height, + float pixel_aspect, float translation[2], float scale, float angle, float mat[4][4]) { float translation_mat[4][4], rotation_mat[4][4], scale_mat[4][4], - center_mat[4][4], inv_center_mat[4][4], + pivot_mat[4][4], inv_pivot_mat[4][4], aspect_mat[4][4], inv_aspect_mat[4][4]; - float scale_vector[3] = {scale, scale, scale}; + float scale_vector[3] = {scale, scale, 1.0f}; + + float pivot[2]; /* XXX this should be a parameter, it is part of the stabilization data */ + + /* Use the motion compensated image center as rotation center. + * This is not 100% correct, but reflects the way the rotation data was + * measured. Actually we'd need a way to find a good pivot, and use that + * both for averaging and for compensation. + */ + /* TODO(sergey) pivot shouldn't be calculated here, rather received + * as a parameter. + */ + pivot[0] = pixel_aspect * buffer_width / 2.0f - translation[0]; + pivot[1] = (float)buffer_height / 2.0f - translation[1]; unit_m4(translation_mat); unit_m4(rotation_mat); unit_m4(scale_mat); - unit_m4(center_mat); unit_m4(aspect_mat); + unit_m4(pivot_mat); + unit_m4(inv_pivot_mat); /* aspect ratio correction matrix */ - aspect_mat[0][0] = 1.0f / aspect; + aspect_mat[0][0] /= pixel_aspect; invert_m4_m4(inv_aspect_mat, aspect_mat); - /* image center as rotation center - * - * Rotation matrix is constructing in a way rotation happens around image center, - * and it's matter of calculating translation in a way, that applying translation - * after rotation would make it so rotation happens around median point of tracks - * used for translation stabilization. - */ - center_mat[3][0] = (float)width / 2.0f; - center_mat[3][1] = (float)height / 2.0f; - invert_m4_m4(inv_center_mat, center_mat); + add_v2_v2(pivot_mat[3], pivot); + sub_v2_v2(inv_pivot_mat[3], pivot); size_to_mat4(scale_mat, scale_vector); /* scale matrix */ add_v2_v2(translation_mat[3], translation); /* translation matrix */ rotate_m4(rotation_mat, 'Z', angle); /* rotation matrix */ /* compose transformation matrix */ - mul_m4_series(mat, translation_mat, center_mat, aspect_mat, rotation_mat, inv_aspect_mat, - scale_mat, inv_center_mat); + mul_m4_series(mat, aspect_mat, translation_mat, + pivot_mat, scale_mat, rotation_mat, inv_pivot_mat, + inv_aspect_mat); } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 161ab3a2b82..ded60af4af2 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7478,7 +7478,7 @@ static void direct_link_movieclip(FileData *fd, MovieClip *clip) clip->tracking_context = NULL; clip->tracking.stats = NULL; - clip->tracking.stabilization.ok = 0; + /* Needed for proper versioning, will be NULL for all newer files anyway. */ clip->tracking.stabilization.rot_track = newdataadr(fd, clip->tracking.stabilization.rot_track); clip->tracking.dopesheet.ok = 0; diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index f41aba1b5b0..394547757e9 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -63,6 +63,7 @@ #include "BKE_scene.h" #include "BKE_sequencer.h" #include "BKE_screen.h" +#include "BKE_tracking.h" #include "BKE_gpencil.h" #include "BLI_math.h" @@ -75,6 +76,26 @@ #include "MEM_guardedalloc.h" +/** + * Setup rotation stabilization from ancient single track spec. + * Former Version of 2D stabilization used a single tracking marker to determine the rotation + * to be compensated. Now several tracks can contribute to rotation detection and this feature + * is enabled by the MovieTrackingTrack#flag on a per track base. + */ +static void migrate_single_rot_stabilization_track_settings(MovieTrackingStabilization *stab) +{ + if (stab->rot_track) { + if (!(stab->rot_track->flag & TRACK_USE_2D_STAB_ROT)) { + stab->tot_rot_track++; + stab->rot_track->flag |= TRACK_USE_2D_STAB_ROT; + } + } + stab->rot_track = NULL; /* this field is now ignored */ + + /* by default show the track lists expanded, to improve "discoverability" */ + stab->flag |= TRACKING_SHOW_STAB_TRACKS; +} + static void do_version_constraints_radians_degrees_270_1(ListBase *lb) { bConstraint *con; @@ -1321,4 +1342,41 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) /* ------- end of grease pencil initialization --------------- */ } + if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingTrack", "float", "weight_stab")) { + MovieClip *clip; + for (clip = main->movieclip.first; clip; clip = clip->id.next) { + MovieTracking *tracking = &clip->tracking; + MovieTrackingObject *tracking_object; + for (tracking_object = tracking->objects.first; + tracking_object != NULL; + tracking_object = tracking_object->next) + { + ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object); + MovieTrackingTrack *track; + for (track = tracksbase->first; + track != NULL; + track = track->next) + { + track->weight_stab = track->weight; + } + } + } + } + + if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingStabilization", "int", "tot_rot_track")) { + + MovieClip *clip; + for (clip = main->movieclip.first; clip != NULL; clip = clip->id.next) { + if (clip->tracking.stabilization.rot_track) { + migrate_single_rot_stabilization_track_settings(&clip->tracking.stabilization); + + if (!clip->tracking.stabilization.scale) { + /* ensure init. + * Was previously used for autoscale only, + * now used always (as "target scale") */ + clip->tracking.stabilization.scale = 1.0f; + } + } + } + } } diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.cpp b/source/blender/compositor/nodes/COM_MovieClipNode.cpp index 933223dacac..b3f1b5a4458 100644 --- a/source/blender/compositor/nodes/COM_MovieClipNode.cpp +++ b/source/blender/compositor/nodes/COM_MovieClipNode.cpp @@ -91,7 +91,7 @@ void MovieClipNode::convertToOperations(NodeConverter &converter, const Composit if (stab->flag & TRACKING_2D_STABILIZATION) { int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(movieClip, context.getFramenumber()); - BKE_tracking_stabilization_data_get(&movieClip->tracking, clip_framenr, ibuf->x, ibuf->y, loc, &scale, &angle); + BKE_tracking_stabilization_data_get(movieClip, clip_framenr, ibuf->x, ibuf->y, loc, &scale, &angle); } } diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp index 5ddf15f7684..41f7da7c49f 100644 --- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp +++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp @@ -47,7 +47,7 @@ void MovieClipAttributeOperation::executePixelSampled(float output[4], angle = 0.0f; if (this->m_clip) { int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_clip, this->m_framenumber); - BKE_tracking_stabilization_data_get(&this->m_clip->tracking, clip_framenr, getWidth(), getHeight(), loc, &scale, &angle); + BKE_tracking_stabilization_data_get(this->m_clip, clip_framenr, getWidth(), getHeight(), loc, &scale, &angle); } switch (this->m_attribute) { case MCA_SCALE: diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index 2a5d959bb84..13dcd405ee6 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -185,7 +185,10 @@ void CLIP_OT_detect_features(struct wmOperatorType *ot); void CLIP_OT_stabilize_2d_add(struct wmOperatorType *ot); void CLIP_OT_stabilize_2d_remove(struct wmOperatorType *ot); void CLIP_OT_stabilize_2d_select(struct wmOperatorType *ot); -void CLIP_OT_stabilize_2d_set_rotation(struct wmOperatorType *ot); + +void CLIP_OT_stabilize_2d_rotation_add(struct wmOperatorType *ot); +void CLIP_OT_stabilize_2d_rotation_remove(struct wmOperatorType *ot); +void CLIP_OT_stabilize_2d_rotation_select(struct wmOperatorType *ot); void CLIP_OT_clean_tracks(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index 5964e9a898b..547c2fba66f 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -175,21 +175,14 @@ void clip_graph_tracking_iterate(SpaceClip *sc, bool selected_only, bool include void clip_delete_track(bContext *C, MovieClip *clip, MovieTrackingTrack *track) { MovieTracking *tracking = &clip->tracking; - MovieTrackingStabilization *stab = &tracking->stabilization; MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); - bool has_bundle = false, update_stab = false; + bool has_bundle = false; char track_name_escaped[MAX_NAME], prefix[MAX_NAME * 2]; if (track == act_track) tracking->act_track = NULL; - if (track == stab->rot_track) { - stab->rot_track = NULL; - - update_stab = true; - } - /* handle reconstruction display in 3d viewport */ if (track->flag & TRACK_HAS_BUNDLE) has_bundle = true; @@ -207,8 +200,7 @@ void clip_delete_track(bContext *C, MovieClip *clip, MovieTrackingTrack *track) WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); - if (update_stab) { - tracking->stabilization.ok = false; + if (track->flag & (TRACK_USE_2D_STAB | TRACK_USE_2D_STAB_ROT)) { WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); } diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 396d71f0a20..4f653bab682 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -225,18 +225,6 @@ static void clip_scopes_check_gpencil_change(ScrArea *sa) } } -static void clip_stabilization_tag_refresh(ScrArea *sa) -{ - SpaceClip *sc = (SpaceClip *) sa->spacedata.first; - MovieClip *clip = ED_space_clip_get_clip(sc); - - if (clip) { - MovieTrackingStabilization *stab = &clip->tracking.stabilization; - - stab->ok = false; - } -} - /* ******************** default callbacks for clip space ***************** */ static SpaceLink *clip_new(const bContext *C) @@ -368,7 +356,6 @@ static void clip_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) case NA_REMOVED: case NA_EDITED: case NA_EVALUATED: - clip_stabilization_tag_refresh(sa); /* fall-through */ case NA_SELECTED: @@ -412,7 +399,6 @@ static void clip_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) case NC_SPACE: if (wmn->data == ND_SPACE_CLIP) { clip_scopes_tag_refresh(sa); - clip_stabilization_tag_refresh(sa); ED_area_tag_redraw(sa); } break; @@ -457,7 +443,7 @@ static void clip_operatortypes(void) /* navigation */ WM_operatortype_append(CLIP_OT_frame_jump); - /* foorage */ + /* set optical center to frame center */ WM_operatortype_append(CLIP_OT_set_center_principal); /* selection */ @@ -505,7 +491,9 @@ static void clip_operatortypes(void) WM_operatortype_append(CLIP_OT_stabilize_2d_add); WM_operatortype_append(CLIP_OT_stabilize_2d_remove); WM_operatortype_append(CLIP_OT_stabilize_2d_select); - WM_operatortype_append(CLIP_OT_stabilize_2d_set_rotation); + WM_operatortype_append(CLIP_OT_stabilize_2d_rotation_add); + WM_operatortype_append(CLIP_OT_stabilize_2d_rotation_remove); + WM_operatortype_append(CLIP_OT_stabilize_2d_rotation_select); /* clean-up */ WM_operatortype_append(CLIP_OT_clear_track_path); diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 61bfa5b315b..d28cbe5fb1d 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -1509,8 +1509,10 @@ static int join_tracks_exec(bContext *C, wmOperator *op) SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; + MovieTrackingStabilization *stab = &tracking->stabilization; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking); + bool update_stabilization = false; MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); if (act_track == NULL) { @@ -1528,8 +1530,23 @@ static int join_tracks_exec(bContext *C, wmOperator *op) if (TRACK_VIEW_SELECTED(sc, track) && track != act_track) { BKE_tracking_tracks_join(tracking, act_track, track); - if (tracking->stabilization.rot_track == track) { - tracking->stabilization.rot_track = act_track; + if (track->flag & TRACK_USE_2D_STAB) { + update_stabilization = true; + if ((act_track->flag & TRACK_USE_2D_STAB) == 0) { + act_track->flag |= TRACK_USE_2D_STAB; + } else { + stab->tot_track--; + } + BLI_assert(0 <= stab->tot_track); + } + if (track->flag & TRACK_USE_2D_STAB_ROT) { + update_stabilization = true; + if ((act_track->flag & TRACK_USE_2D_STAB_ROT) == 0) { + act_track->flag |= TRACK_USE_2D_STAB_ROT; + } else { + stab->tot_rot_track--; + } + BLI_assert(0 <= stab->tot_rot_track); } for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first; @@ -1551,6 +1568,10 @@ static int join_tracks_exec(bContext *C, wmOperator *op) } } + if (update_stabilization) { + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); + } + GSetIterator gs_iter; int framenr = ED_space_clip_get_clip_frame_number(sc); GSET_ITER (gs_iter, point_tracks) { diff --git a/source/blender/editors/space_clip/tracking_ops_stabilize.c b/source/blender/editors/space_clip/tracking_ops_stabilize.c index 8d6173e1cea..35b1aead343 100644 --- a/source/blender/editors/space_clip/tracking_ops_stabilize.c +++ b/source/blender/editors/space_clip/tracking_ops_stabilize.c @@ -84,7 +84,6 @@ static int stabilize_2d_add_exec(bContext *C, wmOperator *UNUSED(op)) } if (update) { - stab->ok = 0; DAG_id_tag_update(&clip->id, 0); WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); } @@ -96,7 +95,7 @@ void CLIP_OT_stabilize_2d_add(wmOperatorType *ot) { /* identifiers */ ot->name = "Add Stabilization Tracks"; - ot->description = "Add selected tracks to 2D stabilization tool"; + ot->description = "Add selected tracks to 2D translation stabilization"; ot->idname = "CLIP_OT_stabilize_2d_add"; /* api callbacks */ @@ -139,7 +138,6 @@ static int stabilize_2d_remove_exec(bContext *C, wmOperator *UNUSED(op)) } if (update) { - stab->ok = 0; DAG_id_tag_update(&clip->id, 0); WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); } @@ -151,7 +149,7 @@ void CLIP_OT_stabilize_2d_remove(wmOperatorType *ot) { /* identifiers */ ot->name = "Remove Stabilization Track"; - ot->description = "Remove selected track from stabilization"; + ot->description = "Remove selected track from translation stabilization"; ot->idname = "CLIP_OT_stabilize_2d_remove"; /* api callbacks */ @@ -193,7 +191,7 @@ void CLIP_OT_stabilize_2d_select(wmOperatorType *ot) { /* identifiers */ ot->name = "Select Stabilization Tracks"; - ot->description = "Select tracks which are used for stabilization"; + ot->description = "Select tracks which are used for translation stabilization"; ot->idname = "CLIP_OT_stabilize_2d_select"; /* api callbacks */ @@ -204,20 +202,85 @@ void CLIP_OT_stabilize_2d_select(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/***************** set 2d stabilization rotation track operator ****************/ +/********************** add 2d stabilization tracks for rotation operator ****************/ -static int stabilize_2d_set_rotation_exec(bContext *C, wmOperator *UNUSED(op)) +static int stabilize_2d_rotation_add_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; - MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); + ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); + MovieTrackingStabilization *stab = &tracking->stabilization; + + bool update = false; + for (MovieTrackingTrack *track = tracksbase->first; + track != NULL; + track = track->next) + { + if (TRACK_VIEW_SELECTED(sc, track) && + (track->flag & TRACK_USE_2D_STAB_ROT) == 0) + { + track->flag |= TRACK_USE_2D_STAB_ROT; + stab->tot_rot_track++; + update = true; + } + } + + if (update) { + DAG_id_tag_update(&clip->id, 0); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); + } + + return OPERATOR_FINISHED; +} + +void CLIP_OT_stabilize_2d_rotation_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Add Stabilization Rotation Tracks"; + ot->description = "Add selected tracks to 2D rotation stabilization"; + ot->idname = "CLIP_OT_stabilize_2d_rotation_add"; + + /* api callbacks */ + ot->exec = stabilize_2d_rotation_add_exec; + ot->poll = stabilize_2d_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +/********************** remove 2d stabilization tracks for rotation operator *************/ + +static int stabilize_2d_rotation_remove_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip_get_clip(sc); + MovieTracking *tracking = &clip->tracking; + MovieTrackingStabilization *stab = &tracking->stabilization; + ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); + int a = 0; + bool update = false; - if (act_track != NULL) { - MovieTrackingStabilization *stab = &tracking->stabilization; - stab->rot_track = act_track; - stab->ok = 0; + for (MovieTrackingTrack *track = tracksbase->first; + track != NULL; + track = track->next) + { + if (track->flag & TRACK_USE_2D_STAB_ROT) { + if (a == stab->act_rot_track) { + track->flag &= ~TRACK_USE_2D_STAB_ROT; + stab->act_rot_track--; + stab->tot_rot_track--; + if (stab->act_rot_track < 0) { + stab->act_rot_track = 0; + } + update = true; + break; + } + a++; + } + } + if (update) { DAG_id_tag_update(&clip->id, 0); WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); } @@ -225,18 +288,60 @@ static int stabilize_2d_set_rotation_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void CLIP_OT_stabilize_2d_set_rotation(wmOperatorType *ot) +void CLIP_OT_stabilize_2d_rotation_remove(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Remove Stabilization Rotation Track"; + ot->description = "Remove selected track from rotation stabilization"; + ot->idname = "CLIP_OT_stabilize_2d_rotation_remove"; + + /* api callbacks */ + ot->exec = stabilize_2d_rotation_remove_exec; + ot->poll = stabilize_2d_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +/********************** select 2d stabilization rotation tracks operator *****************/ + +static int stabilize_2d_rotation_select_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip_get_clip(sc); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); + bool update = false; + + for (MovieTrackingTrack *track = tracksbase->first; + track != NULL; + track = track->next) + { + if (track->flag & TRACK_USE_2D_STAB_ROT) { + BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT); + update = true; + } + } + + if (update) { + WM_event_add_notifier(C, NC_MOVIECLIP | ND_SELECT, clip); + } + + return OPERATOR_FINISHED; +} + +void CLIP_OT_stabilize_2d_rotation_select(wmOperatorType *ot) { /* identifiers */ - ot->name = "Set Rotation Track"; - ot->description = "Use active track to compensate rotation when " - "doing 2D stabilization"; - ot->idname = "CLIP_OT_stabilize_2d_set_rotation"; + ot->name = "Select Stabilization Rotation Tracks"; + ot->description = "Select tracks which are used for rotation stabilization"; + ot->idname = "CLIP_OT_stabilize_2d_rotation_select"; /* api callbacks */ - ot->exec = stabilize_2d_set_rotation_exec; + ot->exec = stabilize_2d_rotation_select_exec; ot->poll = stabilize_2d_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } + diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h index 9888b735b8b..42b72c1ff93 100644 --- a/source/blender/makesdna/DNA_tracking_types.h +++ b/source/blender/makesdna/DNA_tracking_types.h @@ -158,7 +158,10 @@ typedef struct MovieTrackingTrack { * Used to prevent jumps of the camera when tracks are appearing or * disappearing. */ - float weight, pad; + float weight; + + /* track weight especially for 2D stabilization */ + float weight_stab; } MovieTrackingTrack; typedef struct MovieTrackingPlaneMarker { @@ -250,19 +253,24 @@ typedef struct MovieTrackingSettings { typedef struct MovieTrackingStabilization { int flag; - int tot_track, act_track; /* total number and index of active track in list */ + int tot_track, act_track; /* total number of translation tracks and index of active track in list */ + int tot_rot_track, act_rot_track; /* total number of rotation tracks and index of active track in list */ /* 2d stabilization */ float maxscale; /* max auto-scale factor */ - MovieTrackingTrack *rot_track; /* track used to stabilize rotation */ + MovieTrackingTrack *rot_track DNA_DEPRECATED; /* use TRACK_USE_2D_STAB_ROT on individual tracks instead */ + + int anchor_frame; /* reference point to anchor stabilization offset */ + float target_pos[2]; /* expected target position of frame after raw stabilization, will be subtracted */ + float target_rot; /* expected target rotation of frame after raw stabilization, will be compensated */ + float scale; /* zoom factor known to be present on original footage. Also used for autoscale */ float locinf, scaleinf, rotinf; /* influence on location, scale and rotation */ int filter; /* filter used for pixel interpolation */ - /* some pre-computing run-time variables */ - int ok; /* are precomputed values and scaled buf relevant? */ - float scale; /* autoscale factor */ + /* initialization and run-time data */ + int ok DNA_DEPRECATED; /* Without effect now, we initialize on every frame. Formerly used for caching of init values */ } MovieTrackingStabilization; typedef struct MovieTrackingReconstruction { @@ -386,7 +394,8 @@ enum { TRACK_USE_2D_STAB = (1 << 8), TRACK_PREVIEW_GRAYSCALE = (1 << 9), TRACK_DOPE_SEL = (1 << 10), - TRACK_PREVIEW_ALPHA = (1 << 11) + TRACK_PREVIEW_ALPHA = (1 << 11), + TRACK_USE_2D_STAB_ROT = (1 << 12) }; /* MovieTrackingTrack->motion_model */ @@ -452,7 +461,9 @@ enum { enum { TRACKING_2D_STABILIZATION = (1 << 0), TRACKING_AUTOSCALE = (1 << 1), - TRACKING_STABILIZE_ROTATION = (1 << 2) + TRACKING_STABILIZE_ROTATION = (1 << 2), + TRACKING_STABILIZE_SCALE = (1 << 3), + TRACKING_SHOW_STAB_TRACKS = (1 << 5) }; /* MovieTrackingStrabilization->filter */ diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 7bad8991798..9cbe132282f 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -422,6 +422,7 @@ extern StructRNA RNA_MovieClipSequence; extern StructRNA RNA_MovieTracking; extern StructRNA RNA_MovieTrackingObject; extern StructRNA RNA_MovieTrackingTrack; +extern StructRNA RNA_MovieTrackingStabilization; extern StructRNA RNA_MulticamSequence; extern StructRNA RNA_MultiresModifier; extern StructRNA RNA_MusgraveTexture; diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 2564bdb800f..0591c65d484 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -394,6 +394,16 @@ static int rna_track_2d_stabilization(CollectionPropertyIterator *UNUSED(iter), return 0; } +static int rna_track_2d_stabilization_rotation(CollectionPropertyIterator *UNUSED(iter), void *data) +{ + MovieTrackingTrack *track = (MovieTrackingTrack *)data; + + if ((track->flag & TRACK_USE_2D_STAB_ROT) == 0) + return 1; + + return 0; +} + static void rna_tracking_stabTracks_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { MovieClip *clip = (MovieClip *)ptr->id.data; @@ -421,23 +431,36 @@ static void rna_tracking_stabTracks_active_index_range(PointerRNA *ptr, int *min *max = max_ii(0, clip->tracking.stabilization.tot_track - 1); } -static void rna_tracking_resetIntrinsics(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_tracking_stabRotTracks_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { MovieClip *clip = (MovieClip *)ptr->id.data; - MovieTracking *tracking = &clip->tracking; + rna_iterator_listbase_begin(iter, &clip->tracking.tracks, rna_track_2d_stabilization_rotation); +} - if (tracking->camera.intrinsics) { - BKE_tracking_distortion_free(tracking->camera.intrinsics); - tracking->camera.intrinsics = NULL; - } +static int rna_tracking_stabRotTracks_active_index_get(PointerRNA *ptr) +{ + MovieClip *clip = (MovieClip *)ptr->id.data; + return clip->tracking.stabilization.act_rot_track; } -static void rna_tracking_flushUpdate(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) +static void rna_tracking_stabRotTracks_active_index_set(PointerRNA *ptr, int value) +{ + MovieClip *clip = (MovieClip *)ptr->id.data; + clip->tracking.stabilization.act_rot_track = value; +} + +static void rna_tracking_stabRotTracks_active_index_range(PointerRNA *ptr, int *min, int *max, + int *UNUSED(softmin), int *UNUSED(softmax)) { MovieClip *clip = (MovieClip *)ptr->id.data; - MovieTrackingStabilization *stab = &clip->tracking.stabilization; - stab->ok = 0; + *min = 0; + *max = max_ii(0, clip->tracking.stabilization.tot_rot_track - 1); +} + +static void rna_tracking_flushUpdate(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) +{ + MovieClip *clip = (MovieClip *)ptr->id.data; nodeUpdateID(scene->nodetree, &clip->id); @@ -446,6 +469,17 @@ static void rna_tracking_flushUpdate(Main *UNUSED(bmain), Scene *scene, PointerR DAG_id_tag_update(&clip->id, 0); } +static void rna_tracking_resetIntrinsics(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + MovieClip *clip = (MovieClip *)ptr->id.data; + MovieTracking *tracking = &clip->tracking; + + if (tracking->camera.intrinsics) { + BKE_tracking_distortion_free(tracking->camera.intrinsics); + tracking->camera.intrinsics = NULL; + } +} + static void rna_trackingObject_tracks_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { MovieTrackingObject *object = (MovieTrackingObject *)ptr->data; @@ -1495,6 +1529,12 @@ static void rna_def_trackingTrack(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Weight", "Influence of this track on a final solution"); + /* weight_stab */ + prop = RNA_def_property(srna, "weight_stab", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "weight_stab"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Stab Weight", "Influence of this track on 2D stabilization"); + /* offset */ prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 2); @@ -1634,15 +1674,15 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem filter_items[] = { - {TRACKING_FILTER_NEAREST, "NEAREST", 0, "Nearest", ""}, - {TRACKING_FILTER_BILINEAR, "BILINEAR", 0, "Bilinear", ""}, - {TRACKING_FILTER_BICUBIC, "BICUBIC", 0, "Bicubic", ""}, + {TRACKING_FILTER_NEAREST, "NEAREST", 0, "Nearest", "No interpolation; use nearest neighbor pixel"}, + {TRACKING_FILTER_BILINEAR, "BILINEAR", 0, "Bilinear", "Simple interpolation between adjacent pixels"}, + {TRACKING_FILTER_BICUBIC, "BICUBIC", 0, "Bicubic", "High quality pixel interpolation"}, {0, NULL, 0, NULL, NULL} }; srna = RNA_def_struct(brna, "MovieTrackingStabilization", NULL); RNA_def_struct_path_func(srna, "rna_trackingStabilization_path"); - RNA_def_struct_ui_text(srna, "Movie tracking stabilization data", "Match-moving stabilization data for tracking"); + RNA_def_struct_ui_text(srna, "Movie tracking stabilization data", "2D stabilization based on tracking markers"); /* 2d stabilization */ prop = RNA_def_property(srna, "use_2d_stabilization", PROP_BOOLEAN, PROP_NONE); @@ -1651,22 +1691,29 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Use 2D stabilization", "Use 2D stabilization for footage"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate"); + /* use_stabilize_rotation */ + prop = RNA_def_property(srna, "use_stabilize_rotation", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_STABILIZE_ROTATION); + RNA_def_property_ui_text(prop, "Stabilize Rotation", "Stabilize detected rotation around center of frame"); + RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate"); + + /* use_stabilize_scale */ + prop = RNA_def_property(srna, "use_stabilize_scale", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_STABILIZE_SCALE); + RNA_def_property_ui_text(prop, "Stabilize Scale", "Compensate any scale changes relative to center of rotation"); + RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate"); + /* tracks */ prop = RNA_def_property(srna, "tracks", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_funcs(prop, "rna_tracking_stabTracks_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", NULL, NULL, NULL, NULL); RNA_def_property_struct_type(prop, "MovieTrackingTrack"); - RNA_def_property_ui_text(prop, "Tracks", "Collection of tracks used for stabilization"); + RNA_def_property_ui_text(prop, "Translation Tracks", "Collection of tracks used for 2D stabilization (translation)"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate"); - /* rotation track */ - prop = RNA_def_property(srna, "rotation_track", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "rot_track"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Rotation Track", "Track used to compensate rotation"); - RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_flushUpdate"); - /* active track index */ prop = RNA_def_property(srna, "active_track_index", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "act_track"); @@ -1674,7 +1721,57 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) RNA_def_property_int_funcs(prop, "rna_tracking_stabTracks_active_index_get", "rna_tracking_stabTracks_active_index_set", "rna_tracking_stabTracks_active_index_range"); - RNA_def_property_ui_text(prop, "Active Track Index", "Index of active track in stabilization tracks list"); + RNA_def_property_ui_text(prop, "Active Track Index", "Index of active track in translation stabilization tracks list"); + + /* tracks used for rotation stabilization */ + prop = RNA_def_property(srna, "rotation_tracks", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_funcs(prop, "rna_tracking_stabRotTracks_begin", "rna_iterator_listbase_next", + "rna_iterator_listbase_end", "rna_iterator_listbase_get", + NULL, NULL, NULL, NULL); + RNA_def_property_struct_type(prop, "MovieTrackingTrack"); + RNA_def_property_ui_text(prop, "Rotation Tracks", "Collection of tracks used for 2D stabilization (translation)"); + RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate"); + + /* active rotation track index */ + prop = RNA_def_property(srna, "active_rotation_track_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "act_rot_track"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_int_funcs(prop, "rna_tracking_stabRotTracks_active_index_get", + "rna_tracking_stabRotTracks_active_index_set", + "rna_tracking_stabRotTracks_active_index_range"); + RNA_def_property_ui_text(prop, "Active Rotation Track Index", "Index of active track in rotation stabilization tracks list"); + + /* anchor frame */ + prop = RNA_def_property(srna, "anchor_frame", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "anchor_frame"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_range(prop, MINFRAME, MAXFRAME); + RNA_def_property_ui_text(prop, "Anchor Frame", "Reference point to anchor stabilization (other frames will be adjusted relative to this frame's position)"); + RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate"); + + /* target position */ + prop = RNA_def_property(srna, "target_pos", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3); /* increment in steps of 0.01 and show 3 digit after point */ + RNA_def_property_float_sdna(prop, NULL, "target_pos"); + RNA_def_property_ui_text(prop, "Expected Position", "Known relative offset of original shot, will be subtracted; e.g. for panning shot, can be animated"); + RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL); + + /* target rotation */ + prop = RNA_def_property(srna, "target_rot", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "target_rot"); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3); + RNA_def_property_ui_text(prop, "Expected Rotation", "Rotation present on original shot, will be compensated; e.g. for deliberate tilting"); + RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL); + + /* target scale */ + prop = RNA_def_property(srna, "target_zoom", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "scale"); + RNA_def_property_range(prop, FLT_EPSILON, 100.0f); + RNA_def_property_ui_range(prop, 0.1f, 10.0f, 1, 3); /* increment in steps of 0.01. Show 3 digit after point */ + RNA_def_property_ui_text(prop, "Expected Zoom", "Explicitly scale resulting frame to compensate zoom of original shot"); + RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate"); /* autoscale */ prop = RNA_def_property(srna, "use_autoscale", PROP_BOOLEAN, PROP_NONE); @@ -1705,13 +1802,6 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Scale Influence", "Influence of stabilization algorithm on footage scale"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate"); - /* use_stabilize_rotation */ - prop = RNA_def_property(srna, "use_stabilize_rotation", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_STABILIZE_ROTATION); - RNA_def_property_ui_text(prop, "Stabilize Rotation", "Stabilize horizon line on the shot"); - RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate"); - /* influence_rotation */ prop = RNA_def_property(srna, "influence_rotation", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "rotinf"); @@ -1723,8 +1813,15 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "filter"); RNA_def_property_enum_items(prop, filter_items); - RNA_def_property_ui_text(prop, "Filter", "Method to use to filter stabilization"); + RNA_def_property_ui_text(prop, "Interpolate", "Interpolation to use for sub-pixel shifts and rotations due to stabilization"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate"); + + /* UI display : show participating tracks */ + prop = RNA_def_property(srna, "show_tracks_expanded", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_SHOW_STAB_TRACKS); + RNA_def_property_ui_text(prop, "Show Tracks", "Show UI list of tracks participating in stabilization"); + RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); } static void rna_def_reconstructedCamera(BlenderRNA *brna) -- cgit v1.2.3 From 5e8c09921e58e1f86d61e825bc8f446bb134ed0d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 16 Aug 2016 13:30:47 +0200 Subject: 2D stabilization: Modify interface so dependency goes strictly from top to bottom --- release/scripts/startup/bl_ui/space_clip.py | 89 ++++++++++------------- source/blender/blenkernel/intern/tracking.c | 1 - source/blender/blenloader/intern/versioning_270.c | 3 - source/blender/makesdna/DNA_tracking_types.h | 1 - source/blender/makesrna/intern/rna_tracking.c | 7 -- 5 files changed, 37 insertions(+), 64 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 9b1c0a16603..b2263618719 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -916,73 +916,58 @@ class CLIP_PT_stabilization(CLIP_PT_reconstruction_panel, Panel): layout.prop(stab, "anchor_frame") - box = layout.box() - row = box.row(align=True) - row.prop(stab, "show_tracks_expanded", text="", emboss=False) + col = layout.column() + col.label(text="Location") + row = col.row() + row.template_list("UI_UL_list", "stabilization_tracks", stab, "tracks", + stab, "active_track_index", rows=2) - if not stab.show_tracks_expanded: - row.label(text="Tracks For Stabilization") - else: - row.label(text="Tracks For Location") - row = box.row() - row.template_list("UI_UL_list", "stabilization_tracks", stab, "tracks", - stab, "active_track_index", rows=2) + sub = row.column(align=True) - sub = row.column(align=True) + sub.operator("clip.stabilize_2d_add", icon='ZOOMIN', text="") + sub.operator("clip.stabilize_2d_remove", icon='ZOOMOUT', text="") - sub.operator("clip.stabilize_2d_add", icon='ZOOMIN', text="") - sub.operator("clip.stabilize_2d_remove", icon='ZOOMOUT', text="") + sub.menu('CLIP_MT_stabilize_2d_specials', text="", + icon='DOWNARROW_HLT') - sub.menu('CLIP_MT_stabilize_2d_specials', text="", - icon='DOWNARROW_HLT') + col.label(text="Expected Position") + row = col.row() + row.prop(stab, "target_pos", text="") + col.prop(stab, "influence_location") - row = box.row() - row.label(text="Tracks For Rotation / Scale") - row = box.row() - row.active = stab.use_stabilize_rotation - row.template_list("UI_UL_list", "stabilization_rotation_tracks", stab, "rotation_tracks", - stab, "active_rotation_track_index", rows=2) + layout.separator() + layout.prop(stab, "use_stabilize_rotation") + col = layout.column() + col.active = stab.use_stabilize_rotation + row = col.row() + row.template_list("UI_UL_list", "stabilization_rotation_tracks", stab, "rotation_tracks", + stab, "active_rotation_track_index", rows=2) - sub = row.column(align=True) + sub = row.column(align=True) - sub.operator("clip.stabilize_2d_rotation_add", icon='ZOOMIN', text="") - sub.operator("clip.stabilize_2d_rotation_remove", icon='ZOOMOUT', text="") + sub.operator("clip.stabilize_2d_rotation_add", icon='ZOOMIN', text="") + sub.operator("clip.stabilize_2d_rotation_remove", icon='ZOOMOUT', text="") - sub.menu('CLIP_MT_stabilize_2d_rotation_specials', text="", - icon='DOWNARROW_HLT') + sub.menu('CLIP_MT_stabilize_2d_rotation_specials', text="", + icon='DOWNARROW_HLT') - layout.prop(stab, "use_stabilize_rotation") - row = layout.row() - row.active = stab.use_stabilize_rotation - row.prop(stab, "use_stabilize_scale") - if stab.use_autoscale: - row = layout.row(align=True) - row.prop(stab, "use_autoscale") - row.prop(stab, "scale_max", text="Max") - else: - layout.prop(stab, "use_autoscale") + col.prop(stab, "target_rot") + col.prop(stab, "influence_rotation") layout.separator() - layout.label(text="Expected Position") - layout.prop(stab, "target_pos", text="") - layout.prop(stab, "target_rot") + col = layout.column() + col.active = stab.use_stabilize_rotation + col.prop(stab, "use_stabilize_scale") + col.prop(stab, "use_autoscale") if stab.use_autoscale: - layout.label(text="Auto Scale Factor: %5.3f" % (1.0 / stab.target_zoom)) + col.prop(stab, "scale_max", text="Max") + col.label(text="Auto Scale Factor: %5.3f" % (1.0 / stab.target_zoom)) else: - layout.prop(stab, "target_zoom") - - layout.separator() - row = layout.row() - row.active = 0 < len(stab.tracks.values()) - row.prop(stab, "influence_location") + col.prop(stab, "target_zoom") - col = layout.column() - col.active = stab.use_stabilize_rotation and 0 < len(stab.rotation_tracks.values()) - row = col.row() - row.prop(stab, "influence_rotation") - row = col.row() - row.prop(stab, "influence_scale") + col.prop(stab, "influence_scale") + layout.separator() layout.prop(stab, "filter_type") diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index d5d3384bb48..e50218c2a19 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -345,7 +345,6 @@ void BKE_tracking_settings_init(MovieTracking *tracking) tracking->stabilization.rotinf = 1.0f; tracking->stabilization.maxscale = 2.0f; tracking->stabilization.filter = TRACKING_FILTER_BILINEAR; - tracking->stabilization.flag |= TRACKING_SHOW_STAB_TRACKS; BKE_tracking_object_add(tracking, "Camera"); } diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 394547757e9..45c73edf908 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -91,9 +91,6 @@ static void migrate_single_rot_stabilization_track_settings(MovieTrackingStabili } } stab->rot_track = NULL; /* this field is now ignored */ - - /* by default show the track lists expanded, to improve "discoverability" */ - stab->flag |= TRACKING_SHOW_STAB_TRACKS; } static void do_version_constraints_radians_degrees_270_1(ListBase *lb) diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h index 42b72c1ff93..8c22fa09477 100644 --- a/source/blender/makesdna/DNA_tracking_types.h +++ b/source/blender/makesdna/DNA_tracking_types.h @@ -463,7 +463,6 @@ enum { TRACKING_AUTOSCALE = (1 << 1), TRACKING_STABILIZE_ROTATION = (1 << 2), TRACKING_STABILIZE_SCALE = (1 << 3), - TRACKING_SHOW_STAB_TRACKS = (1 << 5) }; /* MovieTrackingStrabilization->filter */ diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 0591c65d484..2787ec4ca21 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -1815,13 +1815,6 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) RNA_def_property_enum_items(prop, filter_items); RNA_def_property_ui_text(prop, "Interpolate", "Interpolation to use for sub-pixel shifts and rotations due to stabilization"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate"); - - /* UI display : show participating tracks */ - prop = RNA_def_property(srna, "show_tracks_expanded", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_SHOW_STAB_TRACKS); - RNA_def_property_ui_text(prop, "Show Tracks", "Show UI list of tracks participating in stabilization"); - RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); } static void rna_def_reconstructedCamera(BlenderRNA *brna) -- cgit v1.2.3 From e3576c7bf45a6b5666df093b8194a3c5e4b67a2e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 16 Aug 2016 13:53:29 +0200 Subject: Correct previous commit, need to indent verisoning code --- source/blender/blenloader/intern/versioning_270.c | 56 +++++++++++------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 45c73edf908..18b60883977 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -1339,39 +1339,39 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) /* ------- end of grease pencil initialization --------------- */ } - if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingTrack", "float", "weight_stab")) { - MovieClip *clip; - for (clip = main->movieclip.first; clip; clip = clip->id.next) { - MovieTracking *tracking = &clip->tracking; - MovieTrackingObject *tracking_object; - for (tracking_object = tracking->objects.first; - tracking_object != NULL; - tracking_object = tracking_object->next) - { - ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object); - MovieTrackingTrack *track; - for (track = tracksbase->first; - track != NULL; - track = track->next) + { + if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingTrack", "float", "weight_stab")) { + MovieClip *clip; + for (clip = main->movieclip.first; clip; clip = clip->id.next) { + MovieTracking *tracking = &clip->tracking; + MovieTrackingObject *tracking_object; + for (tracking_object = tracking->objects.first; + tracking_object != NULL; + tracking_object = tracking_object->next) { - track->weight_stab = track->weight; + ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object); + MovieTrackingTrack *track; + for (track = tracksbase->first; + track != NULL; + track = track->next) + { + track->weight_stab = track->weight; + } } } } - } - if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingStabilization", "int", "tot_rot_track")) { - - MovieClip *clip; - for (clip = main->movieclip.first; clip != NULL; clip = clip->id.next) { - if (clip->tracking.stabilization.rot_track) { - migrate_single_rot_stabilization_track_settings(&clip->tracking.stabilization); - - if (!clip->tracking.stabilization.scale) { - /* ensure init. - * Was previously used for autoscale only, - * now used always (as "target scale") */ - clip->tracking.stabilization.scale = 1.0f; + if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingStabilization", "int", "tot_rot_track")) { + MovieClip *clip; + for (clip = main->movieclip.first; clip != NULL; clip = clip->id.next) { + if (clip->tracking.stabilization.rot_track) { + migrate_single_rot_stabilization_track_settings(&clip->tracking.stabilization); + if (!clip->tracking.stabilization.scale) { + /* ensure init. + * Was previously used for autoscale only, + * now used always (as "target scale") */ + clip->tracking.stabilization.scale = 1.0f; + } } } } -- cgit v1.2.3 From cd5116e914fa6198e65eeb325dd74d817f0e580e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 16 Aug 2016 14:24:06 +0200 Subject: 2D stabilizer: Fix compilation error in debug mode --- source/blender/blenkernel/intern/tracking_stabilize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/tracking_stabilize.c b/source/blender/blenkernel/intern/tracking_stabilize.c index 5642ee83fde..1d571099723 100644 --- a/source/blender/blenkernel/intern/tracking_stabilize.c +++ b/source/blender/blenkernel/intern/tracking_stabilize.c @@ -360,7 +360,7 @@ static void retrieve_next_lower_usable_frame(StabContext *ctx, int *next_lower) { MovieTrackingMarker *markers = track->markers; - BLI_assert(0 <= i && i < end); + BLI_assert(0 <= i && i < track->markersnr); while (i >= 0 && (markers[i].framenr > ref_frame || is_effectively_disabled(ctx, track, &markers[i]))) -- cgit v1.2.3 From b7d656c3b24cee4400d8bd4d5e5184e7657227ef Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 16 Aug 2016 14:25:55 +0200 Subject: 2D stabilizer: Revert majority of UI change For now simply reshuffle option so they keep proper dependency flow. Benefits: - Has an ability to hide tracks lists to work with other sliders around. Could be really handy to quickly get rid of lenghty lists. - From a feedback seems to be fitting workflow better. Things to doublecheck on: - Feels a bit misordered: first you define whether one want to have rotation stabilized, then have tracks, then scale options. While this follows dependency flow (which is really good and which we should not violate) it has weird feeling on whether things are really where they have to be. - Autoscale controls visibility of max-scale, can we just make it active/inactive instead? - Autoscale replaces slider with label. Can it be disabled slider instead to reduce visual jumping (disabled slider prevents user input) Hopefully we'll still want to have collapsable box after re-iterating over this points, so we don't waste bits in DNA. --- release/scripts/startup/bl_ui/space_clip.py | 90 +++++++++++++---------- source/blender/blenkernel/intern/tracking.c | 1 + source/blender/blenloader/intern/versioning_270.c | 3 + source/blender/makesdna/DNA_tracking_types.h | 1 + source/blender/makesrna/intern/rna_tracking.c | 7 ++ 5 files changed, 65 insertions(+), 37 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index b2263618719..a9db1266bc6 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -916,58 +916,74 @@ class CLIP_PT_stabilization(CLIP_PT_reconstruction_panel, Panel): layout.prop(stab, "anchor_frame") - col = layout.column() - col.label(text="Location") - row = col.row() - row.template_list("UI_UL_list", "stabilization_tracks", stab, "tracks", - stab, "active_track_index", rows=2) + layout.prop(stab, "use_stabilize_rotation") - sub = row.column(align=True) + box = layout.box() + row = box.row(align=True) + row.prop(stab, "show_tracks_expanded", text="", emboss=False) - sub.operator("clip.stabilize_2d_add", icon='ZOOMIN', text="") - sub.operator("clip.stabilize_2d_remove", icon='ZOOMOUT', text="") + if not stab.show_tracks_expanded: + row.label(text="Tracks For Stabilization") + else: + row.label(text="Tracks For Location") + row = box.row() + row.template_list("UI_UL_list", "stabilization_tracks", stab, "tracks", + stab, "active_track_index", rows=2) - sub.menu('CLIP_MT_stabilize_2d_specials', text="", - icon='DOWNARROW_HLT') + sub = row.column(align=True) - col.label(text="Expected Position") - row = col.row() - row.prop(stab, "target_pos", text="") - col.prop(stab, "influence_location") + sub.operator("clip.stabilize_2d_add", icon='ZOOMIN', text="") + sub.operator("clip.stabilize_2d_remove", icon='ZOOMOUT', text="") - layout.separator() - layout.prop(stab, "use_stabilize_rotation") - col = layout.column() - col.active = stab.use_stabilize_rotation - row = col.row() - row.template_list("UI_UL_list", "stabilization_rotation_tracks", stab, "rotation_tracks", - stab, "active_rotation_track_index", rows=2) + sub.menu('CLIP_MT_stabilize_2d_specials', text="", + icon='DOWNARROW_HLT') - sub = row.column(align=True) + row = box.row() + row.label(text="Tracks For Rotation / Scale") + row = box.row() + row.active = stab.use_stabilize_rotation + row.template_list("UI_UL_list", "stabilization_rotation_tracks", stab, "rotation_tracks", + stab, "active_rotation_track_index", rows=2) - sub.operator("clip.stabilize_2d_rotation_add", icon='ZOOMIN', text="") - sub.operator("clip.stabilize_2d_rotation_remove", icon='ZOOMOUT', text="") + sub = row.column(align=True) - sub.menu('CLIP_MT_stabilize_2d_rotation_specials', text="", - icon='DOWNARROW_HLT') + sub.operator("clip.stabilize_2d_rotation_add", icon='ZOOMIN', text="") + sub.operator("clip.stabilize_2d_rotation_remove", icon='ZOOMOUT', text="") - col.prop(stab, "target_rot") - col.prop(stab, "influence_rotation") + sub.menu('CLIP_MT_stabilize_2d_rotation_specials', text="", + icon='DOWNARROW_HLT') - layout.separator() - col = layout.column() - col.active = stab.use_stabilize_rotation - col.prop(stab, "use_stabilize_scale") - col.prop(stab, "use_autoscale") + row = layout.row() + row.active = stab.use_stabilize_rotation + row.prop(stab, "use_stabilize_scale") if stab.use_autoscale: - col.prop(stab, "scale_max", text="Max") - col.label(text="Auto Scale Factor: %5.3f" % (1.0 / stab.target_zoom)) + row = layout.row(align=True) + row.prop(stab, "use_autoscale") + row.prop(stab, "scale_max", text="Max") else: - col.prop(stab, "target_zoom") + layout.prop(stab, "use_autoscale") - col.prop(stab, "influence_scale") + layout.separator() + layout.label(text="Expected Position") + layout.prop(stab, "target_pos", text="") + layout.prop(stab, "target_rot") + if stab.use_autoscale: + layout.label(text="Auto Scale Factor: %5.3f" % (1.0 / stab.target_zoom)) + else: + layout.prop(stab, "target_zoom") layout.separator() + row = layout.row() + row.active = 0 < len(stab.tracks.values()) + row.prop(stab, "influence_location") + + col = layout.column() + col.active = stab.use_stabilize_rotation and 0 < len(stab.rotation_tracks.values()) + row = col.row() + row.prop(stab, "influence_rotation") + row = col.row() + row.prop(stab, "influence_scale") + layout.prop(stab, "filter_type") diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index e50218c2a19..d5d3384bb48 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -345,6 +345,7 @@ void BKE_tracking_settings_init(MovieTracking *tracking) tracking->stabilization.rotinf = 1.0f; tracking->stabilization.maxscale = 2.0f; tracking->stabilization.filter = TRACKING_FILTER_BILINEAR; + tracking->stabilization.flag |= TRACKING_SHOW_STAB_TRACKS; BKE_tracking_object_add(tracking, "Camera"); } diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 18b60883977..d735f099dc0 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -91,6 +91,9 @@ static void migrate_single_rot_stabilization_track_settings(MovieTrackingStabili } } stab->rot_track = NULL; /* this field is now ignored */ + + /* by default show the track lists expanded, to improve "discoverability" */ + stab->flag |= TRACKING_SHOW_STAB_TRACKS; } static void do_version_constraints_radians_degrees_270_1(ListBase *lb) diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h index 8c22fa09477..42b72c1ff93 100644 --- a/source/blender/makesdna/DNA_tracking_types.h +++ b/source/blender/makesdna/DNA_tracking_types.h @@ -463,6 +463,7 @@ enum { TRACKING_AUTOSCALE = (1 << 1), TRACKING_STABILIZE_ROTATION = (1 << 2), TRACKING_STABILIZE_SCALE = (1 << 3), + TRACKING_SHOW_STAB_TRACKS = (1 << 5) }; /* MovieTrackingStrabilization->filter */ diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 2787ec4ca21..0591c65d484 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -1815,6 +1815,13 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) RNA_def_property_enum_items(prop, filter_items); RNA_def_property_ui_text(prop, "Interpolate", "Interpolation to use for sub-pixel shifts and rotations due to stabilization"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate"); + + /* UI display : show participating tracks */ + prop = RNA_def_property(srna, "show_tracks_expanded", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_SHOW_STAB_TRACKS); + RNA_def_property_ui_text(prop, "Show Tracks", "Show UI list of tracks participating in stabilization"); + RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); } static void rna_def_reconstructedCamera(BlenderRNA *brna) -- cgit v1.2.3 From a74dab86ee3bad8cefff8d0fa3b7ab54c8e2158f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 16 Aug 2016 14:40:23 +0200 Subject: Fix redundant declarations after recent changes in GPU debug --- source/blender/blenlib/BLI_system.h | 5 ----- source/blender/blenlib/intern/system.c | 1 + source/blender/gpu/GPU_debug.h | 2 -- source/blender/gpu/intern/gpu_debug.c | 1 + 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/source/blender/blenlib/BLI_system.h b/source/blender/blenlib/BLI_system.h index 92403eb7dea..938a12dcdcf 100644 --- a/source/blender/blenlib/BLI_system.h +++ b/source/blender/blenlib/BLI_system.h @@ -27,11 +27,6 @@ int BLI_cpu_support_sse2(void); -#if defined(NDEBUG) || !defined(__BLI_UTILDEFINES_H__) -#include -void BLI_system_backtrace(FILE *fp); -#endif - /* getpid */ #ifdef WIN32 # define BLI_SYSTEM_PID_H diff --git a/source/blender/blenlib/intern/system.c b/source/blender/blenlib/intern/system.c index 5d1bdd6d978..898075e651e 100644 --- a/source/blender/blenlib/intern/system.c +++ b/source/blender/blenlib/intern/system.c @@ -25,6 +25,7 @@ #include #include +#include "BLI_utildefines.h" #include "BLI_system.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/gpu/GPU_debug.h b/source/blender/gpu/GPU_debug.h index ec0db43c38c..61b2bc591ce 100644 --- a/source/blender/gpu/GPU_debug.h +++ b/source/blender/gpu/GPU_debug.h @@ -34,8 +34,6 @@ #include "GPU_glew.h" -#include "BLI_utildefines.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/source/blender/gpu/intern/gpu_debug.c b/source/blender/gpu/intern/gpu_debug.c index 5ed51247858..d632e767ca9 100644 --- a/source/blender/gpu/intern/gpu_debug.c +++ b/source/blender/gpu/intern/gpu_debug.c @@ -29,6 +29,7 @@ * \ingroup gpu */ +#include "BLI_utildefines.h" #include "BLI_sys_types.h" #include "BLI_system.h" -- cgit v1.2.3 From 9368bdab016badba7c7eb4ba449acd8d0c165367 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Fri, 12 Aug 2016 18:23:29 +0300 Subject: Fix depsgraph to compute more accurate links for collision & force. Current implementation more or less indiscriminately links physics objects to colliders and forces, ignoring precise details of layer checks and collider groups. The new depsgraph seemed to lack some such links at all. The relevant code in modifiers suffers from a lot of duplication. Different physics simulations use independent implementations of collision and similar things, which results in a lot of variance: * Cloth collides with objects on same or visible layer with dupli. * Softbody collides with objects on same layer without dupli. * Non-hair particles collide on same layer with dupli. * Smoke uses same code as cloth, but needs different modifier. * Dynamic paint "collides" with brushes on any layer without dupli. Force fields with absorption also imply dependency on colliders: * For most systems, colliders are selected from same layer as field. * For non-hair particles, it uses the same exact set as the particles. As a special quirk, smoke ignores smoke flow force fields; on the other hand dependency on such field implies dependency on the smoke domain. This introduces two utility functions each for old and new depsgraph that are flexible enough to handle all these variations, and uses them to handle particles, cloth, smoke, softbody and dynpaint. One thing to watch out for is that depsgraph code shouldn't rely on any properties that don't cause a graph rebuild when changed. This was violated in the original code that was building force field links, while taking zero field weights into account. This change may cause new dependency cycles in cases where necessary dependencies were missing, but may also remove cycles in situations where unnecessary links were previously created. It's also now possible to solve some cycles by switching to explicit groups, since they are now properly taken into account for dependencies. Differential Revision: https://developer.blender.org/D2141 --- source/blender/blenkernel/BKE_collision.h | 4 + source/blender/blenkernel/BKE_effect.h | 2 +- source/blender/blenkernel/depsgraph_private.h | 10 + source/blender/blenkernel/intern/collision.c | 18 +- source/blender/blenkernel/intern/depsgraph.c | 101 +++++----- source/blender/blenkernel/intern/effect.c | 31 +-- source/blender/depsgraph/DEG_depsgraph_build.h | 8 + .../intern/builder/deg_builder_relations.cc | 82 ++++++-- .../intern/builder/deg_builder_relations.h | 5 + source/blender/depsgraph/intern/depsgraph_build.cc | 53 ++++++ source/blender/makesrna/intern/rna_cloth.c | 8 +- source/blender/makesrna/intern/rna_object_force.c | 9 +- source/blender/makesrna/intern/rna_particle.c | 8 +- source/blender/modifiers/intern/MOD_cloth.c | 30 +-- source/blender/modifiers/intern/MOD_dynamicpaint.c | 32 ++-- source/blender/modifiers/intern/MOD_smoke.c | 207 ++------------------- source/blender/modifiers/intern/MOD_softbody.c | 33 +++- 17 files changed, 320 insertions(+), 321 deletions(-) diff --git a/source/blender/blenkernel/BKE_collision.h b/source/blender/blenkernel/BKE_collision.h index d5b4a584ec6..8fedcd4ab06 100644 --- a/source/blender/blenkernel/BKE_collision.h +++ b/source/blender/blenkernel/BKE_collision.h @@ -146,6 +146,10 @@ void collision_get_collider_velocity(float vel_old[3], float vel_new[3], struct ///////////////////////////////////////////////// // used in effect.c ///////////////////////////////////////////////// + +/* explicit control over layer mask and dupli recursion */ +struct Object **get_collisionobjects_ext(struct Scene *scene, struct Object *self, struct Group *group, int layer, unsigned int *numcollobj, unsigned int modifier_type, bool dupli); + struct Object **get_collisionobjects(struct Scene *scene, struct Object *self, struct Group *group, unsigned int *numcollobj, unsigned int modifier_type); typedef struct ColliderCache { diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h index f8fee444d91..b934ec7166d 100644 --- a/source/blender/blenkernel/BKE_effect.h +++ b/source/blender/blenkernel/BKE_effect.h @@ -110,7 +110,7 @@ typedef struct EffectorCache { } EffectorCache; void free_partdeflect(struct PartDeflect *pd); -struct ListBase *pdInitEffectors(struct Scene *scene, struct Object *ob_src, struct ParticleSystem *psys_src, struct EffectorWeights *weights, bool precalc); +struct ListBase *pdInitEffectors(struct Scene *scene, struct Object *ob_src, struct ParticleSystem *psys_src, struct EffectorWeights *weights, bool for_simulation); void pdEndEffectors(struct ListBase **effectors); void pdPrecalculateEffectors(struct ListBase *effectors); void pdDoEffectors(struct ListBase *effectors, struct ListBase *colliders, struct EffectorWeights *weights, struct EffectedPoint *point, float *force, float *impulse); diff --git a/source/blender/blenkernel/depsgraph_private.h b/source/blender/blenkernel/depsgraph_private.h index 7b3199efb41..69ca75836d9 100644 --- a/source/blender/blenkernel/depsgraph_private.h +++ b/source/blender/blenkernel/depsgraph_private.h @@ -34,6 +34,11 @@ #include "DNA_constraint_types.h" #include "BKE_constraint.h" +struct Scene; +struct Group; +struct EffectorWeights; +struct ModifierData; + /* **** DAG relation types *** */ /* scene link to object */ @@ -152,6 +157,11 @@ DagNode *dag_get_node(DagForest *forest, void *fob); DagNode *dag_get_sub_node(DagForest *forest, void *fob); void dag_add_relation(DagForest *forest, DagNode *fob1, DagNode *fob2, short rel, const char *name); +typedef bool (*DagCollobjFilterFunction)(struct Object *obj, struct ModifierData *md); + +void dag_add_collision_relations(DagForest *dag, struct Scene *scene, Object *ob, DagNode *node, struct Group *group, int layer, unsigned int modifier_type, DagCollobjFilterFunction fn, bool dupli, const char *name); +void dag_add_forcefield_relations(DagForest *dag, struct Scene *scene, Object *ob, DagNode *node, struct EffectorWeights *eff, bool add_absorption, int skip_forcefield, const char *name); + void graph_print_queue(DagNodeQueue *nqueue); void graph_print_queue_dist(DagNodeQueue *nqueue); void graph_print_adj_list(DagForest *dag); diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 8cac856b560..35a7aafdbde 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -503,12 +503,13 @@ static void add_collision_object(Object ***objs, unsigned int *numobj, unsigned // return all collision objects in scene // collision object will exclude self -Object **get_collisionobjects(Scene *scene, Object *self, Group *group, unsigned int *numcollobj, unsigned int modifier_type) +Object **get_collisionobjects_ext(Scene *scene, Object *self, Group *group, int layer, unsigned int *numcollobj, unsigned int modifier_type, bool dupli) { Base *base; Object **objs; GroupObject *go; unsigned int numobj= 0, maxobj= 100; + int level = dupli ? 0 : 1; objs= MEM_callocN(sizeof(Object *)*maxobj, "CollisionObjectsArray"); @@ -516,16 +517,14 @@ Object **get_collisionobjects(Scene *scene, Object *self, Group *group, unsigned if (group) { /* use specified group */ for (go= group->gobject.first; go; go= go->next) - add_collision_object(&objs, &numobj, &maxobj, go->ob, self, 0, modifier_type); + add_collision_object(&objs, &numobj, &maxobj, go->ob, self, level, modifier_type); } else { Scene *sce_iter; /* add objects in same layer in scene */ for (SETLOOPER(scene, sce_iter, base)) { - /* Need to check for active layers, too. - Otherwise this check fails if the objects are not on the same layer - DG */ - if ((base->lay & self->lay) || (base->lay & scene->lay)) - add_collision_object(&objs, &numobj, &maxobj, base->object, self, 0, modifier_type); + if ( base->lay & layer ) + add_collision_object(&objs, &numobj, &maxobj, base->object, self, level, modifier_type); } } @@ -535,6 +534,13 @@ Object **get_collisionobjects(Scene *scene, Object *self, Group *group, unsigned return objs; } +Object **get_collisionobjects(Scene *scene, Object *self, Group *group, unsigned int *numcollobj, unsigned int modifier_type) +{ + /* Need to check for active layers, too. + Otherwise this check fails if the objects are not on the same layer - DG */ + return get_collisionobjects_ext(scene, self, group, self->lay | scene->lay, numcollobj, modifier_type, true); +} + static void add_collider_cache_object(ListBase **objs, Object *ob, Object *self, int level) { CollisionModifierData *cmd= NULL; diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 45a23c39910..5f8332dcf0c 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -59,11 +59,14 @@ #include "DNA_windowmanager_types.h" #include "DNA_movieclip_types.h" #include "DNA_mask_types.h" +#include "DNA_modifier_types.h" +#include "DNA_rigidbody_types.h" #include "BKE_anim.h" #include "BKE_animsys.h" #include "BKE_action.h" #include "BKE_DerivedMesh.h" +#include "BKE_collision.h" #include "BKE_effect.h" #include "BKE_fcurve.h" #include "BKE_global.h" @@ -450,49 +453,51 @@ static void dag_add_lamp_driver_relations(DagForest *dag, DagNode *node, Lamp *l la->id.tag &= ~LIB_TAG_DOIT; } -static void check_and_create_collision_relation(DagForest *dag, Object *ob, DagNode *node, Object *ob1, int skip_forcefield, bool no_collision) +static void create_collision_relation(DagForest *dag, DagNode *node, Object *ob1, const char *name) { - DagNode *node2; - if (ob1->pd && (ob1->pd->deflect || ob1->pd->forcefield) && (ob1 != ob)) { - if ((skip_forcefield && ob1->pd->forcefield == skip_forcefield) || (no_collision && ob1->pd->forcefield == 0)) - return; - node2 = dag_get_node(dag, ob1); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Field Collision"); + DagNode *node2 = dag_get_node(dag, ob1); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, name); +} + +void dag_add_collision_relations(DagForest *dag, Scene *scene, Object *ob, DagNode *node, Group *group, int layer, unsigned int modifier_type, DagCollobjFilterFunction fn, bool dupli, const char *name) +{ + unsigned int numcollobj; + Object **collobjs = get_collisionobjects_ext(scene, ob, group, layer, &numcollobj, modifier_type, dupli); + + for (unsigned int i = 0; i < numcollobj; i++) { + Object *ob1 = collobjs[i]; + + if (!fn || fn(ob1, modifiers_findByType(ob1, modifier_type))) { + create_collision_relation(dag, node, ob1, name); + } } + + if (collobjs) + MEM_freeN(collobjs); } -static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Object *ob, DagNode *node, int skip_forcefield, bool no_collision) +void dag_add_forcefield_relations(DagForest *dag, Scene *scene, Object *ob, DagNode *node, EffectorWeights *effector_weights, bool add_absorption, int skip_forcefield, const char *name) { - Base *base; - ParticleSystem *particle_system; + ListBase *effectors = pdInitEffectors(scene, ob, NULL, effector_weights, false); - for (particle_system = ob->particlesystem.first; - particle_system; - particle_system = particle_system->next) - { - EffectorWeights *effector_weights = particle_system->part->effector_weights; - if (effector_weights->group) { - GroupObject *group_object; + if (effectors) { + for (EffectorCache *eff = effectors->first; eff; eff = eff->next) { + if (eff->ob != ob && eff->pd->forcefield != skip_forcefield) { + create_collision_relation(dag, node, eff->ob, name); - for (group_object = effector_weights->group->gobject.first; - group_object; - group_object = group_object->next) - { - if ((group_object->ob->lay & ob->lay)) { - check_and_create_collision_relation(dag, ob, node, group_object->ob, skip_forcefield, no_collision); + if (eff->pd->forcefield == PFIELD_SMOKEFLOW && eff->pd->f_source) { + create_collision_relation(dag, node, eff->pd->f_source, "Smoke Force Domain"); + } + + if (add_absorption && (eff->pd->flag & PFIELD_VISIBILITY)) { + /* Actual code uses get_collider_cache */ + dag_add_collision_relations(dag, scene, ob, node, NULL, eff->ob->lay, eModifierType_Collision, NULL, true, "Force Absorption"); } } } } - /* would be nice to have a list of colliders here - * so for now walk all objects in scene check 'same layer rule' */ - for (base = scene->base.first; base; base = base->next) { - if ((base->lay & ob->lay)) { - Object *ob1 = base->object; - check_and_create_collision_relation(dag, ob, node, ob1, skip_forcefield, no_collision); - } - } + pdEndEffectors(&effectors); } static void build_dag_object(DagForest *dag, DagNode *scenenode, Main *bmain, Scene *scene, Object *ob, int mask) @@ -643,23 +648,13 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Main *bmain, Sc } } - /* softbody collision */ + /* rigidbody force fields */ if ((ob->type == OB_MESH) || (ob->type == OB_CURVE) || (ob->type == OB_LATTICE)) { - if (ob->particlesystem.first || - modifiers_isModifierEnabled(ob, eModifierType_Softbody) || - modifiers_isModifierEnabled(ob, eModifierType_Cloth) || - modifiers_isModifierEnabled(ob, eModifierType_DynamicPaint)) - { - dag_add_collision_field_relation(dag, scene, ob, node, 0, false); /* TODO: use effectorweight->group */ - } - else if (modifiers_isModifierEnabled(ob, eModifierType_Smoke)) { - dag_add_collision_field_relation(dag, scene, ob, node, PFIELD_SMOKEFLOW, false); - } - else if (ob->rigidbody_object) { - dag_add_collision_field_relation(dag, scene, ob, node, 0, true); + if (ob->rigidbody_object && scene->rigidbody_world) { + dag_add_forcefield_relations(dag, scene, ob, node, scene->rigidbody_world->effector_weights, true, 0, "Force Field"); } } - + /* object data drivers */ if (ob->data) { AnimData *adt = BKE_animdata_from_id((ID *)ob->data); @@ -763,8 +758,6 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Main *bmain, Sc BoidRule *rule = NULL; BoidState *state = NULL; ParticleSettings *part = psys->part; - ListBase *effectors = NULL; - EffectorCache *eff; if (part->adt) { dag_add_driver_relation(part->adt, dag, node, 1); @@ -803,18 +796,12 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Main *bmain, Sc } } - effectors = pdInitEffectors(scene, ob, psys, part->effector_weights, false); - - if (effectors) { - for (eff = effectors->first; eff; eff = eff->next) { - if (eff->psys) { - node2 = dag_get_node(dag, eff->ob); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Particle Field"); - } - } + if (part->type != PART_HAIR) { + /* Actual code uses get_collider_cache */ + dag_add_collision_relations(dag, scene, ob, node, part->collision_group, ob->lay, eModifierType_Collision, NULL, true, "Particle Collision"); } - pdEndEffectors(&effectors); + dag_add_forcefield_relations(dag, scene, ob, node, part->effector_weights, part->type == PART_HAIR, 0, "Particle Force Field"); if (part->boids) { for (state = part->boids->states.first; state; state = state->next) { diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 5090e46f1fc..7e6897a2858 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -155,15 +155,20 @@ static EffectorCache *new_effector_cache(Scene *scene, Object *ob, ParticleSyste eff->frame = -1; return eff; } -static void add_object_to_effectors(ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, Object *ob_src) +static void add_object_to_effectors(ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, Object *ob_src, bool for_simulation) { EffectorCache *eff = NULL; - if ( ob == ob_src || weights->weight[ob->pd->forcefield] == 0.0f ) + if ( ob == ob_src ) return; - if (ob->pd->shape == PFIELD_SHAPE_POINTS && !ob->derivedFinal ) - return; + if (for_simulation) { + if (weights->weight[ob->pd->forcefield] == 0.0f ) + return; + + if (ob->pd->shape == PFIELD_SHAPE_POINTS && !ob->derivedFinal ) + return; + } if (*effectors == NULL) *effectors = MEM_callocN(sizeof(ListBase), "effectors list"); @@ -175,7 +180,7 @@ static void add_object_to_effectors(ListBase **effectors, Scene *scene, Effector BLI_addtail(*effectors, eff); } -static void add_particles_to_effectors(ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src) +static void add_particles_to_effectors(ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src, bool for_simulation) { ParticleSettings *part= psys->part; @@ -185,14 +190,14 @@ static void add_particles_to_effectors(ListBase **effectors, Scene *scene, Effec if ( psys == psys_src && (part->flag & PART_SELF_EFFECT) == 0) return; - if ( part->pd && part->pd->forcefield && weights->weight[part->pd->forcefield] != 0.0f) { + if ( part->pd && part->pd->forcefield && (!for_simulation || weights->weight[part->pd->forcefield] != 0.0f)) { if (*effectors == NULL) *effectors = MEM_callocN(sizeof(ListBase), "effectors list"); BLI_addtail(*effectors, new_effector_cache(scene, ob, psys, part->pd)); } - if (part->pd2 && part->pd2->forcefield && weights->weight[part->pd2->forcefield] != 0.0f) { + if (part->pd2 && part->pd2->forcefield && (!for_simulation || weights->weight[part->pd2->forcefield] != 0.0f)) { if (*effectors == NULL) *effectors = MEM_callocN(sizeof(ListBase), "effectors list"); @@ -202,7 +207,7 @@ static void add_particles_to_effectors(ListBase **effectors, Scene *scene, Effec /* returns ListBase handle with objects taking part in the effecting */ ListBase *pdInitEffectors(Scene *scene, Object *ob_src, ParticleSystem *psys_src, - EffectorWeights *weights, bool precalc) + EffectorWeights *weights, bool for_simulation) { Base *base; unsigned int layer= ob_src->lay; @@ -214,13 +219,13 @@ ListBase *pdInitEffectors(Scene *scene, Object *ob_src, ParticleSystem *psys_src for (go= weights->group->gobject.first; go; go= go->next) { if ( (go->ob->lay & layer) ) { if ( go->ob->pd && go->ob->pd->forcefield ) - add_object_to_effectors(&effectors, scene, weights, go->ob, ob_src); + add_object_to_effectors(&effectors, scene, weights, go->ob, ob_src, for_simulation); if ( go->ob->particlesystem.first ) { ParticleSystem *psys= go->ob->particlesystem.first; for ( ; psys; psys=psys->next ) - add_particles_to_effectors(&effectors, scene, weights, go->ob, psys, psys_src); + add_particles_to_effectors(&effectors, scene, weights, go->ob, psys, psys_src, for_simulation); } } } @@ -229,19 +234,19 @@ ListBase *pdInitEffectors(Scene *scene, Object *ob_src, ParticleSystem *psys_src for (base = scene->base.first; base; base= base->next) { if ( (base->lay & layer) ) { if ( base->object->pd && base->object->pd->forcefield ) - add_object_to_effectors(&effectors, scene, weights, base->object, ob_src); + add_object_to_effectors(&effectors, scene, weights, base->object, ob_src, for_simulation); if ( base->object->particlesystem.first ) { ParticleSystem *psys= base->object->particlesystem.first; for ( ; psys; psys=psys->next ) - add_particles_to_effectors(&effectors, scene, weights, base->object, psys, psys_src); + add_particles_to_effectors(&effectors, scene, weights, base->object, psys, psys_src, for_simulation); } } } } - if (precalc) + if (for_simulation) pdPrecalculateEffectors(effectors); return effectors; diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h index 0209e94debe..0945da439ef 100644 --- a/source/blender/depsgraph/DEG_depsgraph_build.h +++ b/source/blender/depsgraph/DEG_depsgraph_build.h @@ -42,6 +42,8 @@ struct Depsgraph; struct Main; struct Scene; +struct Group; +struct EffectorWeights; #ifdef __cplusplus extern "C" { @@ -112,6 +114,12 @@ void DEG_add_object_cache_relation(struct DepsNodeHandle *handle, struct CacheFi /* TODO(sergey): Remove once all geometry update is granular. */ void DEG_add_special_eval_flag(struct Depsgraph *graph, struct ID *id, short flag); +/* Utility functions for physics modifiers */ +typedef bool (*DEG_CollobjFilterFunction)(struct Object *obj, struct ModifierData *md); + +void DEG_add_collision_relations(struct DepsNodeHandle *handle, struct Scene *scene, Object *ob, struct Group *group, int layer, unsigned int modifier_type, DEG_CollobjFilterFunction fn, bool dupli, const char *name); +void DEG_add_forcefield_relations(struct DepsNodeHandle *handle, struct Scene *scene, Object *ob, struct EffectorWeights *eff, bool add_absorption, int skip_forcefield, const char *name); + /* ************************************************ */ #ifdef __cplusplus diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 9ab28331249..2148a3501d8 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -65,6 +65,7 @@ extern "C" { #include "DNA_scene_types.h" #include "DNA_texture_types.h" #include "DNA_world_types.h" +#include "DNA_object_force.h" #include "BKE_action.h" #include "BKE_armature.h" @@ -72,6 +73,7 @@ extern "C" { #include "BKE_constraint.h" #include "BKE_curve.h" #include "BKE_effect.h" +#include "BKE_collision.h" #include "BKE_fcurve.h" #include "BKE_group.h" #include "BKE_key.h" @@ -243,6 +245,69 @@ void DepsgraphRelationBuilder::add_operation_relation( } } +void DepsgraphRelationBuilder::add_collision_relations(const OperationKey &key, Scene *scene, Object *ob, Group *group, int layer, bool dupli, const char *name) +{ + unsigned int numcollobj; + Object **collobjs = get_collisionobjects_ext(scene, ob, group, layer, &numcollobj, eModifierType_Collision, dupli); + + for (unsigned int i = 0; i < numcollobj; i++) + { + Object *ob1 = collobjs[i]; + + ComponentKey trf_key(&ob1->id, DEPSNODE_TYPE_TRANSFORM); + add_relation(trf_key, key, DEPSREL_TYPE_STANDARD, name); + + ComponentKey coll_key(&ob1->id, DEPSNODE_TYPE_GEOMETRY); + add_relation(coll_key, key, DEPSREL_TYPE_STANDARD, name); + } + + if (collobjs) + MEM_freeN(collobjs); +} + +void DepsgraphRelationBuilder::add_forcefield_relations(const OperationKey &key, Scene *scene, Object *ob, ParticleSystem *psys, EffectorWeights *eff, bool add_absorption, const char *name) +{ + ListBase *effectors = pdInitEffectors(scene, ob, psys, eff, false); + + if (effectors) { + for (EffectorCache *eff = (EffectorCache *)effectors->first; eff; eff = eff->next) { + if (eff->ob != ob) { + ComponentKey eff_key(&eff->ob->id, DEPSNODE_TYPE_TRANSFORM); + add_relation(eff_key, key, DEPSREL_TYPE_STANDARD, name); + } + + if (eff->psys) { + if (eff->ob != ob) { + ComponentKey eff_key(&eff->ob->id, DEPSNODE_TYPE_EVAL_PARTICLES); + add_relation(eff_key, key, DEPSREL_TYPE_STANDARD, name); + + /* TODO: remove this when/if EVAL_PARTICLES is sufficient for up to date particles */ + ComponentKey mod_key(&eff->ob->id, DEPSNODE_TYPE_GEOMETRY); + add_relation(mod_key, key, DEPSREL_TYPE_STANDARD, name); + } + else if (eff->psys != psys) { + OperationKey eff_key(&eff->ob->id, DEPSNODE_TYPE_EVAL_PARTICLES, DEG_OPCODE_PSYS_EVAL, eff->psys->name); + add_relation(eff_key, key, DEPSREL_TYPE_STANDARD, name); + } + } + + if (eff->pd->forcefield == PFIELD_SMOKEFLOW && eff->pd->f_source) { + ComponentKey trf_key(&eff->pd->f_source->id, DEPSNODE_TYPE_TRANSFORM); + add_relation(trf_key, key, DEPSREL_TYPE_STANDARD, "Smoke Force Domain"); + + ComponentKey eff_key(&eff->pd->f_source->id, DEPSNODE_TYPE_GEOMETRY); + add_relation(eff_key, key, DEPSREL_TYPE_STANDARD, "Smoke Force Domain"); + } + + if (add_absorption && (eff->pd->flag & PFIELD_VISIBILITY)) { + add_collision_relations(key, scene, ob, NULL, eff->ob->lay, true, "Force Absorption"); + } + } + } + + pdEndEffectors(&effectors); +} + /* **** Functions to build relations between entities **** */ void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene) @@ -1137,20 +1202,13 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob) } #endif - /* effectors */ - ListBase *effectors = pdInitEffectors(scene, ob, psys, part->effector_weights, false); - - if (effectors) { - for (EffectorCache *eff = (EffectorCache *)effectors->first; eff; eff = eff->next) { - if (eff->psys) { - // XXX: DAG_RL_DATA_DATA | DAG_RL_OB_DATA - ComponentKey eff_key(&eff->ob->id, DEPSNODE_TYPE_GEOMETRY); // xxx: particles instead? - add_relation(eff_key, psys_key, DEPSREL_TYPE_STANDARD, "Particle Field"); - } - } + /* collisions */ + if (part->type != PART_HAIR) { + add_collision_relations(psys_key, scene, ob, part->collision_group, ob->lay, true, "Particle Collision"); } - pdEndEffectors(&effectors); + /* effectors */ + add_forcefield_relations(psys_key, scene, ob, psys, part->effector_weights, part->type == PART_HAIR, "Particle Field"); /* boids */ if (part->boids) { diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h index ce6d2c961fd..46e65d464a4 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h @@ -63,6 +63,8 @@ struct bConstraint; struct Scene; struct Tex; struct World; +struct EffectorWeights; +struct ParticleSystem; struct PropertyRNA; @@ -244,6 +246,9 @@ struct DepsgraphRelationBuilder void build_compositor(Scene *scene); void build_gpencil(ID *owner, bGPdata *gpd); + void add_collision_relations(const OperationKey &key, Scene *scene, Object *ob, Group *group, int layer, bool dupli, const char *name); + void add_forcefield_relations(const OperationKey &key, Scene *scene, Object *ob, ParticleSystem *psys, EffectorWeights *eff, bool add_absorption, const char *name); + template OperationDepsNode *find_operation_node(const KeyType &key); diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc index ae830da1252..7a3b19e82c6 100644 --- a/source/blender/depsgraph/intern/depsgraph_build.cc +++ b/source/blender/depsgraph/intern/depsgraph_build.cc @@ -36,11 +36,15 @@ extern "C" { #include "DNA_cachefile_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_object_force.h" #include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BKE_main.h" +#include "BKE_collision.h" +#include "BKE_effect.h" +#include "BKE_modifier.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_debug.h" @@ -304,3 +308,52 @@ void DEG_scene_graph_free(Scene *scene) scene->depsgraph = NULL; } } + +void DEG_add_collision_relations(DepsNodeHandle *handle, Scene *scene, Object *ob, Group *group, int layer, unsigned int modifier_type, DEG_CollobjFilterFunction fn, bool dupli, const char *name) +{ + unsigned int numcollobj; + Object **collobjs = get_collisionobjects_ext(scene, ob, group, layer, &numcollobj, modifier_type, dupli); + + for (unsigned int i = 0; i < numcollobj; i++) { + Object *ob1 = collobjs[i]; + + if (!fn || fn(ob1, modifiers_findByType(ob1, (ModifierType)modifier_type))) { + DEG_add_object_relation(handle, ob1, DEG_OB_COMP_TRANSFORM, name); + DEG_add_object_relation(handle, ob1, DEG_OB_COMP_GEOMETRY, name); + } + } + + if (collobjs) + MEM_freeN(collobjs); +} + +void DEG_add_forcefield_relations(DepsNodeHandle *handle, Scene *scene, Object *ob, EffectorWeights *effector_weights, bool add_absorption, int skip_forcefield, const char *name) +{ + ListBase *effectors = pdInitEffectors(scene, ob, NULL, effector_weights, false); + + if (effectors) { + for (EffectorCache *eff = (EffectorCache*)effectors->first; eff; eff = eff->next) { + if (eff->ob != ob && eff->pd->forcefield != skip_forcefield) { + DEG_add_object_relation(handle, eff->ob, DEG_OB_COMP_TRANSFORM, name); + + if (eff->psys) { + DEG_add_object_relation(handle, eff->ob, DEG_OB_COMP_EVAL_PARTICLES, name); + + /* TODO: remove this when/if EVAL_PARTICLES is sufficient for up to date particles */ + DEG_add_object_relation(handle, eff->ob, DEG_OB_COMP_GEOMETRY, name); + } + + if (eff->pd->forcefield == PFIELD_SMOKEFLOW && eff->pd->f_source) { + DEG_add_object_relation(handle, eff->pd->f_source, DEG_OB_COMP_TRANSFORM, "Smoke Force Domain"); + DEG_add_object_relation(handle, eff->pd->f_source, DEG_OB_COMP_GEOMETRY, "Smoke Force Domain"); + } + + if (add_absorption && (eff->pd->flag & PFIELD_VISIBILITY)) { + DEG_add_collision_relations(handle, scene, ob, NULL, eff->ob->lay, eModifierType_Collision, NULL, true, "Force Absorption"); + } + } + } + } + + pdEndEffectors(&effectors); +} diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c index 91cae32d054..d8bcbc2cc72 100644 --- a/source/blender/makesrna/intern/rna_cloth.c +++ b/source/blender/makesrna/intern/rna_cloth.c @@ -56,6 +56,12 @@ static void rna_cloth_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob); } +static void rna_cloth_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + DAG_relations_tag_update(bmain); + rna_cloth_update(bmain, scene, ptr); +} + static void rna_cloth_pinning_changed(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; @@ -729,7 +735,7 @@ static void rna_def_cloth_collision_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Collision Group", "Limit colliders to this Group"); - RNA_def_property_update(prop, 0, "rna_cloth_update"); + RNA_def_property_update(prop, 0, "rna_cloth_dependency_update"); prop = RNA_def_property(srna, "vertex_group_self_collisions", PROP_STRING, PROP_NONE); RNA_def_property_string_funcs(prop, "rna_CollSettings_selfcol_vgroup_get", "rna_CollSettings_selfcol_vgroup_length", diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index f05813043ca..1d89f7535c4 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -730,6 +730,11 @@ static void rna_softbody_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Point WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob); } +static void rna_softbody_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + DAG_relations_tag_update(bmain); + rna_softbody_update(bmain, scene, ptr); +} static EnumPropertyItem *rna_Effector_shape_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) @@ -1378,7 +1383,7 @@ static void rna_def_field(BlenderRNA *brna) prop = RNA_def_property(srna, "use_absorption", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_VISIBILITY); RNA_def_property_ui_text(prop, "Absorption", "Force gets absorbed by collision objects"); - RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_dependency_update"); prop = RNA_def_property(srna, "use_multiple_springs", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_MULTIPLE_SPRINGS); @@ -1855,7 +1860,7 @@ static void rna_def_softbody(BlenderRNA *brna) prop = RNA_def_property(srna, "collision_group", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Collision Group", "Limit colliders to this Group"); - RNA_def_property_update(prop, 0, "rna_softbody_update"); + RNA_def_property_update(prop, 0, "rna_softbody_dependency_update"); prop = RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "effector_weights"); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index eabf41cb332..5e3fa4b467d 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -630,6 +630,12 @@ static void rna_Particle_reset(Main *bmain, Scene *scene, PointerRNA *ptr) particle_recalc(bmain, scene, ptr, PSYS_RECALC_RESET); } +static void rna_Particle_reset_dependency(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + DAG_relations_tag_update(bmain); + rna_Particle_reset(bmain, scene, ptr); +} + static void rna_Particle_change_type(Main *bmain, Scene *scene, PointerRNA *ptr) { particle_recalc(bmain, scene, ptr, PSYS_RECALC_RESET | PSYS_RECALC_TYPE); @@ -2744,7 +2750,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "collision_group", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Collision Group", "Limit colliders to this Group"); - RNA_def_property_update(prop, 0, "rna_Particle_reset"); + RNA_def_property_update(prop, 0, "rna_Particle_reset_dependency"); /* global physical properties */ prop = RNA_def_property(srna, "drag_factor", PROP_FLOAT, PROP_NONE); diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index 6cc2f097be8..d15a6fcb1c8 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -123,19 +123,11 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, { ClothModifierData *clmd = (ClothModifierData *) md; - Base *base; - if (clmd) { - for (base = scene->base.first; base; base = base->next) { - Object *ob1 = base->object; - if (ob1 != ob) { - CollisionModifierData *coll_clmd = (CollisionModifierData *)modifiers_findByType(ob1, eModifierType_Collision); - if (coll_clmd) { - DagNode *curNode = dag_get_node(forest, ob1); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Cloth Collision"); - } - } - } + /* Actual code uses get_collisionobjects */ + dag_add_collision_relations(forest, scene, ob, obNode, clmd->coll_parms->group, ob->lay|scene->lay, eModifierType_Collision, NULL, true, "Cloth Collision"); + + dag_add_forcefield_relations(forest, scene, ob, obNode, clmd->sim_parms->effector_weights, true, 0, "Cloth Field"); } } @@ -147,16 +139,10 @@ static void updateDepsgraph(ModifierData *md, { ClothModifierData *clmd = (ClothModifierData *)md; if (clmd != NULL) { - Base *base; - for (base = scene->base.first; base; base = base->next) { - Object *ob1 = base->object; - if (ob1 != ob) { - CollisionModifierData *coll_clmd = (CollisionModifierData *)modifiers_findByType(ob1, eModifierType_Collision); - if (coll_clmd) { - DEG_add_object_relation(node, ob1, DEG_OB_COMP_TRANSFORM, "Cloth Modifier"); - } - } - } + /* Actual code uses get_collisionobjects */ + DEG_add_collision_relations(node, scene, ob, clmd->coll_parms->group, ob->lay|scene->lay, eModifierType_Collision, NULL, true, "Cloth Collision"); + + DEG_add_forcefield_relations(node, scene, ob, clmd->sim_parms->effector_weights, true, 0, "Cloth Field"); } } diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c index edf959f42c6..bde20e56748 100644 --- a/source/blender/modifiers/intern/MOD_dynamicpaint.c +++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c @@ -114,6 +114,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, return dm; } +static bool is_brush_cb(Object *UNUSED(ob), ModifierData *pmd) +{ + return ((DynamicPaintModifierData*)pmd)->brush != NULL; +} + static void updateDepgraph(ModifierData *md, DagForest *forest, struct Main *UNUSED(bmain), struct Scene *scene, @@ -124,16 +129,13 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, /* add relation from canvases to all brush objects */ if (pmd && pmd->canvas) { - Base *base = scene->base.first; - - for (; base; base = base->next) { - DynamicPaintModifierData *pmd2 = - (DynamicPaintModifierData *)modifiers_findByType(base->object, eModifierType_DynamicPaint); - - if (pmd2 && pmd2->brush && ob != base->object) { - DagNode *brushNode = dag_get_node(forest, base->object); - dag_add_relation(forest, brushNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Dynamic Paint Brush"); + for (DynamicPaintSurface *surface = pmd->canvas->surfaces.first; surface; surface = surface->next) { + if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) { + dag_add_forcefield_relations(forest, scene, ob, obNode, surface->effector_weights, true, 0, "Dynamic Paint Field"); } + + /* Actual code uses custom loop over group/scene without layer checks in dynamicPaint_doStep */ + dag_add_collision_relations(forest, scene, ob, obNode, surface->brush_group, -1, eModifierType_DynamicPaint, is_brush_cb, false, "Dynamic Paint Brush"); } } } @@ -147,13 +149,13 @@ static void updateDepsgraph(ModifierData *md, DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; /* Add relation from canvases to all brush objects. */ if (pmd->canvas != NULL) { - Base *base = scene->base.first; - for (; base; base = base->next) { - DynamicPaintModifierData *pmd2 = - (DynamicPaintModifierData *)modifiers_findByType(base->object, eModifierType_DynamicPaint); - if (pmd2 && pmd2->brush && ob != base->object) { - DEG_add_object_relation(node, base->object, DEG_OB_COMP_TRANSFORM, "Dynamic Paint Brush"); + for (DynamicPaintSurface *surface = pmd->canvas->surfaces.first; surface; surface = surface->next) { + if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) { + DEG_add_forcefield_relations(node, scene, ob, surface->effector_weights, true, 0, "Dynamic Paint Field"); } + + /* Actual code uses custom loop over group/scene without layer checks in dynamicPaint_doStep */ + DEG_add_collision_relations(node, scene, ob, surface->brush_group, -1, eModifierType_DynamicPaint, is_brush_cb, false, "Dynamic Paint Brush"); } } } diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c index 237d4cc6718..f04d7432a8f 100644 --- a/source/blender/modifiers/intern/MOD_smoke.c +++ b/source/blender/modifiers/intern/MOD_smoke.c @@ -117,219 +117,48 @@ static bool dependsOnTime(ModifierData *UNUSED(md)) return true; } -static void update_depsgraph_flow_coll_object(DagForest *forest, - DagNode *obNode, - Object *object2) +static bool is_flow_cb(Object *UNUSED(ob), ModifierData *md) { - SmokeModifierData *smd; - if ((object2->id.tag & LIB_TAG_DOIT) == 0) { - return; - } - object2->id.tag &= ~LIB_TAG_DOIT; - smd = (SmokeModifierData *)modifiers_findByType(object2, eModifierType_Smoke); - if (smd && (((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) || - ((smd->type & MOD_SMOKE_TYPE_COLL) && smd->coll))) - { - DagNode *curNode = dag_get_node(forest, object2); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Smoke Flow/Coll"); - } - if ((object2->transflag & OB_DUPLIGROUP) && object2->dup_group) { - GroupObject *go; - for (go = object2->dup_group->gobject.first; - go != NULL; - go = go->next) - { - if (go->ob == NULL) { - continue; - } - update_depsgraph_flow_coll_object(forest, obNode, go->ob); - } - } + SmokeModifierData *smd = (SmokeModifierData *) md; + return (smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow; } -static void update_depsgraph_field_source_object(DagForest *forest, - DagNode *obNode, - Object *object, - Object *object2) +static bool is_coll_cb(Object *UNUSED(ob), ModifierData *md) { - if ((object2->id.tag & LIB_TAG_DOIT) == 0) { - return; - } - object2->id.tag &= ~LIB_TAG_DOIT; - if (object2->pd && object2->pd->forcefield == PFIELD_SMOKEFLOW && object2->pd->f_source == object) { - DagNode *node2 = dag_get_node(forest, object2); - dag_add_relation(forest, obNode, node2, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Field Source Object"); - } - if ((object2->transflag & OB_DUPLIGROUP) && object2->dup_group) { - GroupObject *go; - for (go = object2->dup_group->gobject.first; - go != NULL; - go = go->next) - { - if (go->ob == NULL) { - continue; - } - update_depsgraph_field_source_object(forest, obNode, object, go->ob); - } - } + SmokeModifierData *smd = (SmokeModifierData *) md; + return (smd->type & MOD_SMOKE_TYPE_COLL) && smd->coll; } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Main *bmain, + struct Main *UNUSED(bmain), struct Scene *scene, struct Object *ob, DagNode *obNode) { SmokeModifierData *smd = (SmokeModifierData *) md; - Base *base; if (smd && (smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) { - if (smd->domain->fluid_group || smd->domain->coll_group) { - GroupObject *go = NULL; - - if (smd->domain->fluid_group) - for (go = smd->domain->fluid_group->gobject.first; go; go = go->next) { - if (go->ob) { - SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(go->ob, eModifierType_Smoke); - - /* check for initialized smoke object */ - if (smd2 && (smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) { - DagNode *curNode = dag_get_node(forest, go->ob); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Smoke Flow"); - } - } - } - - if (smd->domain->coll_group) - for (go = smd->domain->coll_group->gobject.first; go; go = go->next) { - if (go->ob) { - SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(go->ob, eModifierType_Smoke); - - /* check for initialized smoke object */ - if (smd2 && (smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll) { - DagNode *curNode = dag_get_node(forest, go->ob); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Smoke Coll"); - } - } - } - } - else { - BKE_main_id_tag_listbase(&bmain->object, LIB_TAG_DOIT, true); - base = scene->base.first; - for (; base; base = base->next) { - update_depsgraph_flow_coll_object(forest, obNode, base->object); - } - } - /* add relation to all "smoke flow" force fields */ - base = scene->base.first; - BKE_main_id_tag_listbase(&bmain->object, LIB_TAG_DOIT, true); - for (; base; base = base->next) { - update_depsgraph_field_source_object(forest, obNode, ob, base->object); - } - } -} + /* Actual code uses get_collisionobjects */ + dag_add_collision_relations(forest, scene, ob, obNode, smd->domain->fluid_group, ob->lay|scene->lay, eModifierType_Smoke, is_flow_cb, true, "Smoke Flow"); + dag_add_collision_relations(forest, scene, ob, obNode, smd->domain->coll_group, ob->lay|scene->lay, eModifierType_Smoke, is_coll_cb, true, "Smoke Coll"); -static void update_depsgraph_flow_coll_object_new(struct DepsNodeHandle *node, - Object *object2) -{ - SmokeModifierData *smd; - if ((object2->id.tag & LIB_TAG_DOIT) == 0) { - return; - } - object2->id.tag &= ~LIB_TAG_DOIT; - smd = (SmokeModifierData *)modifiers_findByType(object2, eModifierType_Smoke); - if (smd && (((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) || - ((smd->type & MOD_SMOKE_TYPE_COLL) && smd->coll))) - { - DEG_add_object_relation(node, object2, DEG_OB_COMP_TRANSFORM, "Smoke Flow/Coll"); - DEG_add_object_relation(node, object2, DEG_OB_COMP_GEOMETRY, "Smoke Flow/Coll"); - } - if ((object2->transflag & OB_DUPLIGROUP) && object2->dup_group) { - GroupObject *go; - for (go = object2->dup_group->gobject.first; - go != NULL; - go = go->next) - { - if (go->ob == NULL) { - continue; - } - update_depsgraph_flow_coll_object_new(node, go->ob); - } - } -} - -static void update_depsgraph_field_source_object_new(struct DepsNodeHandle *node, - Object *object, - Object *object2) -{ - if ((object2->id.tag & LIB_TAG_DOIT) == 0) { - return; - } - object2->id.tag &= ~LIB_TAG_DOIT; - if (object2->pd && object2->pd->forcefield == PFIELD_SMOKEFLOW && object2->pd->f_source == object) { - DEG_add_object_relation(node, object2, DEG_OB_COMP_TRANSFORM, "Field Source Object"); - DEG_add_object_relation(node, object2, DEG_OB_COMP_GEOMETRY, "Field Source Object"); - } - if ((object2->transflag & OB_DUPLIGROUP) && object2->dup_group) { - GroupObject *go; - for (go = object2->dup_group->gobject.first; - go != NULL; - go = go->next) - { - if (go->ob == NULL) { - continue; - } - update_depsgraph_field_source_object_new(node, object, go->ob); - } + dag_add_forcefield_relations(forest, scene, ob, obNode, smd->domain->effector_weights, true, PFIELD_SMOKEFLOW, "Smoke Force Field"); } } static void updateDepsgraph(ModifierData *md, - struct Main *bmain, + struct Main *UNUSED(bmain), struct Scene *scene, Object *ob, struct DepsNodeHandle *node) { SmokeModifierData *smd = (SmokeModifierData *)md; - Base *base; + if (smd && (smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) { - if (smd->domain->fluid_group || smd->domain->coll_group) { - GroupObject *go = NULL; - if (smd->domain->fluid_group != NULL) { - for (go = smd->domain->fluid_group->gobject.first; go; go = go->next) { - if (go->ob != NULL) { - SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(go->ob, eModifierType_Smoke); - /* Check for initialized smoke object. */ - if (smd2 && (smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) { - DEG_add_object_relation(node, go->ob, DEG_OB_COMP_TRANSFORM, "Smoke Flow"); - } - } - } - } - if (smd->domain->coll_group != NULL) { - for (go = smd->domain->coll_group->gobject.first; go; go = go->next) { - if (go->ob != NULL) { - SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(go->ob, eModifierType_Smoke); - /* Check for initialized smoke object. */ - if (smd2 && (smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll) { - DEG_add_object_relation(node, go->ob, DEG_OB_COMP_TRANSFORM, "Smoke Coll"); - } - } - } - } - } - else { - BKE_main_id_tag_listbase(&bmain->object, LIB_TAG_DOIT, true); - base = scene->base.first; - for (; base; base = base->next) { - update_depsgraph_flow_coll_object_new(node, base->object); - } - } - /* add relation to all "smoke flow" force fields */ - base = scene->base.first; - BKE_main_id_tag_listbase(&bmain->object, LIB_TAG_DOIT, true); - for (; base; base = base->next) { - update_depsgraph_field_source_object_new(node, ob, base->object); - } + /* Actual code uses get_collisionobjects */ + DEG_add_collision_relations(node, scene, ob, smd->domain->fluid_group, ob->lay|scene->lay, eModifierType_Smoke, is_flow_cb, true, "Smoke Flow"); + DEG_add_collision_relations(node, scene, ob, smd->domain->coll_group, ob->lay|scene->lay, eModifierType_Smoke, is_coll_cb, true, "Smoke Coll"); + + DEG_add_forcefield_relations(node, scene, ob, smd->domain->effector_weights, true, PFIELD_SMOKEFLOW, "Smoke Force Field"); } } diff --git a/source/blender/modifiers/intern/MOD_softbody.c b/source/blender/modifiers/intern/MOD_softbody.c index 98a1412d0c6..17adc7f1520 100644 --- a/source/blender/modifiers/intern/MOD_softbody.c +++ b/source/blender/modifiers/intern/MOD_softbody.c @@ -35,6 +35,7 @@ #include #include "DNA_scene_types.h" +#include "DNA_object_force.h" #include "BLI_utildefines.h" @@ -42,6 +43,9 @@ #include "BKE_particle.h" #include "BKE_softbody.h" +#include "depsgraph_private.h" +#include "DEG_depsgraph_build.h" + #include "MOD_modifiertypes.h" static void deformVerts(ModifierData *md, Object *ob, @@ -58,6 +62,31 @@ static bool dependsOnTime(ModifierData *UNUSED(md)) return true; } +static void updateDepgraph(ModifierData *UNUSED(md), DagForest *forest, + struct Main *UNUSED(bmain), + Scene *scene, Object *ob, DagNode *obNode) +{ + if (ob->soft) { + /* Actual code uses ccd_build_deflector_hash */ + dag_add_collision_relations(forest, scene, ob, obNode, ob->soft->collision_group, ob->lay, eModifierType_Collision, NULL, false, "Softbody Collision"); + + dag_add_forcefield_relations(forest, scene, ob, obNode, ob->soft->effector_weights, true, 0, "Softbody Field"); + } +} + +static void updateDepsgraph(ModifierData *UNUSED(md), + struct Main *UNUSED(bmain), + struct Scene *scene, + Object *ob, + struct DepsNodeHandle *node) +{ + if (ob->soft) { + /* Actual code uses ccd_build_deflector_hash */ + DEG_add_collision_relations(node, scene, ob, ob->soft->collision_group, ob->lay, eModifierType_Collision, NULL, false, "Softbody Collision"); + + DEG_add_forcefield_relations(node, scene, ob, ob->soft->effector_weights, true, 0, "Softbody Field"); + } +} ModifierTypeInfo modifierType_Softbody = { /* name */ "Softbody", @@ -80,8 +109,8 @@ ModifierTypeInfo modifierType_Softbody = { /* requiredDataMask */ NULL, /* freeData */ NULL, /* isDisabled */ NULL, - /* updateDepgraph */ NULL, - /* updateDepsgraph */ NULL, + /* updateDepgraph */ updateDepgraph, + /* updateDepsgraph */ updateDepsgraph, /* dependsOnTime */ dependsOnTime, /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, -- cgit v1.2.3 From ae475e355488db27c4b9fcc33385080578403833 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 16 Aug 2016 14:57:56 +0200 Subject: Fix release build after recent fix for debug one It's becoming annoying to have public API dependent on build type and everything. Let's just always have API defined and do stubs in the function implementation instead. --- source/blender/blenlib/BLI_system.h | 3 +++ source/blender/blenlib/BLI_utildefines.h | 2 +- source/blender/makesrna/intern/makesrna.c | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/blenlib/BLI_system.h b/source/blender/blenlib/BLI_system.h index 938a12dcdcf..f51b9623803 100644 --- a/source/blender/blenlib/BLI_system.h +++ b/source/blender/blenlib/BLI_system.h @@ -21,11 +21,14 @@ #ifndef __BLI_SYSTEM_H__ #define __BLI_SYSTEM_H__ +#include + /** \file BLI_system.h * \ingroup bli */ int BLI_cpu_support_sse2(void); +void BLI_system_backtrace(FILE *fp); /* getpid */ #ifdef WIN32 diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index d504e503c68..746eb922c65 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -633,7 +633,7 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size); * for aborting need to define WITH_ASSERT_ABORT */ #ifndef NDEBUG -extern void BLI_system_backtrace(FILE *fp); +# include "BLI_system.h" # ifdef WITH_ASSERT_ABORT # define _BLI_DUMMY_ABORT abort # else diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 1f8ef0dbab5..569c1ee5f3f 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -50,7 +50,7 @@ #ifndef NDEBUG void BLI_system_backtrace(FILE *fp) { - (void)fp; + (void)fp; } #endif -- cgit v1.2.3 From 64a6a86d57ee0c8810b7738bc42950c336d82952 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 16 Aug 2016 16:15:55 +0200 Subject: Fix two memleaks found by coverity. --- source/blender/alembic/intern/alembic_capi.cc | 3 +++ source/blender/collada/TransformWriter.cpp | 1 + 2 files changed, 4 insertions(+) diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc index 0e96ac22e11..f9364d55753 100644 --- a/source/blender/alembic/intern/alembic_capi.cc +++ b/source/blender/alembic/intern/alembic_capi.cc @@ -585,6 +585,9 @@ static void import_startjob(void *user_data, short *stop, short *do_update, floa IArchive *archive = open_archive(data->filename); if (!archive || !archive->valid()) { + if (archive) { + delete archive; + } data->error_code = ABC_ARCHIVE_FAIL; return; } diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp index e205608a365..b16e2e2b0d3 100644 --- a/source/blender/collada/TransformWriter.cpp +++ b/source/blender/collada/TransformWriter.cpp @@ -49,6 +49,7 @@ void TransformWriter::add_node_transform(COLLADASW::Node& node, float mat[4][4], double dmat[4][4]; UnitConverter *converter = new UnitConverter(); converter->mat4_to_dae_double(dmat, local); + delete converter; TransformBase::decompose(local, loc, rot, NULL, scale); -- cgit v1.2.3 From 1e4e140efb43d05ff3361694f429338d2b90f140 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 16 Aug 2016 18:19:52 +0200 Subject: More fixes from coverity report. --- source/blender/blenkernel/intern/anim_sys.c | 2 +- source/blender/blenkernel/intern/smoke.c | 12 ++++++++--- source/blender/blenkernel/intern/writeffmpeg.c | 2 +- .../editors/animation/anim_channels_defines.c | 23 +++++++++++----------- source/blender/makesrna/intern/rna_scene_api.c | 4 ++-- source/gameengine/Ketsji/KX_NavMeshObject.cpp | 7 ++++++- 6 files changed, 31 insertions(+), 19 deletions(-) diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 1a5d77bbc07..e3764adb969 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1513,7 +1513,7 @@ static bool animsys_store_rna_setting( if (array_len && array_index >= array_len) { if (G.debug & G_DEBUG) { printf("Animato: Invalid array index. ID = '%s', '%s[%d]', array length is %d\n", - (ptr && ptr->id.data) ? (((ID *)ptr->id.data)->name + 2) : "", + (ptr->id.data) ? (((ID *)ptr->id.data)->name + 2) : "", path, array_index, array_len - 1); } } diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 3fc72628c97..f622d541f3a 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -3051,9 +3051,15 @@ float smoke_get_velocity_at(struct Object *ob, float position[3], float velocity int smoke_get_data_flags(SmokeDomainSettings *sds) { int flags = 0; - if (smoke_has_heat(sds->fluid)) flags |= SM_ACTIVE_HEAT; - if (smoke_has_fuel(sds->fluid)) flags |= SM_ACTIVE_FIRE; - if (smoke_has_colors(sds->fluid)) flags |= SM_ACTIVE_COLORS; + + if (sds->fluid) { + if (smoke_has_heat(sds->fluid)) + flags |= SM_ACTIVE_HEAT; + if (smoke_has_fuel(sds->fluid)) + flags |= SM_ACTIVE_FIRE; + if (smoke_has_colors(sds->fluid)) + flags |= SM_ACTIVE_COLORS; + } return flags; } diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 9dbc045f1b0..de55a1977bf 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -1393,7 +1393,7 @@ int BKE_ffmpeg_property_add_string(RenderData *rd, const char *type, const char avcodec_get_context_defaults3(&c, NULL); - strncpy(name_, str, sizeof(name_)); + BLI_strncpy(name_, str, sizeof(name_)); name = name_; while (*name == ' ') name++; diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 3085e383909..d727ea0a957 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -3901,7 +3901,12 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void /* send notifiers before doing anything else... */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - + + /* verify that we have a channel to operate on. */ + if (!ale_setting) { + return; + } + if (ale_setting->type == ANIMTYPE_GPLAYER) WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, NULL); @@ -3909,17 +3914,13 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void if (ANIM_animdata_get_context(C, &ac) == 0) return; - /* verify that we have a channel to operate on, and that it has all we need */ - if (ale_setting) { - /* check if the setting is on... */ - on = ANIM_channel_setting_get(&ac, ale_setting, setting); - - /* on == -1 means setting not found... */ - if (on == -1) - return; - } - else + /* check if the setting is on... */ + on = ANIM_channel_setting_get(&ac, ale_setting, setting); + + /* on == -1 means setting not found... */ + if (on == -1) { return; + } /* get all channels that can possibly be chosen - but ignore hierarchy */ filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index ed51f0cffb0..519f28bea24 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -278,8 +278,8 @@ static void rna_Scene_collada_export( int use_object_instantiation, int use_blender_profile, int sort_by_name, - int export_transformation_type, - int open_sim) + int open_sim, + int export_transformation_type) { collada_export(scene, filepath, apply_modifiers, export_mesh_type, selected, include_children, include_armatures, include_shapekeys, deform_bones_only, diff --git a/source/gameengine/Ketsji/KX_NavMeshObject.cpp b/source/gameengine/Ketsji/KX_NavMeshObject.cpp index b8907ca5c6b..5beda2e038a 100644 --- a/source/gameengine/Ketsji/KX_NavMeshObject.cpp +++ b/source/gameengine/Ketsji/KX_NavMeshObject.cpp @@ -306,7 +306,12 @@ bool KX_NavMeshObject::BuildNavMesh() || vertsPerPoly<3) { printf("Can't build navigation mesh data for object:%s\n", m_name.ReadPtr()); - if (vertices) delete[] vertices; + if (vertices) { + delete[] vertices; + } + if (dvertices) { + delete[] dvertices; + } return false; } -- cgit v1.2.3 From a67ca5e30cc92ad65d93434a6c2a699d7563b04f Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 16 Aug 2016 18:22:03 +0200 Subject: Cleanup unused return value (was making coverity sad). --- source/blender/blenlib/intern/array_store.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/blender/blenlib/intern/array_store.c b/source/blender/blenlib/intern/array_store.c index 6000c1a680c..21ddddad32e 100644 --- a/source/blender/blenlib/intern/array_store.c +++ b/source/blender/blenlib/intern/array_store.c @@ -579,7 +579,7 @@ static void bchunk_list_calc_trim_len( /** * Append and don't manage merging small chunks. */ -static bool bchunk_list_append_only( +static void bchunk_list_append_only( BArrayMemory *bs_mem, BChunkList *chunk_list, BChunk *chunk) { @@ -588,7 +588,6 @@ static bool bchunk_list_append_only( cref->link = chunk; chunk_list->chunk_refs_len += 1; chunk->users += 1; - return chunk; } /** -- cgit v1.2.3 From b90421019b0257f52a6b75dcc57a0c96fa4159b6 Mon Sep 17 00:00:00 2001 From: Antonioya Date: Tue, 16 Aug 2016 22:28:34 +0200 Subject: Fix T49097: GP ruler data reinstances GP_Palette Color If the ruler is saved, a new color was created for each ruler. With the change, a color is created for the first instance, and it reused in the following instances. The default color is the current default color for GP. --- source/blender/editors/space_view3d/view3d_ruler.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index 37b068e3e49..dda1a64726c 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -297,6 +297,8 @@ static bool view3d_ruler_to_gpencil(bContext *C, RulerInfo *ruler_info) bGPDlayer *gpl; bGPDframe *gpf; bGPDstroke *gps; + bGPDpalette *palette; + bGPDpalettecolor *palcolor; RulerItem *ruler_item; const char *ruler_name = RULER_ID; bool changed = false; @@ -312,6 +314,17 @@ static bool view3d_ruler_to_gpencil(bContext *C, RulerInfo *ruler_info) gpl->flag |= GP_LAYER_HIDE; } + /* try to get active palette or create a new one */ + palette = BKE_gpencil_palette_getactive(scene->gpd); + if (palette == NULL) { + palette = BKE_gpencil_palette_addnew(scene->gpd, DATA_("GP_Palette"), true); + } + /* try to get color with the ruler name or create a new one */ + palcolor = BKE_gpencil_palettecolor_getbyname(palette, (char *)ruler_name); + if (palcolor == NULL) { + palcolor = BKE_gpencil_palettecolor_addnew(palette, (char *)ruler_name, true); + } + gpf = BKE_gpencil_layer_getframe(gpl, CFRA, true); BKE_gpencil_free_strokes(gpf); @@ -342,6 +355,9 @@ static bool view3d_ruler_to_gpencil(bContext *C, RulerInfo *ruler_info) } } gps->flag = GP_STROKE_3DSPACE; + /* assign color to stroke */ + strcpy(gps->colorname, palcolor->info); + gps->palcolor = palcolor; BLI_addtail(&gpf->strokes, gps); changed = true; } -- cgit v1.2.3 From d41dfe36e53baa997187e5ca2f9b88e22da645fe Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 16 Aug 2016 22:36:26 +0200 Subject: First set of UI/i18n messages fixes (mostly new GP code). --- .../scripts/modules/bl_i18n_utils/utils_spell_check.py | 2 ++ source/blender/editors/io/io_alembic.c | 8 +++++--- source/blender/editors/io/io_cache.c | 1 + source/blender/makesrna/intern/rna_gpencil.c | 17 +++++++++-------- source/blender/makesrna/intern/rna_scene.c | 11 +++++++---- source/blender/makesrna/intern/rna_sculpt_paint.c | 6 +++--- 6 files changed, 27 insertions(+), 18 deletions(-) diff --git a/release/scripts/modules/bl_i18n_utils/utils_spell_check.py b/release/scripts/modules/bl_i18n_utils/utils_spell_check.py index ba782160edd..d2049eadaa1 100644 --- a/release/scripts/modules/bl_i18n_utils/utils_spell_check.py +++ b/release/scripts/modules/bl_i18n_utils/utils_spell_check.py @@ -197,6 +197,7 @@ class SpellChecker: "unmute", "unpremultiply", "unprojected", + "unprotect", "unreacted", "unregister", "unselected", "unselectable", @@ -493,6 +494,7 @@ class SpellChecker: "musgrave", "nayar", "netravali", + "ogawa", "oren", "preetham", "prewitt", diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.c index 7a7c42e501b..7714b02a362 100644 --- a/source/blender/editors/io/io_alembic.c +++ b/source/blender/editors/io/io_alembic.c @@ -215,7 +215,8 @@ static void wm_alembic_export_draw(bContext *UNUSED(C), wmOperator *op) void WM_OT_alembic_export(wmOperatorType *ot) { - ot->name = "Export Alembic Archive"; + ot->name = "Export Alembic"; + ot->description = "Export current scene in an Alembic archive"; ot->idname = "WM_OT_alembic_export"; ot->invoke = wm_alembic_export_invoke; @@ -237,7 +238,7 @@ void WM_OT_alembic_export(wmOperatorType *ot) "Transform Samples", "Number of times per frame transformations are sampled", 1, 128); RNA_def_int(ot->srna, "gsamples", 1, 1, 128, - "Geometry Samples", "Number of times per frame object datas are sampled", 1, 128); + "Geometry Samples", "Number of times per frame object data are sampled", 1, 128); RNA_def_float(ot->srna, "sh_open", 0.0f, -1.0f, 1.0f, "Shutter Open", "Time at which the shutter is open", -1.0f, 1.0f); @@ -428,7 +429,8 @@ static int wm_alembic_import_exec(bContext *C, wmOperator *op) void WM_OT_alembic_import(wmOperatorType *ot) { - ot->name = "Import Alembic Archive"; + ot->name = "Import Alembic"; + ot->description = "Load an Alembic archive"; ot->idname = "WM_OT_alembic_import"; ot->invoke = WM_operator_filesel; diff --git a/source/blender/editors/io/io_cache.c b/source/blender/editors/io/io_cache.c index d6e2c1ae204..c5eea94f5e1 100644 --- a/source/blender/editors/io/io_cache.c +++ b/source/blender/editors/io/io_cache.c @@ -117,6 +117,7 @@ static int cachefile_open_exec(bContext *C, wmOperator *op) void CACHEFILE_OT_open(wmOperatorType *ot) { ot->name = "Open Cache File"; + ot->description = "Load a cache file"; ot->idname = "CACHEFILE_OT_open"; ot->invoke = cachefile_open_invoke; diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 9476c964b40..48d7dcfa2e4 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -920,19 +920,19 @@ static void rna_def_gpencil_triangle(BlenderRNA *brna) /* point v1 */ prop = RNA_def_property(srna, "v1", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "v1"); - RNA_def_property_ui_text(prop, "v1", "First triangle vertice index"); + RNA_def_property_ui_text(prop, "v1", "First triangle vertex index"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* point v2 */ prop = RNA_def_property(srna, "v2", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "v2"); - RNA_def_property_ui_text(prop, "v2", "Second triangle vertice index"); + RNA_def_property_ui_text(prop, "v2", "Second triangle vertex index"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* point v3 */ prop = RNA_def_property(srna, "v3", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "v3"); - RNA_def_property_ui_text(prop, "v3", "Third triangle vertice index"); + RNA_def_property_ui_text(prop, "v3", "Third triangle vertex index"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); } @@ -1147,7 +1147,8 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) // TODO: replace these with a "draw type" combo (i.e. strokes only, filled strokes, strokes + fills, volumetric)? prop = RNA_def_property(srna, "use_volumetric_strokes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_VOLUMETRIC); - RNA_def_property_ui_text(prop, "Volumetric Strokes", "Draw strokes as a series of circular blobs, resulting in a volumetric effect"); + RNA_def_property_ui_text(prop, "Volumetric Strokes", + "Draw strokes as a series of circular blobs, resulting in a volumetric effect"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); prop = RNA_def_property(srna, "opacity", PROP_FLOAT, PROP_NONE); @@ -1176,7 +1177,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "thickness"); //RNA_def_property_range(prop, 1, 10); /* 10 px limit comes from Windows OpenGL limits for natively-drawn strokes */ RNA_def_property_int_funcs(prop, NULL, NULL, "rna_GPencilLayer_line_width_range"); - RNA_def_property_ui_text(prop, "Thickness", "Thickness change to apply current strokes (in pixels)"); + RNA_def_property_ui_text(prop, "Thickness", "Thickness change to apply to current strokes (in pixels)"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); /* Onion-Skinning */ @@ -1243,8 +1244,8 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) prop = RNA_def_property(srna, "unlock_color", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_UNLOCK_COLOR); RNA_def_property_ui_icon(prop, ICON_RESTRICT_COLOR_OFF, 1); - RNA_def_property_ui_text(prop, "Unlock color", "Unprotect colors selected from further editing " - "and/or frame changes"); + RNA_def_property_ui_text(prop, "Unlock Color", + "Unprotect selected colors from further editing and/or frame changes"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); @@ -1301,7 +1302,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "inverse"); RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "MatrixInverse", "Parent inverse transformation matrix"); + RNA_def_property_ui_text(prop, "Inverse Matrix", "Parent inverse transformation matrix"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); /* read only parented flag */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 156c327f97c..200f464f1c0 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2162,22 +2162,25 @@ static void rna_def_gpencil_brush(BlenderRNA *brna) prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "draw_angle"); RNA_def_property_range(prop, 0.0f, M_PI_2); - RNA_def_property_ui_text(prop, "Angle", "Angle of drawing when brush has full size"); + RNA_def_property_ui_text(prop, "Angle", + "Direction of the stroke at which brush gives maximal thickness " + "(0° for horizontal, 90° for vertical)"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); /* Factor to change brush size depending of angle */ prop = RNA_def_property(srna, "angle_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "draw_angle_factor"); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Angle Factor", "Factor to apply when the brush rotate of its full size"); + RNA_def_property_ui_text(prop, "Angle Factor", + "Reduce brush thickness by this factor when stroke is perpendicular to 'Angle' direction"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); /* Smoothing factor for new strokes */ prop = RNA_def_property(srna, "pen_smooth_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "draw_smoothfac"); RNA_def_property_range(prop, 0.0, 2.0f); - RNA_def_property_ui_text(prop, "Smooth", "Amount of smoothing to apply to newly created strokes, to " - "reduce jitter/noise"); + RNA_def_property_ui_text(prop, "Smooth", + "Amount of smoothing to apply to newly created strokes, to reduce jitter/noise"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); /* Iterations of the Smoothing factor */ diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index acde2e0957e..a8e80dbc4a3 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -1024,17 +1024,17 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna) prop = RNA_def_property(srna, "affect_position", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_APPLY_POSITION); - RNA_def_property_ui_text(prop, "Affect position", "The brush affects the position of the point"); + RNA_def_property_ui_text(prop, "Affect Position", "The brush affects the position of the point"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "affect_strength", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_APPLY_STRENGTH); - RNA_def_property_ui_text(prop, "Affect strength", "The brush affects the color strength of the point"); + RNA_def_property_ui_text(prop, "Affect Strength", "The brush affects the color strength of the point"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "affect_thickness", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_APPLY_THICKNESS); - RNA_def_property_ui_text(prop, "Affect thickness", "The brush affects the thickness of the point"); + RNA_def_property_ui_text(prop, "Affect Thickness", "The brush affects the thickness of the point"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "selection_alpha", PROP_FLOAT, PROP_NONE); -- cgit v1.2.3 From 34928ca98aba6706a1126c60b4b02c5d39f7e53c Mon Sep 17 00:00:00 2001 From: Antonioya Date: Wed, 17 Aug 2016 09:04:50 +0200 Subject: GPencil: Change ruler line thickness to make it thicker --- source/blender/editors/space_view3d/view3d_ruler.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index dda1a64726c..67a40ae4180 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -355,6 +355,7 @@ static bool view3d_ruler_to_gpencil(bContext *C, RulerInfo *ruler_info) } } gps->flag = GP_STROKE_3DSPACE; + gps->thickness = 3; /* assign color to stroke */ strcpy(gps->colorname, palcolor->info); gps->palcolor = palcolor; -- cgit v1.2.3 From e392658405f3f768ec90e2bbe60b944b0c791bc7 Mon Sep 17 00:00:00 2001 From: Antonioya Date: Wed, 17 Aug 2016 09:11:58 +0200 Subject: Fix T49100: Replace old tooltip for GPencil brush iterations --- source/blender/makesrna/intern/rna_scene.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 200f464f1c0..a3b13340a1f 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2188,8 +2188,7 @@ static void rna_def_gpencil_brush(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "draw_smoothlvl"); RNA_def_property_range(prop, 1, 3); RNA_def_property_ui_text(prop, "Iterations", - "Number of times to smooth newly created strokes " - "[+ reason/effect of using higher values of this property]"); + "Number of times to smooth newly created strokes"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); /* Subdivision level for new strokes */ -- cgit v1.2.3 From de28940b159e71671dc9e426c21704eeeecfd68b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 17 Aug 2016 10:33:54 +0200 Subject: 2D Stabilzier: Don't use len() for checking whether something is enabled or not This code runs on every redraw and iterates the whole tracks list, which is something we should avoid. --- release/scripts/startup/bl_ui/space_clip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index a9db1266bc6..afa9db1f336 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -978,7 +978,7 @@ class CLIP_PT_stabilization(CLIP_PT_reconstruction_panel, Panel): row.prop(stab, "influence_location") col = layout.column() - col.active = stab.use_stabilize_rotation and 0 < len(stab.rotation_tracks.values()) + col.active = stab.use_stabilize_rotation row = col.row() row.prop(stab, "influence_rotation") row = col.row() -- cgit v1.2.3 From 1c633dea1ca48b05057657f90ce29f9159af95b6 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 17 Aug 2016 10:36:38 +0200 Subject: 2D Stabilizer: Use more consistent RNA naming for properties Annoying i did not notice this originally, but for RNA we need to keep things as much consistent as possible. --- release/scripts/startup/bl_ui/space_clip.py | 4 ++-- source/blender/makesrna/intern/rna_tracking.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index afa9db1f336..5f3b9c76865 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -965,8 +965,8 @@ class CLIP_PT_stabilization(CLIP_PT_reconstruction_panel, Panel): layout.separator() layout.label(text="Expected Position") - layout.prop(stab, "target_pos", text="") - layout.prop(stab, "target_rot") + layout.prop(stab, "target_position", text="") + layout.prop(stab, "target_rotation") if stab.use_autoscale: layout.label(text="Auto Scale Factor: %5.3f" % (1.0 / stab.target_zoom)) else: diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 0591c65d484..4ef418dc5ff 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -1750,7 +1750,7 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate"); /* target position */ - prop = RNA_def_property(srna, "target_pos", PROP_FLOAT, PROP_TRANSLATION); + prop = RNA_def_property(srna, "target_position", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 2); RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3); /* increment in steps of 0.01 and show 3 digit after point */ RNA_def_property_float_sdna(prop, NULL, "target_pos"); @@ -1758,7 +1758,7 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL); /* target rotation */ - prop = RNA_def_property(srna, "target_rot", PROP_FLOAT, PROP_ANGLE); + prop = RNA_def_property(srna, "target_rotation", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "target_rot"); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3); -- cgit v1.2.3 From 83d94ef4d054ade1edc5888d6782f096af325e62 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 17 Aug 2016 10:40:34 +0200 Subject: 2D stabilizer: One more occurrence of len() in the drawing code --- release/scripts/startup/bl_ui/space_clip.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 5f3b9c76865..ee6c068dc71 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -973,9 +973,7 @@ class CLIP_PT_stabilization(CLIP_PT_reconstruction_panel, Panel): layout.prop(stab, "target_zoom") layout.separator() - row = layout.row() - row.active = 0 < len(stab.tracks.values()) - row.prop(stab, "influence_location") + layout.prop(stab, "influence_location") col = layout.column() col.active = stab.use_stabilize_rotation -- cgit v1.2.3 From 069bc4086c8afbf03d5fd5e8d63fcd6c46b2864e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 17 Aug 2016 10:45:52 +0200 Subject: 2D stabilizer: Remove redundant rows from the interface --- release/scripts/startup/bl_ui/space_clip.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index ee6c068dc71..c7094109261 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -977,10 +977,8 @@ class CLIP_PT_stabilization(CLIP_PT_reconstruction_panel, Panel): col = layout.column() col.active = stab.use_stabilize_rotation - row = col.row() - row.prop(stab, "influence_rotation") - row = col.row() - row.prop(stab, "influence_scale") + col.prop(stab, "influence_rotation") + col.prop(stab, "influence_scale") layout.prop(stab, "filter_type") -- cgit v1.2.3 From 1e605357b5ed3d206e36e88dc3ebc7961b5552ef Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 17 Aug 2016 10:47:05 +0200 Subject: 2D stabilizer: Remove check for markers count in the track This would be a real disaster if track has no markers, which we should not masquerade and detect such weird cases as soon as possible. --- .../blender/blenkernel/intern/tracking_stabilize.c | 25 ++++++++++------------ 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/source/blender/blenkernel/intern/tracking_stabilize.c b/source/blender/blenkernel/intern/tracking_stabilize.c index 1d571099723..c352625789f 100644 --- a/source/blender/blenkernel/intern/tracking_stabilize.c +++ b/source/blender/blenkernel/intern/tracking_stabilize.c @@ -414,21 +414,18 @@ static MovieTrackingMarker *get_closest_marker(StabContext *ctx, MovieTrackingTrack *track, int ref_frame) { - if (track->markersnr > 0) { - int next_lower = MINAFRAME; - int next_higher = MAXFRAME; - int i = search_closest_marker_index(track, ref_frame); - retrieve_next_higher_usable_frame(ctx, track, i, ref_frame, &next_higher); - retrieve_next_lower_usable_frame(ctx, track, i, ref_frame, &next_lower); - - if ((next_higher - ref_frame) < (ref_frame - next_lower)) { - return BKE_tracking_marker_get_exact(track, next_higher); - } - else { - return BKE_tracking_marker_get_exact(track, next_lower); - } + int next_lower = MINAFRAME; + int next_higher = MAXFRAME; + int i = search_closest_marker_index(track, ref_frame); + retrieve_next_higher_usable_frame(ctx, track, i, ref_frame, &next_higher); + retrieve_next_lower_usable_frame(ctx, track, i, ref_frame, &next_lower); + + if ((next_higher - ref_frame) < (ref_frame - next_lower)) { + return BKE_tracking_marker_get_exact(track, next_higher); + } + else { + return BKE_tracking_marker_get_exact(track, next_lower); } - return NULL; } -- cgit v1.2.3 From 1fb8bbcd3e978444e76ddbb090268b824b9d9894 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 17 Aug 2016 10:49:42 +0200 Subject: 2D stabilizer: Use exact getter instead of regular one followed with frame check --- source/blender/blenkernel/intern/tracking_stabilize.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/intern/tracking_stabilize.c b/source/blender/blenkernel/intern/tracking_stabilize.c index c352625789f..4d72d851ae9 100644 --- a/source/blender/blenkernel/intern/tracking_stabilize.c +++ b/source/blender/blenkernel/intern/tracking_stabilize.c @@ -438,16 +438,16 @@ static MovieTrackingMarker *get_tracking_data_point( StabContext *ctx, MovieTrackingTrack *track, int framenr, - float *weight) + float *r_weight) { - MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); - if (marker && marker->framenr == framenr && !(marker->flag & MARKER_DISABLED)) { - *weight = get_animated_weight(ctx, track, framenr); + MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, framenr); + if (marker != NULL && !(marker->flag & MARKER_DISABLED)) { + *r_weight = get_animated_weight(ctx, track, framenr); return marker; } else { - /* no marker at this frame (=gap) or marker disabled */ - *weight = 0.0f; + /* No marker at this frame (=gap) or marker disabled. */ + *r_weight = 0.0f; return NULL; } } -- cgit v1.2.3 From acbef397ac5a0916344dcde87222088ed0f6d200 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 17 Aug 2016 10:55:41 +0200 Subject: 2D stabilizer: Cover rotation tracks label with enabled flag --- release/scripts/startup/bl_ui/space_clip.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index c7094109261..7dfa0693d20 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -938,10 +938,10 @@ class CLIP_PT_stabilization(CLIP_PT_reconstruction_panel, Panel): sub.menu('CLIP_MT_stabilize_2d_specials', text="", icon='DOWNARROW_HLT') - row = box.row() - row.label(text="Tracks For Rotation / Scale") - row = box.row() - row.active = stab.use_stabilize_rotation + col = box.column() + col.active = stab.use_stabilize_rotation + col.label(text="Tracks For Rotation / Scale") + row = col.row() row.template_list("UI_UL_list", "stabilization_rotation_tracks", stab, "rotation_tracks", stab, "active_rotation_track_index", rows=2) -- cgit v1.2.3 From 186ee0934fbe5e93780cf2eae3f2b81eacb9810b Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 17 Aug 2016 12:53:03 +0200 Subject: More UI messages fixes and cleanup. --- source/blender/editors/io/io_alembic.c | 2 +- source/blender/makesrna/intern/rna_tracking.c | 28 ++++++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.c index 7714b02a362..63c6f3dfecf 100644 --- a/source/blender/editors/io/io_alembic.c +++ b/source/blender/editors/io/io_alembic.c @@ -267,7 +267,7 @@ void WM_OT_alembic_export(wmOperatorType *ot) RNA_def_boolean(ot->srna, "normals", 1, "Normals", "Export normals"); - RNA_def_boolean(ot->srna, "vcolors", 0, "Vertex colors", "Export vertex colors"); + RNA_def_boolean(ot->srna, "vcolors", 0, "Vertex Colors", "Export vertex colors"); RNA_def_boolean(ot->srna, "face_sets", 0, "Face Sets", "Export per face shading group assignments"); diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 4ef418dc5ff..cbfebe5efc4 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -1674,7 +1674,7 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem filter_items[] = { - {TRACKING_FILTER_NEAREST, "NEAREST", 0, "Nearest", "No interpolation; use nearest neighbor pixel"}, + {TRACKING_FILTER_NEAREST, "NEAREST", 0, "Nearest", "No interpolation, use nearest neighbor pixel"}, {TRACKING_FILTER_BILINEAR, "BILINEAR", 0, "Bilinear", "Simple interpolation between adjacent pixels"}, {TRACKING_FILTER_BICUBIC, "BICUBIC", 0, "Bicubic", "High quality pixel interpolation"}, {0, NULL, 0, NULL, NULL} @@ -1711,7 +1711,8 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) "rna_iterator_listbase_end", "rna_iterator_listbase_get", NULL, NULL, NULL, NULL); RNA_def_property_struct_type(prop, "MovieTrackingTrack"); - RNA_def_property_ui_text(prop, "Translation Tracks", "Collection of tracks used for 2D stabilization (translation)"); + RNA_def_property_ui_text(prop, "Translation Tracks", + "Collection of tracks used for 2D stabilization (translation)"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate"); /* active track index */ @@ -1721,7 +1722,8 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) RNA_def_property_int_funcs(prop, "rna_tracking_stabTracks_active_index_get", "rna_tracking_stabTracks_active_index_set", "rna_tracking_stabTracks_active_index_range"); - RNA_def_property_ui_text(prop, "Active Track Index", "Index of active track in translation stabilization tracks list"); + RNA_def_property_ui_text(prop, "Active Track Index", + "Index of active track in translation stabilization tracks list"); /* tracks used for rotation stabilization */ prop = RNA_def_property(srna, "rotation_tracks", PROP_COLLECTION, PROP_NONE); @@ -1739,14 +1741,17 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) RNA_def_property_int_funcs(prop, "rna_tracking_stabRotTracks_active_index_get", "rna_tracking_stabRotTracks_active_index_set", "rna_tracking_stabRotTracks_active_index_range"); - RNA_def_property_ui_text(prop, "Active Rotation Track Index", "Index of active track in rotation stabilization tracks list"); + RNA_def_property_ui_text(prop, "Active Rotation Track Index", + "Index of active track in rotation stabilization tracks list"); /* anchor frame */ prop = RNA_def_property(srna, "anchor_frame", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "anchor_frame"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, MINFRAME, MAXFRAME); - RNA_def_property_ui_text(prop, "Anchor Frame", "Reference point to anchor stabilization (other frames will be adjusted relative to this frame's position)"); + RNA_def_property_ui_text(prop, "Anchor Frame", + "Reference point to anchor stabilization " + "(other frames will be adjusted relative to this frame's position)"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate"); /* target position */ @@ -1754,7 +1759,9 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) RNA_def_property_array(prop, 2); RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3); /* increment in steps of 0.01 and show 3 digit after point */ RNA_def_property_float_sdna(prop, NULL, "target_pos"); - RNA_def_property_ui_text(prop, "Expected Position", "Known relative offset of original shot, will be subtracted; e.g. for panning shot, can be animated"); + RNA_def_property_ui_text(prop, "Expected Position", + "Known relative offset of original shot, will be subtracted " + "(e.g. for panning shot, can be animated)"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL); /* target rotation */ @@ -1762,7 +1769,8 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "target_rot"); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3); - RNA_def_property_ui_text(prop, "Expected Rotation", "Rotation present on original shot, will be compensated; e.g. for deliberate tilting"); + RNA_def_property_ui_text(prop, "Expected Rotation", + "Rotation present on original shot, will be compensated (e.g. for deliberate tilting)"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL); /* target scale */ @@ -1770,7 +1778,8 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "scale"); RNA_def_property_range(prop, FLT_EPSILON, 100.0f); RNA_def_property_ui_range(prop, 0.1f, 10.0f, 1, 3); /* increment in steps of 0.01. Show 3 digit after point */ - RNA_def_property_ui_text(prop, "Expected Zoom", "Explicitly scale resulting frame to compensate zoom of original shot"); + RNA_def_property_ui_text(prop, "Expected Zoom", + "Explicitly scale resulting frame to compensate zoom of original shot"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate"); /* autoscale */ @@ -1813,7 +1822,8 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "filter"); RNA_def_property_enum_items(prop, filter_items); - RNA_def_property_ui_text(prop, "Interpolate", "Interpolation to use for sub-pixel shifts and rotations due to stabilization"); + RNA_def_property_ui_text(prop, "Interpolate", + "Interpolation to use for sub-pixel shifts and rotations due to stabilization"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate"); /* UI display : show participating tracks */ -- cgit v1.2.3 From 294eac2991560a79aa3fc48d30965ee54508a322 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 9 Aug 2016 15:19:11 +0200 Subject: CMake: Move main platform checks to separate files Basically title says it all. The goal is to make platform maintenance easier, so you don't have to constantly scroll back and forth looking for if() branches to check which exact platform you're currently working on. Ideally we also would move option defaults to a platform files, but that i'm not sure how to implement in a nice way yet. Reviewers: mont29 Reviewed By: mont29 Differential Revision: https://developer.blender.org/D2148 --- CMakeLists.txt | 1578 +------------------- build_files/cmake/platform/platform_apple.cmake | 430 ++++++ build_files/cmake/platform/platform_unix.cmake | 425 ++++++ build_files/cmake/platform/platform_win32.cmake | 87 ++ .../cmake/platform/platform_win32_mingw.cmake | 302 ++++ .../cmake/platform/platform_win32_msvc.cmake | 452 ++++++ 6 files changed, 1700 insertions(+), 1574 deletions(-) create mode 100644 build_files/cmake/platform/platform_apple.cmake create mode 100644 build_files/cmake/platform/platform_unix.cmake create mode 100644 build_files/cmake/platform/platform_win32.cmake create mode 100644 build_files/cmake/platform/platform_win32_mingw.cmake create mode 100644 build_files/cmake/platform/platform_win32_msvc.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 281aa52cae3..170537b7dfa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,7 @@ endif() # this starts out unset list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/Modules") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/platform") # avoid having empty buildtype set(CMAKE_BUILD_TYPE_INIT "Release") @@ -900,1582 +901,11 @@ endif() # - APPLE if(UNIX AND NOT APPLE) - macro(find_package_wrapper) - if(WITH_STATIC_LIBS) - find_package_static(${ARGV}) - else() - find_package(${ARGV}) - endif() - endmacro() - - find_package_wrapper(JPEG REQUIRED) - find_package_wrapper(PNG REQUIRED) - find_package_wrapper(ZLIB REQUIRED) - find_package_wrapper(Freetype REQUIRED) - - if(WITH_LZO AND WITH_SYSTEM_LZO) - find_package_wrapper(LZO) - if(NOT LZO_FOUND) - message(FATAL_ERROR "Failed finding system LZO version!") - endif() - endif() - - if(WITH_SYSTEM_EIGEN3) - find_package_wrapper(Eigen3) - if(NOT EIGEN3_FOUND) - message(FATAL_ERROR "Failed finding system Eigen3 version!") - endif() - endif() - # else values are set below for all platforms - - if(WITH_PYTHON) - # No way to set py35, remove for now. - # find_package(PythonLibs) - - # Use our own instead, since without py is such a rare case, - # require this package - # XXX Linking errors with debian static python :/ -# find_package_wrapper(PythonLibsUnix REQUIRED) - find_package(PythonLibsUnix REQUIRED) - endif() - - if(WITH_IMAGE_OPENEXR) - find_package_wrapper(OpenEXR) # our own module - if(NOT OPENEXR_FOUND) - set(WITH_IMAGE_OPENEXR OFF) - endif() - endif() - - if(WITH_IMAGE_OPENJPEG) - find_package_wrapper(OpenJPEG) - if(NOT OPENJPEG_FOUND) - set(WITH_IMAGE_OPENJPEG OFF) - endif() - endif() - - if(WITH_IMAGE_TIFF) - # XXX Linking errors with debian static tiff :/ -# find_package_wrapper(TIFF) - find_package(TIFF) - if(NOT TIFF_FOUND) - set(WITH_IMAGE_TIFF OFF) - endif() - endif() - - # Audio IO - if(WITH_SYSTEM_AUDASPACE) - find_package_wrapper(Audaspace) - if(NOT AUDASPACE_FOUND OR NOT AUDASPACE_C_FOUND) - message(FATAL_ERROR "Audaspace external library not found!") - endif() - endif() - - if(WITH_OPENAL) - find_package_wrapper(OpenAL) - if(NOT OPENAL_FOUND) - set(WITH_OPENAL OFF) - endif() - endif() - - if(WITH_SDL) - if(WITH_SDL_DYNLOAD) - set(SDL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extern/sdlew/include/SDL2") - set(SDL_LIBRARY) - else() - find_package_wrapper(SDL2) - if(SDL2_FOUND) - # Use same names for both versions of SDL until we move to 2.x. - set(SDL_INCLUDE_DIR "${SDL2_INCLUDE_DIR}") - set(SDL_LIBRARY "${SDL2_LIBRARY}") - set(SDL_FOUND "${SDL2_FOUND}") - else() - find_package_wrapper(SDL) - endif() - mark_as_advanced( - SDL_INCLUDE_DIR - SDL_LIBRARY - ) - # unset(SDLMAIN_LIBRARY CACHE) - if(NOT SDL_FOUND) - set(WITH_SDL OFF) - endif() - endif() - endif() - - if(WITH_JACK) - find_package_wrapper(Jack) - if(NOT JACK_FOUND) - set(WITH_JACK OFF) - endif() - endif() - - # Codecs - if(WITH_CODEC_SNDFILE) - find_package_wrapper(SndFile) - if(NOT SNDFILE_FOUND) - set(WITH_CODEC_SNDFILE OFF) - endif() - endif() - - if(WITH_CODEC_FFMPEG) - set(FFMPEG /usr CACHE PATH "FFMPEG Directory") - set(FFMPEG_LIBRARIES avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries") - - mark_as_advanced(FFMPEG) - - # lame, but until we have proper find module for ffmpeg - set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include) - if(EXISTS "${FFMPEG}/include/ffmpeg/") - list(APPEND FFMPEG_INCLUDE_DIRS "${FFMPEG}/include/ffmpeg") - endif() - # end lameness - - mark_as_advanced(FFMPEG_LIBRARIES) - set(FFMPEG_LIBPATH ${FFMPEG}/lib) - endif() - - if(WITH_FFTW3) - find_package_wrapper(Fftw3) - if(NOT FFTW3_FOUND) - set(WITH_FFTW3 OFF) - endif() - endif() - - if(WITH_OPENCOLLADA) - find_package_wrapper(OpenCOLLADA) - if(OPENCOLLADA_FOUND) - find_package_wrapper(XML2) - find_package_wrapper(PCRE) - else() - set(WITH_OPENCOLLADA OFF) - endif() - endif() - - if(WITH_MEM_JEMALLOC) - find_package_wrapper(JeMalloc) - if(NOT JEMALLOC_FOUND) - set(WITH_MEM_JEMALLOC OFF) - endif() - endif() - - if(WITH_INPUT_NDOF) - find_package_wrapper(Spacenav) - if(SPACENAV_FOUND) - # use generic names within blenders buildsystem. - set(NDOF_INCLUDE_DIRS ${SPACENAV_INCLUDE_DIRS}) - set(NDOF_LIBRARIES ${SPACENAV_LIBRARIES}) - else() - set(WITH_INPUT_NDOF OFF) - endif() - endif() - - if(WITH_CYCLES_OSL) - set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation") - if(NOT OSL_ROOT) - set(OSL_ROOT ${CYCLES_OSL}) - endif() - find_package_wrapper(OpenShadingLanguage) - if(OSL_FOUND) - if(${OSL_LIBRARY_VERSION_MAJOR} EQUAL "1" AND ${OSL_LIBRARY_VERSION_MINOR} LESS "6") - # Note: --whole-archive is needed to force loading of all symbols in liboslexec, - # otherwise LLVM is missing the osl_allocate_closure_component function - set(OSL_LIBRARIES - ${OSL_OSLCOMP_LIBRARY} - -Wl,--whole-archive ${OSL_OSLEXEC_LIBRARY} - -Wl,--no-whole-archive ${OSL_OSLQUERY_LIBRARY} - ) - endif() - else() - message(STATUS "OSL not found, disabling it from Cycles") - set(WITH_CYCLES_OSL OFF) - endif() - endif() - - if(WITH_OPENVDB) - find_package_wrapper(OpenVDB) - find_package_wrapper(TBB) - if(NOT OPENVDB_FOUND OR NOT TBB_FOUND) - set(WITH_OPENVDB OFF) - set(WITH_OPENVDB_BLOSC OFF) - message(STATUS "OpenVDB not found, disabling it") - endif() - endif() - - if(WITH_ALEMBIC) - find_package_wrapper(Alembic) - - if(WITH_ALEMBIC_HDF5) - set(HDF5_ROOT_DIR ${LIBDIR}/hdf5) - find_package_wrapper(HDF5) - endif() - - if(NOT ALEMBIC_FOUND OR (WITH_ALEMBIC_HDF5 AND NOT HDF5_FOUND)) - set(WITH_ALEMBIC OFF) - set(WITH_ALEMBIC_HDF5 OFF) - endif() - endif() - - if(WITH_BOOST) - # uses in build instructions to override include and library variables - if(NOT BOOST_CUSTOM) - if(WITH_STATIC_LIBS) - set(Boost_USE_STATIC_LIBS ON) - endif() - set(Boost_USE_MULTITHREADED ON) - set(__boost_packages filesystem regex system thread date_time) - if(WITH_CYCLES_OSL) - if(NOT (${OSL_LIBRARY_VERSION_MAJOR} EQUAL "1" AND ${OSL_LIBRARY_VERSION_MINOR} LESS "6")) - list(APPEND __boost_packages wave) - else() - endif() - endif() - if(WITH_INTERNATIONAL) - list(APPEND __boost_packages locale) - endif() - if(WITH_CYCLES_NETWORK) - list(APPEND __boost_packages serialization) - endif() - if(WITH_OPENVDB) - list(APPEND __boost_packages iostreams) - endif() - find_package(Boost 1.48 COMPONENTS ${__boost_packages}) - if(NOT Boost_FOUND) - # try to find non-multithreaded if -mt not found, this flag - # doesn't matter for us, it has nothing to do with thread - # safety, but keep it to not disturb build setups - set(Boost_USE_MULTITHREADED OFF) - find_package(Boost 1.48 COMPONENTS ${__boost_packages}) - endif() - unset(__boost_packages) - if(Boost_USE_STATIC_LIBS AND WITH_BOOST_ICU) - find_package(IcuLinux) - endif() - mark_as_advanced(Boost_DIR) # why doesnt boost do this? - endif() - - set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS}) - set(BOOST_LIBRARIES ${Boost_LIBRARIES}) - set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS}) - set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB") - endif() - - if(WITH_OPENIMAGEIO) - find_package_wrapper(OpenImageIO) - if(NOT OPENIMAGEIO_PUGIXML_FOUND AND WITH_CYCLES_STANDALONE) - find_package_wrapper(PugiXML) - else() - set(PUGIXML_INCLUDE_DIR "${OPENIMAGEIO_INCLUDE_DIR/OpenImageIO}") - set(PUGIXML_LIBRARIES "") - endif() - - set(OPENIMAGEIO_LIBRARIES - ${OPENIMAGEIO_LIBRARIES} - ${PNG_LIBRARIES} - ${JPEG_LIBRARIES} - ${ZLIB_LIBRARIES} - ${BOOST_LIBRARIES} - ) - set(OPENIMAGEIO_LIBPATH) # TODO, remove and reference the absolute path everywhere - set(OPENIMAGEIO_DEFINITIONS "") - - if(WITH_IMAGE_TIFF) - list(APPEND OPENIMAGEIO_LIBRARIES "${TIFF_LIBRARY}") - endif() - if(WITH_IMAGE_OPENEXR) - list(APPEND OPENIMAGEIO_LIBRARIES "${OPENEXR_LIBRARIES}") - endif() - - if(NOT OPENIMAGEIO_FOUND) - set(WITH_OPENIMAGEIO OFF) - message(STATUS "OpenImageIO not found, disabling WITH_CYCLES") - endif() - endif() - - if(WITH_OPENCOLORIO) - find_package_wrapper(OpenColorIO) - - set(OPENCOLORIO_LIBRARIES ${OPENCOLORIO_LIBRARIES}) - set(OPENCOLORIO_LIBPATH) # TODO, remove and reference the absolute path everywhere - set(OPENCOLORIO_DEFINITIONS) - - if(NOT OPENCOLORIO_FOUND) - set(WITH_OPENCOLORIO OFF) - message(STATUS "OpenColorIO not found") - endif() - endif() - - if(WITH_LLVM) - find_package_wrapper(LLVM) - - if(NOT LLVM_FOUND) - set(WITH_LLVM OFF) - message(STATUS "LLVM not found") - endif() - endif() - - if(WITH_LLVM OR WITH_SDL_DYNLOAD) - # Fix for conflict with Mesa llvmpipe - set(PLATFORM_LINKFLAGS - "${PLATFORM_LINKFLAGS} -Wl,--version-script='${CMAKE_SOURCE_DIR}/source/creator/blender.map'" - ) - endif() - - if(WITH_OPENSUBDIV) - find_package_wrapper(OpenSubdiv) - - set(OPENSUBDIV_LIBRARIES ${OPENSUBDIV_LIBRARIES}) - set(OPENSUBDIV_LIBPATH) # TODO, remove and reference the absolute path everywhere - - if(NOT OPENSUBDIV_FOUND) - set(WITH_OPENSUBDIV OFF) - message(STATUS "OpenSubdiv not found") - endif() - endif() - - # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed - list(APPEND PLATFORM_LINKLIBS -lutil -lc -lm) - - find_package(Threads REQUIRED) - list(APPEND PLATFORM_LINKLIBS ${CMAKE_THREAD_LIBS_INIT}) - # used by other platforms - set(PTHREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) - - if(CMAKE_DL_LIBS) - list(APPEND PLATFORM_LINKLIBS ${CMAKE_DL_LIBS}) - endif() - - if(CMAKE_SYSTEM_NAME MATCHES "Linux") - if(NOT WITH_PYTHON_MODULE) - # binreloc is linux only - set(BINRELOC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/binreloc/include) - set(WITH_BINRELOC ON) - endif() - endif() - - # lfs on glibc, all compilers should use - add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE) - - # GNU Compiler - if(CMAKE_COMPILER_IS_GNUCC) - set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing") - - # use ld.gold linker if available, could make optional - execute_process( - COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version - ERROR_QUIET OUTPUT_VARIABLE LD_VERSION) - if("${LD_VERSION}" MATCHES "GNU gold") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=gold") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold") - else() - message(STATUS "GNU gold linker isn't available, using the default system linker.") - endif() - unset(LD_VERSION) - - # CLang is the same as GCC for now. - elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") - set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing") - # Solaris CC - elseif(CMAKE_C_COMPILER_ID MATCHES "SunPro") - set(PLATFORM_CFLAGS "-pipe -features=extensions -fPIC -D__FUNCTION__=__func__") - - # Intel C++ Compiler - elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") - # think these next two are broken - find_program(XIAR xiar) - if(XIAR) - set(CMAKE_AR "${XIAR}") - endif() - mark_as_advanced(XIAR) - - find_program(XILD xild) - if(XILD) - set(CMAKE_LINKER "${XILD}") - endif() - mark_as_advanced(XILD) - - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise -prec_div -parallel") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fp-model precise -prec_div -parallel") - - # set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -diag-enable sc3") - set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing") - set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -static-intel") - endif() - + include(platform_unix) elseif(WIN32) - - add_definitions(-DWIN32) - - if(MSVC) - # Minimum MSVC Version - if(MSVC_VERSION EQUAL 1800) - set(_min_ver "18.0.31101") - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_min_ver}) - message(FATAL_ERROR - "Visual Studio 2013 (Update 4, ${_min_ver}) required, " - "found (${CMAKE_CXX_COMPILER_VERSION})") - endif() - endif() - if(MSVC_VERSION EQUAL 1900) - set(_min_ver "19.0.24210") - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_min_ver}) - message(FATAL_ERROR - "Visual Studio 2015 (Update 3, ${_min_ver}) required, " - "found (${CMAKE_CXX_COMPILER_VERSION})") - endif() - endif() - unset(_min_ver) - - # needed for some MSVC installations - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO") - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO") - - list(APPEND PLATFORM_LINKLIBS - ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 - advapi32 shfolder shell32 ole32 oleaut32 uuid psapi Dbghelp - ) - - if(WITH_INPUT_IME) - list(APPEND PLATFORM_LINKLIBS imm32) - endif() - - add_definitions( - -D_CRT_NONSTDC_NO_DEPRECATE - -D_CRT_SECURE_NO_DEPRECATE - -D_SCL_SECURE_NO_DEPRECATE - -D_CONSOLE - -D_LIB - ) - - # MSVC11 needs _ALLOW_KEYWORD_MACROS to build - add_definitions(-D_ALLOW_KEYWORD_MACROS) - - # We want to support Vista level ABI - add_definitions(-D_WIN32_WINNT=0x600) - - # Make cmake find the msvc redistributables - set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE) - include(InstallRequiredSystemLibraries) - - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /nologo /J /Gd /MP /EHsc") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo /J /Gd /MP") - - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT") - set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT") - set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT") - set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT") - - set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO ") - set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib ") - - # Ignore meaningless for us linker warnings. - set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /ignore:4049 /ignore:4217 /ignore:4221") - set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221") - - # MSVC only, Mingw doesnt need - if(CMAKE_CL_64) - set(PLATFORM_LINKFLAGS "/MACHINE:X64 /OPT:NOREF ${PLATFORM_LINKFLAGS}") - else() - set(PLATFORM_LINKFLAGS "/MACHINE:IX86 /LARGEADDRESSAWARE ${PLATFORM_LINKFLAGS}") - endif() - - set(PLATFORM_LINKFLAGS_DEBUG "/IGNORE:4099 /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libc.lib") - - if(NOT DEFINED LIBDIR) - - # Setup 64bit and 64bit windows systems - if(CMAKE_CL_64) - message(STATUS "64 bit compiler detected.") - set(LIBDIR_BASE "win64") - else() - message(STATUS "32 bit compiler detected.") - set(LIBDIR_BASE "windows") - endif() - - if(MSVC_VERSION EQUAL 1900) - message(STATUS "Visual Studio 2015 detected.") - set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc14) - else() - message(STATUS "Visual Studio 2013 detected.") - set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc12) - endif() - else() - message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}") - endif() - if(NOT EXISTS "${LIBDIR}/") - message(FATAL_ERROR "Windows requires pre-compiled libs at: '${LIBDIR}'") - endif() - - # Add each of our libraries to our cmake_prefix_path so find_package() could work - file(GLOB children RELATIVE ${LIBDIR} ${LIBDIR}/*) - foreach(child ${children}) - if(IS_DIRECTORY ${LIBDIR}/${child}) - list(APPEND CMAKE_PREFIX_PATH ${LIBDIR}/${child}) - endif() - endforeach() - - set(ZLIB_INCLUDE_DIRS ${LIBDIR}/zlib/include) - set(ZLIB_LIBRARIES ${LIBDIR}/zlib/lib/libz_st.lib) - set(ZLIB_INCLUDE_DIR ${LIBDIR}/zlib/include) - set(ZLIB_LIBRARY ${LIBDIR}/zlib/lib/libz_st.lib) - set(ZLIB_DIR ${LIBDIR}/zlib) - #find_package(zlib) # we want to find before finding things that depend on it like png - - - find_package(png) - if(NOT PNG_FOUND) - message(WARNING "Using HARDCODED libpng locations") - set(PNG_PNG_INCLUDE_DIR ${LIBDIR}/png/include) - set(PNG_LIBRARIES libpng) - set(PNG "${LIBDIR}/png") - set(PNG_INCLUDE_DIRS "${PNG}/include") - set(PNG_LIBPATH ${PNG}/lib) # not cmake defined - endif() - - set(JPEG_NAMES ${JPEG_NAMES} libjpeg) - find_package(jpeg REQUIRED) - - set(PTHREADS_INCLUDE_DIRS ${LIBDIR}/pthreads/include) - set(PTHREADS_LIBRARIES ${LIBDIR}/pthreads/lib/pthreadVC2.lib) - - set(FREETYPE ${LIBDIR}/freetype) - set(FREETYPE_INCLUDE_DIRS - ${LIBDIR}/freetype/include - ${LIBDIR}/freetype/include/freetype2 - ) - set(FREETYPE_LIBRARY ${LIBDIR}/freetype/lib/freetype2ST.lib) - find_package(freetype REQUIRED) - - if(WITH_FFTW3) - set(FFTW3 ${LIBDIR}/fftw3) - set(FFTW3_LIBRARIES libfftw) - set(FFTW3_INCLUDE_DIRS ${FFTW3}/include) - set(FFTW3_LIBPATH ${FFTW3}/lib) - endif() - - if(WITH_OPENCOLLADA) - set(OPENCOLLADA ${LIBDIR}/opencollada) - - set(OPENCOLLADA_INCLUDE_DIRS - ${OPENCOLLADA}/include/opencollada/COLLADAStreamWriter - ${OPENCOLLADA}/include/opencollada/COLLADABaseUtils - ${OPENCOLLADA}/include/opencollada/COLLADAFramework - ${OPENCOLLADA}/include/opencollada/COLLADASaxFrameworkLoader - ${OPENCOLLADA}/include/opencollada/GeneratedSaxParser - ) - - set(OPENCOLLADA_LIBRARIES - ${OPENCOLLADA}/lib/opencollada/OpenCOLLADASaxFrameworkLoader.lib - ${OPENCOLLADA}/lib/opencollada/OpenCOLLADAFramework.lib - ${OPENCOLLADA}/lib/opencollada/OpenCOLLADABaseUtils.lib - ${OPENCOLLADA}/lib/opencollada/OpenCOLLADAStreamWriter.lib - ${OPENCOLLADA}/lib/opencollada/MathMLSolver.lib - ${OPENCOLLADA}/lib/opencollada/GeneratedSaxParser.lib - ${OPENCOLLADA}/lib/opencollada/xml.lib - ${OPENCOLLADA}/lib/opencollada/buffer.lib - ${OPENCOLLADA}/lib/opencollada/ftoa.lib - ) - - if(NOT WITH_LLVM) - list(APPEND OPENCOLLADA_LIBRARIES ${OPENCOLLADA}/lib/opencollada/UTF.lib) - endif() - - set(PCRE_LIBRARIES - ${OPENCOLLADA}/lib/opencollada/pcre.lib - ) - endif() - - if(WITH_CODEC_FFMPEG) - set(FFMPEG_INCLUDE_DIRS - ${LIBDIR}/ffmpeg/include - ${LIBDIR}/ffmpeg/include/msvc - ) - find_package(FFMPEG) - if(NOT FFMPEG_FOUND) - message(WARNING "Using HARDCODED ffmpeg locations") - set(FFMPEG_LIBRARY_VERSION 55) - set(FFMPEG_LIBRARY_VERSION_AVU 52) - set(FFMPEG_LIBRARIES - ${LIBDIR}/ffmpeg/lib/avcodec-${FFMPEG_LIBRARY_VERSION}.lib - ${LIBDIR}/ffmpeg/lib/avformat-${FFMPEG_LIBRARY_VERSION}.lib - ${LIBDIR}/ffmpeg/lib/avdevice-${FFMPEG_LIBRARY_VERSION}.lib - ${LIBDIR}/ffmpeg/lib/avutil-${FFMPEG_LIBRARY_VERSION_AVU}.lib - ${LIBDIR}/ffmpeg/lib/swscale-2.lib - ) - endif() - endif() - - if(WITH_IMAGE_OPENEXR) - set(OPENEXR_ROOT_DIR ${LIBDIR}/openexr) - set(OPENEXR_VERSION "2.1") - find_package(OPENEXR REQUIRED) - if(NOT OPENEXR_FOUND) - message(WARNING "Using HARDCODED OpenEXR locations") - set(OPENEXR ${LIBDIR}/openexr) - set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include) - set(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR}/include/OpenEXR) - set(OPENEXR_LIBPATH ${OPENEXR}/lib) - set(OPENEXR_LIBRARIES - optimized ${OPENEXR_LIBPATH}/Iex-2_2.lib - optimized ${OPENEXR_LIBPATH}/Half.lib - optimized ${OPENEXR_LIBPATH}/IlmImf-2_2.lib - optimized ${OPENEXR_LIBPATH}/Imath-2_2.lib - optimized ${OPENEXR_LIBPATH}/IlmThread-2_2.lib - debug ${OPENEXR_LIBPATH}/Iex-2_2_d.lib - debug ${OPENEXR_LIBPATH}/Half_d.lib - debug ${OPENEXR_LIBPATH}/IlmImf-2_2_d.lib - debug ${OPENEXR_LIBPATH}/Imath-2_2_d.lib - debug ${OPENEXR_LIBPATH}/IlmThread-2_2_d.lib - ) - endif() - endif() - - if(WITH_IMAGE_TIFF) - # Try to find tiff first then complain and set static and maybe wrong paths - find_package(TIFF) - if(NOT TIFF_FOUND) - message(WARNING "Using HARDCODED libtiff locations") - set(TIFF_LIBRARY ${LIBDIR}/tiff/lib/libtiff.lib) - set(TIFF_INCLUDE_DIR ${LIBDIR}/tiff/include) - endif() - endif() - - if(WITH_JACK) - set(JACK_INCLUDE_DIRS - ${LIBDIR}/jack/include/jack - ${LIBDIR}/jack/include - ) - set(JACK_LIBRARIES optimized ${LIBDIR}/jack/lib/libjack.lib debug ${LIBDIR}/jack/lib/libjack_d.lib) - endif() - - if(WITH_PYTHON) - set(PYTHON_VERSION 3.5) # CACHE STRING) - - string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION}) - # Use shared libs for vc2008 and vc2010 until we actually have vc2010 libs - set(PYTHON_LIBRARY ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.lib) - unset(_PYTHON_VERSION_NO_DOTS) - - # Shared includes for both vc2008 and vc2010 - set(PYTHON_INCLUDE_DIR ${LIBDIR}/python/include/python${PYTHON_VERSION}) - - # uncached vars - set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") - set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}") - endif() - - if(WITH_BOOST) - if(WITH_CYCLES_OSL) - set(boost_extra_libs wave) - endif() - if(WITH_INTERNATIONAL) - list(APPEND boost_extra_libs locale) - endif() - if(WITH_OPENVDB) - list(APPEND boost_extra_libs iostreams) - endif() - set(Boost_USE_STATIC_RUNTIME ON) # prefix lib - set(Boost_USE_MULTITHREADED ON) # suffix -mt - set(Boost_USE_STATIC_LIBS ON) # suffix -s - find_package(Boost COMPONENTS date_time filesystem thread regex system ${boost_extra_libs}) - if(NOT Boost_FOUND) - message(WARNING "USING HARDCODED boost locations") - set(BOOST ${LIBDIR}/boost) - set(BOOST_INCLUDE_DIR ${BOOST}/include) - if(MSVC12) - set(BOOST_LIBPATH ${BOOST}/lib) - set(BOOST_POSTFIX "vc120-mt-s-1_60.lib") - set(BOOST_DEBUG_POSTFIX "vc120-mt-sgd-1_60.lib") - else() - set(BOOST_LIBPATH ${BOOST}/lib) - set(BOOST_POSTFIX "vc140-mt-s-1_60.lib") - set(BOOST_DEBUG_POSTFIX "vc140-mt-sgd-1_60.lib") - endif() - set(BOOST_LIBRARIES - optimized libboost_date_time-${BOOST_POSTFIX} - optimized libboost_filesystem-${BOOST_POSTFIX} - optimized libboost_regex-${BOOST_POSTFIX} - optimized libboost_system-${BOOST_POSTFIX} - optimized libboost_thread-${BOOST_POSTFIX} - debug libboost_date_time-${BOOST_DEBUG_POSTFIX} - debug libboost_filesystem-${BOOST_DEBUG_POSTFIX} - debug libboost_regex-${BOOST_DEBUG_POSTFIX} - debug libboost_system-${BOOST_DEBUG_POSTFIX} - debug libboost_thread-${BOOST_DEBUG_POSTFIX} - ) - if(WITH_CYCLES_OSL) - set(BOOST_LIBRARIES ${BOOST_LIBRARIES} - optimized libboost_wave-${BOOST_POSTFIX} - debug libboost_wave-${BOOST_DEBUG_POSTFIX}) - endif() - if(WITH_INTERNATIONAL) - set(BOOST_LIBRARIES ${BOOST_LIBRARIES} - optimized libboost_locale-${BOOST_POSTFIX} - debug libboost_locale-${BOOST_DEBUG_POSTFIX}) - endif() - else() # we found boost using find_package - set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS}) - set(BOOST_LIBRARIES ${Boost_LIBRARIES}) - set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS}) - endif() - set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB") - endif() - - if(WITH_OPENIMAGEIO) - find_package(OpenImageIO) - set(OPENIMAGEIO ${LIBDIR}/openimageio) - set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include) - set(OIIO_OPTIMIZED optimized OpenImageIO optimized OpenImageIO_Util) - set(OIIO_DEBUG debug OpenImageIO_d debug OpenImageIO_Util_d) - set(OPENIMAGEIO_LIBRARIES ${OIIO_OPTIMIZED} ${OIIO_DEBUG}) - set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib) - set(OPENIMAGEIO_DEFINITIONS "-DUSE_TBB=0") - set(OPENCOLORIO_DEFINITIONS "-DOCIO_STATIC_BUILD") - set(OPENIMAGEIO_IDIFF "${OPENIMAGEIO}/bin/idiff.exe") - add_definitions(-DOIIO_STATIC_BUILD) - endif() - - if(WITH_LLVM) - set(LLVM_ROOT_DIR ${LIBDIR}/llvm CACHE PATH "Path to the LLVM installation") - file(GLOB LLVM_LIBRARY_OPTIMIZED ${LLVM_ROOT_DIR}/lib/*.lib) - - if(EXISTS ${LLVM_ROOT_DIR}/debug/lib) - foreach(LLVM_OPTIMIZED_LIB ${LLVM_LIBRARY_OPTIMIZED}) - get_filename_component(LIBNAME ${LLVM_OPTIMIZED_LIB} ABSOLUTE) - list(APPEND LLVM_LIBS optimized ${LIBNAME}) - endforeach(LLVM_OPTIMIZED_LIB) - - file(GLOB LLVM_LIBRARY_DEBUG ${LLVM_ROOT_DIR}/debug/lib/*.lib) - - foreach(LLVM_DEBUG_LIB ${LLVM_LIBRARY_DEBUG}) - get_filename_component(LIBNAME ${LLVM_DEBUG_LIB} ABSOLUTE) - list(APPEND LLVM_LIBS debug ${LIBNAME}) - endforeach(LLVM_DEBUG_LIB) - - set(LLVM_LIBRARY ${LLVM_LIBS}) - else() - message(WARNING "LLVM debug libs not present on this system. Using release libs for debug builds.") - set(LLVM_LIBRARY ${LLVM_LIBRARY_OPTIMIZED}) - endif() - - endif() - - if(WITH_OPENCOLORIO) - set(OPENCOLORIO ${LIBDIR}/opencolorio) - set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include) - set(OPENCOLORIO_LIBRARIES OpenColorIO) - set(OPENCOLORIO_LIBPATH ${LIBDIR}/opencolorio/lib) - set(OPENCOLORIO_DEFINITIONS) - endif() - - if(WITH_OPENVDB) - set(BLOSC_LIBRARIES optimized ${LIBDIR}/blosc/lib/libblosc.lib debug ${LIBDIR}/blosc/lib/libblosc_d.lib) - set(TBB_LIBRARIES optimized ${LIBDIR}/tbb/lib/tbb.lib debug ${LIBDIR}/tbb/lib/tbb_debug.lib) - set(TBB_INCLUDE_DIR ${LIBDIR}/tbb/include) - set(OPENVDB ${LIBDIR}/openvdb) - set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include ${TBB_INCLUDE_DIR}) - set(OPENVDB_LIBRARIES optimized openvdb debug openvdb_d ${TBB_LIBRARIES} ${BLOSC_LIBRARIES}) - set(OPENVDB_LIBPATH ${LIBDIR}/openvdb/lib) - endif() - - if(WITH_ALEMBIC) - set(ALEMBIC ${LIBDIR}/alembic) - set(ALEMBIC_INCLUDE_DIR ${ALEMBIC}/include) - set(ALEMBIC_INCLUDE_DIRS ${ALEMBIC_INCLUDE_DIR}) - set(ALEMBIC_LIBPATH ${ALEMBIC}/lib) - set(ALEMBIC_LIBRARIES optimized alembic debug alembic_d) - endif() - - if(WITH_MOD_CLOTH_ELTOPO) - set(LAPACK ${LIBDIR}/lapack) - # set(LAPACK_INCLUDE_DIR ${LAPACK}/include) - set(LAPACK_LIBPATH ${LAPACK}/lib) - set(LAPACK_LIBRARIES - ${LIBDIR}/lapack/lib/libf2c.lib - ${LIBDIR}/lapack/lib/clapack_nowrap.lib - ${LIBDIR}/lapack/lib/BLAS_nowrap.lib - ) - endif() - - if(WITH_OPENSUBDIV) - set(OPENSUBDIV_INCLUDE_DIR ${LIBDIR}/opensubdiv/include) - set(OPENSUBDIV_LIBPATH ${LIBDIR}/opensubdiv/lib) - set(OPENSUBDIV_LIBRARIES ${OPENSUBDIV_LIBPATH}/osdCPU.lib ${OPENSUBDIV_LIBPATH}/osdGPU.lib) - find_package(OpenSubdiv) - endif() - - if(WITH_SDL) - set(SDL ${LIBDIR}/sdl) - set(SDL_INCLUDE_DIR ${SDL}/include) - set(SDL_LIBPATH ${SDL}/lib) - # MinGW TODO: Update MinGW to SDL2 - if(NOT CMAKE_COMPILER_IS_GNUCC) - set(SDL_LIBRARY SDL2) - else() - set(SDL_LIBRARY SDL) - endif() - endif() - - # Audio IO - if(WITH_SYSTEM_AUDASPACE) - set(AUDASPACE_INCLUDE_DIRS ${LIBDIR}/audaspace/include/audaspace) - set(AUDASPACE_LIBRARIES ${LIBDIR}/audaspace/lib/audaspace.lib) - set(AUDASPACE_C_INCLUDE_DIRS ${LIBDIR}/audaspace/include/audaspace) - set(AUDASPACE_C_LIBRARIES ${LIBDIR}/audaspace/lib/audaspace-c.lib) - set(AUDASPACE_PY_INCLUDE_DIRS ${LIBDIR}/audaspace/include/audaspace) - set(AUDASPACE_PY_LIBRARIES ${LIBDIR}/audaspace/lib/audaspace-py.lib) - endif() - - # used in many places so include globally, like OpenGL - blender_include_dirs_sys("${PTHREADS_INCLUDE_DIRS}") - - elseif(CMAKE_COMPILER_IS_GNUCC) - # keep GCC specific stuff here - include(CheckCSourceCompiles) - # Setup 64bit and 64bit windows systems - CHECK_C_SOURCE_COMPILES(" - #ifndef __MINGW64__ - #error - #endif - int main(void) { return 0; } - " - WITH_MINGW64 - ) - - if(NOT DEFINED LIBDIR) - if(WITH_MINGW64) - message(STATUS "Compiling for 64 bit with MinGW-w64.") - set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw64) - else() - message(STATUS "Compiling for 32 bit with MinGW-w32.") - set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw32) - - if(WITH_RAYOPTIMIZATION) - message(WARNING "MinGW-w32 is known to be unstable with 'WITH_RAYOPTIMIZATION' option enabled.") - endif() - endif() - else() - message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}") - endif() - if(NOT EXISTS "${LIBDIR}/") - message(FATAL_ERROR "Windows requires pre-compiled libs at: '${LIBDIR}'") - endif() - - list(APPEND PLATFORM_LINKLIBS - -lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 - -lz -lstdc++ -lole32 -luuid -lwsock32 -lpsapi -ldbghelp - ) - - if(WITH_INPUT_IME) - list(APPEND PLATFORM_LINKLIBS -limm32) - endif() - - set(PLATFORM_CFLAGS "-pipe -funsigned-char -fno-strict-aliasing") - - if(WITH_MINGW64) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive") - list(APPEND PLATFORM_LINKLIBS -lpthread) - - add_definitions(-DFREE_WINDOWS64 -DMS_WIN64) - endif() - - add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE) - - add_definitions(-DFREE_WINDOWS) - - set(PNG "${LIBDIR}/png") - set(PNG_INCLUDE_DIRS "${PNG}/include") - set(PNG_LIBPATH ${PNG}/lib) # not cmake defined - - if(WITH_MINGW64) - set(JPEG_LIBRARIES jpeg) - else() - set(JPEG_LIBRARIES libjpeg) - endif() - set(PNG_LIBRARIES png) - - set(ZLIB ${LIBDIR}/zlib) - set(ZLIB_INCLUDE_DIRS ${ZLIB}/include) - set(ZLIB_LIBPATH ${ZLIB}/lib) - set(ZLIB_LIBRARIES z) - - set(JPEG "${LIBDIR}/jpeg") - set(JPEG_INCLUDE_DIR "${JPEG}/include") - set(JPEG_LIBPATH ${JPEG}/lib) # not cmake defined - - # comes with own pthread library - if(NOT WITH_MINGW64) - set(PTHREADS ${LIBDIR}/pthreads) - #set(PTHREADS_INCLUDE_DIRS ${PTHREADS}/include) - set(PTHREADS_LIBPATH ${PTHREADS}/lib) - set(PTHREADS_LIBRARIES pthreadGC2) - endif() - - set(FREETYPE ${LIBDIR}/freetype) - set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2) - set(FREETYPE_LIBPATH ${FREETYPE}/lib) - set(FREETYPE_LIBRARY freetype) - - if(WITH_FFTW3) - set(FFTW3 ${LIBDIR}/fftw3) - set(FFTW3_LIBRARIES fftw3) - set(FFTW3_INCLUDE_DIRS ${FFTW3}/include) - set(FFTW3_LIBPATH ${FFTW3}/lib) - endif() - - if(WITH_OPENCOLLADA) - set(OPENCOLLADA ${LIBDIR}/opencollada) - set(OPENCOLLADA_INCLUDE_DIRS - ${OPENCOLLADA}/include/opencollada/COLLADAStreamWriter - ${OPENCOLLADA}/include/opencollada/COLLADABaseUtils - ${OPENCOLLADA}/include/opencollada/COLLADAFramework - ${OPENCOLLADA}/include/opencollada/COLLADASaxFrameworkLoader - ${OPENCOLLADA}/include/opencollada/GeneratedSaxParser - ) - set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib/opencollada) - set(OPENCOLLADA_LIBRARIES - OpenCOLLADAStreamWriter - OpenCOLLADASaxFrameworkLoader - OpenCOLLADAFramework - OpenCOLLADABaseUtils - GeneratedSaxParser - UTF MathMLSolver buffer ftoa xml - ) - set(PCRE_LIBRARIES pcre) - endif() - - if(WITH_CODEC_FFMPEG) - set(FFMPEG ${LIBDIR}/ffmpeg) - set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include) - if(WITH_MINGW64) - set(FFMPEG_LIBRARIES avcodec.dll avformat.dll avdevice.dll avutil.dll swscale.dll swresample.dll) - else() - set(FFMPEG_LIBRARIES avcodec-55 avformat-55 avdevice-55 avutil-52 swscale-2) - endif() - set(FFMPEG_LIBPATH ${FFMPEG}/lib) - endif() - - if(WITH_IMAGE_OPENEXR) - set(OPENEXR ${LIBDIR}/openexr) - set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include) - set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR) - set(OPENEXR_LIBRARIES Half IlmImf Imath IlmThread Iex) - set(OPENEXR_LIBPATH ${OPENEXR}/lib) - endif() - - if(WITH_IMAGE_TIFF) - set(TIFF ${LIBDIR}/tiff) - set(TIFF_LIBRARY tiff) - set(TIFF_INCLUDE_DIR ${TIFF}/include) - set(TIFF_LIBPATH ${TIFF}/lib) - endif() - - if(WITH_JACK) - set(JACK ${LIBDIR}/jack) - set(JACK_INCLUDE_DIRS ${JACK}/include/jack ${JACK}/include) - set(JACK_LIBRARIES jack) - set(JACK_LIBPATH ${JACK}/lib) - - # TODO, gives linking errors, force off - set(WITH_JACK OFF) - endif() - - if(WITH_PYTHON) - # normally cached but not since we include them with blender - set(PYTHON_VERSION 3.5) # CACHE STRING) - string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION}) - set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}") # CACHE PATH) - set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}mw.lib") # CACHE FILEPATH) - unset(_PYTHON_VERSION_NO_DOTS) - - # uncached vars - set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") - set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}") - endif() - - if(WITH_BOOST) - set(BOOST ${LIBDIR}/boost) - set(BOOST_INCLUDE_DIR ${BOOST}/include) - if(WITH_MINGW64) - set(BOOST_POSTFIX "mgw47-mt-s-1_49") - set(BOOST_DEBUG_POSTFIX "mgw47-mt-sd-1_49") - else() - set(BOOST_POSTFIX "mgw46-mt-s-1_49") - set(BOOST_DEBUG_POSTFIX "mgw46-mt-sd-1_49") - endif() - set(BOOST_LIBRARIES - optimized boost_date_time-${BOOST_POSTFIX} boost_filesystem-${BOOST_POSTFIX} - boost_regex-${BOOST_POSTFIX} - boost_system-${BOOST_POSTFIX} boost_thread-${BOOST_POSTFIX} - debug boost_date_time-${BOOST_DEBUG_POSTFIX} boost_filesystem-${BOOST_DEBUG_POSTFIX} - boost_regex-${BOOST_DEBUG_POSTFIX} - boost_system-${BOOST_DEBUG_POSTFIX} boost_thread-${BOOST_DEBUG_POSTFIX}) - if(WITH_INTERNATIONAL) - set(BOOST_LIBRARIES ${BOOST_LIBRARIES} - optimized boost_locale-${BOOST_POSTFIX} - debug boost_locale-${BOOST_DEBUG_POSTFIX} - ) - endif() - if(WITH_CYCLES_OSL) - set(BOOST_LIBRARIES ${BOOST_LIBRARIES} - optimized boost_wave-${BOOST_POSTFIX} - debug boost_wave-${BOOST_DEBUG_POSTFIX} - ) - endif() - set(BOOST_LIBPATH ${BOOST}/lib) - set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB -DBOOST_THREAD_USE_LIB ") - endif() - - if(WITH_OPENIMAGEIO) - set(OPENIMAGEIO ${LIBDIR}/openimageio) - set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include) - set(OPENIMAGEIO_LIBRARIES OpenImageIO) - set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib) - set(OPENIMAGEIO_DEFINITIONS "") - set(OPENIMAGEIO_IDIFF "${OPENIMAGEIO}/bin/idiff.exe") - endif() - - if(WITH_LLVM) - set(LLVM_ROOT_DIR ${LIBDIR}/llvm CACHE PATH "Path to the LLVM installation") - set(LLVM_LIBPATH ${LLVM_ROOT_DIR}/lib) - # Explicitly set llvm lib order. - #---- WARNING ON GCC ORDER OF LIBS IS IMPORTANT, DO NOT CHANGE! --------- - set(LLVM_LIBRARY LLVMSelectionDAG LLVMCodeGen LLVMScalarOpts LLVMAnalysis LLVMArchive - LLVMAsmParser LLVMAsmPrinter - LLVMBitReader LLVMBitWriter - LLVMDebugInfo LLVMExecutionEngine - LLVMInstCombine LLVMInstrumentation - LLVMInterpreter LLVMJIT - LLVMLinker LLVMMC - LLVMMCDisassembler LLVMMCJIT - LLVMMCParser LLVMObject - LLVMRuntimeDyld - LLVMSupport - LLVMTableGen LLVMTarget - LLVMTransformUtils LLVMVectorize - LLVMX86AsmParser LLVMX86AsmPrinter - LLVMX86CodeGen LLVMX86Desc - LLVMX86Disassembler LLVMX86Info - LLVMX86Utils LLVMipa - LLVMipo LLVMCore) - # imagehelp is needed by LLVM 3.1 on MinGW, check lib\Support\Windows\Signals.inc - list(APPEND PLATFORM_LINKLIBS -limagehlp) - endif() - - if(WITH_OPENCOLORIO) - set(OPENCOLORIO ${LIBDIR}/opencolorio) - set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include) - set(OPENCOLORIO_LIBRARIES OpenColorIO) - set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib) - set(OPENCOLORIO_DEFINITIONS) - endif() - - if(WITH_SDL) - set(SDL ${LIBDIR}/sdl) - set(SDL_INCLUDE_DIR ${SDL}/include) - set(SDL_LIBRARY SDL) - set(SDL_LIBPATH ${SDL}/lib) - endif() - - if(WITH_OPENVDB) - set(OPENVDB ${LIBDIR}/openvdb) - set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include) - set(OPENVDB_LIBRARIES openvdb ${TBB_LIBRARIES}) - set(OPENVDB_LIBPATH ${LIBDIR}/openvdb/lib) - set(OPENVDB_DEFINITIONS) - endif() - - if(WITH_ALEMBIC) - # TODO(sergey): For until someone drops by and compiles libraries for - # MinGW we allow users to compile their own Alembic library and use - # that via find_package(), - # - # Once precompiled libraries are there we'll use hardcoded locations. - find_package_wrapper(Alembic) - if(WITH_ALEMBIC_HDF5) - set(HDF5_ROOT_DIR ${LIBDIR}/hdf5) - find_package_wrapper(HDF5) - endif() - if(NOT ALEMBIC_FOUND OR (WITH_ALEMBIC_HDF5 AND NOT HDF5_FOUND)) - set(WITH_ALEMBIC OFF) - set(WITH_ALEMBIC_HDF5 OFF) - endif() - endif() - - set(PLATFORM_LINKFLAGS "-Xlinker --stack=2097152") - - ## DISABLE - causes linking errors - ## for re-distribution, so users dont need mingw installed - # set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -static-libgcc -static-libstdc++") - - endif() - - # Things common to both mingw and MSVC should go here - - set(WINTAB_INC ${LIBDIR}/wintab/include) - - if(WITH_OPENAL) - set(OPENAL ${LIBDIR}/openal) - set(OPENALDIR ${LIBDIR}/openal) - set(OPENAL_INCLUDE_DIR ${OPENAL}/include) - if(MSVC) - set(OPENAL_LIBRARY openal32) - else() - set(OPENAL_LIBRARY wrap_oal) - endif() - set(OPENAL_LIBPATH ${OPENAL}/lib) - endif() - - if(WITH_CODEC_SNDFILE) - set(SNDFILE ${LIBDIR}/sndfile) - set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include) - set(SNDFILE_LIBRARIES libsndfile-1) - set(SNDFILE_LIBPATH ${SNDFILE}/lib) # TODO, deprecate - endif() - - if(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD) - add_definitions(-D__SSE__ -D__MMX__) - endif() - - if(WITH_CYCLES_OSL) - set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation") - - find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib) - find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib) - find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib) - find_library(OSL_LIB_EXEC_DEBUG NAMES oslexec_d PATHS ${CYCLES_OSL}/lib) - find_library(OSL_LIB_COMP_DEBUG NAMES oslcomp_d PATHS ${CYCLES_OSL}/lib) - find_library(OSL_LIB_QUERY_DEBUG NAMES oslquery_d PATHS ${CYCLES_OSL}/lib) - list(APPEND OSL_LIBRARIES - optimized ${OSL_LIB_COMP} - optimized ${OSL_LIB_EXEC} - optimized ${OSL_LIB_QUERY} - debug ${OSL_LIB_EXEC_DEBUG} - debug ${OSL_LIB_COMP_DEBUG} - debug ${OSL_LIB_QUERY_DEBUG} - ) - find_path(OSL_INCLUDE_DIR OSL/oslclosure.h PATHS ${CYCLES_OSL}/include) - find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin) - - if(OSL_INCLUDE_DIR AND OSL_LIBRARIES AND OSL_COMPILER) - set(OSL_FOUND TRUE) - else() - message(STATUS "OSL not found") - set(WITH_CYCLES_OSL OFF) - endif() - endif() - + include(platform_win32) elseif(APPLE) - - if(NOT DEFINED LIBDIR) - set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal) - else() - message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}") - endif() - if(NOT EXISTS "${LIBDIR}/") - message(FATAL_ERROR "Mac OSX requires pre-compiled libs at: '${LIBDIR}'") - endif() - - if(WITH_OPENAL) - find_package(OpenAL) - if(OPENAL_FOUND) - set(WITH_OPENAL ON) - set(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include") - else() - set(WITH_OPENAL OFF) - endif() - endif() - - if(WITH_ALEMBIC) - set(ALEMBIC ${LIBDIR}/alembic) - set(ALEMBIC_INCLUDE_DIR ${ALEMBIC}/include) - set(ALEMBIC_INCLUDE_DIRS ${ALEMBIC_INCLUDE_DIR}) - set(ALEMBIC_LIBPATH ${ALEMBIC}/lib) - set(ALEMBIC_LIBRARIES Alembic) - endif() - - if(WITH_OPENSUBDIV) - set(OPENSUBDIV ${LIBDIR}/opensubdiv) - set(OPENSUBDIV_LIBPATH ${OPENSUBDIV}/lib) - find_library(OSL_LIB_UTIL NAMES osdutil PATHS ${OPENSUBDIV_LIBPATH}) - find_library(OSL_LIB_CPU NAMES osdCPU PATHS ${OPENSUBDIV_LIBPATH}) - find_library(OSL_LIB_GPU NAMES osdGPU PATHS ${OPENSUBDIV_LIBPATH}) - set(OPENSUBDIV_INCLUDE_DIR ${OPENSUBDIV}/include) - set(OPENSUBDIV_INCLUDE_DIRS ${OPENSUBDIV_INCLUDE_DIR}) - list(APPEND OPENSUBDIV_LIBRARIES ${OSL_LIB_UTIL} ${OSL_LIB_CPU} ${OSL_LIB_GPU}) - endif() - - if(WITH_JACK) - find_library(JACK_FRAMEWORK - NAMES jackmp - ) - set(JACK_INCLUDE_DIRS ${JACK_FRAMEWORK}/headers) - if(NOT JACK_FRAMEWORK) - set(WITH_JACK OFF) - endif() - endif() - - if(WITH_CODEC_SNDFILE) - set(SNDFILE ${LIBDIR}/sndfile) - set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include) - set(SNDFILE_LIBRARIES sndfile FLAC ogg vorbis vorbisenc) - set(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib) # TODO, deprecate - endif() - - if(WITH_PYTHON) - # we use precompiled libraries for py 3.5 and up by default - set(PYTHON_VERSION 3.5) - if(NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK) - # normally cached but not since we include them with blender - set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}m") - set(PYTHON_EXECUTABLE "${LIBDIR}/python/bin/python${PYTHON_VERSION}m") - set(PYTHON_LIBRARY python${PYTHON_VERSION}m) - set(PYTHON_LIBPATH "${LIBDIR}/python/lib/python${PYTHON_VERSION}") - # set(PYTHON_LINKFLAGS "-u _PyMac_Error") # won't build with this enabled - else() - # module must be compiled against Python framework - set(_py_framework "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}") - - set(PYTHON_INCLUDE_DIR "${_py_framework}/include/python${PYTHON_VERSION}m") - set(PYTHON_EXECUTABLE "${_py_framework}/bin/python${PYTHON_VERSION}m") - set(PYTHON_LIBPATH "${_py_framework}/lib/python${PYTHON_VERSION}/config-${PYTHON_VERSION}m") - #set(PYTHON_LIBRARY python${PYTHON_VERSION}) - #set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework Python") # won't build with this enabled - - unset(_py_framework) - endif() - - # uncached vars - set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") - set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}") - - if(NOT EXISTS "${PYTHON_EXECUTABLE}") - message(FATAL_ERROR "Python executable missing: ${PYTHON_EXECUTABLE}") - endif() - endif() - - if(WITH_FFTW3) - set(FFTW3 ${LIBDIR}/fftw3) - set(FFTW3_INCLUDE_DIRS ${FFTW3}/include) - set(FFTW3_LIBRARIES fftw3) - set(FFTW3_LIBPATH ${FFTW3}/lib) - endif() - - set(PNG_LIBRARIES png) - set(JPEG_LIBRARIES jpeg) - - set(ZLIB /usr) - set(ZLIB_INCLUDE_DIRS "${ZLIB}/include") - set(ZLIB_LIBRARIES z bz2) - - set(FREETYPE ${LIBDIR}/freetype) - set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2) - set(FREETYPE_LIBPATH ${FREETYPE}/lib) - set(FREETYPE_LIBRARY freetype) - - if(WITH_IMAGE_OPENEXR) - set(OPENEXR ${LIBDIR}/openexr) - set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include) - set(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR}/include/OpenEXR) - set(OPENEXR_LIBRARIES Iex Half IlmImf Imath IlmThread) - set(OPENEXR_LIBPATH ${OPENEXR}/lib) - endif() - - if(WITH_CODEC_FFMPEG) - set(FFMPEG ${LIBDIR}/ffmpeg) - set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include) - set(FFMPEG_LIBRARIES - avcodec avdevice avformat avutil - mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg - ) - set(FFMPEG_LIBPATH ${FFMPEG}/lib) - endif() - - find_library(SYSTEMSTUBS_LIBRARY - NAMES - SystemStubs - PATHS - ) - mark_as_advanced(SYSTEMSTUBS_LIBRARY) - if(SYSTEMSTUBS_LIBRARY) - list(APPEND PLATFORM_LINKLIBS SystemStubs) - endif() - - set(PLATFORM_CFLAGS "-pipe -funsigned-char") - set(PLATFORM_LINKFLAGS - "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio" - ) - if(WITH_CODEC_QUICKTIME) - set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit") - if(CMAKE_OSX_ARCHITECTURES MATCHES i386) - set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime") - # libSDL still needs 32bit carbon quicktime - endif() - endif() - - if(WITH_CXX11) - list(APPEND PLATFORM_LINKLIBS c++) - else() - list(APPEND PLATFORM_LINKLIBS stdc++) - endif() - - if(WITH_JACK) - set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -F/Library/Frameworks -weak_framework jackmp") - endif() - - if(WITH_PYTHON_MODULE OR WITH_PYTHON_FRAMEWORK) - # force cmake to link right framework - set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/Python") - endif() - - if(WITH_OPENCOLLADA) - set(OPENCOLLADA ${LIBDIR}/opencollada) - - set(OPENCOLLADA_INCLUDE_DIRS - ${LIBDIR}/opencollada/include/COLLADAStreamWriter - ${LIBDIR}/opencollada/include/COLLADABaseUtils - ${LIBDIR}/opencollada/include/COLLADAFramework - ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader - ${LIBDIR}/opencollada/include/GeneratedSaxParser - ) - - set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib) - set(OPENCOLLADA_LIBRARIES - OpenCOLLADASaxFrameworkLoader - -lOpenCOLLADAFramework - -lOpenCOLLADABaseUtils - -lOpenCOLLADAStreamWriter - -lMathMLSolver - -lGeneratedSaxParser - -lxml2 -lbuffer -lftoa - ) - # Use UTF functions from collada if LLVM is not enabled - if(NOT WITH_LLVM) - list(APPEND OPENCOLLADA_LIBRARIES -lUTF) - endif() - # pcre is bundled with openCollada - #set(PCRE ${LIBDIR}/pcre) - #set(PCRE_LIBPATH ${PCRE}/lib) - set(PCRE_LIBRARIES pcre) - #libxml2 is used - #set(EXPAT ${LIBDIR}/expat) - #set(EXPAT_LIBPATH ${EXPAT}/lib) - set(EXPAT_LIB) - endif() - - if(WITH_SDL) - set(SDL ${LIBDIR}/sdl) - set(SDL_INCLUDE_DIR ${SDL}/include) - set(SDL_LIBRARY SDL2) - set(SDL_LIBPATH ${SDL}/lib) - set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -lazy_framework ForceFeedback") - endif() - - set(PNG "${LIBDIR}/png") - set(PNG_INCLUDE_DIRS "${PNG}/include") - set(PNG_LIBPATH ${PNG}/lib) - - set(JPEG "${LIBDIR}/jpeg") - set(JPEG_INCLUDE_DIR "${JPEG}/include") - set(JPEG_LIBPATH ${JPEG}/lib) - - if(WITH_IMAGE_TIFF) - set(TIFF ${LIBDIR}/tiff) - set(TIFF_INCLUDE_DIR ${TIFF}/include) - set(TIFF_LIBRARY tiff) - set(TIFF_LIBPATH ${TIFF}/lib) - endif() - - if(WITH_BOOST) - set(BOOST ${LIBDIR}/boost) - set(BOOST_INCLUDE_DIR ${BOOST}/include) - set(BOOST_LIBRARIES - boost_date_time-mt - boost_filesystem-mt - boost_regex-mt - boost_system-mt - boost_thread-mt - boost_wave-mt - ) - if(WITH_INTERNATIONAL) - list(APPEND BOOST_LIBRARIES boost_locale-mt) - endif() - if(WITH_CYCLES_NETWORK) - list(APPEND BOOST_LIBRARIES boost_serialization-mt) - endif() - if(WITH_OPENVDB) - list(APPEND BOOST_LIBRARIES boost_iostreams-mt) - endif() - set(BOOST_LIBPATH ${BOOST}/lib) - set(BOOST_DEFINITIONS) - endif() - - if(WITH_INTERNATIONAL OR WITH_CODEC_FFMPEG) - set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -liconv") # boost_locale and ffmpeg needs it ! - endif() - - if(WITH_OPENIMAGEIO) - set(OPENIMAGEIO ${LIBDIR}/openimageio) - set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include) - set(OPENIMAGEIO_LIBRARIES - ${OPENIMAGEIO}/lib/libOpenImageIO.a - ${PNG_LIBRARIES} - ${JPEG_LIBRARIES} - ${TIFF_LIBRARY} - ${OPENEXR_LIBRARIES} - ${ZLIB_LIBRARIES} - ) - set(OPENIMAGEIO_LIBPATH - ${OPENIMAGEIO}/lib - ${JPEG_LIBPATH} - ${PNG_LIBPATH} - ${TIFF_LIBPATH} - ${OPENEXR_LIBPATH} - ${ZLIB_LIBPATH} - ) - set(OPENIMAGEIO_DEFINITIONS "-DOIIO_STATIC_BUILD") - set(OPENIMAGEIO_IDIFF "${LIBDIR}/openimageio/bin/idiff") - endif() - - if(WITH_OPENCOLORIO) - set(OPENCOLORIO ${LIBDIR}/opencolorio) - set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include) - set(OPENCOLORIO_LIBRARIES OpenColorIO tinyxml yaml-cpp) - set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib) - endif() - - if(WITH_OPENVDB) - set(OPENVDB ${LIBDIR}/openvdb) - set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include) - set(TBB_INCLUDE_DIRS ${LIBDIR}/tbb/include) - set(TBB_LIBRARIES ${LIBDIR}/tbb/lib/libtbb.a) - set(OPENVDB_LIBRARIES openvdb blosc ${TBB_LIBRARIES}) - set(OPENVDB_LIBPATH ${LIBDIR}/openvdb/lib) - set(OPENVDB_DEFINITIONS) - endif() - - if(WITH_LLVM) - set(LLVM_ROOT_DIR ${LIBDIR}/llvm CACHE PATH "Path to the LLVM installation") - set(LLVM_VERSION "3.4" CACHE STRING "Version of LLVM to use") - if(EXISTS "${LLVM_ROOT_DIR}/bin/llvm-config") - set(LLVM_CONFIG "${LLVM_ROOT_DIR}/bin/llvm-config") - else() - set(LLVM_CONFIG llvm-config) - endif() - execute_process(COMMAND ${LLVM_CONFIG} --version - OUTPUT_VARIABLE LLVM_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND ${LLVM_CONFIG} --prefix - OUTPUT_VARIABLE LLVM_ROOT_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND ${LLVM_CONFIG} --libdir - OUTPUT_VARIABLE LLVM_LIBPATH - OUTPUT_STRIP_TRAILING_WHITESPACE) - find_library(LLVM_LIBRARY - NAMES LLVMAnalysis # first of a whole bunch of libs to get - PATHS ${LLVM_LIBPATH}) - - if(LLVM_LIBRARY AND LLVM_ROOT_DIR AND LLVM_LIBPATH) - if(LLVM_STATIC) - # if static LLVM libraries were requested, use llvm-config to generate - # the list of what libraries we need, and substitute that in the right - # way for LLVM_LIBRARY. - execute_process(COMMAND ${LLVM_CONFIG} --libfiles - OUTPUT_VARIABLE LLVM_LIBRARY - OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY}) - else() - set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -lLLVM-3.4") - endif() - else() - message(FATAL_ERROR "LLVM not found.") - endif() - endif() - - if(WITH_CYCLES_OSL) - set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation") - - find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib) - find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib) - find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib) - # WARNING! depends on correct order of OSL libs linking - list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} -force_load ${OSL_LIB_EXEC} ${OSL_LIB_QUERY}) - find_path(OSL_INCLUDE_DIR OSL/oslclosure.h PATHS ${CYCLES_OSL}/include) - find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin) - - if(OSL_INCLUDE_DIR AND OSL_LIBRARIES AND OSL_COMPILER) - set(OSL_FOUND TRUE) - else() - message(STATUS "OSL not found") - set(WITH_CYCLES_OSL OFF) - endif() - endif() - - if(WITH_OPENMP) - execute_process(COMMAND ${CMAKE_C_COMPILER} --version OUTPUT_VARIABLE COMPILER_VENDOR) - string(SUBSTRING "${COMPILER_VENDOR}" 0 5 VENDOR_NAME) # truncate output - if(${VENDOR_NAME} MATCHES "Apple") # Apple does not support OpenMP reliable with gcc and not with clang - set(WITH_OPENMP OFF) - else() # vanilla gcc or clang_omp support OpenMP - message(STATUS "Using special OpenMP enabled compiler !") # letting find_package(OpenMP) module work for gcc - if(CMAKE_C_COMPILER_ID MATCHES "Clang") # clang-omp in darwin libs - set(OPENMP_FOUND ON) - set(OpenMP_C_FLAGS "-fopenmp" CACHE STRING "C compiler flags for OpenMP parallization" FORCE) - set(OpenMP_CXX_FLAGS "-fopenmp" CACHE STRING "C++ compiler flags for OpenMP parallization" FORCE) - include_directories(${LIBDIR}/openmp/include) - link_directories(${LIBDIR}/openmp/lib) - # This is a workaround for our helperbinaries ( datatoc, masgfmt, ... ), - # They are linked also to omp lib, so we need it in builddir for runtime exexcution, - # TODO: remove all unneeded dependencies from these - - # for intermediate binaries, in respect to lib ID - execute_process( - COMMAND ditto -arch ${CMAKE_OSX_ARCHITECTURES} - ${LIBDIR}/openmp/lib/libiomp5.dylib - ${CMAKE_BINARY_DIR}/Resources/lib/libiomp5.dylib) - endif() - endif() - endif() - - set(EXETYPE MACOSX_BUNDLE) - - set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g") - set(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g") - if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR CMAKE_OSX_ARCHITECTURES MATCHES "i386") - set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -msse -msse2 -msse3 -mssse3") - set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic -msse -msse2 -msse3 -mssse3") - if(NOT CMAKE_C_COMPILER_ID MATCHES "Clang") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ftree-vectorize -fvariable-expansion-in-unroller") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ftree-vectorize -fvariable-expansion-in-unroller") - endif() - else() - set(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing") - set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing") - endif() - - if(${XCODE_VERSION} VERSION_EQUAL 5 OR ${XCODE_VERSION} VERSION_GREATER 5) - # Xcode 5 is always using CLANG, which has too low template depth of 128 for libmv - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=1024") - endif() - # Get rid of eventually clashes, we export some symbols explicite as local - set(PLATFORM_LINKFLAGS - "${PLATFORM_LINKFLAGS} -Xlinker -unexported_symbols_list -Xlinker ${CMAKE_SOURCE_DIR}/source/creator/osx_locals.map" - ) - - if(WITH_CXX11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") - set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -stdlib=libc++") - endif() - - # Suppress ranlib "has no symbols" warnings (workaround for T48250) - set(CMAKE_C_ARCHIVE_CREATE " Scr ") - set(CMAKE_CXX_ARCHIVE_CREATE " Scr ") - set(CMAKE_C_ARCHIVE_FINISH " -no_warning_for_no_symbols -c ") - set(CMAKE_CXX_ARCHIVE_FINISH " -no_warning_for_no_symbols -c ") + include(platform_apple) endif() #----------------------------------------------------------------------------- diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake new file mode 100644 index 00000000000..b28b74804d3 --- /dev/null +++ b/build_files/cmake/platform/platform_apple.cmake @@ -0,0 +1,430 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# The Original Code is Copyright (C) 2016, Blender Foundation +# All rights reserved. +# +# Contributor(s): Sergey Sharybin. +# +# ***** END GPL LICENSE BLOCK ***** + +# Libraries configuration for Apple. + +if(NOT DEFINED LIBDIR) + set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal) +else() + message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}") +endif() +if(NOT EXISTS "${LIBDIR}/") + message(FATAL_ERROR "Mac OSX requires pre-compiled libs at: '${LIBDIR}'") +endif() + +if(WITH_OPENAL) + find_package(OpenAL) + if(OPENAL_FOUND) + set(WITH_OPENAL ON) + set(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include") + else() + set(WITH_OPENAL OFF) + endif() +endif() + +if(WITH_ALEMBIC) + set(ALEMBIC ${LIBDIR}/alembic) + set(ALEMBIC_INCLUDE_DIR ${ALEMBIC}/include) + set(ALEMBIC_INCLUDE_DIRS ${ALEMBIC_INCLUDE_DIR}) + set(ALEMBIC_LIBPATH ${ALEMBIC}/lib) + set(ALEMBIC_LIBRARIES Alembic) +endif() + +if(WITH_OPENSUBDIV) + set(OPENSUBDIV ${LIBDIR}/opensubdiv) + set(OPENSUBDIV_LIBPATH ${OPENSUBDIV}/lib) + find_library(OSL_LIB_UTIL NAMES osdutil PATHS ${OPENSUBDIV_LIBPATH}) + find_library(OSL_LIB_CPU NAMES osdCPU PATHS ${OPENSUBDIV_LIBPATH}) + find_library(OSL_LIB_GPU NAMES osdGPU PATHS ${OPENSUBDIV_LIBPATH}) + set(OPENSUBDIV_INCLUDE_DIR ${OPENSUBDIV}/include) + set(OPENSUBDIV_INCLUDE_DIRS ${OPENSUBDIV_INCLUDE_DIR}) + list(APPEND OPENSUBDIV_LIBRARIES ${OSL_LIB_UTIL} ${OSL_LIB_CPU} ${OSL_LIB_GPU}) +endif() + +if(WITH_JACK) + find_library(JACK_FRAMEWORK + NAMES jackmp + ) + set(JACK_INCLUDE_DIRS ${JACK_FRAMEWORK}/headers) + if(NOT JACK_FRAMEWORK) + set(WITH_JACK OFF) + endif() +endif() + +if(WITH_CODEC_SNDFILE) + set(SNDFILE ${LIBDIR}/sndfile) + set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include) + set(SNDFILE_LIBRARIES sndfile FLAC ogg vorbis vorbisenc) + set(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib) # TODO, deprecate +endif() + +if(WITH_PYTHON) + # we use precompiled libraries for py 3.5 and up by default + set(PYTHON_VERSION 3.5) + if(NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK) + # normally cached but not since we include them with blender + set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}m") + set(PYTHON_EXECUTABLE "${LIBDIR}/python/bin/python${PYTHON_VERSION}m") + set(PYTHON_LIBRARY python${PYTHON_VERSION}m) + set(PYTHON_LIBPATH "${LIBDIR}/python/lib/python${PYTHON_VERSION}") + # set(PYTHON_LINKFLAGS "-u _PyMac_Error") # won't build with this enabled + else() + # module must be compiled against Python framework + set(_py_framework "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}") + + set(PYTHON_INCLUDE_DIR "${_py_framework}/include/python${PYTHON_VERSION}m") + set(PYTHON_EXECUTABLE "${_py_framework}/bin/python${PYTHON_VERSION}m") + set(PYTHON_LIBPATH "${_py_framework}/lib/python${PYTHON_VERSION}/config-${PYTHON_VERSION}m") + #set(PYTHON_LIBRARY python${PYTHON_VERSION}) + #set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework Python") # won't build with this enabled + + unset(_py_framework) + endif() + + # uncached vars + set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") + set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}") + + if(NOT EXISTS "${PYTHON_EXECUTABLE}") + message(FATAL_ERROR "Python executable missing: ${PYTHON_EXECUTABLE}") + endif() +endif() + +if(WITH_FFTW3) + set(FFTW3 ${LIBDIR}/fftw3) + set(FFTW3_INCLUDE_DIRS ${FFTW3}/include) + set(FFTW3_LIBRARIES fftw3) + set(FFTW3_LIBPATH ${FFTW3}/lib) +endif() + +set(PNG_LIBRARIES png) +set(JPEG_LIBRARIES jpeg) + +set(ZLIB /usr) +set(ZLIB_INCLUDE_DIRS "${ZLIB}/include") +set(ZLIB_LIBRARIES z bz2) + +set(FREETYPE ${LIBDIR}/freetype) +set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2) +set(FREETYPE_LIBPATH ${FREETYPE}/lib) +set(FREETYPE_LIBRARY freetype) + +if(WITH_IMAGE_OPENEXR) + set(OPENEXR ${LIBDIR}/openexr) + set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include) + set(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR}/include/OpenEXR) + set(OPENEXR_LIBRARIES Iex Half IlmImf Imath IlmThread) + set(OPENEXR_LIBPATH ${OPENEXR}/lib) +endif() + +if(WITH_CODEC_FFMPEG) + set(FFMPEG ${LIBDIR}/ffmpeg) + set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include) + set(FFMPEG_LIBRARIES + avcodec avdevice avformat avutil + mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg + ) + set(FFMPEG_LIBPATH ${FFMPEG}/lib) +endif() + +find_library(SYSTEMSTUBS_LIBRARY + NAMES + SystemStubs + PATHS +) +mark_as_advanced(SYSTEMSTUBS_LIBRARY) +if(SYSTEMSTUBS_LIBRARY) + list(APPEND PLATFORM_LINKLIBS SystemStubs) +endif() + +set(PLATFORM_CFLAGS "-pipe -funsigned-char") +set(PLATFORM_LINKFLAGS + "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio" +) +if(WITH_CODEC_QUICKTIME) + set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit") + if(CMAKE_OSX_ARCHITECTURES MATCHES i386) + set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime") + # libSDL still needs 32bit carbon quicktime + endif() +endif() + +if(WITH_CXX11) + list(APPEND PLATFORM_LINKLIBS c++) +else() + list(APPEND PLATFORM_LINKLIBS stdc++) +endif() + +if(WITH_JACK) + set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -F/Library/Frameworks -weak_framework jackmp") +endif() + +if(WITH_PYTHON_MODULE OR WITH_PYTHON_FRAMEWORK) + # force cmake to link right framework + set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/Python") +endif() + +if(WITH_OPENCOLLADA) + set(OPENCOLLADA ${LIBDIR}/opencollada) + + set(OPENCOLLADA_INCLUDE_DIRS + ${LIBDIR}/opencollada/include/COLLADAStreamWriter + ${LIBDIR}/opencollada/include/COLLADABaseUtils + ${LIBDIR}/opencollada/include/COLLADAFramework + ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader + ${LIBDIR}/opencollada/include/GeneratedSaxParser + ) + + set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib) + set(OPENCOLLADA_LIBRARIES + OpenCOLLADASaxFrameworkLoader + -lOpenCOLLADAFramework + -lOpenCOLLADABaseUtils + -lOpenCOLLADAStreamWriter + -lMathMLSolver + -lGeneratedSaxParser + -lxml2 -lbuffer -lftoa + ) + # Use UTF functions from collada if LLVM is not enabled + if(NOT WITH_LLVM) + list(APPEND OPENCOLLADA_LIBRARIES -lUTF) + endif() + # pcre is bundled with openCollada + #set(PCRE ${LIBDIR}/pcre) + #set(PCRE_LIBPATH ${PCRE}/lib) + set(PCRE_LIBRARIES pcre) + #libxml2 is used + #set(EXPAT ${LIBDIR}/expat) + #set(EXPAT_LIBPATH ${EXPAT}/lib) + set(EXPAT_LIB) +endif() + +if(WITH_SDL) + set(SDL ${LIBDIR}/sdl) + set(SDL_INCLUDE_DIR ${SDL}/include) + set(SDL_LIBRARY SDL2) + set(SDL_LIBPATH ${SDL}/lib) + set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -lazy_framework ForceFeedback") +endif() + +set(PNG "${LIBDIR}/png") +set(PNG_INCLUDE_DIRS "${PNG}/include") +set(PNG_LIBPATH ${PNG}/lib) + +set(JPEG "${LIBDIR}/jpeg") +set(JPEG_INCLUDE_DIR "${JPEG}/include") +set(JPEG_LIBPATH ${JPEG}/lib) + +if(WITH_IMAGE_TIFF) + set(TIFF ${LIBDIR}/tiff) + set(TIFF_INCLUDE_DIR ${TIFF}/include) + set(TIFF_LIBRARY tiff) + set(TIFF_LIBPATH ${TIFF}/lib) +endif() + +if(WITH_BOOST) + set(BOOST ${LIBDIR}/boost) + set(BOOST_INCLUDE_DIR ${BOOST}/include) + set(BOOST_LIBRARIES + boost_date_time-mt + boost_filesystem-mt + boost_regex-mt + boost_system-mt + boost_thread-mt + boost_wave-mt + ) + if(WITH_INTERNATIONAL) + list(APPEND BOOST_LIBRARIES boost_locale-mt) + endif() + if(WITH_CYCLES_NETWORK) + list(APPEND BOOST_LIBRARIES boost_serialization-mt) + endif() + if(WITH_OPENVDB) + list(APPEND BOOST_LIBRARIES boost_iostreams-mt) + endif() + set(BOOST_LIBPATH ${BOOST}/lib) + set(BOOST_DEFINITIONS) +endif() + +if(WITH_INTERNATIONAL OR WITH_CODEC_FFMPEG) + set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -liconv") # boost_locale and ffmpeg needs it ! +endif() + +if(WITH_OPENIMAGEIO) + set(OPENIMAGEIO ${LIBDIR}/openimageio) + set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include) + set(OPENIMAGEIO_LIBRARIES + ${OPENIMAGEIO}/lib/libOpenImageIO.a + ${PNG_LIBRARIES} + ${JPEG_LIBRARIES} + ${TIFF_LIBRARY} + ${OPENEXR_LIBRARIES} + ${ZLIB_LIBRARIES} + ) + set(OPENIMAGEIO_LIBPATH + ${OPENIMAGEIO}/lib + ${JPEG_LIBPATH} + ${PNG_LIBPATH} + ${TIFF_LIBPATH} + ${OPENEXR_LIBPATH} + ${ZLIB_LIBPATH} + ) + set(OPENIMAGEIO_DEFINITIONS "-DOIIO_STATIC_BUILD") + set(OPENIMAGEIO_IDIFF "${LIBDIR}/openimageio/bin/idiff") +endif() + +if(WITH_OPENCOLORIO) + set(OPENCOLORIO ${LIBDIR}/opencolorio) + set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include) + set(OPENCOLORIO_LIBRARIES OpenColorIO tinyxml yaml-cpp) + set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib) +endif() + +if(WITH_OPENVDB) + set(OPENVDB ${LIBDIR}/openvdb) + set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include) + set(TBB_INCLUDE_DIRS ${LIBDIR}/tbb/include) + set(TBB_LIBRARIES ${LIBDIR}/tbb/lib/libtbb.a) + set(OPENVDB_LIBRARIES openvdb blosc ${TBB_LIBRARIES}) + set(OPENVDB_LIBPATH ${LIBDIR}/openvdb/lib) + set(OPENVDB_DEFINITIONS) +endif() + +if(WITH_LLVM) + set(LLVM_ROOT_DIR ${LIBDIR}/llvm CACHE PATH "Path to the LLVM installation") + set(LLVM_VERSION "3.4" CACHE STRING "Version of LLVM to use") + if(EXISTS "${LLVM_ROOT_DIR}/bin/llvm-config") + set(LLVM_CONFIG "${LLVM_ROOT_DIR}/bin/llvm-config") + else() + set(LLVM_CONFIG llvm-config) + endif() + execute_process(COMMAND ${LLVM_CONFIG} --version + OUTPUT_VARIABLE LLVM_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${LLVM_CONFIG} --prefix + OUTPUT_VARIABLE LLVM_ROOT_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${LLVM_CONFIG} --libdir + OUTPUT_VARIABLE LLVM_LIBPATH + OUTPUT_STRIP_TRAILING_WHITESPACE) + find_library(LLVM_LIBRARY + NAMES LLVMAnalysis # first of a whole bunch of libs to get + PATHS ${LLVM_LIBPATH}) + + if(LLVM_LIBRARY AND LLVM_ROOT_DIR AND LLVM_LIBPATH) + if(LLVM_STATIC) + # if static LLVM libraries were requested, use llvm-config to generate + # the list of what libraries we need, and substitute that in the right + # way for LLVM_LIBRARY. + execute_process(COMMAND ${LLVM_CONFIG} --libfiles + OUTPUT_VARIABLE LLVM_LIBRARY + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY}) + else() + set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -lLLVM-3.4") + endif() + else() + message(FATAL_ERROR "LLVM not found.") + endif() +endif() + +if(WITH_CYCLES_OSL) + set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation") + + find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib) + find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib) + find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib) + # WARNING! depends on correct order of OSL libs linking + list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} -force_load ${OSL_LIB_EXEC} ${OSL_LIB_QUERY}) + find_path(OSL_INCLUDE_DIR OSL/oslclosure.h PATHS ${CYCLES_OSL}/include) + find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin) + + if(OSL_INCLUDE_DIR AND OSL_LIBRARIES AND OSL_COMPILER) + set(OSL_FOUND TRUE) + else() + message(STATUS "OSL not found") + set(WITH_CYCLES_OSL OFF) + endif() +endif() + +if(WITH_OPENMP) + execute_process(COMMAND ${CMAKE_C_COMPILER} --version OUTPUT_VARIABLE COMPILER_VENDOR) + string(SUBSTRING "${COMPILER_VENDOR}" 0 5 VENDOR_NAME) # truncate output + if(${VENDOR_NAME} MATCHES "Apple") # Apple does not support OpenMP reliable with gcc and not with clang + set(WITH_OPENMP OFF) + else() # vanilla gcc or clang_omp support OpenMP + message(STATUS "Using special OpenMP enabled compiler !") # letting find_package(OpenMP) module work for gcc + if(CMAKE_C_COMPILER_ID MATCHES "Clang") # clang-omp in darwin libs + set(OPENMP_FOUND ON) + set(OpenMP_C_FLAGS "-fopenmp" CACHE STRING "C compiler flags for OpenMP parallization" FORCE) + set(OpenMP_CXX_FLAGS "-fopenmp" CACHE STRING "C++ compiler flags for OpenMP parallization" FORCE) + include_directories(${LIBDIR}/openmp/include) + link_directories(${LIBDIR}/openmp/lib) + # This is a workaround for our helperbinaries ( datatoc, masgfmt, ... ), + # They are linked also to omp lib, so we need it in builddir for runtime exexcution, + # TODO: remove all unneeded dependencies from these + + # for intermediate binaries, in respect to lib ID + execute_process( + COMMAND ditto -arch ${CMAKE_OSX_ARCHITECTURES} + ${LIBDIR}/openmp/lib/libiomp5.dylib + ${CMAKE_BINARY_DIR}/Resources/lib/libiomp5.dylib) + endif() + endif() +endif() + +set(EXETYPE MACOSX_BUNDLE) + +set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g") +set(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g") +if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR CMAKE_OSX_ARCHITECTURES MATCHES "i386") + set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -msse -msse2 -msse3 -mssse3") + set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic -msse -msse2 -msse3 -mssse3") + if(NOT CMAKE_C_COMPILER_ID MATCHES "Clang") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ftree-vectorize -fvariable-expansion-in-unroller") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ftree-vectorize -fvariable-expansion-in-unroller") + endif() +else() + set(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing") + set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing") +endif() + +if(${XCODE_VERSION} VERSION_EQUAL 5 OR ${XCODE_VERSION} VERSION_GREATER 5) + # Xcode 5 is always using CLANG, which has too low template depth of 128 for libmv + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=1024") +endif() +# Get rid of eventually clashes, we export some symbols explicite as local +set(PLATFORM_LINKFLAGS + "${PLATFORM_LINKFLAGS} -Xlinker -unexported_symbols_list -Xlinker ${CMAKE_SOURCE_DIR}/source/creator/osx_locals.map" +) + +if(WITH_CXX11) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -stdlib=libc++") +endif() + +# Suppress ranlib "has no symbols" warnings (workaround for T48250) +set(CMAKE_C_ARCHIVE_CREATE " Scr ") +set(CMAKE_CXX_ARCHIVE_CREATE " Scr ") +set(CMAKE_C_ARCHIVE_FINISH " -no_warning_for_no_symbols -c ") +set(CMAKE_CXX_ARCHIVE_FINISH " -no_warning_for_no_symbols -c ") diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake new file mode 100644 index 00000000000..0e0dc382ca3 --- /dev/null +++ b/build_files/cmake/platform/platform_unix.cmake @@ -0,0 +1,425 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# The Original Code is Copyright (C) 2016, Blender Foundation +# All rights reserved. +# +# Contributor(s): Sergey Sharybin. +# +# ***** END GPL LICENSE BLOCK ***** + +# Libraries configuration for any *nix system including Linux and Unix. + +macro(find_package_wrapper) + if(WITH_STATIC_LIBS) + find_package_static(${ARGV}) + else() + find_package(${ARGV}) + endif() +endmacro() + +find_package_wrapper(JPEG REQUIRED) +find_package_wrapper(PNG REQUIRED) +find_package_wrapper(ZLIB REQUIRED) +find_package_wrapper(Freetype REQUIRED) + +if(WITH_LZO AND WITH_SYSTEM_LZO) + find_package_wrapper(LZO) + if(NOT LZO_FOUND) + message(FATAL_ERROR "Failed finding system LZO version!") + endif() +endif() + +if(WITH_SYSTEM_EIGEN3) + find_package_wrapper(Eigen3) + if(NOT EIGEN3_FOUND) + message(FATAL_ERROR "Failed finding system Eigen3 version!") + endif() +endif() +# else values are set below for all platforms + +if(WITH_PYTHON) + # No way to set py35, remove for now. + # find_package(PythonLibs) + + # Use our own instead, since without py is such a rare case, + # require this package + # XXX Linking errors with debian static python :/ +# find_package_wrapper(PythonLibsUnix REQUIRED) + find_package(PythonLibsUnix REQUIRED) +endif() + +if(WITH_IMAGE_OPENEXR) + find_package_wrapper(OpenEXR) # our own module + if(NOT OPENEXR_FOUND) + set(WITH_IMAGE_OPENEXR OFF) + endif() +endif() + +if(WITH_IMAGE_OPENJPEG) + find_package_wrapper(OpenJPEG) + if(NOT OPENJPEG_FOUND) + set(WITH_IMAGE_OPENJPEG OFF) + endif() +endif() + +if(WITH_IMAGE_TIFF) + # XXX Linking errors with debian static tiff :/ +# find_package_wrapper(TIFF) + find_package(TIFF) + if(NOT TIFF_FOUND) + set(WITH_IMAGE_TIFF OFF) + endif() +endif() + +# Audio IO +if(WITH_SYSTEM_AUDASPACE) + find_package_wrapper(Audaspace) + if(NOT AUDASPACE_FOUND OR NOT AUDASPACE_C_FOUND) + message(FATAL_ERROR "Audaspace external library not found!") + endif() +endif() + +if(WITH_OPENAL) + find_package_wrapper(OpenAL) + if(NOT OPENAL_FOUND) + set(WITH_OPENAL OFF) + endif() +endif() + +if(WITH_SDL) + if(WITH_SDL_DYNLOAD) + set(SDL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extern/sdlew/include/SDL2") + set(SDL_LIBRARY) + else() + find_package_wrapper(SDL2) + if(SDL2_FOUND) + # Use same names for both versions of SDL until we move to 2.x. + set(SDL_INCLUDE_DIR "${SDL2_INCLUDE_DIR}") + set(SDL_LIBRARY "${SDL2_LIBRARY}") + set(SDL_FOUND "${SDL2_FOUND}") + else() + find_package_wrapper(SDL) + endif() + mark_as_advanced( + SDL_INCLUDE_DIR + SDL_LIBRARY + ) + # unset(SDLMAIN_LIBRARY CACHE) + if(NOT SDL_FOUND) + set(WITH_SDL OFF) + endif() + endif() +endif() + +if(WITH_JACK) + find_package_wrapper(Jack) + if(NOT JACK_FOUND) + set(WITH_JACK OFF) + endif() +endif() + +# Codecs +if(WITH_CODEC_SNDFILE) + find_package_wrapper(SndFile) + if(NOT SNDFILE_FOUND) + set(WITH_CODEC_SNDFILE OFF) + endif() +endif() + +if(WITH_CODEC_FFMPEG) + set(FFMPEG /usr CACHE PATH "FFMPEG Directory") + set(FFMPEG_LIBRARIES avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries") + + mark_as_advanced(FFMPEG) + + # lame, but until we have proper find module for ffmpeg + set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include) + if(EXISTS "${FFMPEG}/include/ffmpeg/") + list(APPEND FFMPEG_INCLUDE_DIRS "${FFMPEG}/include/ffmpeg") + endif() + # end lameness + + mark_as_advanced(FFMPEG_LIBRARIES) + set(FFMPEG_LIBPATH ${FFMPEG}/lib) +endif() + +if(WITH_FFTW3) + find_package_wrapper(Fftw3) + if(NOT FFTW3_FOUND) + set(WITH_FFTW3 OFF) + endif() +endif() + +if(WITH_OPENCOLLADA) + find_package_wrapper(OpenCOLLADA) + if(OPENCOLLADA_FOUND) + find_package_wrapper(XML2) + find_package_wrapper(PCRE) + else() + set(WITH_OPENCOLLADA OFF) + endif() +endif() + +if(WITH_MEM_JEMALLOC) + find_package_wrapper(JeMalloc) + if(NOT JEMALLOC_FOUND) + set(WITH_MEM_JEMALLOC OFF) + endif() +endif() + +if(WITH_INPUT_NDOF) + find_package_wrapper(Spacenav) + if(SPACENAV_FOUND) + # use generic names within blenders buildsystem. + set(NDOF_INCLUDE_DIRS ${SPACENAV_INCLUDE_DIRS}) + set(NDOF_LIBRARIES ${SPACENAV_LIBRARIES}) + else() + set(WITH_INPUT_NDOF OFF) + endif() +endif() + +if(WITH_CYCLES_OSL) + set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation") + if(NOT OSL_ROOT) + set(OSL_ROOT ${CYCLES_OSL}) + endif() + find_package_wrapper(OpenShadingLanguage) + if(OSL_FOUND) + if(${OSL_LIBRARY_VERSION_MAJOR} EQUAL "1" AND ${OSL_LIBRARY_VERSION_MINOR} LESS "6") + # Note: --whole-archive is needed to force loading of all symbols in liboslexec, + # otherwise LLVM is missing the osl_allocate_closure_component function + set(OSL_LIBRARIES + ${OSL_OSLCOMP_LIBRARY} + -Wl,--whole-archive ${OSL_OSLEXEC_LIBRARY} + -Wl,--no-whole-archive ${OSL_OSLQUERY_LIBRARY} + ) + endif() + else() + message(STATUS "OSL not found, disabling it from Cycles") + set(WITH_CYCLES_OSL OFF) + endif() +endif() + +if(WITH_OPENVDB) + find_package_wrapper(OpenVDB) + find_package_wrapper(TBB) + if(NOT OPENVDB_FOUND OR NOT TBB_FOUND) + set(WITH_OPENVDB OFF) + set(WITH_OPENVDB_BLOSC OFF) + message(STATUS "OpenVDB not found, disabling it") + endif() +endif() + +if(WITH_ALEMBIC) + find_package_wrapper(Alembic) + + if(WITH_ALEMBIC_HDF5) + set(HDF5_ROOT_DIR ${LIBDIR}/hdf5) + find_package_wrapper(HDF5) + endif() + + if(NOT ALEMBIC_FOUND OR (WITH_ALEMBIC_HDF5 AND NOT HDF5_FOUND)) + set(WITH_ALEMBIC OFF) + set(WITH_ALEMBIC_HDF5 OFF) + endif() +endif() + +if(WITH_BOOST) + # uses in build instructions to override include and library variables + if(NOT BOOST_CUSTOM) + if(WITH_STATIC_LIBS) + set(Boost_USE_STATIC_LIBS ON) + endif() + set(Boost_USE_MULTITHREADED ON) + set(__boost_packages filesystem regex system thread date_time) + if(WITH_CYCLES_OSL) + if(NOT (${OSL_LIBRARY_VERSION_MAJOR} EQUAL "1" AND ${OSL_LIBRARY_VERSION_MINOR} LESS "6")) + list(APPEND __boost_packages wave) + else() + endif() + endif() + if(WITH_INTERNATIONAL) + list(APPEND __boost_packages locale) + endif() + if(WITH_CYCLES_NETWORK) + list(APPEND __boost_packages serialization) + endif() + if(WITH_OPENVDB) + list(APPEND __boost_packages iostreams) + endif() + find_package(Boost 1.48 COMPONENTS ${__boost_packages}) + if(NOT Boost_FOUND) + # try to find non-multithreaded if -mt not found, this flag + # doesn't matter for us, it has nothing to do with thread + # safety, but keep it to not disturb build setups + set(Boost_USE_MULTITHREADED OFF) + find_package(Boost 1.48 COMPONENTS ${__boost_packages}) + endif() + unset(__boost_packages) + if(Boost_USE_STATIC_LIBS AND WITH_BOOST_ICU) + find_package(IcuLinux) + endif() + mark_as_advanced(Boost_DIR) # why doesnt boost do this? + endif() + + set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS}) + set(BOOST_LIBRARIES ${Boost_LIBRARIES}) + set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS}) + set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB") +endif() + +if(WITH_OPENIMAGEIO) + find_package_wrapper(OpenImageIO) + if(NOT OPENIMAGEIO_PUGIXML_FOUND AND WITH_CYCLES_STANDALONE) + find_package_wrapper(PugiXML) + else() + set(PUGIXML_INCLUDE_DIR "${OPENIMAGEIO_INCLUDE_DIR/OpenImageIO}") + set(PUGIXML_LIBRARIES "") + endif() + + set(OPENIMAGEIO_LIBRARIES + ${OPENIMAGEIO_LIBRARIES} + ${PNG_LIBRARIES} + ${JPEG_LIBRARIES} + ${ZLIB_LIBRARIES} + ${BOOST_LIBRARIES} + ) + set(OPENIMAGEIO_LIBPATH) # TODO, remove and reference the absolute path everywhere + set(OPENIMAGEIO_DEFINITIONS "") + + if(WITH_IMAGE_TIFF) + list(APPEND OPENIMAGEIO_LIBRARIES "${TIFF_LIBRARY}") + endif() + if(WITH_IMAGE_OPENEXR) + list(APPEND OPENIMAGEIO_LIBRARIES "${OPENEXR_LIBRARIES}") + endif() + + if(NOT OPENIMAGEIO_FOUND) + set(WITH_OPENIMAGEIO OFF) + message(STATUS "OpenImageIO not found, disabling WITH_CYCLES") + endif() +endif() + +if(WITH_OPENCOLORIO) + find_package_wrapper(OpenColorIO) + + set(OPENCOLORIO_LIBRARIES ${OPENCOLORIO_LIBRARIES}) + set(OPENCOLORIO_LIBPATH) # TODO, remove and reference the absolute path everywhere + set(OPENCOLORIO_DEFINITIONS) + + if(NOT OPENCOLORIO_FOUND) + set(WITH_OPENCOLORIO OFF) + message(STATUS "OpenColorIO not found") + endif() +endif() + +if(WITH_LLVM) + find_package_wrapper(LLVM) + + if(NOT LLVM_FOUND) + set(WITH_LLVM OFF) + message(STATUS "LLVM not found") + endif() +endif() + +if(WITH_LLVM OR WITH_SDL_DYNLOAD) + # Fix for conflict with Mesa llvmpipe + set(PLATFORM_LINKFLAGS + "${PLATFORM_LINKFLAGS} -Wl,--version-script='${CMAKE_SOURCE_DIR}/source/creator/blender.map'" + ) +endif() + +if(WITH_OPENSUBDIV) + find_package_wrapper(OpenSubdiv) + + set(OPENSUBDIV_LIBRARIES ${OPENSUBDIV_LIBRARIES}) + set(OPENSUBDIV_LIBPATH) # TODO, remove and reference the absolute path everywhere + + if(NOT OPENSUBDIV_FOUND) + set(WITH_OPENSUBDIV OFF) + message(STATUS "OpenSubdiv not found") + endif() +endif() + +# OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed +list(APPEND PLATFORM_LINKLIBS -lutil -lc -lm) + +find_package(Threads REQUIRED) +list(APPEND PLATFORM_LINKLIBS ${CMAKE_THREAD_LIBS_INIT}) +# used by other platforms +set(PTHREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) + +if(CMAKE_DL_LIBS) + list(APPEND PLATFORM_LINKLIBS ${CMAKE_DL_LIBS}) +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux") + if(NOT WITH_PYTHON_MODULE) + # binreloc is linux only + set(BINRELOC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/binreloc/include) + set(WITH_BINRELOC ON) + endif() +endif() + +# lfs on glibc, all compilers should use +add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE) + +# GNU Compiler +if(CMAKE_COMPILER_IS_GNUCC) + set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing") + + # use ld.gold linker if available, could make optional + execute_process( + COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version + ERROR_QUIET OUTPUT_VARIABLE LD_VERSION) + if("${LD_VERSION}" MATCHES "GNU gold") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=gold") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold") + else() + message(STATUS "GNU gold linker isn't available, using the default system linker.") + endif() + unset(LD_VERSION) + +# CLang is the same as GCC for now. +elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") + set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing") +# Solaris CC +elseif(CMAKE_C_COMPILER_ID MATCHES "SunPro") + set(PLATFORM_CFLAGS "-pipe -features=extensions -fPIC -D__FUNCTION__=__func__") + +# Intel C++ Compiler +elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") + # think these next two are broken + find_program(XIAR xiar) + if(XIAR) + set(CMAKE_AR "${XIAR}") + endif() + mark_as_advanced(XIAR) + + find_program(XILD xild) + if(XILD) + set(CMAKE_LINKER "${XILD}") + endif() + mark_as_advanced(XILD) + + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise -prec_div -parallel") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fp-model precise -prec_div -parallel") + + # set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -diag-enable sc3") + set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing") + set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -static-intel") +endif() diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake new file mode 100644 index 00000000000..631973b758b --- /dev/null +++ b/build_files/cmake/platform/platform_win32.cmake @@ -0,0 +1,87 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# The Original Code is Copyright (C) 2016, Blender Foundation +# All rights reserved. +# +# Contributor(s): Sergey Sharybin. +# +# ***** END GPL LICENSE BLOCK ***** + +# Libraries configuration for Windows. + +add_definitions(-DWIN32) + +if(MSVC) + include(platform_win32_msvc) +elseif(CMAKE_COMPILER_IS_GNUCC) + include(platform_win32_mingw) +endif() + +# Things common to both mingw and MSVC should go here + +set(WINTAB_INC ${LIBDIR}/wintab/include) + +if(WITH_OPENAL) + set(OPENAL ${LIBDIR}/openal) + set(OPENALDIR ${LIBDIR}/openal) + set(OPENAL_INCLUDE_DIR ${OPENAL}/include) + if(MSVC) + set(OPENAL_LIBRARY openal32) + else() + set(OPENAL_LIBRARY wrap_oal) + endif() + set(OPENAL_LIBPATH ${OPENAL}/lib) +endif() + +if(WITH_CODEC_SNDFILE) + set(SNDFILE ${LIBDIR}/sndfile) + set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include) + set(SNDFILE_LIBRARIES libsndfile-1) + set(SNDFILE_LIBPATH ${SNDFILE}/lib) # TODO, deprecate +endif() + +if(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD) + add_definitions(-D__SSE__ -D__MMX__) +endif() + +if(WITH_CYCLES_OSL) + set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation") + + find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib) + find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib) + find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib) + find_library(OSL_LIB_EXEC_DEBUG NAMES oslexec_d PATHS ${CYCLES_OSL}/lib) + find_library(OSL_LIB_COMP_DEBUG NAMES oslcomp_d PATHS ${CYCLES_OSL}/lib) + find_library(OSL_LIB_QUERY_DEBUG NAMES oslquery_d PATHS ${CYCLES_OSL}/lib) + list(APPEND OSL_LIBRARIES + optimized ${OSL_LIB_COMP} + optimized ${OSL_LIB_EXEC} + optimized ${OSL_LIB_QUERY} + debug ${OSL_LIB_EXEC_DEBUG} + debug ${OSL_LIB_COMP_DEBUG} + debug ${OSL_LIB_QUERY_DEBUG} + ) + find_path(OSL_INCLUDE_DIR OSL/oslclosure.h PATHS ${CYCLES_OSL}/include) + find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin) + + if(OSL_INCLUDE_DIR AND OSL_LIBRARIES AND OSL_COMPILER) + set(OSL_FOUND TRUE) + else() + message(STATUS "OSL not found") + set(WITH_CYCLES_OSL OFF) + endif() +endif() diff --git a/build_files/cmake/platform/platform_win32_mingw.cmake b/build_files/cmake/platform/platform_win32_mingw.cmake new file mode 100644 index 00000000000..216568bd069 --- /dev/null +++ b/build_files/cmake/platform/platform_win32_mingw.cmake @@ -0,0 +1,302 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# The Original Code is Copyright (C) 2016, Blender Foundation +# All rights reserved. +# +# Contributor(s): Sergey Sharybin. +# +# ***** END GPL LICENSE BLOCK ***** + +# Libraries configuration for Windows when compiling with MinGW. + +# keep GCC specific stuff here +include(CheckCSourceCompiles) +# Setup 64bit and 64bit windows systems +CHECK_C_SOURCE_COMPILES(" + #ifndef __MINGW64__ + #error + #endif + int main(void) { return 0; } + " + WITH_MINGW64 +) + +if(NOT DEFINED LIBDIR) + if(WITH_MINGW64) + message(STATUS "Compiling for 64 bit with MinGW-w64.") + set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw64) + else() + message(STATUS "Compiling for 32 bit with MinGW-w32.") + set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw32) + + if(WITH_RAYOPTIMIZATION) + message(WARNING "MinGW-w32 is known to be unstable with 'WITH_RAYOPTIMIZATION' option enabled.") + endif() + endif() +else() + message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}") +endif() +if(NOT EXISTS "${LIBDIR}/") + message(FATAL_ERROR "Windows requires pre-compiled libs at: '${LIBDIR}'") +endif() + +list(APPEND PLATFORM_LINKLIBS + -lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 + -lz -lstdc++ -lole32 -luuid -lwsock32 -lpsapi -ldbghelp +) + +if(WITH_INPUT_IME) + list(APPEND PLATFORM_LINKLIBS -limm32) +endif() + +set(PLATFORM_CFLAGS "-pipe -funsigned-char -fno-strict-aliasing") + +if(WITH_MINGW64) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive") + list(APPEND PLATFORM_LINKLIBS -lpthread) + + add_definitions(-DFREE_WINDOWS64 -DMS_WIN64) +endif() + +add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE) + +add_definitions(-DFREE_WINDOWS) + +set(PNG "${LIBDIR}/png") +set(PNG_INCLUDE_DIRS "${PNG}/include") +set(PNG_LIBPATH ${PNG}/lib) # not cmake defined + +if(WITH_MINGW64) + set(JPEG_LIBRARIES jpeg) +else() + set(JPEG_LIBRARIES libjpeg) +endif() +set(PNG_LIBRARIES png) + +set(ZLIB ${LIBDIR}/zlib) +set(ZLIB_INCLUDE_DIRS ${ZLIB}/include) +set(ZLIB_LIBPATH ${ZLIB}/lib) +set(ZLIB_LIBRARIES z) + +set(JPEG "${LIBDIR}/jpeg") +set(JPEG_INCLUDE_DIR "${JPEG}/include") +set(JPEG_LIBPATH ${JPEG}/lib) # not cmake defined + +# comes with own pthread library +if(NOT WITH_MINGW64) + set(PTHREADS ${LIBDIR}/pthreads) + #set(PTHREADS_INCLUDE_DIRS ${PTHREADS}/include) + set(PTHREADS_LIBPATH ${PTHREADS}/lib) + set(PTHREADS_LIBRARIES pthreadGC2) +endif() + +set(FREETYPE ${LIBDIR}/freetype) +set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2) +set(FREETYPE_LIBPATH ${FREETYPE}/lib) +set(FREETYPE_LIBRARY freetype) + +if(WITH_FFTW3) + set(FFTW3 ${LIBDIR}/fftw3) + set(FFTW3_LIBRARIES fftw3) + set(FFTW3_INCLUDE_DIRS ${FFTW3}/include) + set(FFTW3_LIBPATH ${FFTW3}/lib) +endif() + +if(WITH_OPENCOLLADA) + set(OPENCOLLADA ${LIBDIR}/opencollada) + set(OPENCOLLADA_INCLUDE_DIRS + ${OPENCOLLADA}/include/opencollada/COLLADAStreamWriter + ${OPENCOLLADA}/include/opencollada/COLLADABaseUtils + ${OPENCOLLADA}/include/opencollada/COLLADAFramework + ${OPENCOLLADA}/include/opencollada/COLLADASaxFrameworkLoader + ${OPENCOLLADA}/include/opencollada/GeneratedSaxParser + ) + set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib/opencollada) + set(OPENCOLLADA_LIBRARIES + OpenCOLLADAStreamWriter + OpenCOLLADASaxFrameworkLoader + OpenCOLLADAFramework + OpenCOLLADABaseUtils + GeneratedSaxParser + UTF MathMLSolver buffer ftoa xml + ) + set(PCRE_LIBRARIES pcre) +endif() + +if(WITH_CODEC_FFMPEG) + set(FFMPEG ${LIBDIR}/ffmpeg) + set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include) + if(WITH_MINGW64) + set(FFMPEG_LIBRARIES avcodec.dll avformat.dll avdevice.dll avutil.dll swscale.dll swresample.dll) + else() + set(FFMPEG_LIBRARIES avcodec-55 avformat-55 avdevice-55 avutil-52 swscale-2) + endif() + set(FFMPEG_LIBPATH ${FFMPEG}/lib) +endif() + +if(WITH_IMAGE_OPENEXR) + set(OPENEXR ${LIBDIR}/openexr) + set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include) + set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR) + set(OPENEXR_LIBRARIES Half IlmImf Imath IlmThread Iex) + set(OPENEXR_LIBPATH ${OPENEXR}/lib) +endif() + +if(WITH_IMAGE_TIFF) + set(TIFF ${LIBDIR}/tiff) + set(TIFF_LIBRARY tiff) + set(TIFF_INCLUDE_DIR ${TIFF}/include) + set(TIFF_LIBPATH ${TIFF}/lib) +endif() + +if(WITH_JACK) + set(JACK ${LIBDIR}/jack) + set(JACK_INCLUDE_DIRS ${JACK}/include/jack ${JACK}/include) + set(JACK_LIBRARIES jack) + set(JACK_LIBPATH ${JACK}/lib) + + # TODO, gives linking errors, force off + set(WITH_JACK OFF) +endif() + +if(WITH_PYTHON) + # normally cached but not since we include them with blender + set(PYTHON_VERSION 3.5) # CACHE STRING) + string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION}) + set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}") # CACHE PATH) + set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}mw.lib") # CACHE FILEPATH) + unset(_PYTHON_VERSION_NO_DOTS) + + # uncached vars + set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") + set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}") +endif() + +if(WITH_BOOST) + set(BOOST ${LIBDIR}/boost) + set(BOOST_INCLUDE_DIR ${BOOST}/include) + if(WITH_MINGW64) + set(BOOST_POSTFIX "mgw47-mt-s-1_49") + set(BOOST_DEBUG_POSTFIX "mgw47-mt-sd-1_49") + else() + set(BOOST_POSTFIX "mgw46-mt-s-1_49") + set(BOOST_DEBUG_POSTFIX "mgw46-mt-sd-1_49") + endif() + set(BOOST_LIBRARIES + optimized boost_date_time-${BOOST_POSTFIX} boost_filesystem-${BOOST_POSTFIX} + boost_regex-${BOOST_POSTFIX} + boost_system-${BOOST_POSTFIX} boost_thread-${BOOST_POSTFIX} + debug boost_date_time-${BOOST_DEBUG_POSTFIX} boost_filesystem-${BOOST_DEBUG_POSTFIX} + boost_regex-${BOOST_DEBUG_POSTFIX} + boost_system-${BOOST_DEBUG_POSTFIX} boost_thread-${BOOST_DEBUG_POSTFIX}) + if(WITH_INTERNATIONAL) + set(BOOST_LIBRARIES ${BOOST_LIBRARIES} + optimized boost_locale-${BOOST_POSTFIX} + debug boost_locale-${BOOST_DEBUG_POSTFIX} + ) + endif() + if(WITH_CYCLES_OSL) + set(BOOST_LIBRARIES ${BOOST_LIBRARIES} + optimized boost_wave-${BOOST_POSTFIX} + debug boost_wave-${BOOST_DEBUG_POSTFIX} + ) + endif() + set(BOOST_LIBPATH ${BOOST}/lib) + set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB -DBOOST_THREAD_USE_LIB ") +endif() + +if(WITH_OPENIMAGEIO) + set(OPENIMAGEIO ${LIBDIR}/openimageio) + set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include) + set(OPENIMAGEIO_LIBRARIES OpenImageIO) + set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib) + set(OPENIMAGEIO_DEFINITIONS "") + set(OPENIMAGEIO_IDIFF "${OPENIMAGEIO}/bin/idiff.exe") +endif() + +if(WITH_LLVM) + set(LLVM_ROOT_DIR ${LIBDIR}/llvm CACHE PATH "Path to the LLVM installation") + set(LLVM_LIBPATH ${LLVM_ROOT_DIR}/lib) + # Explicitly set llvm lib order. + #---- WARNING ON GCC ORDER OF LIBS IS IMPORTANT, DO NOT CHANGE! --------- + set(LLVM_LIBRARY LLVMSelectionDAG LLVMCodeGen LLVMScalarOpts LLVMAnalysis LLVMArchive + LLVMAsmParser LLVMAsmPrinter + LLVMBitReader LLVMBitWriter + LLVMDebugInfo LLVMExecutionEngine + LLVMInstCombine LLVMInstrumentation + LLVMInterpreter LLVMJIT + LLVMLinker LLVMMC + LLVMMCDisassembler LLVMMCJIT + LLVMMCParser LLVMObject + LLVMRuntimeDyld + LLVMSupport + LLVMTableGen LLVMTarget + LLVMTransformUtils LLVMVectorize + LLVMX86AsmParser LLVMX86AsmPrinter + LLVMX86CodeGen LLVMX86Desc + LLVMX86Disassembler LLVMX86Info + LLVMX86Utils LLVMipa + LLVMipo LLVMCore) + # imagehelp is needed by LLVM 3.1 on MinGW, check lib\Support\Windows\Signals.inc + list(APPEND PLATFORM_LINKLIBS -limagehlp) +endif() + +if(WITH_OPENCOLORIO) + set(OPENCOLORIO ${LIBDIR}/opencolorio) + set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include) + set(OPENCOLORIO_LIBRARIES OpenColorIO) + set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib) + set(OPENCOLORIO_DEFINITIONS) +endif() + +if(WITH_SDL) + set(SDL ${LIBDIR}/sdl) + set(SDL_INCLUDE_DIR ${SDL}/include) + set(SDL_LIBRARY SDL) + set(SDL_LIBPATH ${SDL}/lib) +endif() + +if(WITH_OPENVDB) + set(OPENVDB ${LIBDIR}/openvdb) + set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include) + set(OPENVDB_LIBRARIES openvdb ${TBB_LIBRARIES}) + set(OPENVDB_LIBPATH ${LIBDIR}/openvdb/lib) + set(OPENVDB_DEFINITIONS) +endif() + +if(WITH_ALEMBIC) + # TODO(sergey): For until someone drops by and compiles libraries for + # MinGW we allow users to compile their own Alembic library and use + # that via find_package(), + # + # Once precompiled libraries are there we'll use hardcoded locations. + find_package_wrapper(Alembic) + if(WITH_ALEMBIC_HDF5) + set(HDF5_ROOT_DIR ${LIBDIR}/hdf5) + find_package_wrapper(HDF5) + endif() + if(NOT ALEMBIC_FOUND OR (WITH_ALEMBIC_HDF5 AND NOT HDF5_FOUND)) + set(WITH_ALEMBIC OFF) + set(WITH_ALEMBIC_HDF5 OFF) + endif() +endif() + +set(PLATFORM_LINKFLAGS "-Xlinker --stack=2097152") + +## DISABLE - causes linking errors +## for re-distribution, so users dont need mingw installed +# set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -static-libgcc -static-libstdc++") diff --git a/build_files/cmake/platform/platform_win32_msvc.cmake b/build_files/cmake/platform/platform_win32_msvc.cmake new file mode 100644 index 00000000000..696a37115d3 --- /dev/null +++ b/build_files/cmake/platform/platform_win32_msvc.cmake @@ -0,0 +1,452 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# The Original Code is Copyright (C) 2016, Blender Foundation +# All rights reserved. +# +# Contributor(s): Sergey Sharybin. +# +# ***** END GPL LICENSE BLOCK ***** + +# Libraries configuration for Windows when compiling with MSVC. + +add_definitions(-DWIN32) +# Minimum MSVC Version +if(MSVC_VERSION EQUAL 1800) + set(_min_ver "18.0.31101") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_min_ver}) + message(FATAL_ERROR + "Visual Studio 2013 (Update 4, ${_min_ver}) required, " + "found (${CMAKE_CXX_COMPILER_VERSION})") + endif() +endif() +if(MSVC_VERSION EQUAL 1900) + set(_min_ver "19.0.24210") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_min_ver}) + message(FATAL_ERROR + "Visual Studio 2015 (Update 3, ${_min_ver}) required, " + "found (${CMAKE_CXX_COMPILER_VERSION})") + endif() +endif() +unset(_min_ver) + +# needed for some MSVC installations +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO") +set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO") + +list(APPEND PLATFORM_LINKLIBS + ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 + advapi32 shfolder shell32 ole32 oleaut32 uuid psapi Dbghelp +) + +if(WITH_INPUT_IME) + list(APPEND PLATFORM_LINKLIBS imm32) +endif() + +add_definitions( + -D_CRT_NONSTDC_NO_DEPRECATE + -D_CRT_SECURE_NO_DEPRECATE + -D_SCL_SECURE_NO_DEPRECATE + -D_CONSOLE + -D_LIB +) + +# MSVC11 needs _ALLOW_KEYWORD_MACROS to build +add_definitions(-D_ALLOW_KEYWORD_MACROS) + +# We want to support Vista level ABI +add_definitions(-D_WIN32_WINNT=0x600) + +# Make cmake find the msvc redistributables +set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE) +include(InstallRequiredSystemLibraries) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /nologo /J /Gd /MP /EHsc") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo /J /Gd /MP") + +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") +set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") +set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT") +set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT") +set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT") +set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT") + +set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO ") +set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib ") + +# Ignore meaningless for us linker warnings. +set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /ignore:4049 /ignore:4217 /ignore:4221") +set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221") + +# MSVC only, Mingw doesnt need +if(CMAKE_CL_64) + set(PLATFORM_LINKFLAGS "/MACHINE:X64 /OPT:NOREF ${PLATFORM_LINKFLAGS}") +else() + set(PLATFORM_LINKFLAGS "/MACHINE:IX86 /LARGEADDRESSAWARE ${PLATFORM_LINKFLAGS}") +endif() + +set(PLATFORM_LINKFLAGS_DEBUG "/IGNORE:4099 /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libc.lib") + +if(NOT DEFINED LIBDIR) + + # Setup 64bit and 64bit windows systems + if(CMAKE_CL_64) + message(STATUS "64 bit compiler detected.") + set(LIBDIR_BASE "win64") + else() + message(STATUS "32 bit compiler detected.") + set(LIBDIR_BASE "windows") + endif() + + if(MSVC_VERSION EQUAL 1900) + message(STATUS "Visual Studio 2015 detected.") + set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc14) + else() + message(STATUS "Visual Studio 2013 detected.") + set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc12) + endif() +else() + message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}") +endif() +if(NOT EXISTS "${LIBDIR}/") + message(FATAL_ERROR "Windows requires pre-compiled libs at: '${LIBDIR}'") +endif() + +# Add each of our libraries to our cmake_prefix_path so find_package() could work +file(GLOB children RELATIVE ${LIBDIR} ${LIBDIR}/*) +foreach(child ${children}) + if(IS_DIRECTORY ${LIBDIR}/${child}) + list(APPEND CMAKE_PREFIX_PATH ${LIBDIR}/${child}) + endif() +endforeach() + +set(ZLIB_INCLUDE_DIRS ${LIBDIR}/zlib/include) +set(ZLIB_LIBRARIES ${LIBDIR}/zlib/lib/libz_st.lib) +set(ZLIB_INCLUDE_DIR ${LIBDIR}/zlib/include) +set(ZLIB_LIBRARY ${LIBDIR}/zlib/lib/libz_st.lib) +set(ZLIB_DIR ${LIBDIR}/zlib) +#find_package(zlib) # we want to find before finding things that depend on it like png + + +find_package(png) +if(NOT PNG_FOUND) + message(WARNING "Using HARDCODED libpng locations") + set(PNG_PNG_INCLUDE_DIR ${LIBDIR}/png/include) + set(PNG_LIBRARIES libpng) + set(PNG "${LIBDIR}/png") + set(PNG_INCLUDE_DIRS "${PNG}/include") + set(PNG_LIBPATH ${PNG}/lib) # not cmake defined +endif() + +set(JPEG_NAMES ${JPEG_NAMES} libjpeg) +find_package(jpeg REQUIRED) + +set(PTHREADS_INCLUDE_DIRS ${LIBDIR}/pthreads/include) +set(PTHREADS_LIBRARIES ${LIBDIR}/pthreads/lib/pthreadVC2.lib) + +set(FREETYPE ${LIBDIR}/freetype) +set(FREETYPE_INCLUDE_DIRS + ${LIBDIR}/freetype/include + ${LIBDIR}/freetype/include/freetype2 +) +set(FREETYPE_LIBRARY ${LIBDIR}/freetype/lib/freetype2ST.lib) +find_package(freetype REQUIRED) + +if(WITH_FFTW3) + set(FFTW3 ${LIBDIR}/fftw3) + set(FFTW3_LIBRARIES libfftw) + set(FFTW3_INCLUDE_DIRS ${FFTW3}/include) + set(FFTW3_LIBPATH ${FFTW3}/lib) +endif() + +if(WITH_OPENCOLLADA) + set(OPENCOLLADA ${LIBDIR}/opencollada) + + set(OPENCOLLADA_INCLUDE_DIRS + ${OPENCOLLADA}/include/opencollada/COLLADAStreamWriter + ${OPENCOLLADA}/include/opencollada/COLLADABaseUtils + ${OPENCOLLADA}/include/opencollada/COLLADAFramework + ${OPENCOLLADA}/include/opencollada/COLLADASaxFrameworkLoader + ${OPENCOLLADA}/include/opencollada/GeneratedSaxParser + ) + + set(OPENCOLLADA_LIBRARIES + ${OPENCOLLADA}/lib/opencollada/OpenCOLLADASaxFrameworkLoader.lib + ${OPENCOLLADA}/lib/opencollada/OpenCOLLADAFramework.lib + ${OPENCOLLADA}/lib/opencollada/OpenCOLLADABaseUtils.lib + ${OPENCOLLADA}/lib/opencollada/OpenCOLLADAStreamWriter.lib + ${OPENCOLLADA}/lib/opencollada/MathMLSolver.lib + ${OPENCOLLADA}/lib/opencollada/GeneratedSaxParser.lib + ${OPENCOLLADA}/lib/opencollada/xml.lib + ${OPENCOLLADA}/lib/opencollada/buffer.lib + ${OPENCOLLADA}/lib/opencollada/ftoa.lib + ) + + if(NOT WITH_LLVM) + list(APPEND OPENCOLLADA_LIBRARIES ${OPENCOLLADA}/lib/opencollada/UTF.lib) + endif() + + set(PCRE_LIBRARIES + ${OPENCOLLADA}/lib/opencollada/pcre.lib + ) +endif() + +if(WITH_CODEC_FFMPEG) + set(FFMPEG_INCLUDE_DIRS + ${LIBDIR}/ffmpeg/include + ${LIBDIR}/ffmpeg/include/msvc + ) + find_package(FFMPEG) + if(NOT FFMPEG_FOUND) + message(WARNING "Using HARDCODED ffmpeg locations") + set(FFMPEG_LIBRARY_VERSION 55) + set(FFMPEG_LIBRARY_VERSION_AVU 52) + set(FFMPEG_LIBRARIES + ${LIBDIR}/ffmpeg/lib/avcodec-${FFMPEG_LIBRARY_VERSION}.lib + ${LIBDIR}/ffmpeg/lib/avformat-${FFMPEG_LIBRARY_VERSION}.lib + ${LIBDIR}/ffmpeg/lib/avdevice-${FFMPEG_LIBRARY_VERSION}.lib + ${LIBDIR}/ffmpeg/lib/avutil-${FFMPEG_LIBRARY_VERSION_AVU}.lib + ${LIBDIR}/ffmpeg/lib/swscale-2.lib + ) + endif() +endif() + +if(WITH_IMAGE_OPENEXR) + set(OPENEXR_ROOT_DIR ${LIBDIR}/openexr) + set(OPENEXR_VERSION "2.1") + find_package(OPENEXR REQUIRED) + if(NOT OPENEXR_FOUND) + message(WARNING "Using HARDCODED OpenEXR locations") + set(OPENEXR ${LIBDIR}/openexr) + set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include) + set(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR}/include/OpenEXR) + set(OPENEXR_LIBPATH ${OPENEXR}/lib) + set(OPENEXR_LIBRARIES + optimized ${OPENEXR_LIBPATH}/Iex-2_2.lib + optimized ${OPENEXR_LIBPATH}/Half.lib + optimized ${OPENEXR_LIBPATH}/IlmImf-2_2.lib + optimized ${OPENEXR_LIBPATH}/Imath-2_2.lib + optimized ${OPENEXR_LIBPATH}/IlmThread-2_2.lib + debug ${OPENEXR_LIBPATH}/Iex-2_2_d.lib + debug ${OPENEXR_LIBPATH}/Half_d.lib + debug ${OPENEXR_LIBPATH}/IlmImf-2_2_d.lib + debug ${OPENEXR_LIBPATH}/Imath-2_2_d.lib + debug ${OPENEXR_LIBPATH}/IlmThread-2_2_d.lib + ) + endif() +endif() + +if(WITH_IMAGE_TIFF) + # Try to find tiff first then complain and set static and maybe wrong paths + find_package(TIFF) + if(NOT TIFF_FOUND) + message(WARNING "Using HARDCODED libtiff locations") + set(TIFF_LIBRARY ${LIBDIR}/tiff/lib/libtiff.lib) + set(TIFF_INCLUDE_DIR ${LIBDIR}/tiff/include) + endif() +endif() + +if(WITH_JACK) + set(JACK_INCLUDE_DIRS + ${LIBDIR}/jack/include/jack + ${LIBDIR}/jack/include + ) + set(JACK_LIBRARIES optimized ${LIBDIR}/jack/lib/libjack.lib debug ${LIBDIR}/jack/lib/libjack_d.lib) +endif() + +if(WITH_PYTHON) + set(PYTHON_VERSION 3.5) # CACHE STRING) + + string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION}) + # Use shared libs for vc2008 and vc2010 until we actually have vc2010 libs + set(PYTHON_LIBRARY ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.lib) + unset(_PYTHON_VERSION_NO_DOTS) + + # Shared includes for both vc2008 and vc2010 + set(PYTHON_INCLUDE_DIR ${LIBDIR}/python/include/python${PYTHON_VERSION}) + + # uncached vars + set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") + set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}") +endif() + +if(WITH_BOOST) + if(WITH_CYCLES_OSL) + set(boost_extra_libs wave) + endif() + if(WITH_INTERNATIONAL) + list(APPEND boost_extra_libs locale) + endif() + if(WITH_OPENVDB) + list(APPEND boost_extra_libs iostreams) + endif() + set(Boost_USE_STATIC_RUNTIME ON) # prefix lib + set(Boost_USE_MULTITHREADED ON) # suffix -mt + set(Boost_USE_STATIC_LIBS ON) # suffix -s + find_package(Boost COMPONENTS date_time filesystem thread regex system ${boost_extra_libs}) + if(NOT Boost_FOUND) + message(WARNING "USING HARDCODED boost locations") + set(BOOST ${LIBDIR}/boost) + set(BOOST_INCLUDE_DIR ${BOOST}/include) + if(MSVC12) + set(BOOST_LIBPATH ${BOOST}/lib) + set(BOOST_POSTFIX "vc120-mt-s-1_60.lib") + set(BOOST_DEBUG_POSTFIX "vc120-mt-sgd-1_60.lib") + else() + set(BOOST_LIBPATH ${BOOST}/lib) + set(BOOST_POSTFIX "vc140-mt-s-1_60.lib") + set(BOOST_DEBUG_POSTFIX "vc140-mt-sgd-1_60.lib") + endif() + set(BOOST_LIBRARIES + optimized libboost_date_time-${BOOST_POSTFIX} + optimized libboost_filesystem-${BOOST_POSTFIX} + optimized libboost_regex-${BOOST_POSTFIX} + optimized libboost_system-${BOOST_POSTFIX} + optimized libboost_thread-${BOOST_POSTFIX} + debug libboost_date_time-${BOOST_DEBUG_POSTFIX} + debug libboost_filesystem-${BOOST_DEBUG_POSTFIX} + debug libboost_regex-${BOOST_DEBUG_POSTFIX} + debug libboost_system-${BOOST_DEBUG_POSTFIX} + debug libboost_thread-${BOOST_DEBUG_POSTFIX} + ) + if(WITH_CYCLES_OSL) + set(BOOST_LIBRARIES ${BOOST_LIBRARIES} + optimized libboost_wave-${BOOST_POSTFIX} + debug libboost_wave-${BOOST_DEBUG_POSTFIX}) + endif() + if(WITH_INTERNATIONAL) + set(BOOST_LIBRARIES ${BOOST_LIBRARIES} + optimized libboost_locale-${BOOST_POSTFIX} + debug libboost_locale-${BOOST_DEBUG_POSTFIX}) + endif() + else() # we found boost using find_package + set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS}) + set(BOOST_LIBRARIES ${Boost_LIBRARIES}) + set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS}) + endif() + set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB") +endif() + +if(WITH_OPENIMAGEIO) + find_package(OpenImageIO) + set(OPENIMAGEIO ${LIBDIR}/openimageio) + set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include) + set(OIIO_OPTIMIZED optimized OpenImageIO optimized OpenImageIO_Util) + set(OIIO_DEBUG debug OpenImageIO_d debug OpenImageIO_Util_d) + set(OPENIMAGEIO_LIBRARIES ${OIIO_OPTIMIZED} ${OIIO_DEBUG}) + set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib) + set(OPENIMAGEIO_DEFINITIONS "-DUSE_TBB=0") + set(OPENCOLORIO_DEFINITIONS "-DOCIO_STATIC_BUILD") + set(OPENIMAGEIO_IDIFF "${OPENIMAGEIO}/bin/idiff.exe") + add_definitions(-DOIIO_STATIC_BUILD) +endif() + +if(WITH_LLVM) + set(LLVM_ROOT_DIR ${LIBDIR}/llvm CACHE PATH "Path to the LLVM installation") + file(GLOB LLVM_LIBRARY_OPTIMIZED ${LLVM_ROOT_DIR}/lib/*.lib) + + if(EXISTS ${LLVM_ROOT_DIR}/debug/lib) + foreach(LLVM_OPTIMIZED_LIB ${LLVM_LIBRARY_OPTIMIZED}) + get_filename_component(LIBNAME ${LLVM_OPTIMIZED_LIB} ABSOLUTE) + list(APPEND LLVM_LIBS optimized ${LIBNAME}) + endforeach(LLVM_OPTIMIZED_LIB) + + file(GLOB LLVM_LIBRARY_DEBUG ${LLVM_ROOT_DIR}/debug/lib/*.lib) + + foreach(LLVM_DEBUG_LIB ${LLVM_LIBRARY_DEBUG}) + get_filename_component(LIBNAME ${LLVM_DEBUG_LIB} ABSOLUTE) + list(APPEND LLVM_LIBS debug ${LIBNAME}) + endforeach(LLVM_DEBUG_LIB) + + set(LLVM_LIBRARY ${LLVM_LIBS}) + else() + message(WARNING "LLVM debug libs not present on this system. Using release libs for debug builds.") + set(LLVM_LIBRARY ${LLVM_LIBRARY_OPTIMIZED}) + endif() + +endif() + +if(WITH_OPENCOLORIO) + set(OPENCOLORIO ${LIBDIR}/opencolorio) + set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include) + set(OPENCOLORIO_LIBRARIES OpenColorIO) + set(OPENCOLORIO_LIBPATH ${LIBDIR}/opencolorio/lib) + set(OPENCOLORIO_DEFINITIONS) +endif() + +if(WITH_OPENVDB) + set(BLOSC_LIBRARIES optimized ${LIBDIR}/blosc/lib/libblosc.lib debug ${LIBDIR}/blosc/lib/libblosc_d.lib) + set(TBB_LIBRARIES optimized ${LIBDIR}/tbb/lib/tbb.lib debug ${LIBDIR}/tbb/lib/tbb_debug.lib) + set(TBB_INCLUDE_DIR ${LIBDIR}/tbb/include) + set(OPENVDB ${LIBDIR}/openvdb) + set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include ${TBB_INCLUDE_DIR}) + set(OPENVDB_LIBRARIES optimized openvdb debug openvdb_d ${TBB_LIBRARIES} ${BLOSC_LIBRARIES}) + set(OPENVDB_LIBPATH ${LIBDIR}/openvdb/lib) +endif() + +if(WITH_ALEMBIC) + set(ALEMBIC ${LIBDIR}/alembic) + set(ALEMBIC_INCLUDE_DIR ${ALEMBIC}/include) + set(ALEMBIC_INCLUDE_DIRS ${ALEMBIC_INCLUDE_DIR}) + set(ALEMBIC_LIBPATH ${ALEMBIC}/lib) + set(ALEMBIC_LIBRARIES optimized alembic debug alembic_d) +endif() + +if(WITH_MOD_CLOTH_ELTOPO) + set(LAPACK ${LIBDIR}/lapack) + # set(LAPACK_INCLUDE_DIR ${LAPACK}/include) + set(LAPACK_LIBPATH ${LAPACK}/lib) + set(LAPACK_LIBRARIES + ${LIBDIR}/lapack/lib/libf2c.lib + ${LIBDIR}/lapack/lib/clapack_nowrap.lib + ${LIBDIR}/lapack/lib/BLAS_nowrap.lib + ) +endif() + +if(WITH_OPENSUBDIV) + set(OPENSUBDIV_INCLUDE_DIR ${LIBDIR}/opensubdiv/include) + set(OPENSUBDIV_LIBPATH ${LIBDIR}/opensubdiv/lib) + set(OPENSUBDIV_LIBRARIES ${OPENSUBDIV_LIBPATH}/osdCPU.lib ${OPENSUBDIV_LIBPATH}/osdGPU.lib) + find_package(OpenSubdiv) +endif() + +if(WITH_SDL) + set(SDL ${LIBDIR}/sdl) + set(SDL_INCLUDE_DIR ${SDL}/include) + set(SDL_LIBPATH ${SDL}/lib) + # MinGW TODO: Update MinGW to SDL2 + if(NOT CMAKE_COMPILER_IS_GNUCC) + set(SDL_LIBRARY SDL2) + else() + set(SDL_LIBRARY SDL) + endif() +endif() + +# Audio IO +if(WITH_SYSTEM_AUDASPACE) + set(AUDASPACE_INCLUDE_DIRS ${LIBDIR}/audaspace/include/audaspace) + set(AUDASPACE_LIBRARIES ${LIBDIR}/audaspace/lib/audaspace.lib) + set(AUDASPACE_C_INCLUDE_DIRS ${LIBDIR}/audaspace/include/audaspace) + set(AUDASPACE_C_LIBRARIES ${LIBDIR}/audaspace/lib/audaspace-c.lib) + set(AUDASPACE_PY_INCLUDE_DIRS ${LIBDIR}/audaspace/include/audaspace) + set(AUDASPACE_PY_LIBRARIES ${LIBDIR}/audaspace/lib/audaspace-py.lib) +endif() + +# used in many places so include globally, like OpenGL +blender_include_dirs_sys("${PTHREADS_INCLUDE_DIRS}") -- cgit v1.2.3 From 47e08ee924e1629a4ddd945f6173b9d9cec6c2b0 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 17 Aug 2016 14:51:25 +0200 Subject: Fix T49086: UV Along Stroke can be set as vector input for environment texture --- source/blender/editors/space_node/node_templates.c | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 09594ab543c..ec525e684b0 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -428,6 +428,20 @@ static int ui_node_item_name_compare(const void *a, const void *b) return BLI_natstrcmp(type_a->ui_name, type_b->ui_name); } +static bool ui_node_item_special_poll(const bNodeTree *UNUSED(ntree), + const bNodeType *ntype) +{ + if (STREQ(ntype->idname, "ShaderNodeUVAlongStroke")) { + /* TODO(sergey): Currently we don't have Freestyle nodes edited from + * the buttons context, so can ignore it's nodes completely. + * + * However, we might want to do some extra checks here later. + */ + return false; + } + return true; +} + static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) { bNodeTree *ntree = arg->ntree; @@ -452,11 +466,17 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) BLI_array_declare(sorted_ntypes); NODE_TYPES_BEGIN(ntype) { - if (compatibility && !(ntype->compatibility & compatibility)) + if (compatibility && !(ntype->compatibility & compatibility)) { continue; + } - if (ntype->nclass != nclass) + if (ntype->nclass != nclass) { continue; + } + + if (!ui_node_item_special_poll(ntree, ntype)) { + continue; + } BLI_array_append(sorted_ntypes, ntype); } -- cgit v1.2.3 From ab775b6ae9930e1fc6b8536f5ca150557286a119 Mon Sep 17 00:00:00 2001 From: Antonioya Date: Wed, 17 Aug 2016 16:23:05 +0200 Subject: Fix T49102: Angle option of new GP brush settings is too restricted in value Now the range is between -90 to 90 degrees to give more customization options. --- source/blender/makesrna/intern/rna_scene.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index a3b13340a1f..98df12719d3 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2161,10 +2161,10 @@ static void rna_def_gpencil_brush(BlenderRNA *brna) /* Angle when brush is full size */ prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "draw_angle"); - RNA_def_property_range(prop, 0.0f, M_PI_2); + RNA_def_property_range(prop, -M_PI_2, M_PI_2); RNA_def_property_ui_text(prop, "Angle", "Direction of the stroke at which brush gives maximal thickness " - "(0° for horizontal, 90° for vertical)"); + "(0° for horizontal)"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); /* Factor to change brush size depending of angle */ -- cgit v1.2.3 From 8cac980a289676b34613fe77c9fb1f2fd57212d8 Mon Sep 17 00:00:00 2001 From: Mai Lavelle Date: Wed, 17 Aug 2016 10:33:28 -0400 Subject: Cycles: Fix regression where smoke wouldn't show in renders --- intern/cycles/kernel/geom/geom_attribute.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/intern/cycles/kernel/geom/geom_attribute.h b/intern/cycles/kernel/geom/geom_attribute.h index 8604d30ad34..08ccee56335 100644 --- a/intern/cycles/kernel/geom/geom_attribute.h +++ b/intern/cycles/kernel/geom/geom_attribute.h @@ -73,7 +73,11 @@ ccl_device_inline AttributeDescriptor find_attribute(KernelGlobals *kg, const Sh AttributeDescriptor desc; desc.element = (AttributeElement)attr_map.y; - if(ccl_fetch(sd, prim) == PRIM_NONE && desc.element != ATTR_ELEMENT_MESH) { + if(ccl_fetch(sd, prim) == PRIM_NONE && + desc.element != ATTR_ELEMENT_MESH && + desc.element != ATTR_ELEMENT_VOXEL && + desc.element != ATTR_ELEMENT_OBJECT) + { return attribute_not_found(); } -- cgit v1.2.3 From e3b5aa9bb1efd0781912dc1d6795e68f082164d0 Mon Sep 17 00:00:00 2001 From: Howard Trickey Date: Wed, 17 Aug 2016 11:23:11 -0400 Subject: Fix Bevel crashes T49088 and T48858. Was calling the fast path for finding edge order in cases where it should not have been called. --- source/blender/bmesh/tools/bmesh_bevel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index b647f5a667d..1dfb9dee8eb 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -3563,7 +3563,7 @@ static void find_bevel_edge_order(BMesh *bm, BevVert *bv, BMEdge *first_bme) BLI_assert(first_bme != NULL); bv->edges[i].e = first_bme; BM_BEVEL_EDGE_TAG_ENABLE(first_bme); - if (fast_bevel_edge_order(bv)) + if (i == 0 && fast_bevel_edge_order(bv)) break; i = bevel_edge_order_extend(bm, bv, i); i++; @@ -3588,6 +3588,7 @@ static void find_bevel_edge_order(BMesh *bm, BevVert *bv, BMEdge *first_bme) e2 = (i == bv->edgecount - 1) ? &bv->edges[0] : &bv->edges[i + 1]; bme = e->e; bme2 = e2->e; + BLI_assert(bme != NULL); BM_ITER_ELEM(l, &iter, bme, BM_LOOPS_OF_EDGE) { f = l->f; if ((l->prev->e == bme2 || l->next->e == bme2) && !e->fnext && !e2->fprev) -- cgit v1.2.3 From c783e65762aaded75074493fd565a930185f9f78 Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Wed, 17 Aug 2016 21:24:13 +0200 Subject: Fix/add some tooltips to 'Object Align' operator options. --- release/scripts/startup/bl_operators/object_align.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/release/scripts/startup/bl_operators/object_align.py b/release/scripts/startup/bl_operators/object_align.py index 5c3d95e113c..a6ee16e6b71 100644 --- a/release/scripts/startup/bl_operators/object_align.py +++ b/release/scripts/startup/bl_operators/object_align.py @@ -365,6 +365,7 @@ class AlignObjects(Operator): ) align_mode = EnumProperty( name="Align Mode:", + description="Side of object to use for alignment", items=(('OPT_1', "Negative Sides", ""), ('OPT_2', "Centers", ""), ('OPT_3', "Positive Sides", ""), @@ -373,10 +374,11 @@ class AlignObjects(Operator): ) relative_to = EnumProperty( name="Relative To:", - items=(('OPT_1', "Scene Origin", ""), - ('OPT_2', "3D Cursor", ""), - ('OPT_3', "Selection", ""), - ('OPT_4', "Active", ""), + description="Reference location to align to", + items=(('OPT_1', "Scene Origin", "Use the Scene Origin as the position for the selected objects to align to"), + ('OPT_2', "3D Cursor", "Use the 3D cursor as the position for the selected objects to align to"), + ('OPT_3', "Selection", "Use the selected objects as the position for the selected objects to align to"), + ('OPT_4', "Active", "Use the active object as the position for the selected objects to align to"), ), default='OPT_4', ) -- cgit v1.2.3 From 294b0756b441ac7a41d861ea6fd1088a8a6fd8ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Wed, 17 Aug 2016 22:06:05 +0200 Subject: Fix T49081: Alembic sampling times are not taking start frame into account. This resulted in animations always starting at frame 0. --- source/blender/alembic/intern/abc_exporter.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/source/blender/alembic/intern/abc_exporter.cc b/source/blender/alembic/intern/abc_exporter.cc index 127e8853789..f71d78bd60e 100644 --- a/source/blender/alembic/intern/abc_exporter.cc +++ b/source/blender/alembic/intern/abc_exporter.cc @@ -175,7 +175,7 @@ void AbcExporter::getShutterSamples(double step, bool time_relative, /* sample all frame */ if (shutter_open == 0.0 && shutter_close == 1.0) { for (double t = 0; t < 1.0; t += step) { - samples.push_back(t / time_factor); + samples.push_back((t + m_settings.frame_start) / time_factor); } } else { @@ -184,7 +184,7 @@ void AbcExporter::getShutterSamples(double step, bool time_relative, const double time_inc = (shutter_close - shutter_open) / nsamples; for (double t = shutter_open; t <= shutter_close; t += time_inc) { - samples.push_back(t / time_factor); + samples.push_back((t + m_settings.frame_start) / time_factor); } } } @@ -325,16 +325,18 @@ void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled) break; } - double f = *begin; - setCurrentFrame(bmain, f); + const double frame = *begin; - if (shape_frames.count(f) != 0) { + /* 'frame' is offset by start frame, so need to cancel the offset. */ + setCurrentFrame(bmain, frame - m_settings.frame_start); + + if (shape_frames.count(frame) != 0) { for (int i = 0, e = m_shapes.size(); i != e; ++i) { m_shapes[i]->write(); } } - if (xform_frames.count(f) == 0) { + if (xform_frames.count(frame) == 0) { continue; } -- cgit v1.2.3 From 8e7bbe66ddc402fccf05defc109e6dced74b567b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Wed, 17 Aug 2016 22:20:15 +0200 Subject: Alembic import: fix scene min/max time computation to take objects with transform animations into account. --- source/blender/alembic/intern/abc_camera.cc | 2 +- source/blender/alembic/intern/abc_curves.cc | 2 +- source/blender/alembic/intern/abc_mesh.cc | 6 ++++-- source/blender/alembic/intern/abc_nurbs.cc | 2 +- source/blender/alembic/intern/abc_points.cc | 2 +- source/blender/alembic/intern/abc_transform.cc | 2 +- source/blender/alembic/intern/abc_util.h | 11 ++++++++++- 7 files changed, 19 insertions(+), 8 deletions(-) diff --git a/source/blender/alembic/intern/abc_camera.cc b/source/blender/alembic/intern/abc_camera.cc index 38a6d3d33cf..5c34ec1391f 100644 --- a/source/blender/alembic/intern/abc_camera.cc +++ b/source/blender/alembic/intern/abc_camera.cc @@ -109,7 +109,7 @@ AbcCameraReader::AbcCameraReader(const Alembic::Abc::IObject &object, ImportSett ICamera abc_cam(m_iobject, kWrapExisting); m_schema = abc_cam.getSchema(); - get_min_max_time(m_schema, m_min_time, m_max_time); + get_min_max_time(m_iobject, m_schema, m_min_time, m_max_time); } bool AbcCameraReader::valid() const diff --git a/source/blender/alembic/intern/abc_curves.cc b/source/blender/alembic/intern/abc_curves.cc index 4e1e4e7e490..2b54741a5c5 100644 --- a/source/blender/alembic/intern/abc_curves.cc +++ b/source/blender/alembic/intern/abc_curves.cc @@ -190,7 +190,7 @@ AbcCurveReader::AbcCurveReader(const Alembic::Abc::IObject &object, ImportSettin ICurves abc_curves(object, kWrapExisting); m_curves_schema = abc_curves.getSchema(); - get_min_max_time(m_curves_schema, m_min_time, m_max_time); + get_min_max_time(m_iobject, m_curves_schema, m_min_time, m_max_time); } bool AbcCurveReader::valid() const diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc index f1c7b6b3aa3..b80b7c0c4c8 100644 --- a/source/blender/alembic/intern/abc_mesh.cc +++ b/source/blender/alembic/intern/abc_mesh.cc @@ -968,7 +968,8 @@ AbcMeshReader::AbcMeshReader(const IObject &object, ImportSettings &settings) IPolyMesh ipoly_mesh(m_iobject, kWrapExisting); m_schema = ipoly_mesh.getSchema(); - get_min_max_time(m_schema, m_min_time, m_max_time); + + get_min_max_time(m_iobject, m_schema, m_min_time, m_max_time); } bool AbcMeshReader::valid() const @@ -1120,7 +1121,8 @@ AbcSubDReader::AbcSubDReader(const IObject &object, ImportSettings &settings) ISubD isubd_mesh(m_iobject, kWrapExisting); m_schema = isubd_mesh.getSchema(); - get_min_max_time(m_schema, m_min_time, m_max_time); + + get_min_max_time(m_iobject, m_schema, m_min_time, m_max_time); } bool AbcSubDReader::valid() const diff --git a/source/blender/alembic/intern/abc_nurbs.cc b/source/blender/alembic/intern/abc_nurbs.cc index a3c18ad6301..4f57dfdae9e 100644 --- a/source/blender/alembic/intern/abc_nurbs.cc +++ b/source/blender/alembic/intern/abc_nurbs.cc @@ -201,7 +201,7 @@ AbcNurbsReader::AbcNurbsReader(const IObject &object, ImportSettings &settings) : AbcObjectReader(object, settings) { getNurbsPatches(m_iobject); - get_min_max_time(m_schemas[0].first, m_min_time, m_max_time); + get_min_max_time(m_iobject, m_schemas[0].first, m_min_time, m_max_time); } bool AbcNurbsReader::valid() const diff --git a/source/blender/alembic/intern/abc_points.cc b/source/blender/alembic/intern/abc_points.cc index fa5b71ac094..758d4827b8a 100644 --- a/source/blender/alembic/intern/abc_points.cc +++ b/source/blender/alembic/intern/abc_points.cc @@ -141,7 +141,7 @@ AbcPointsReader::AbcPointsReader(const Alembic::Abc::IObject &object, ImportSett { IPoints ipoints(m_iobject, kWrapExisting); m_schema = ipoints.getSchema(); - get_min_max_time(m_schema, m_min_time, m_max_time); + get_min_max_time(m_iobject, m_schema, m_min_time, m_max_time); } bool AbcPointsReader::valid() const diff --git a/source/blender/alembic/intern/abc_transform.cc b/source/blender/alembic/intern/abc_transform.cc index 3326ae0ed84..7f8984f9970 100644 --- a/source/blender/alembic/intern/abc_transform.cc +++ b/source/blender/alembic/intern/abc_transform.cc @@ -137,7 +137,7 @@ AbcEmptyReader::AbcEmptyReader(const Alembic::Abc::IObject &object, ImportSettin Alembic::AbcGeom::IXform xform(object, Alembic::AbcGeom::kWrapExisting); m_schema = xform.getSchema(); - get_min_max_time(m_schema, m_min_time, m_max_time); + get_min_max_time(m_iobject, m_schema, m_min_time, m_max_time); } bool AbcEmptyReader::valid() const diff --git a/source/blender/alembic/intern/abc_util.h b/source/blender/alembic/intern/abc_util.h index 688a25d85f6..8cdfe21e43f 100644 --- a/source/blender/alembic/intern/abc_util.h +++ b/source/blender/alembic/intern/abc_util.h @@ -64,7 +64,7 @@ void create_input_transform(const Alembic::AbcGeom::ISampleSelector &sample_sel, float r_mat[4][4], float scale, bool has_alembic_parent = false); template -void get_min_max_time(const Schema &schema, chrono_t &min, chrono_t &max) +void get_min_max_time_ex(const Schema &schema, chrono_t &min, chrono_t &max) { const Alembic::Abc::TimeSamplingPtr &time_samp = schema.getTimeSampling(); @@ -81,6 +81,15 @@ void get_min_max_time(const Schema &schema, chrono_t &min, chrono_t &max) } } +template +void get_min_max_time(const Alembic::AbcGeom::IObject &object, const Schema &schema, chrono_t &min, chrono_t &max) +{ + get_min_max_time_ex(schema, min, max); + + Alembic::AbcGeom::IXform parent(object.getParent(), Alembic::AbcGeom::kWrapExisting); + get_min_max_time_ex(parent.getSchema(), min, max); +} + bool has_property(const Alembic::Abc::ICompoundProperty &prop, const std::string &name); /* ************************** */ -- cgit v1.2.3 From 11e9c5e10a9914413af704d714bd1a5991112fa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Wed, 17 Aug 2016 23:03:34 +0200 Subject: Fix T49104: normal problem in imported Alembic objects Recompute the normals if the normals are supposed to be varying (e.g. in the ISchema). --- source/blender/alembic/intern/alembic_capi.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc index f9364d55753..f42c708b4c2 100644 --- a/source/blender/alembic/intern/alembic_capi.cc +++ b/source/blender/alembic/intern/alembic_capi.cc @@ -936,12 +936,12 @@ static DerivedMesh *read_mesh_sample(DerivedMesh *dm, const IObject &iobject, co CDStreamConfig config = get_config(new_dm ? new_dm : dm); - bool has_loop_normals = false; - read_mesh_sample(&settings, schema, sample_sel, config, has_loop_normals); + bool do_normals = false; + read_mesh_sample(&settings, schema, sample_sel, config, do_normals); if (new_dm) { /* Check if we had ME_SMOOTH flag set to restore it. */ - if (!has_loop_normals && check_smooth_poly_flag(dm)) { + if (!do_normals && check_smooth_poly_flag(dm)) { set_smooth_poly_flag(new_dm); } @@ -951,6 +951,10 @@ static DerivedMesh *read_mesh_sample(DerivedMesh *dm, const IObject &iobject, co return new_dm; } + if (do_normals) { + CDDM_calc_normals(dm); + } + return dm; } -- cgit v1.2.3 From c0161a1bab71331f518bd5c8c1b091df7ee12074 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 14 Aug 2016 15:33:21 +0200 Subject: Fix T48913: cycles viewport render stuck in loop due to non-unique dupli ID. --- intern/cycles/blender/blender_util.h | 2 +- source/blender/blenkernel/intern/object_dupli.c | 16 ++++++++++++---- source/blender/makesdna/DNA_object_types.h | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index d5dbaba094b..e79f2bbb27d 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -698,7 +698,7 @@ protected: /* Object Key */ -enum { OBJECT_PERSISTENT_ID_SIZE = 8 }; +enum { OBJECT_PERSISTENT_ID_SIZE = 16 }; struct ObjectKey { void *parent; diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c index 21a0246353e..3a0222b1c4b 100644 --- a/source/blender/blenkernel/intern/object_dupli.c +++ b/source/blender/blenkernel/intern/object_dupli.c @@ -221,31 +221,39 @@ static void make_child_duplis(const DupliContext *ctx, void *userdata, MakeChild if (ctx->group) { unsigned int lay = ctx->group->layer; + unsigned int groupid = 0; GroupObject *go; - for (go = ctx->group->gobject.first; go; go = go->next) { + for (go = ctx->group->gobject.first; go; go = go->next, groupid++) { Object *ob = go->ob; if ((ob->lay & lay) && ob != obedit && is_child(ob, parent)) { + DupliContext pctx; + copy_dupli_context(&pctx, ctx, ctx->object, NULL, groupid, false); + /* mballs have a different dupli handling */ if (ob->type != OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */ - make_child_duplis_cb(ctx, userdata, ob); + make_child_duplis_cb(&pctx, userdata, ob); } } } else { unsigned int lay = ctx->scene->lay; + unsigned int baseid = 0; Base *base; - for (base = ctx->scene->base.first; base; base = base->next) { + for (base = ctx->scene->base.first; base; base = base->next, baseid++) { Object *ob = base->object; if ((base->lay & lay) && ob != obedit && is_child(ob, parent)) { + DupliContext pctx; + copy_dupli_context(&pctx, ctx, ctx->object, NULL, baseid, false); + /* mballs have a different dupli handling */ if (ob->type != OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */ - make_child_duplis_cb(ctx, userdata, ob); + make_child_duplis_cb(&pctx, userdata, ob); } } } diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index d53c8360bb5..d24c7faa9f5 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -331,7 +331,7 @@ typedef struct DupliObject { /* persistent identifier for a dupli object, for inter-frame matching of * objects with motion blur, or inter-update matching for syncing */ - int persistent_id[8]; /* MAX_DUPLI_RECUR */ + int persistent_id[16]; /* 2*MAX_DUPLI_RECUR */ /* particle this dupli was generated from */ struct ParticleSystem *particle_system; -- cgit v1.2.3 From 40b367479c6fe23d6f2b6d822f2d5266485619f3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 17 Aug 2016 23:49:55 +0200 Subject: Code cleanup to use array.data() rather than &array[0]. These latter can cause MSVC debug asserts if the array is empty. With C++11 we'll be able to do this for std::vector later. This hopefully fixes an assert in the Cycles subdivision code. --- intern/cycles/render/mesh.cpp | 22 +++++++++++----------- intern/cycles/render/mesh_subdivision.cpp | 18 +++++++++--------- intern/cycles/subd/subd_dice.cpp | 2 +- intern/cycles/subd/subd_patch_table.cpp | 4 ++-- intern/cycles/subd/subd_patch_table.h | 2 +- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp index fcf4e69984d..257e83171e9 100644 --- a/intern/cycles/render/mesh.cpp +++ b/intern/cycles/render/mesh.cpp @@ -298,17 +298,17 @@ int Mesh::split_vertex(int vertex) foreach(Attribute& attr, attributes.attributes) { if(attr.element == ATTR_ELEMENT_VERTEX) { - vector tmp(attr.data_sizeof()); - memcpy(&tmp[0], attr.data() + tmp.size()*vertex, tmp.size()); - attr.add(&tmp[0]); + array tmp(attr.data_sizeof()); + memcpy(tmp.data(), attr.data() + tmp.size()*vertex, tmp.size()); + attr.add(tmp.data()); } } foreach(Attribute& attr, subd_attributes.attributes) { if(attr.element == ATTR_ELEMENT_VERTEX) { - vector tmp(attr.data_sizeof()); - memcpy(&tmp[0], attr.data() + tmp.size()*vertex, tmp.size()); - attr.add(&tmp[0]); + array tmp(attr.data_sizeof()); + memcpy(tmp.data(), attr.data() + tmp.size()*vertex, tmp.size()); + attr.add(tmp.data()); } } @@ -474,7 +474,7 @@ void Mesh::add_face_normals() bool flip = transform_negative_scaled; if(triangles_size) { - float3 *verts_ptr = &verts[0]; + float3 *verts_ptr = verts.data(); for(size_t i = 0; i < triangles_size; i++) { fN[i] = compute_face_normal(get_triangle(i), verts_ptr); @@ -568,7 +568,7 @@ void Mesh::pack_normals(Scene *scene, uint *tri_shader, float4 *vnormal) bool last_smooth = false; size_t triangles_size = num_triangles(); - int *shader_ptr = (shader.size())? &shader[0]: NULL; + int *shader_ptr = shader.data(); bool do_transform = transform_applied; Transform ntfm = transform_normal; @@ -608,7 +608,7 @@ void Mesh::pack_verts(const vector& tri_prim_index, size_t verts_size = verts.size(); if(verts_size && subd_faces.size()) { - float2 *vert_patch_uv_ptr = &vert_patch_uv[0]; + float2 *vert_patch_uv_ptr = vert_patch_uv.data(); for(size_t i = 0; i < verts_size; i++) { tri_patch_uv[i] = vert_patch_uv_ptr[i]; @@ -636,8 +636,8 @@ void Mesh::pack_curves(Scene *scene, float4 *curve_key_co, float4 *curve_data, s /* pack curve keys */ if(curve_keys_size) { - float3 *keys_ptr = &curve_keys[0]; - float *radius_ptr = &curve_radius[0]; + float3 *keys_ptr = curve_keys.data(); + float *radius_ptr = curve_radius.data(); for(size_t i = 0; i < curve_keys_size; i++) curve_key_co[i] = make_float4(keys_ptr[i].x, keys_ptr[i].y, keys_ptr[i].z, radius_ptr[i]); diff --git a/intern/cycles/render/mesh_subdivision.cpp b/intern/cycles/render/mesh_subdivision.cpp index efb40efbb79..c9cc5df68a4 100644 --- a/intern/cycles/render/mesh_subdivision.cpp +++ b/intern/cycles/render/mesh_subdivision.cpp @@ -45,7 +45,7 @@ namespace Far { setNumBaseVertices(refiner, mesh.verts.size()); setNumBaseFaces(refiner, mesh.subd_faces.size()); - ccl::Mesh::SubdFace* face = &mesh.subd_faces[0]; + ccl::Mesh::SubdFace* face = mesh.subd_faces.data(); for(int i = 0; i < mesh.subd_faces.size(); i++, face++) { setNumBaseFaceVertices(refiner, i, face->num_corners); @@ -57,7 +57,7 @@ namespace Far { template<> bool TopologyRefinerFactory::assignComponentTopology(TopologyRefiner& refiner, ccl::Mesh const& mesh) { - ccl::Mesh::SubdFace* face = &mesh.subd_faces[0]; + ccl::Mesh::SubdFace* face = mesh.subd_faces.data() for(int i = 0; i < mesh.subd_faces.size(); i++, face++) { IndexArray face_verts = getBaseFaceVertices(refiner, i); @@ -195,14 +195,14 @@ public: verts[i].value = mesh->verts[i]; } - OsdValue* src = &verts[0]; + OsdValue* src = verts.data() for(int i = 0; i < refiner->GetMaxLevel(); i++) { OsdValue* dest = src + refiner->GetLevel(i).GetNumVertices(); Far::PrimvarRefiner(*refiner).Interpolate(i+1, src, dest); src = dest; } - patch_table->ComputeLocalPointValues(&verts[0], &verts[num_refiner_verts]); + patch_table->ComputeLocalPointValues(verts.data(), &verts[num_refiner_verts]); /* create patch map */ patch_map = new Far::PatchMap(*patch_table); @@ -219,7 +219,7 @@ public: attr.resize(num_refiner_verts + num_local_points); attr.flags |= ATTR_FINAL_SIZE; - char* src = &attr.buffer[0]; + char* src = attr.buffer.data(); for(int i = 0; i < refiner->GetMaxLevel(); i++) { char* dest = src + refiner->GetLevel(i).GetNumVertices() * attr.data_sizeof(); @@ -235,12 +235,12 @@ public: } if(attr.same_storage(attr.type, TypeDesc::TypeFloat)) { - patch_table->ComputeLocalPointValues((OsdValue*)&attr.buffer[0], - (OsdValue*)&attr.buffer[num_refiner_verts * attr.data_sizeof()]); + patch_table->ComputeLocalPointValues((OsdValue*)attr.buffer.data(), + (OsdValue*)(attr.buffer.data() + num_refiner_verts * attr.data_sizeof())); } else { - patch_table->ComputeLocalPointValues((OsdValue*)&attr.buffer[0], - (OsdValue*)&attr.buffer[num_refiner_verts * attr.data_sizeof()]); + patch_table->ComputeLocalPointValues((OsdValue*)attr.buffer.data(), + (OsdValue*)(attr.buffer.data() + num_refiner_verts * attr.data_sizeof())); } } else if(attr.element == ATTR_ELEMENT_CORNER || attr.element == ATTR_ELEMENT_CORNER_BYTE) { diff --git a/intern/cycles/subd/subd_dice.cpp b/intern/cycles/subd/subd_dice.cpp index 36981a20f3c..a1bd349b167 100644 --- a/intern/cycles/subd/subd_dice.cpp +++ b/intern/cycles/subd/subd_dice.cpp @@ -57,7 +57,7 @@ void EdgeDice::reserve(int num_verts) Attribute *attr_vN = mesh->attributes.add(ATTR_STD_VERTEX_NORMAL); - mesh_P = &mesh->verts[0]; + mesh_P = mesh->verts.data(); mesh_N = attr_vN->data_float3(); } diff --git a/intern/cycles/subd/subd_patch_table.cpp b/intern/cycles/subd/subd_patch_table.cpp index 68ec1b2c6a6..62572efa88a 100644 --- a/intern/cycles/subd/subd_patch_table.cpp +++ b/intern/cycles/subd/subd_patch_table.cpp @@ -214,7 +214,7 @@ void PackedPatchTable::pack(Far::PatchTable* patch_table, int offset) } table.resize(total_size()); - uint* data = &table[0]; + uint* data = table.data(); uint* array = data; uint* index = array + num_arrays * PATCH_ARRAY_SIZE; @@ -259,7 +259,7 @@ void PackedPatchTable::pack(Far::PatchTable* patch_table, int offset) void PackedPatchTable::copy_adjusting_offsets(uint* dest, int doffset) { - uint* src = &table[0]; + uint* src = table.data(); /* arrays */ for(int i = 0; i < num_arrays; i++) { diff --git a/intern/cycles/subd/subd_patch_table.h b/intern/cycles/subd/subd_patch_table.h index c8c7ecf9e47..3166a1691d8 100644 --- a/intern/cycles/subd/subd_patch_table.h +++ b/intern/cycles/subd/subd_patch_table.h @@ -43,7 +43,7 @@ namespace Far { struct PatchTable; } #define PATCH_NODE_SIZE 1 struct PackedPatchTable { - vector table; + array table; size_t num_arrays; size_t num_indices; -- cgit v1.2.3 From 7baf93c711ad1af621b41314f59c1597fbd41ca5 Mon Sep 17 00:00:00 2001 From: Mai Lavelle Date: Wed, 17 Aug 2016 18:49:18 -0400 Subject: Revert "Code cleanup to use array.data() rather than &array[0]." This reverts commit 40b367479c6fe23d6f2b6d822f2d5266485619f3. Didn't build or solve any known issue. Please don't push changes without testing them first. --- intern/cycles/render/mesh.cpp | 22 +++++++++++----------- intern/cycles/render/mesh_subdivision.cpp | 18 +++++++++--------- intern/cycles/subd/subd_dice.cpp | 2 +- intern/cycles/subd/subd_patch_table.cpp | 4 ++-- intern/cycles/subd/subd_patch_table.h | 2 +- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp index 257e83171e9..fcf4e69984d 100644 --- a/intern/cycles/render/mesh.cpp +++ b/intern/cycles/render/mesh.cpp @@ -298,17 +298,17 @@ int Mesh::split_vertex(int vertex) foreach(Attribute& attr, attributes.attributes) { if(attr.element == ATTR_ELEMENT_VERTEX) { - array tmp(attr.data_sizeof()); - memcpy(tmp.data(), attr.data() + tmp.size()*vertex, tmp.size()); - attr.add(tmp.data()); + vector tmp(attr.data_sizeof()); + memcpy(&tmp[0], attr.data() + tmp.size()*vertex, tmp.size()); + attr.add(&tmp[0]); } } foreach(Attribute& attr, subd_attributes.attributes) { if(attr.element == ATTR_ELEMENT_VERTEX) { - array tmp(attr.data_sizeof()); - memcpy(tmp.data(), attr.data() + tmp.size()*vertex, tmp.size()); - attr.add(tmp.data()); + vector tmp(attr.data_sizeof()); + memcpy(&tmp[0], attr.data() + tmp.size()*vertex, tmp.size()); + attr.add(&tmp[0]); } } @@ -474,7 +474,7 @@ void Mesh::add_face_normals() bool flip = transform_negative_scaled; if(triangles_size) { - float3 *verts_ptr = verts.data(); + float3 *verts_ptr = &verts[0]; for(size_t i = 0; i < triangles_size; i++) { fN[i] = compute_face_normal(get_triangle(i), verts_ptr); @@ -568,7 +568,7 @@ void Mesh::pack_normals(Scene *scene, uint *tri_shader, float4 *vnormal) bool last_smooth = false; size_t triangles_size = num_triangles(); - int *shader_ptr = shader.data(); + int *shader_ptr = (shader.size())? &shader[0]: NULL; bool do_transform = transform_applied; Transform ntfm = transform_normal; @@ -608,7 +608,7 @@ void Mesh::pack_verts(const vector& tri_prim_index, size_t verts_size = verts.size(); if(verts_size && subd_faces.size()) { - float2 *vert_patch_uv_ptr = vert_patch_uv.data(); + float2 *vert_patch_uv_ptr = &vert_patch_uv[0]; for(size_t i = 0; i < verts_size; i++) { tri_patch_uv[i] = vert_patch_uv_ptr[i]; @@ -636,8 +636,8 @@ void Mesh::pack_curves(Scene *scene, float4 *curve_key_co, float4 *curve_data, s /* pack curve keys */ if(curve_keys_size) { - float3 *keys_ptr = curve_keys.data(); - float *radius_ptr = curve_radius.data(); + float3 *keys_ptr = &curve_keys[0]; + float *radius_ptr = &curve_radius[0]; for(size_t i = 0; i < curve_keys_size; i++) curve_key_co[i] = make_float4(keys_ptr[i].x, keys_ptr[i].y, keys_ptr[i].z, radius_ptr[i]); diff --git a/intern/cycles/render/mesh_subdivision.cpp b/intern/cycles/render/mesh_subdivision.cpp index c9cc5df68a4..efb40efbb79 100644 --- a/intern/cycles/render/mesh_subdivision.cpp +++ b/intern/cycles/render/mesh_subdivision.cpp @@ -45,7 +45,7 @@ namespace Far { setNumBaseVertices(refiner, mesh.verts.size()); setNumBaseFaces(refiner, mesh.subd_faces.size()); - ccl::Mesh::SubdFace* face = mesh.subd_faces.data(); + ccl::Mesh::SubdFace* face = &mesh.subd_faces[0]; for(int i = 0; i < mesh.subd_faces.size(); i++, face++) { setNumBaseFaceVertices(refiner, i, face->num_corners); @@ -57,7 +57,7 @@ namespace Far { template<> bool TopologyRefinerFactory::assignComponentTopology(TopologyRefiner& refiner, ccl::Mesh const& mesh) { - ccl::Mesh::SubdFace* face = mesh.subd_faces.data() + ccl::Mesh::SubdFace* face = &mesh.subd_faces[0]; for(int i = 0; i < mesh.subd_faces.size(); i++, face++) { IndexArray face_verts = getBaseFaceVertices(refiner, i); @@ -195,14 +195,14 @@ public: verts[i].value = mesh->verts[i]; } - OsdValue* src = verts.data() + OsdValue* src = &verts[0]; for(int i = 0; i < refiner->GetMaxLevel(); i++) { OsdValue* dest = src + refiner->GetLevel(i).GetNumVertices(); Far::PrimvarRefiner(*refiner).Interpolate(i+1, src, dest); src = dest; } - patch_table->ComputeLocalPointValues(verts.data(), &verts[num_refiner_verts]); + patch_table->ComputeLocalPointValues(&verts[0], &verts[num_refiner_verts]); /* create patch map */ patch_map = new Far::PatchMap(*patch_table); @@ -219,7 +219,7 @@ public: attr.resize(num_refiner_verts + num_local_points); attr.flags |= ATTR_FINAL_SIZE; - char* src = attr.buffer.data(); + char* src = &attr.buffer[0]; for(int i = 0; i < refiner->GetMaxLevel(); i++) { char* dest = src + refiner->GetLevel(i).GetNumVertices() * attr.data_sizeof(); @@ -235,12 +235,12 @@ public: } if(attr.same_storage(attr.type, TypeDesc::TypeFloat)) { - patch_table->ComputeLocalPointValues((OsdValue*)attr.buffer.data(), - (OsdValue*)(attr.buffer.data() + num_refiner_verts * attr.data_sizeof())); + patch_table->ComputeLocalPointValues((OsdValue*)&attr.buffer[0], + (OsdValue*)&attr.buffer[num_refiner_verts * attr.data_sizeof()]); } else { - patch_table->ComputeLocalPointValues((OsdValue*)attr.buffer.data(), - (OsdValue*)(attr.buffer.data() + num_refiner_verts * attr.data_sizeof())); + patch_table->ComputeLocalPointValues((OsdValue*)&attr.buffer[0], + (OsdValue*)&attr.buffer[num_refiner_verts * attr.data_sizeof()]); } } else if(attr.element == ATTR_ELEMENT_CORNER || attr.element == ATTR_ELEMENT_CORNER_BYTE) { diff --git a/intern/cycles/subd/subd_dice.cpp b/intern/cycles/subd/subd_dice.cpp index a1bd349b167..36981a20f3c 100644 --- a/intern/cycles/subd/subd_dice.cpp +++ b/intern/cycles/subd/subd_dice.cpp @@ -57,7 +57,7 @@ void EdgeDice::reserve(int num_verts) Attribute *attr_vN = mesh->attributes.add(ATTR_STD_VERTEX_NORMAL); - mesh_P = mesh->verts.data(); + mesh_P = &mesh->verts[0]; mesh_N = attr_vN->data_float3(); } diff --git a/intern/cycles/subd/subd_patch_table.cpp b/intern/cycles/subd/subd_patch_table.cpp index 62572efa88a..68ec1b2c6a6 100644 --- a/intern/cycles/subd/subd_patch_table.cpp +++ b/intern/cycles/subd/subd_patch_table.cpp @@ -214,7 +214,7 @@ void PackedPatchTable::pack(Far::PatchTable* patch_table, int offset) } table.resize(total_size()); - uint* data = table.data(); + uint* data = &table[0]; uint* array = data; uint* index = array + num_arrays * PATCH_ARRAY_SIZE; @@ -259,7 +259,7 @@ void PackedPatchTable::pack(Far::PatchTable* patch_table, int offset) void PackedPatchTable::copy_adjusting_offsets(uint* dest, int doffset) { - uint* src = table.data(); + uint* src = &table[0]; /* arrays */ for(int i = 0; i < num_arrays; i++) { diff --git a/intern/cycles/subd/subd_patch_table.h b/intern/cycles/subd/subd_patch_table.h index 3166a1691d8..c8c7ecf9e47 100644 --- a/intern/cycles/subd/subd_patch_table.h +++ b/intern/cycles/subd/subd_patch_table.h @@ -43,7 +43,7 @@ namespace Far { struct PatchTable; } #define PATCH_NODE_SIZE 1 struct PackedPatchTable { - array table; + vector table; size_t num_arrays; size_t num_indices; -- cgit v1.2.3 From e8b5e66db18c315970dfcb063bced40264841228 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 17 Aug 2016 23:49:55 +0200 Subject: Code cleanup to use array.data() rather than &array[0] (Now without the build errors) --- intern/cycles/render/mesh.cpp | 22 +++++++++++----------- intern/cycles/render/mesh_subdivision.cpp | 8 ++++---- intern/cycles/subd/subd_dice.cpp | 2 +- intern/cycles/subd/subd_patch_table.cpp | 4 ++-- intern/cycles/subd/subd_patch_table.h | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp index fcf4e69984d..257e83171e9 100644 --- a/intern/cycles/render/mesh.cpp +++ b/intern/cycles/render/mesh.cpp @@ -298,17 +298,17 @@ int Mesh::split_vertex(int vertex) foreach(Attribute& attr, attributes.attributes) { if(attr.element == ATTR_ELEMENT_VERTEX) { - vector tmp(attr.data_sizeof()); - memcpy(&tmp[0], attr.data() + tmp.size()*vertex, tmp.size()); - attr.add(&tmp[0]); + array tmp(attr.data_sizeof()); + memcpy(tmp.data(), attr.data() + tmp.size()*vertex, tmp.size()); + attr.add(tmp.data()); } } foreach(Attribute& attr, subd_attributes.attributes) { if(attr.element == ATTR_ELEMENT_VERTEX) { - vector tmp(attr.data_sizeof()); - memcpy(&tmp[0], attr.data() + tmp.size()*vertex, tmp.size()); - attr.add(&tmp[0]); + array tmp(attr.data_sizeof()); + memcpy(tmp.data(), attr.data() + tmp.size()*vertex, tmp.size()); + attr.add(tmp.data()); } } @@ -474,7 +474,7 @@ void Mesh::add_face_normals() bool flip = transform_negative_scaled; if(triangles_size) { - float3 *verts_ptr = &verts[0]; + float3 *verts_ptr = verts.data(); for(size_t i = 0; i < triangles_size; i++) { fN[i] = compute_face_normal(get_triangle(i), verts_ptr); @@ -568,7 +568,7 @@ void Mesh::pack_normals(Scene *scene, uint *tri_shader, float4 *vnormal) bool last_smooth = false; size_t triangles_size = num_triangles(); - int *shader_ptr = (shader.size())? &shader[0]: NULL; + int *shader_ptr = shader.data(); bool do_transform = transform_applied; Transform ntfm = transform_normal; @@ -608,7 +608,7 @@ void Mesh::pack_verts(const vector& tri_prim_index, size_t verts_size = verts.size(); if(verts_size && subd_faces.size()) { - float2 *vert_patch_uv_ptr = &vert_patch_uv[0]; + float2 *vert_patch_uv_ptr = vert_patch_uv.data(); for(size_t i = 0; i < verts_size; i++) { tri_patch_uv[i] = vert_patch_uv_ptr[i]; @@ -636,8 +636,8 @@ void Mesh::pack_curves(Scene *scene, float4 *curve_key_co, float4 *curve_data, s /* pack curve keys */ if(curve_keys_size) { - float3 *keys_ptr = &curve_keys[0]; - float *radius_ptr = &curve_radius[0]; + float3 *keys_ptr = curve_keys.data(); + float *radius_ptr = curve_radius.data(); for(size_t i = 0; i < curve_keys_size; i++) curve_key_co[i] = make_float4(keys_ptr[i].x, keys_ptr[i].y, keys_ptr[i].z, radius_ptr[i]); diff --git a/intern/cycles/render/mesh_subdivision.cpp b/intern/cycles/render/mesh_subdivision.cpp index efb40efbb79..f87425f0042 100644 --- a/intern/cycles/render/mesh_subdivision.cpp +++ b/intern/cycles/render/mesh_subdivision.cpp @@ -45,7 +45,7 @@ namespace Far { setNumBaseVertices(refiner, mesh.verts.size()); setNumBaseFaces(refiner, mesh.subd_faces.size()); - ccl::Mesh::SubdFace* face = &mesh.subd_faces[0]; + const ccl::Mesh::SubdFace* face = mesh.subd_faces.data(); for(int i = 0; i < mesh.subd_faces.size(); i++, face++) { setNumBaseFaceVertices(refiner, i, face->num_corners); @@ -57,7 +57,7 @@ namespace Far { template<> bool TopologyRefinerFactory::assignComponentTopology(TopologyRefiner& refiner, ccl::Mesh const& mesh) { - ccl::Mesh::SubdFace* face = &mesh.subd_faces[0]; + const ccl::Mesh::SubdFace* face = mesh.subd_faces.data(); for(int i = 0; i < mesh.subd_faces.size(); i++, face++) { IndexArray face_verts = getBaseFaceVertices(refiner, i); @@ -195,7 +195,7 @@ public: verts[i].value = mesh->verts[i]; } - OsdValue* src = &verts[0]; + OsdValue* src = verts.data(); for(int i = 0; i < refiner->GetMaxLevel(); i++) { OsdValue* dest = src + refiner->GetLevel(i).GetNumVertices(); Far::PrimvarRefiner(*refiner).Interpolate(i+1, src, dest); @@ -219,7 +219,7 @@ public: attr.resize(num_refiner_verts + num_local_points); attr.flags |= ATTR_FINAL_SIZE; - char* src = &attr.buffer[0]; + char* src = attr.buffer.data(); for(int i = 0; i < refiner->GetMaxLevel(); i++) { char* dest = src + refiner->GetLevel(i).GetNumVertices() * attr.data_sizeof(); diff --git a/intern/cycles/subd/subd_dice.cpp b/intern/cycles/subd/subd_dice.cpp index 36981a20f3c..a1bd349b167 100644 --- a/intern/cycles/subd/subd_dice.cpp +++ b/intern/cycles/subd/subd_dice.cpp @@ -57,7 +57,7 @@ void EdgeDice::reserve(int num_verts) Attribute *attr_vN = mesh->attributes.add(ATTR_STD_VERTEX_NORMAL); - mesh_P = &mesh->verts[0]; + mesh_P = mesh->verts.data(); mesh_N = attr_vN->data_float3(); } diff --git a/intern/cycles/subd/subd_patch_table.cpp b/intern/cycles/subd/subd_patch_table.cpp index 68ec1b2c6a6..62572efa88a 100644 --- a/intern/cycles/subd/subd_patch_table.cpp +++ b/intern/cycles/subd/subd_patch_table.cpp @@ -214,7 +214,7 @@ void PackedPatchTable::pack(Far::PatchTable* patch_table, int offset) } table.resize(total_size()); - uint* data = &table[0]; + uint* data = table.data(); uint* array = data; uint* index = array + num_arrays * PATCH_ARRAY_SIZE; @@ -259,7 +259,7 @@ void PackedPatchTable::pack(Far::PatchTable* patch_table, int offset) void PackedPatchTable::copy_adjusting_offsets(uint* dest, int doffset) { - uint* src = &table[0]; + uint* src = table.data(); /* arrays */ for(int i = 0; i < num_arrays; i++) { diff --git a/intern/cycles/subd/subd_patch_table.h b/intern/cycles/subd/subd_patch_table.h index c8c7ecf9e47..3166a1691d8 100644 --- a/intern/cycles/subd/subd_patch_table.h +++ b/intern/cycles/subd/subd_patch_table.h @@ -43,7 +43,7 @@ namespace Far { struct PatchTable; } #define PATCH_NODE_SIZE 1 struct PackedPatchTable { - vector table; + array table; size_t num_arrays; size_t num_indices; -- cgit v1.2.3 From f92a6b8d1bea43d7b539d3e268913100257db981 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 18 Aug 2016 02:18:39 +0200 Subject: Fix compiler warning after fix for T48913. --- source/blender/blenkernel/intern/object_dupli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c index 3a0222b1c4b..14cc5ec0849 100644 --- a/source/blender/blenkernel/intern/object_dupli.c +++ b/source/blender/blenkernel/intern/object_dupli.c @@ -221,7 +221,7 @@ static void make_child_duplis(const DupliContext *ctx, void *userdata, MakeChild if (ctx->group) { unsigned int lay = ctx->group->layer; - unsigned int groupid = 0; + int groupid = 0; GroupObject *go; for (go = ctx->group->gobject.first; go; go = go->next, groupid++) { Object *ob = go->ob; @@ -240,7 +240,7 @@ static void make_child_duplis(const DupliContext *ctx, void *userdata, MakeChild } else { unsigned int lay = ctx->scene->lay; - unsigned int baseid = 0; + int baseid = 0; Base *base; for (base = ctx->scene->base.first; base; base = base->next, baseid++) { Object *ob = base->object; -- cgit v1.2.3 From a195dd15d4373ff0e240566795ff7795ca7485e6 Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Wed, 17 Aug 2016 00:12:28 -0400 Subject: NDOF: suppress buttons debug log Accidentally left this in the 3D mouse code. Mac only. --- intern/ghost/intern/GHOST_NDOFManagerCocoa.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm b/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm index 6fee39dcb82..b56757cd0fe 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm +++ b/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm @@ -210,7 +210,9 @@ static void DeviceEvent(uint32_t unused, uint32_t msg_type, void* msg_arg) case kConnexionCmdHandleButtons: { int button_bits = has_old_driver ? s->buttons8 : s->buttons; +#ifdef DEBUG_NDOF_BUTTONS printf("button bits: 0x%08x\n", button_bits); +#endif ndof_manager->updateButtons(button_bits, now); ghost_system->notifyExternalEventProcessed(); break; -- cgit v1.2.3 From b10d0058d72da3051895481ae5830a7b668b7d80 Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Thu, 18 Aug 2016 00:21:55 -0400 Subject: NDOF: compile 3D mouse code only if WITH_INPUT_NDOF When WITH_INPUT_NDOF is disabled, 3D mouse handling code is removed from: - GHOST (was mostly done, finished the job) - window manager - various editors - RNA - keymaps The input tab of user prefs does not show 3D mouse settings. Key map editor does not show NDOF mappings. DNA does not change. On my Mac the compiled binary is 42KB smaller after this change. It runs fine WITH_INPUT_NDOF on or off. --- intern/ghost/GHOST_C-api.h | 2 ++ intern/ghost/GHOST_ISystem.h | 2 ++ intern/ghost/GHOST_Types.h | 4 +++ intern/ghost/intern/GHOST_C-api.cpp | 3 +- intern/ghost/intern/GHOST_EventNDOF.h | 5 +++- intern/ghost/intern/GHOST_NDOFManager.h | 4 +++ intern/ghost/intern/GHOST_NDOFManagerCocoa.h | 4 --- intern/ghost/intern/GHOST_NDOFManagerUnix.cpp | 4 --- intern/ghost/intern/GHOST_NDOFManagerUnix.h | 3 -- intern/ghost/intern/GHOST_NDOFManagerWin32.cpp | 4 --- intern/ghost/intern/GHOST_NDOFManagerWin32.h | 4 --- intern/ghost/intern/GHOST_System.cpp | 11 +++---- intern/ghost/intern/GHOST_System.h | 4 +++ intern/ghost/intern/GHOST_SystemWin32.cpp | 6 ++-- release/scripts/startup/bl_ui/space_userpref.py | 19 ++++++------ source/blender/editors/CMakeLists.txt | 4 +++ .../blender/editors/interface/interface_handlers.c | 9 +++++- source/blender/editors/interface/view2d_ops.c | 7 ++++- source/blender/editors/sculpt_paint/paint_stroke.c | 2 ++ source/blender/editors/space_action/action_ops.c | 2 ++ source/blender/editors/space_clip/clip_intern.h | 2 ++ source/blender/editors/space_clip/clip_ops.c | 2 ++ source/blender/editors/space_clip/space_clip.c | 8 +++++ source/blender/editors/space_graph/graph_ops.c | 2 ++ source/blender/editors/space_image/image_intern.h | 2 ++ source/blender/editors/space_image/image_ops.c | 2 ++ source/blender/editors/space_image/space_image.c | 4 +++ source/blender/editors/space_logic/space_logic.c | 2 ++ source/blender/editors/space_nla/nla_ops.c | 2 ++ source/blender/editors/space_node/node_ops.c | 2 ++ .../editors/space_sequencer/sequencer_ops.c | 4 +++ source/blender/editors/space_time/time_ops.c | 2 ++ source/blender/editors/space_view3d/view3d_draw.c | 5 +++- source/blender/editors/space_view3d/view3d_edit.c | 4 +++ source/blender/editors/space_view3d/view3d_fly.c | 35 ++++++++++++++++------ .../blender/editors/space_view3d/view3d_intern.h | 7 ++++- source/blender/editors/space_view3d/view3d_ops.c | 7 +++-- source/blender/editors/space_view3d/view3d_walk.c | 34 +++++++++++++++------ source/blender/editors/transform/transform_ops.c | 2 +- source/blender/makesrna/intern/CMakeLists.txt | 4 +++ source/blender/makesrna/intern/rna_userdef.c | 12 ++++++++ source/blender/makesrna/intern/rna_wm.c | 12 +++++++- source/blender/windowmanager/CMakeLists.txt | 4 +++ source/blender/windowmanager/WM_api.h | 8 ++++- source/blender/windowmanager/WM_types.h | 2 ++ .../blender/windowmanager/intern/wm_event_system.c | 12 ++++++++ source/blender/windowmanager/intern/wm_init_exit.c | 3 ++ source/blender/windowmanager/intern/wm_operators.c | 10 +++---- source/blender/windowmanager/wm_event_types.h | 10 ++++++- 49 files changed, 236 insertions(+), 72 deletions(-) diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index f1484a298d3..ff1922af4f3 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -433,6 +433,7 @@ extern GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle, GHOST_TButtonMask mask, int *isDown); +#ifdef WITH_INPUT_NDOF /*************************************************************************************** * Access to 3D mouse. ***************************************************************************************/ @@ -442,6 +443,7 @@ extern GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle, * \param deadzone Deadzone of the 3D mouse (both for rotation and pan) relative to full range */ extern void GHOST_setNDOFDeadZone(float deadzone); +#endif /*************************************************************************************** diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index 08045b93db9..03193d6e1da 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -377,11 +377,13 @@ public: */ virtual GHOST_TSuccess getButtonState(GHOST_TButtonMask mask, bool& isDown) const = 0; +#ifdef WITH_INPUT_NDOF /** * Sets 3D mouse deadzone * \param deadzone: Deadzone of the 3D mouse (both for rotation and pan) relative to full range */ virtual void setNDOFDeadZone(float deadzone) = 0; +#endif /** * Toggles console diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 0dd5d15b011..9ee4599a4a6 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -172,8 +172,10 @@ typedef enum { GHOST_kEventWheel, /// Mouse wheel event GHOST_kEventTrackpad, /// Trackpad event +#ifdef WITH_INPUT_NDOF GHOST_kEventNDOFMotion, /// N degree of freedom device motion event GHOST_kEventNDOFButton, /// N degree of freedom device button event +#endif GHOST_kEventKeyDown, GHOST_kEventKeyUp, @@ -478,6 +480,7 @@ typedef enum { GHOST_kFinished } GHOST_TProgress; +#ifdef WITH_INPUT_NDOF typedef struct { /** N-degree of freedom device data v3 [GSoC 2010] */ // Each component normally ranges from -1 to +1, but can exceed that. @@ -497,6 +500,7 @@ typedef struct { GHOST_TButtonAction action; short button; } GHOST_TEventNDOFButtonData; +#endif // WITH_INPUT_NDOF typedef struct { /** The key code. */ diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp index ccd7f57f9a4..41bc735e1e2 100644 --- a/intern/ghost/intern/GHOST_C-api.cpp +++ b/intern/ghost/intern/GHOST_C-api.cpp @@ -406,12 +406,13 @@ GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle, } +#ifdef WITH_INPUT_NDOF void GHOST_setNDOFDeadZone(float deadzone) { GHOST_ISystem *system = GHOST_ISystem::getSystem(); system->setNDOFDeadZone(deadzone); } - +#endif void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 canAccept) { diff --git a/intern/ghost/intern/GHOST_EventNDOF.h b/intern/ghost/intern/GHOST_EventNDOF.h index b4037896b93..754e1091860 100644 --- a/intern/ghost/intern/GHOST_EventNDOF.h +++ b/intern/ghost/intern/GHOST_EventNDOF.h @@ -22,9 +22,12 @@ /** \file ghost/intern/GHOST_EventNDOF.h * \ingroup GHOST - * Declaration of GHOST_EventManager class. */ +#ifndef WITH_INPUT_NDOF +# error NDOF code included in non-NDOF-enabled build +#endif + #ifndef __GHOST_EVENTNDOF_H__ #define __GHOST_EVENTNDOF_H__ diff --git a/intern/ghost/intern/GHOST_NDOFManager.h b/intern/ghost/intern/GHOST_NDOFManager.h index d3c70bbac50..83d06ef5871 100644 --- a/intern/ghost/intern/GHOST_NDOFManager.h +++ b/intern/ghost/intern/GHOST_NDOFManager.h @@ -21,6 +21,10 @@ * ***** END GPL LICENSE BLOCK ***** */ +#ifndef WITH_INPUT_NDOF +# error NDOF code included in non-NDOF-enabled build +#endif + #ifndef __GHOST_NDOFMANAGER_H__ #define __GHOST_NDOFMANAGER_H__ diff --git a/intern/ghost/intern/GHOST_NDOFManagerCocoa.h b/intern/ghost/intern/GHOST_NDOFManagerCocoa.h index 464ba48145e..3f1bfcf57fc 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerCocoa.h +++ b/intern/ghost/intern/GHOST_NDOFManagerCocoa.h @@ -24,8 +24,6 @@ #ifndef __GHOST_NDOFMANAGERCOCOA_H__ #define __GHOST_NDOFMANAGERCOCOA_H__ -#ifdef WITH_INPUT_NDOF - #include "GHOST_NDOFManager.h" // Event capture is handled within the NDOF manager on Macintosh, @@ -40,6 +38,4 @@ public: bool available(); }; - -#endif // WITH_INPUT_NDOF #endif // #include guard diff --git a/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp b/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp index 8fea2a0261b..ded13b5c094 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp +++ b/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp @@ -21,8 +21,6 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WITH_INPUT_NDOF - #include "GHOST_NDOFManagerUnix.h" #include "GHOST_System.h" @@ -144,5 +142,3 @@ bool GHOST_NDOFManagerUnix::processEvents() return anyProcessed; } - -#endif /* WITH_INPUT_NDOF */ diff --git a/intern/ghost/intern/GHOST_NDOFManagerUnix.h b/intern/ghost/intern/GHOST_NDOFManagerUnix.h index 278a8cb6fe0..3fd171d9e76 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerUnix.h +++ b/intern/ghost/intern/GHOST_NDOFManagerUnix.h @@ -24,8 +24,6 @@ #ifndef __GHOST_NDOFMANAGERUNIX_H__ #define __GHOST_NDOFMANAGERUNIX_H__ -#ifdef WITH_INPUT_NDOF - #include "GHOST_NDOFManager.h" /* Event capture is handled within the NDOF manager on Linux, @@ -43,5 +41,4 @@ private: bool m_available; }; -#endif /* WITH_INPUT_NDOF */ #endif /* __GHOST_NDOFMANAGERUNIX_H__ */ diff --git a/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp b/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp index 7ccd2e602b4..0023ee7e1d0 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp +++ b/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp @@ -22,8 +22,6 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WITH_INPUT_NDOF // use contents of this file - #include "GHOST_NDOFManagerWin32.h" @@ -40,5 +38,3 @@ bool GHOST_NDOFManagerWin32::available() // always available since RawInput is built into Windows return true; } - -#endif // WITH_INPUT_NDOF diff --git a/intern/ghost/intern/GHOST_NDOFManagerWin32.h b/intern/ghost/intern/GHOST_NDOFManagerWin32.h index 9b5192817eb..2f7bc9ee732 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerWin32.h +++ b/intern/ghost/intern/GHOST_NDOFManagerWin32.h @@ -25,8 +25,6 @@ #ifndef __GHOST_NDOFMANAGERWIN32_H__ #define __GHOST_NDOFMANAGERWIN32_H__ -#ifdef WITH_INPUT_NDOF - #include "GHOST_NDOFManager.h" @@ -37,6 +35,4 @@ public: bool available(); }; - -#endif // WITH_INPUT_NDOF #endif // #include guard diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index c53580818e6..56d68b98ce0 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -38,11 +38,13 @@ #include "GHOST_DisplayManager.h" #include "GHOST_EventManager.h" -#include "GHOST_NDOFManager.h" #include "GHOST_TimerTask.h" #include "GHOST_TimerManager.h" #include "GHOST_WindowManager.h" +#ifdef WITH_INPUT_NDOF +# include "GHOST_NDOFManager.h" +#endif GHOST_System::GHOST_System() : m_nativePixel(false), @@ -292,14 +294,12 @@ GHOST_TSuccess GHOST_System::getButtonState(GHOST_TButtonMask mask, bool& isDown return success; } +#ifdef WITH_INPUT_NDOF void GHOST_System::setNDOFDeadZone(float deadzone) { -#ifdef WITH_INPUT_NDOF this->m_ndofManager->setDeadZone(deadzone); -#else - (void)deadzone; -#endif } +#endif GHOST_TSuccess GHOST_System::init() { @@ -345,6 +345,7 @@ GHOST_TSuccess GHOST_System::exit() delete m_ndofManager; m_ndofManager = NULL; #endif + return GHOST_kSuccess; } diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h index a10259bc9e9..af083996d91 100644 --- a/intern/ghost/intern/GHOST_System.h +++ b/intern/ghost/intern/GHOST_System.h @@ -48,7 +48,9 @@ class GHOST_Event; class GHOST_TimerManager; class GHOST_Window; class GHOST_WindowManager; +#ifdef WITH_INPUT_NDOF class GHOST_NDOFManager; +#endif /** * Implementation of platform independent functionality of the GHOST_ISystem @@ -236,6 +238,7 @@ public: */ GHOST_TSuccess getButtonState(GHOST_TButtonMask mask, bool& isDown) const; +#ifdef WITH_INPUT_NDOF /*************************************************************************************** * Access to 3D mouse. ***************************************************************************************/ @@ -245,6 +248,7 @@ public: * \param deadzone: Deadzone of the 3D mouse (both for rotation and pan) relative to full range */ void setNDOFDeadZone(float deadzone); +#endif /*************************************************************************************** * Other (internal) functionality. diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 1ce8002520f..f884b0fadb1 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -57,7 +57,7 @@ #include "GHOST_WindowWin32.h" #ifdef WITH_INPUT_NDOF -#include "GHOST_NDOFManagerWin32.h" + #include "GHOST_NDOFManagerWin32.h" #endif // Key code values not found in winuser.h @@ -125,9 +125,9 @@ static void initRawInput() { #ifdef WITH_INPUT_NDOF -#define DEVICE_COUNT 2 + #define DEVICE_COUNT 2 #else -#define DEVICE_COUNT 1 + #define DEVICE_COUNT 1 #endif RAWINPUTDEVICE devices[DEVICE_COUNT]; diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 1512f4f4600..dcafac66fca 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -1177,15 +1177,16 @@ class USERPREF_PT_input(Panel): sub.prop(walk, "view_height") sub.prop(walk, "jump_height") - col.separator() - col.label(text="NDOF Device:") - sub = col.column(align=True) - sub.prop(inputs, "ndof_sensitivity", text="NDOF Sensitivity") - sub.prop(inputs, "ndof_orbit_sensitivity", text="NDOF Orbit Sensitivity") - sub.prop(inputs, "ndof_deadzone", text="NDOF Deadzone") - sub = col.column(align=True) - sub.row().prop(inputs, "ndof_view_navigate_method", expand=True) - sub.row().prop(inputs, "ndof_view_rotate_method", expand=True) + if inputs.use_ndof: + col.separator() + col.label(text="NDOF Device:") + sub = col.column(align=True) + sub.prop(inputs, "ndof_sensitivity", text="NDOF Sensitivity") + sub.prop(inputs, "ndof_orbit_sensitivity", text="NDOF Orbit Sensitivity") + sub.prop(inputs, "ndof_deadzone", text="NDOF Deadzone") + sub = col.column(align=True) + sub.row().prop(inputs, "ndof_view_navigate_method", expand=True) + sub.row().prop(inputs, "ndof_view_rotate_method", expand=True) row.separator() diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt index 084006ce277..1559512d713 100644 --- a/source/blender/editors/CMakeLists.txt +++ b/source/blender/editors/CMakeLists.txt @@ -19,6 +19,10 @@ # ***** END GPL LICENSE BLOCK ***** if(WITH_BLENDER) + if(WITH_INPUT_NDOF) + add_definitions(-DWITH_INPUT_NDOF) + endif() + add_subdirectory(animation) add_subdirectory(armature) add_subdirectory(curve) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 79831cefde6..d05a80bed62 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -5415,6 +5415,7 @@ static bool ui_numedit_but_HSVCUBE( return changed; } +#ifdef WITH_INPUT_NDOF static void ui_ndofedit_but_HSVCUBE( uiBut *but, uiHandleButtonData *data, const wmNDOFMotionData *ndof, @@ -5487,6 +5488,7 @@ static void ui_ndofedit_but_HSVCUBE( copy_v3_v3(data->vec, rgb); ui_but_v3_set(but, data->vec); } +#endif /* WITH_INPUT_NDOF */ static int ui_do_but_HSVCUBE( bContext *C, uiBlock *block, uiBut *but, @@ -5514,6 +5516,7 @@ static int ui_do_but_HSVCUBE( return WM_UI_HANDLER_BREAK; } +#ifdef WITH_INPUT_NDOF else if (event->type == NDOF_MOTION) { const wmNDOFMotionData *ndof = event->customdata; const enum eSnapType snap = ui_event_to_snap(event); @@ -5525,6 +5528,7 @@ static int ui_do_but_HSVCUBE( return WM_UI_HANDLER_BREAK; } +#endif /* WITH_INPUT_NDOF */ /* XXX hardcoded keymap check.... */ else if (event->type == BACKSPACEKEY && event->val == KM_PRESS) { if (ELEM(but->a1, UI_GRAD_V_ALT, UI_GRAD_L_ALT)) { @@ -5680,6 +5684,7 @@ static bool ui_numedit_but_HSVCIRCLE( return changed; } +#ifdef WITH_INPUT_NDOF static void ui_ndofedit_but_HSVCIRCLE( uiBut *but, uiHandleButtonData *data, const wmNDOFMotionData *ndof, @@ -5750,7 +5755,7 @@ static void ui_ndofedit_but_HSVCIRCLE( ui_but_v3_set(but, data->vec); } - +#endif /* WITH_INPUT_NDOF */ static int ui_do_but_HSVCIRCLE( bContext *C, uiBlock *block, uiBut *but, @@ -5778,6 +5783,7 @@ static int ui_do_but_HSVCIRCLE( return WM_UI_HANDLER_BREAK; } +#ifdef WITH_INPUT_NDOF else if (event->type == NDOF_MOTION) { const enum eSnapType snap = ui_event_to_snap(event); const wmNDOFMotionData *ndof = event->customdata; @@ -5789,6 +5795,7 @@ static int ui_do_but_HSVCIRCLE( return WM_UI_HANDLER_BREAK; } +#endif /* WITH_INPUT_NDOF */ /* XXX hardcoded keymap check.... */ else if (event->type == BACKSPACEKEY && event->val == KM_PRESS) { int len; diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index f60fed398ec..f095ba9a03d 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1296,7 +1296,7 @@ static void VIEW2D_OT_zoom_border(wmOperatorType *ot) WM_operator_properties_gesture_border(ot, false); } - +#ifdef WITH_INPUT_NDOF static int view2d_ndof_invoke(bContext *C, wmOperator *op, const wmEvent *event) { if (event->type != NDOF_MOTION) { @@ -1369,6 +1369,7 @@ static void VIEW2D_OT_ndof(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_LOCK_BYPASS; } +#endif /* WITH_INPUT_NDOF */ /* ********************************************************* */ /* SMOOTH VIEW */ @@ -2067,7 +2068,9 @@ void ED_operatortypes_view2d(void) WM_operatortype_append(VIEW2D_OT_zoom); WM_operatortype_append(VIEW2D_OT_zoom_border); +#ifdef WITH_INPUT_NDOF WM_operatortype_append(VIEW2D_OT_ndof); +#endif WM_operatortype_append(VIEW2D_OT_smoothview); @@ -2097,7 +2100,9 @@ void ED_keymap_view2d(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_down", WHEELDOWNMOUSE, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_up", WHEELUPMOUSE, KM_PRESS, KM_SHIFT, 0); +#ifdef WITH_INPUT_NDOF WM_keymap_add_item(keymap, "VIEW2D_OT_ndof", NDOF_MOTION, 0, 0, 0); +#endif /* zoom - single step */ WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_out", WHEELOUTMOUSE, KM_PRESS, 0, 0); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 1431958501d..d53d87db228 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -1102,12 +1102,14 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) paint_stroke_add_sample(p, stroke, event->mval[0], event->mval[1], pressure); paint_stroke_sample_average(stroke, &sample_average); +#ifdef WITH_INPUT_NDOF /* let NDOF motion pass through to the 3D view so we can paint and rotate simultaneously! * this isn't perfect... even when an extra MOUSEMOVE is spoofed, the stroke discards it * since the 2D deltas are zero -- code in this file needs to be updated to use the * post-NDOF_MOTION MOUSEMOVE */ if (event->type == NDOF_MOTION) return OPERATOR_PASS_THROUGH; +#endif /* one time initialization */ if (!stroke->stroke_init) { diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index a261202b690..718a4fd3c38 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -240,7 +240,9 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) /* auto-set range */ WM_keymap_add_item(keymap, "ACTION_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "ACTION_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); +#ifdef WITH_INPUT_NDOF WM_keymap_add_item(keymap, "ACTION_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); +#endif WM_keymap_add_item(keymap, "ACTION_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ACTION_OT_view_frame", PAD0, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index 13dcd405ee6..14393c6968b 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -106,7 +106,9 @@ void CLIP_OT_change_frame(wmOperatorType *ot); void CLIP_OT_rebuild_proxy(struct wmOperatorType *ot); void CLIP_OT_mode_set(struct wmOperatorType *ot); +#ifdef WITH_INPUT_NDOF void CLIP_OT_view_ndof(struct wmOperatorType *ot); +#endif void CLIP_OT_prefetch(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 83876ae2669..6778a0b1805 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -1405,6 +1405,7 @@ void CLIP_OT_mode_set(wmOperatorType *ot) RNA_def_enum(ot->srna, "mode", rna_enum_clip_editor_mode_items, SC_MODE_TRACKING, "Mode", ""); } +#ifdef WITH_INPUT_NDOF /********************** NDOF operator *********************/ /* Combined pan/zoom from a 3D mouse device. @@ -1451,6 +1452,7 @@ void CLIP_OT_view_ndof(wmOperatorType *ot) ot->invoke = clip_view_ndof_invoke; ot->poll = ED_space_clip_view_clip_poll; } +#endif /* WITH_INPUT_NDOF */ /********************** Prefetch operator *********************/ diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 4f653bab682..05e69968e35 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -429,7 +429,9 @@ static void clip_operatortypes(void) WM_operatortype_append(CLIP_OT_change_frame); WM_operatortype_append(CLIP_OT_rebuild_proxy); WM_operatortype_append(CLIP_OT_mode_set); +#ifdef WITH_INPUT_NDOF WM_operatortype_append(CLIP_OT_view_ndof); +#endif WM_operatortype_append(CLIP_OT_prefetch); WM_operatortype_append(CLIP_OT_set_scene_frames); WM_operatortype_append(CLIP_OT_cursor_set); @@ -622,8 +624,10 @@ static void clip_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "CLIP_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); +#ifdef WITH_INPUT_NDOF WM_keymap_add_item(keymap, "CLIP_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "CLIP_OT_view_ndof", NDOF_MOTION, 0, 0, 0); +#endif /* jump to special frame */ kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); @@ -779,7 +783,9 @@ static void clip_keymap(struct wmKeyConfig *keyconf) /* view */ WM_keymap_add_item(keymap, "CLIP_OT_graph_view_all", HOMEKEY, KM_PRESS, 0, 0); +#ifdef WITH_INPUT_NDOF WM_keymap_add_item(keymap, "CLIP_OT_graph_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); +#endif WM_keymap_add_item(keymap, "CLIP_OT_graph_center_current_frame", PADPERIOD, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", LKEY, KM_PRESS, 0, 0); @@ -810,7 +816,9 @@ static void clip_keymap(struct wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "extend", true); /* toggle */ WM_keymap_add_item(keymap, "CLIP_OT_dopesheet_view_all", HOMEKEY, KM_PRESS, 0, 0); +#ifdef WITH_INPUT_NDOF WM_keymap_add_item(keymap, "CLIP_OT_dopesheet_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); +#endif } const char *clip_context_dir[] = {"edit_movieclip", "edit_mask", NULL}; diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 478dbd3d9c0..75f0da83e77 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -632,7 +632,9 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) /* auto-set range */ WM_keymap_add_item(keymap, "GRAPH_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "GRAPH_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); +#ifdef WITH_INPUT_NDOF WM_keymap_add_item(keymap, "GRAPH_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); +#endif WM_keymap_add_item(keymap, "GRAPH_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "GRAPH_OT_view_frame", PAD0, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h index 69993c3be65..52d04ad4956 100644 --- a/source/blender/editors/space_image/image_intern.h +++ b/source/blender/editors/space_image/image_intern.h @@ -64,7 +64,9 @@ void IMAGE_OT_view_zoom_in(struct wmOperatorType *ot); void IMAGE_OT_view_zoom_out(struct wmOperatorType *ot); void IMAGE_OT_view_zoom_ratio(struct wmOperatorType *ot); void IMAGE_OT_view_zoom_border(struct wmOperatorType *ot); +#ifdef WITH_INPUT_NDOF void IMAGE_OT_view_ndof(struct wmOperatorType *ot); +#endif void IMAGE_OT_new(struct wmOperatorType *ot); void IMAGE_OT_open(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 1158e692182..f9d76da9f87 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -656,6 +656,7 @@ void IMAGE_OT_view_zoom(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_HIDDEN); } +#ifdef WITH_INPUT_NDOF /********************** NDOF operator *********************/ /* Combined pan/zoom from a 3D mouse device. @@ -705,6 +706,7 @@ void IMAGE_OT_view_ndof(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_LOCK_BYPASS; } +#endif /* WITH_INPUT_NDOF */ /********************** view all operator *********************/ diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 35a658eac23..6ddf78290aa 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -235,7 +235,9 @@ static void image_operatortypes(void) WM_operatortype_append(IMAGE_OT_view_zoom_out); WM_operatortype_append(IMAGE_OT_view_zoom_ratio); WM_operatortype_append(IMAGE_OT_view_zoom_border); +#ifdef WITH_INPUT_NDOF WM_operatortype_append(IMAGE_OT_view_ndof); +#endif WM_operatortype_append(IMAGE_OT_new); WM_operatortype_append(IMAGE_OT_open); @@ -296,8 +298,10 @@ static void image_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "IMAGE_OT_view_pan", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "IMAGE_OT_view_pan", MOUSEPAN, 0, 0, 0); +#ifdef WITH_INPUT_NDOF WM_keymap_add_item(keymap, "IMAGE_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); // or view selected? WM_keymap_add_item(keymap, "IMAGE_OT_view_ndof", NDOF_MOTION, 0, 0, 0); +#endif WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_in", WHEELINMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_out", WHEELOUTMOUSE, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c index 69966e9bf34..12ca141128b 100644 --- a/source/blender/editors/space_logic/space_logic.c +++ b/source/blender/editors/space_logic/space_logic.c @@ -186,7 +186,9 @@ static void logic_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "LOGIC_MT_logicbricks_add", AKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "LOGIC_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); +#ifdef WITH_INPUT_NDOF WM_keymap_add_item(keymap, "LOGIC_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); +#endif } static void logic_refresh(const bContext *UNUSED(C), ScrArea *UNUSED(sa)) diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index 386950ead3a..48037a10b2d 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -242,7 +242,9 @@ static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap) WM_keymap_add_item(keymap, "NLA_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "NLA_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); +#ifdef WITH_INPUT_NDOF WM_keymap_add_item(keymap, "NLA_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); +#endif WM_keymap_add_item(keymap, "NLA_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NLA_OT_view_frame", PAD0, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index 7788173a8ee..5118d52efc4 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -295,7 +295,9 @@ void node_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "NODE_OT_hide_socket_toggle", HKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "NODE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); +#ifdef WITH_INPUT_NDOF WM_keymap_add_item(keymap, "NODE_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); +#endif WM_keymap_add_item(keymap, "NODE_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "NODE_OT_select_border", BKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 655e029cfdd..a3cfcae77b8 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -201,7 +201,9 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_separate", GKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); +#ifdef WITH_INPUT_NDOF WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); +#endif WM_keymap_add_item(keymap, "SEQUENCER_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_view_frame", PAD0, KM_PRESS, 0, 0); @@ -340,7 +342,9 @@ void sequencer_keymap(wmKeyConfig *keyconf) /* Preview Region ----------------------------------------------------------- */ keymap = WM_keymap_find(keyconf, "SequencerPreview", SPACE_SEQ, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all_preview", HOMEKEY, KM_PRESS, 0, 0); +#ifdef WITH_INPUT_NDOF WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all_preview", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); +#endif WM_keymap_add_item(keymap, "SEQUENCER_OT_view_ghost_border", OKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c index 7dd45327352..872793128f0 100644 --- a/source/blender/editors/space_time/time_ops.c +++ b/source/blender/editors/space_time/time_ops.c @@ -219,7 +219,9 @@ void time_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "TIME_OT_start_frame_set", SKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "TIME_OT_end_frame_set", EKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "TIME_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); +#ifdef WITH_INPUT_NDOF WM_keymap_add_item(keymap, "TIME_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); +#endif WM_keymap_add_item(keymap, "TIME_OT_view_frame", PAD0, KM_PRESS, 0, 0); } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 1de06af0478..d2a52de0e28 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -645,6 +645,7 @@ static void draw_view_axis(RegionView3D *rv3d, rcti *rect) glDisable(GL_BLEND); } +#ifdef WITH_INPUT_NDOF /* draw center and axis of rotation for ongoing 3D mouse navigation */ static void draw_rotation_guide(RegionView3D *rv3d) { @@ -749,6 +750,7 @@ static void draw_rotation_guide(RegionView3D *rv3d) glDisable(GL_POINT_SMOOTH); glDepthMask(1); } +#endif /* WITH_INPUT_NDOF */ static void draw_view_icon(RegionView3D *rv3d, rcti *rect) { @@ -3917,10 +3919,11 @@ static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, Vie BDR_drawSketch(C); } +#ifdef WITH_INPUT_NDOF if ((U.ndof_flag & NDOF_SHOW_GUIDE) && ((rv3d->viewlock & RV3D_LOCKED) == 0) && (rv3d->persp != RV3D_CAMOB)) /* TODO: draw something else (but not this) during fly mode */ draw_rotation_guide(rv3d); - +#endif } static bool is_cursor_visible(Scene *scene) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 215d90a8878..9b8ca2d26da 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1329,6 +1329,8 @@ void VIEW3D_OT_rotate(wmOperatorType *ot) ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR; } +#ifdef WITH_INPUT_NDOF + /** \name NDOF Utility Functions * \{ */ @@ -1894,6 +1896,8 @@ void VIEW3D_OT_ndof_all(struct wmOperatorType *ot) ot->flag = 0; } +#endif /* WITH_INPUT_NDOF */ + /* ************************ viewmove ******************************** */ diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 31377d0fce8..04a6aa215f4 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -26,8 +26,10 @@ /* defines VIEW3D_OT_fly modal operator */ -//#define NDOF_FLY_DEBUG -//#define NDOF_FLY_DRAW_TOOMUCH /* is this needed for ndof? - commented so redraw doesnt thrash - campbell */ +#ifdef WITH_INPUT_NDOF +//# define NDOF_FLY_DEBUG +//# define NDOF_FLY_DRAW_TOOMUCH /* is this needed for ndof? - commented so redraw doesnt thrash - campbell */ +#endif /* WITH_INPUT_NDOF */ #include "DNA_object_types.h" @@ -203,7 +205,10 @@ typedef struct FlyInfo { int mval[2]; /* latest 2D mouse values */ int center_mval[2]; /* center mouse values */ float width, height; /* camera viewport dimensions */ + +#ifdef WITH_INPUT_NDOF wmNDOFMotionData *ndof; /* latest 3D mouse values */ +#endif /* fly state state */ float speed; /* the speed the view is moving per redraw */ @@ -381,7 +386,10 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent fly->timer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, 0.01f); copy_v2_v2_int(fly->mval, event->mval); + +#ifdef WITH_INPUT_NDOF fly->ndof = NULL; +#endif fly->time_lastdraw = fly->time_lastwheel = PIL_check_seconds_timer(); @@ -449,8 +457,10 @@ static int flyEnd(bContext *C, FlyInfo *fly) rv3d->rflag &= ~RV3D_NAVIGATING; +#ifdef WITH_INPUT_NDOF if (fly->ndof) MEM_freeN(fly->ndof); +#endif if (fly->state == FLY_CONFIRM) { MEM_freeN(fly); @@ -469,6 +479,7 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e else if (event->type == MOUSEMOVE) { copy_v2_v2_int(fly->mval, event->mval); } +#ifdef WITH_INPUT_NDOF else if (event->type == NDOF_MOTION) { /* do these automagically get delivered? yes. */ // puts("ndof motion detected in fly mode!"); @@ -478,15 +489,15 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e switch (incoming_ndof->progress) { case P_STARTING: /* start keeping track of 3D mouse position */ -#ifdef NDOF_FLY_DEBUG +# ifdef NDOF_FLY_DEBUG puts("start keeping track of 3D mouse position"); -#endif +# endif /* fall-through */ case P_IN_PROGRESS: /* update 3D mouse position */ -#ifdef NDOF_FLY_DEBUG +# ifdef NDOF_FLY_DEBUG putchar('.'); fflush(stdout); -#endif +# endif if (fly->ndof == NULL) { // fly->ndof = MEM_mallocN(sizeof(wmNDOFMotionData), tag_name); fly->ndof = MEM_dupallocN(incoming_ndof); @@ -498,9 +509,9 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e break; case P_FINISHING: /* stop keeping track of 3D mouse position */ -#ifdef NDOF_FLY_DEBUG +# ifdef NDOF_FLY_DEBUG puts("stop keeping track of 3D mouse position"); -#endif +# endif if (fly->ndof) { MEM_freeN(fly->ndof); // free(fly->ndof); @@ -513,6 +524,7 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e break; /* should always be one of the above 3 */ } } +#endif /* WITH_INPUT_NDOF */ /* handle modal keymap first */ else if (event->type == EVT_MODAL_MAP) { switch (event->val) { @@ -959,6 +971,7 @@ static int flyApply(bContext *C, FlyInfo *fly) return OPERATOR_FINISHED; } +#ifdef WITH_INPUT_NDOF static void flyApply_ndof(bContext *C, FlyInfo *fly) { Object *lock_ob = ED_view3d_cameracontrol_object_get(fly->v3d_camera_control); @@ -977,6 +990,7 @@ static void flyApply_ndof(bContext *C, FlyInfo *fly) } } } +#endif /* WITH_INPUT_NDOF */ static int fly_invoke(bContext *C, wmOperator *op, const wmEvent *event) { @@ -1023,12 +1037,15 @@ static int fly_modal(bContext *C, wmOperator *op, const wmEvent *event) flyEvent(C, op, fly, event); +#ifdef WITH_INPUT_NDOF if (fly->ndof) { /* 3D mouse overrules [2D mouse + timer] */ if (event->type == NDOF_MOTION) { flyApply_ndof(C, fly); } } - else if (event->type == TIMER && event->customdata == fly->timer) { + else +#endif /* WITH_INPUT_NDOF */ + if (event->type == TIMER && event->customdata == fly->timer) { flyApply(C, fly); } diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index bdd2702a6ce..314dadbaa52 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -46,7 +46,6 @@ struct bContext; struct bMotionPath; struct bPoseChannel; struct Mesh; -struct wmNDOFMotionData; struct wmOperatorType; struct wmWindowManager; struct wmKeyConfig; @@ -76,10 +75,12 @@ void VIEW3D_OT_dolly(struct wmOperatorType *ot); void VIEW3D_OT_zoom_camera_1_to_1(struct wmOperatorType *ot); void VIEW3D_OT_move(struct wmOperatorType *ot); void VIEW3D_OT_rotate(struct wmOperatorType *ot); +#ifdef WITH_INPUT_NDOF void VIEW3D_OT_ndof_orbit(struct wmOperatorType *ot); void VIEW3D_OT_ndof_orbit_zoom(struct wmOperatorType *ot); void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot); void VIEW3D_OT_ndof_all(struct wmOperatorType *ot); +#endif /* WITH_INPUT_NDOF */ void VIEW3D_OT_view_all(struct wmOperatorType *ot); void VIEW3D_OT_viewnumpad(struct wmOperatorType *ot); void VIEW3D_OT_view_selected(struct wmOperatorType *ot); @@ -111,11 +112,15 @@ void view3d_orbit_apply_dyn_ofs( float r_ofs[3], const float ofs_old[3], const float viewquat_old[4], const float viewquat_new[4], const float dyn_ofs[3]); +#ifdef WITH_INPUT_NDOF +struct wmNDOFMotionData; + void view3d_ndof_fly( const struct wmNDOFMotionData *ndof, struct View3D *v3d, struct RegionView3D *rv3d, const bool use_precision, const short protectflag, bool *r_has_translate, bool *r_has_rotate); +#endif /* WITH_INPUT_NDOF */ /* view3d_fly.c */ void view3d_keymap(struct wmKeyConfig *keyconf); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index b273f46fca3..cfeb8af280e 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -164,10 +164,12 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_zoom); WM_operatortype_append(VIEW3D_OT_zoom_camera_1_to_1); WM_operatortype_append(VIEW3D_OT_dolly); +#ifdef WITH_INPUT_NDOF WM_operatortype_append(VIEW3D_OT_ndof_orbit_zoom); WM_operatortype_append(VIEW3D_OT_ndof_orbit); WM_operatortype_append(VIEW3D_OT_ndof_pan); WM_operatortype_append(VIEW3D_OT_ndof_all); +#endif /* WITH_INPUT_NDOF */ WM_operatortype_append(VIEW3D_OT_view_all); WM_operatortype_append(VIEW3D_OT_viewnumpad); WM_operatortype_append(VIEW3D_OT_view_orbit); @@ -363,7 +365,7 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "VIEW3D_OT_localview", PADSLASHKEY, KM_PRESS, 0, 0); - /* NDOF: begin */ +#ifdef WITH_INPUT_NDOF /* note: positioned here so keymaps show keyboard keys if assigned */ /* 3D mouse */ WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_orbit_zoom", NDOF_MOTION, 0, 0, 0); @@ -392,8 +394,7 @@ void view3d_keymap(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_TOP, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_TOP); RNA_boolean_set(kmi->ptr, "align_active", true); - /* NDOF: end */ - +#endif /* WITH_INPUT_NDOF */ /* layers, shift + alt are properties set in invoke() */ RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", ACCENTGRAVEKEY, KM_PRESS, 0, 0)->ptr, "nr", 0); diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index c9e4bb301b8..17c08ed4205 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -59,8 +59,10 @@ #include "view3d_intern.h" /* own include */ -//#define NDOF_WALK_DEBUG -//#define NDOF_WALK_DRAW_TOOMUCH /* is this needed for ndof? - commented so redraw doesnt thrash - campbell */ +#ifdef WITH_INPUT_NDOF +//# define NDOF_WALK_DEBUG +//# define NDOF_WALK_DRAW_TOOMUCH /* is this needed for ndof? - commented so redraw doesnt thrash - campbell */ +#endif #define USE_TABLET_SUPPORT @@ -254,7 +256,10 @@ typedef struct WalkInfo { int prev_mval[2]; /* previous 2D mouse values */ int center_mval[2]; /* center mouse values */ int moffset[2]; + +#ifdef WITH_INPUT_NDOF wmNDOFMotionData *ndof; /* latest 3D mouse values */ +#endif /* walk state state */ float base_speed; /* the base speed without run/slow down modifications */ @@ -572,7 +577,9 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) walk->timer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, 0.01f); +#ifdef WITH_INPUT_NDOF walk->ndof = NULL; +#endif walk->time_lastdraw = PIL_check_seconds_timer(); @@ -639,8 +646,10 @@ static int walkEnd(bContext *C, WalkInfo *walk) rv3d->rflag &= ~RV3D_NAVIGATING; +#ifdef WITH_INPUT_NDOF if (walk->ndof) MEM_freeN(walk->ndof); +#endif /* restore the cursor */ WM_cursor_modal_restore(win); @@ -743,6 +752,7 @@ static void walkEvent(bContext *C, wmOperator *op, WalkInfo *walk, const wmEvent } } } +#ifdef WITH_INPUT_NDOF else if (event->type == NDOF_MOTION) { /* do these automagically get delivered? yes. */ // puts("ndof motion detected in walk mode!"); @@ -752,15 +762,15 @@ static void walkEvent(bContext *C, wmOperator *op, WalkInfo *walk, const wmEvent switch (incoming_ndof->progress) { case P_STARTING: /* start keeping track of 3D mouse position */ -#ifdef NDOF_WALK_DEBUG +# ifdef NDOF_WALK_DEBUG puts("start keeping track of 3D mouse position"); -#endif +# endif /* fall-through */ case P_IN_PROGRESS: /* update 3D mouse position */ -#ifdef NDOF_WALK_DEBUG +# ifdef NDOF_WALK_DEBUG putchar('.'); fflush(stdout); -#endif +# endif if (walk->ndof == NULL) { // walk->ndof = MEM_mallocN(sizeof(wmNDOFMotionData), tag_name); walk->ndof = MEM_dupallocN(incoming_ndof); @@ -772,9 +782,9 @@ static void walkEvent(bContext *C, wmOperator *op, WalkInfo *walk, const wmEvent break; case P_FINISHING: /* stop keeping track of 3D mouse position */ -#ifdef NDOF_WALK_DEBUG +# ifdef NDOF_WALK_DEBUG puts("stop keeping track of 3D mouse position"); -#endif +# endif if (walk->ndof) { MEM_freeN(walk->ndof); // free(walk->ndof); @@ -789,6 +799,7 @@ static void walkEvent(bContext *C, wmOperator *op, WalkInfo *walk, const wmEvent break; /* should always be one of the above 3 */ } } +#endif /* WITH_INPUT_NDOF */ /* handle modal keymap first */ else if (event->type == EVT_MODAL_MAP) { switch (event->val) { @@ -1323,6 +1334,7 @@ static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk) #undef WALK_BOOST_FACTOR } +#ifdef WITH_INPUT_NDOF static void walkApply_ndof(bContext *C, WalkInfo *walk) { Object *lock_ob = ED_view3d_cameracontrol_object_get(walk->v3d_camera_control); @@ -1341,6 +1353,7 @@ static void walkApply_ndof(bContext *C, WalkInfo *walk) } } } +#endif /* WITH_INPUT_NDOF */ /****** walk operator ******/ static int walk_invoke(bContext *C, wmOperator *op, const wmEvent *event) @@ -1388,12 +1401,15 @@ static int walk_modal(bContext *C, wmOperator *op, const wmEvent *event) walkEvent(C, op, walk, event); +#ifdef WITH_INPUT_NDOF if (walk->ndof) { /* 3D mouse overrules [2D mouse + timer] */ if (event->type == NDOF_MOTION) { walkApply_ndof(C, walk); } } - else if (event->type == TIMER && event->customdata == walk->timer) { + else +#endif /* WITH_INPUT_NDOF */ + if (event->type == TIMER && event->customdata == walk->timer) { walkApply(C, op, walk); } diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 6e399d9fde3..cbe58ddf586 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -386,7 +386,7 @@ static int transform_modal(bContext *C, wmOperator *op, const wmEvent *event) TransInfo *t = op->customdata; const enum TfmMode mode_prev = t->mode; -#if 0 +#if defined(WITH_INPUT_NDOF) && 0 // stable 2D mouse coords map to different 3D coords while the 3D mouse is active // in other words, 2D deltas are no longer good enough! // disable until individual 'transformers' behave better diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 44e99bd2995..0f3ea27a7f9 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -327,6 +327,10 @@ if(WITH_OPENVDB) endif() endif() +if(WITH_INPUT_NDOF) + add_definitions(-DWITH_INPUT_NDOF) +endif() + # Build makesrna executable blender_include_dirs( . diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index cbf7bb4d5e0..29c0e948a4c 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -292,11 +292,13 @@ static void rna_userdef_autokeymode_set(PointerRNA *ptr, int value) } } +#ifdef WITH_INPUT_NDOF static void rna_userdef_ndof_deadzone_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { UserDef *userdef = ptr->data; WM_ndof_deadzone_set(userdef->ndof_deadzone); } +#endif static void rna_userdef_timecode_style_set(PointerRNA *ptr, int value) { @@ -4333,6 +4335,7 @@ static void rna_def_userdef_input(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; +#ifdef WITH_INPUT_NDOF static EnumPropertyItem ndof_view_navigation_items[] = { {0, "FREE", 0, "Free", "Use full 6 degrees of freedom by default"}, {NDOF_MODE_ORBIT, "ORBIT", 0, "Orbit", "Orbit about the view center by default"}, @@ -4344,6 +4347,7 @@ static void rna_def_userdef_input(BlenderRNA *brna) {0, "TRACKBALL", 0, "Trackball", "Use trackball style rotation in the viewport"}, {0, NULL, 0, NULL, NULL} }; +#endif /* WITH_INPUT_NDOF */ static EnumPropertyItem view_zoom_styles[] = { {USER_ZOOM_CONT, "CONTINUE", 0, "Continue", "Old style zoom, continues while moving mouse up or down"}, @@ -4421,6 +4425,7 @@ static void rna_def_userdef_input(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Tweak Threshold", "Number of pixels you have to drag before tweak event is triggered"); +#ifdef WITH_INPUT_NDOF /* 3D mouse settings */ /* global options */ prop = RNA_def_property(srna, "ndof_sensitivity", PROP_FLOAT, PROP_NONE); @@ -4501,6 +4506,13 @@ static void rna_def_userdef_input(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_FLY_HELICOPTER); RNA_def_property_ui_text(prop, "Helicopter Mode", "Device up/down directly controls your Z position"); + /* let Python know whether NDOF is enabled */ + prop = RNA_def_boolean(srna, "use_ndof", true, "", ""); +#else + prop = RNA_def_boolean(srna, "use_ndof", false, "", ""); +#endif /* WITH_INPUT_NDOF */ + RNA_def_property_flag(prop, PROP_IDPROPERTY); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "mouse_double_click_time", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "dbl_click_time"); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 026d2e209a3..ba77e2a1768 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -118,6 +118,7 @@ static EnumPropertyItem event_textinput_type_items[] = { {0, NULL, 0, NULL, NULL} }; +#ifdef WITH_INPUT_NDOF static EnumPropertyItem event_ndof_type_items[] = { {NDOF_MOTION, "NDOF_MOTION", 0, "Motion", ""}, /* buttons on all 3dconnexion devices */ @@ -167,7 +168,8 @@ static EnumPropertyItem event_ndof_type_items[] = { {NDOF_BUTTON_C, "NDOF_BUTTON_C", 0, "Button C", ""}, {0, NULL, 0, NULL, NULL} }; -#endif +#endif /* WITH_INPUT_NDOF */ +#endif /* RNA_RUNTIME */ /* not returned: CAPSLOCKKEY, UNKNOWNKEY */ EnumPropertyItem rna_enum_event_type_items[] = { @@ -332,6 +334,7 @@ EnumPropertyItem rna_enum_event_type_items[] = { {TIMERREPORT, "TIMER_REPORT", 0, "Timer Report", "TmrReport"}, {TIMERREGION, "TIMERREGION", 0, "Timer Region", "TmrReg"}, {0, "", 0, NULL, NULL}, +#ifdef WITH_INPUT_NDOF {NDOF_MOTION, "NDOF_MOTION", 0, "NDOF Motion", "NdofMov"}, /* buttons on all 3dconnexion devices */ {NDOF_BUTTON_MENU, "NDOF_BUTTON_MENU", 0, "NDOF Menu", "NdofMenu"}, @@ -379,6 +382,7 @@ EnumPropertyItem rna_enum_event_type_items[] = { {NDOF_BUTTON_B, "NDOF_BUTTON_B", 0, "NDOF Button B", "NdofBB"}, {NDOF_BUTTON_C, "NDOF_BUTTON_C", 0, "NDOF Button C", "NdofBC"}, {0, NULL, 0, NULL, NULL} +#endif /* WITH_INPUT_NDOF */ }; EnumPropertyItem rna_enum_event_value_items[] = { @@ -701,10 +705,12 @@ static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value) kmi->type = TIMER; kmi->val = KM_NOTHING; break; +#ifdef WITH_INPUT_NDOF case KMI_TYPE_NDOF: kmi->type = NDOF_MOTION; kmi->val = KM_NOTHING; break; +#endif } } } @@ -738,7 +744,9 @@ static EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *UNUSED(C), PointerR if (map_type == KMI_TYPE_MOUSE) return event_mouse_type_items; if (map_type == KMI_TYPE_TWEAK) return event_tweak_type_items; if (map_type == KMI_TYPE_TIMER) return event_timer_type_items; +#ifdef WITH_INPUT_NDOF if (map_type == KMI_TYPE_NDOF) return event_ndof_type_items; +#endif if (map_type == KMI_TYPE_TEXTINPUT) return event_textinput_type_items; else return rna_enum_event_type_items; } @@ -2014,7 +2022,9 @@ static void rna_def_keyconfig(BlenderRNA *brna) {KMI_TYPE_KEYBOARD, "KEYBOARD", 0, "Keyboard", ""}, {KMI_TYPE_TWEAK, "TWEAK", 0, "Tweak", ""}, {KMI_TYPE_MOUSE, "MOUSE", 0, "Mouse", ""}, +#ifdef WITH_INPUT_NDOF {KMI_TYPE_NDOF, "NDOF", 0, "NDOF", ""}, +#endif {KMI_TYPE_TEXTINPUT, "TEXTINPUT", 0, "Text Input", ""}, {KMI_TYPE_TIMER, "TIMER", 0, "Timer", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index 01188cb7f65..b6245a8c0d1 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -146,6 +146,10 @@ if(WITH_OPENSUBDIV) add_definitions(-DWITH_OPENSUBDIV) endif() +if(WITH_INPUT_NDOF) + add_definitions(-DWITH_INPUT_NDOF) +endif() + if(WIN32) if(WITH_INPUT_IME) add_definitions(-DWITH_INPUT_IME) diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 69905fc296b..2b82f1becb3 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -64,7 +64,10 @@ struct wmDrag; struct ImBuf; struct ImageFormatData; struct ARegion; + +#ifdef WITH_INPUT_NDOF struct wmNDOFMotionData; +#endif typedef struct wmJob wmJob; @@ -186,9 +189,10 @@ void WM_event_add_mousemove(struct bContext *C); bool WM_modal_tweak_exit(const struct wmEvent *event, int tweak_event); bool WM_event_is_absolute(const struct wmEvent *event); +#ifdef WITH_INPUT_NDOF /* 3D mouse */ void WM_ndof_deadzone_set(float deadzone); - +#endif /* notifiers */ void WM_event_add_notifier(const struct bContext *C, unsigned int type, void *reference); void WM_main_add_notifier(unsigned int type, void *reference); @@ -498,11 +502,13 @@ bool write_crash_blend(void); /* Lock the interface for any communication */ void WM_set_locked_interface(struct wmWindowManager *wm, bool lock); +#ifdef WITH_INPUT_NDOF void WM_event_ndof_pan_get(const struct wmNDOFMotionData *ndof, float r_pan[3], const bool use_zoom); void WM_event_ndof_rotate_get(const struct wmNDOFMotionData *ndof, float r_rot[3]); float WM_event_ndof_to_axis_angle(const struct wmNDOFMotionData *ndof, float axis[3]); void WM_event_ndof_to_quat(const struct wmNDOFMotionData *ndof, float q[4]); +#endif /* WITH_INPUT_NDOF */ float WM_event_tablet_data(const struct wmEvent *event, int *pen_flip, float tilt[2]); bool WM_event_is_tablet(const struct wmEvent *event); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 3c0e99bddd0..0fe3e8a0fcf 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -485,6 +485,7 @@ typedef enum { /* motion progress, for modal handlers */ P_FINISHED } wmProgress; +#ifdef WITH_INPUT_NDOF typedef struct wmNDOFMotionData { /* awfully similar to GHOST_TEventNDOFMotionData... */ /* Each component normally ranges from -1 to +1, but can exceed that. @@ -496,6 +497,7 @@ typedef struct wmNDOFMotionData { float dt; /* time since previous NDOF Motion event */ wmProgress progress; /* is this the first event, the last, or one of many in between? */ } wmNDOFMotionData; +#endif /* WITH_INPUT_NDOF */ typedef struct wmTimer { struct wmTimer *next, *prev; diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 01dc77127d2..77d74399769 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -567,6 +567,7 @@ void WM_event_print(const wmEvent *event) BLI_str_utf8_size(event->utf8_buf), event->utf8_buf, event->keymap_idname, (const void *)event); +#ifdef WITH_INPUT_NDOF if (ISNDOF(event->type)) { const wmNDOFMotionData *ndof = event->customdata; if (event->type == NDOF_MOTION) { @@ -577,6 +578,7 @@ void WM_event_print(const wmEvent *event) /* ndof buttons printed already */ } } +#endif /* WITH_INPUT_NDOF */ if (event->tablet_data) { const wmTabletData *wmtab = event->tablet_data; @@ -613,10 +615,12 @@ bool WM_event_is_absolute(const wmEvent *event) return (event->tablet_data != NULL); } +#ifdef WITH_INPUT_NDOF void WM_ndof_deadzone_set(float deadzone) { GHOST_setNDOFDeadZone(deadzone); } +#endif static void wm_add_reports(ReportList *reports) { @@ -2423,9 +2427,11 @@ void wm_event_do_handlers(bContext *C) /* for regions having custom cursors */ wm_paintcursor_test(C, event); } +#ifdef WITH_INPUT_NDOF else if (event->type == NDOF_MOTION) { win->addmousemove = true; } +#endif for (sa = win->screen->areabase.first; sa; sa = sa->next) { /* after restoring a screen from SCREENMAXIMIZED we have to wait @@ -3026,6 +3032,7 @@ static void update_tablet_data(wmWindow *win, wmEvent *event) } } +#ifdef WITH_INPUT_NDOF /* adds customdata to event */ static void attach_ndof_data(wmEvent *event, const GHOST_TEventNDOFMotionData *ghost) { @@ -3052,6 +3059,7 @@ static void attach_ndof_data(wmEvent *event, const GHOST_TEventNDOFMotionData *g event->customdata = data; event->customdatafree = 1; } +#endif /* WITH_INPUT_NDOF */ /* imperfect but probably usable... draw/enable drags to other windows */ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *win, wmEvent *event) @@ -3439,6 +3447,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U break; } +#ifdef WITH_INPUT_NDOF case GHOST_kEventNDOFMotion: { event.type = NDOF_MOTION; @@ -3474,6 +3483,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U break; } +#endif /* WITH_INPUT_NDOF */ case GHOST_kEventUnknown: case GHOST_kNumEventTypes: @@ -3545,6 +3555,7 @@ void WM_set_locked_interface(wmWindowManager *wm, bool lock) } +#ifdef WITH_INPUT_NDOF /* -------------------------------------------------------------------- */ /* NDOF */ @@ -3587,6 +3598,7 @@ void WM_event_ndof_to_quat(const struct wmNDOFMotionData *ndof, float q[4]) angle = WM_event_ndof_to_axis_angle(ndof, axis); axis_angle_to_quat(q, axis, angle); } +#endif /* WITH_INPUT_NDOF */ /* if this is a tablet event, return tablet pressure and set *pen_flip * to 1 if the eraser tool is being used, 0 otherwise */ diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 3022d865460..73622cda483 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -198,8 +198,11 @@ void WM_init(bContext *C, int argc, const char **argv) BLT_lang_set(NULL); if (!G.background) { + +#ifdef WITH_INPUT_NDOF /* sets 3D mouse deadzone */ WM_ndof_deadzone_set(U.ndof_deadzone); +#endif GPU_init(); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 78273615602..fcdab746d57 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -4348,7 +4348,6 @@ void wm_window_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap = WM_keymap_find(keyconf, "Window", 0, 0); wmKeyMapItem *kmi; - const char *data_path; /* note, this doesn't replace existing keymap items */ WM_keymap_verify_item(keymap, "WM_OT_window_duplicate", WKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); @@ -4386,7 +4385,9 @@ void wm_window_keymap(wmKeyConfig *keyconf) /* menus that can be accessed anywhere in blender */ WM_keymap_verify_item(keymap, "WM_OT_search_menu", SPACEKEY, KM_PRESS, 0, 0); +#ifdef WITH_INPUT_NDOF WM_keymap_add_menu(keymap, "USERPREF_MT_ndof_settings", NDOF_BUTTON_MENU, KM_PRESS, 0, 0); +#endif /* Space switching */ kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", F2KEY, KM_PRESS, KM_SHIFT, 0); /* new in 2.5x, was DXF export */ @@ -4433,8 +4434,9 @@ void wm_window_keymap(wmKeyConfig *keyconf) RNA_string_set(kmi->ptr, "data_path", "area.type"); RNA_string_set(kmi->ptr, "value", "DOPESHEET_EDITOR"); +#ifdef WITH_INPUT_NDOF /* ndof speed */ - data_path = "user_preferences.inputs.ndof_sensitivity"; + const char *data_path = "user_preferences.inputs.ndof_sensitivity"; kmi = WM_keymap_add_item(keymap, "WM_OT_context_scale_float", NDOF_BUTTON_PLUS, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", data_path); RNA_float_set(kmi->ptr, "value", 1.1f); @@ -4450,9 +4452,7 @@ void wm_window_keymap(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "WM_OT_context_scale_float", NDOF_BUTTON_MINUS, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "data_path", data_path); RNA_float_set(kmi->ptr, "value", 1.0f / 1.5f); - data_path = NULL; - (void)data_path; - +#endif /* WITH_INPUT_NDOF */ gesture_circle_modal_keymap(keyconf); gesture_border_modal_keymap(keyconf); diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index 3085f138846..0936b294d1b 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -40,7 +40,9 @@ enum { EVT_DATA_GESTURE = 1, EVT_DATA_TIMER = 2, EVT_DATA_DRAGDROP = 3, +#ifdef WITH_INPUT_NDOF EVT_DATA_NDOF_MOTION = 4, +#endif }; /* tablet active, matches GHOST_TTabletMode */ @@ -236,6 +238,7 @@ enum { /* *** End of keyboard codes. *** */ +#ifdef WITH_INPUT_NDOF /* NDOF (from SpaceNavigator & friends) * These should be kept in sync with GHOST_NDOFManager.h * Ordering matters, exact values do not. */ @@ -290,6 +293,7 @@ enum { NDOF_BUTTON_C, /* the end */ NDOF_LAST, +#endif /* WITH_INPUT_NDOF */ /* ********** End of Input devices. ********** */ @@ -369,8 +373,12 @@ enum { /* test whether the event is tweak event */ #define ISTWEAK(event_type) ((event_type) >= EVT_TWEAK_L && (event_type) <= EVT_GESTURE) +#ifdef WITH_INPUT_NDOF /* test whether the event is a NDOF event */ -#define ISNDOF(event_type) ((event_type) >= NDOF_MOTION && (event_type) < NDOF_LAST) +# define ISNDOF(event_type) ((event_type) >= NDOF_MOTION && (event_type) < NDOF_LAST) +#else +# define ISNDOF(event_type) false +#endif /* test whether event type is acceptable as hotkey, excluding modifiers */ #define ISHOTKEY(event_type) \ -- cgit v1.2.3 From 12c3002618e998051701f9db2fb92f947aa1cda5 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 18 Aug 2016 10:36:06 +0200 Subject: Cleanup: ifdef function which is only used from ifdef-ed code --- source/blender/editors/interface/view2d_ops.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index f095ba9a03d..d2b2f12c1a5 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -127,6 +127,7 @@ static int view_pan_init(bContext *C, wmOperator *op) return 1; } +#ifdef WITH_INPUT_NDOF static int view_pan_poll(bContext *C) { ARegion *ar = CTX_wm_region(C); @@ -144,6 +145,7 @@ static int view_pan_poll(bContext *C) /* view can pan */ return 1; } +#endif /* apply transform to view (i.e. adjust 'cur' rect) */ static void view_pan_apply_ex(bContext *C, v2dViewPanData *vpd, float dx, float dy) -- cgit v1.2.3 From 8a72ec80a0d7b35abe28f27e79ad59e6dd5b967d Mon Sep 17 00:00:00 2001 From: Thomas Beck Date: Thu, 18 Aug 2016 11:28:41 +0200 Subject: Fix bplayer (c) after NDOF changes from merwin --- source/blenderplayer/bad_level_call_stubs/stubs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index cdfd326d986..d8a4ddc8d4f 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -336,7 +336,9 @@ void WM_jobs_callbacks(struct wmJob *job, void WM_jobs_start(struct wmWindowManager *wm, struct wmJob *job) RET_NONE void WM_report(ReportType type, const char *message) RET_NONE -void WM_ndof_deadzone_set(float deadzone) RET_NONE +#ifdef WITH_INPUT_NDOF + void WM_ndof_deadzone_set(float deadzone) RET_NONE +#endif void WM_uilisttype_init(void) RET_NONE struct uiListType *WM_uilisttype_find(const char *idname, bool quiet) RET_NULL -- cgit v1.2.3 From 26f4f7edcab2896c8afec30d0431044b237c8ed6 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 17 Aug 2016 21:46:38 +0200 Subject: Final UI messages fixes (for this session...). --- source/blender/editors/gpencil/gpencil_data.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 876f873e5fa..8733c7bf5a8 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -1439,8 +1439,8 @@ static int gp_brush_remove_exec(bContext *C, wmOperator *op) if (ELEM(NULL, ts, brush)) return OPERATOR_CANCELLED; - if (BLI_listbase_count(&ts->gp_brushes) < 2) { - BKE_report(op->reports, RPT_ERROR, "Grease Pencil needs a brush. Unable to delete brush"); + if (BLI_listbase_count_ex(&ts->gp_brushes, 2) < 2) { + BKE_report(op->reports, RPT_ERROR, "Grease Pencil needs a brush, unable to delete the last one"); return OPERATOR_CANCELLED; } @@ -1466,7 +1466,7 @@ static int gp_brush_remove_exec(bContext *C, wmOperator *op) void GPENCIL_OT_brush_remove(wmOperatorType *ot) { /* identifiers */ - ot->name = "Remove brush"; + ot->name = "Remove Brush"; ot->idname = "GPENCIL_OT_brush_remove"; ot->description = "Remove active Grease Pencil drawing brush"; @@ -1797,8 +1797,8 @@ static int gp_palette_remove_exec(bContext *C, wmOperator *op) if (ELEM(NULL, gpd, palette)) return OPERATOR_CANCELLED; - if (BLI_listbase_count(&gpd->palettes) < 2) { - BKE_report(op->reports, RPT_ERROR, "Grease Pencil needs a palette. Unable to delete palette"); + if (BLI_listbase_count_ex(&gpd->palettes, 2) < 2) { + BKE_report(op->reports, RPT_ERROR, "Grease Pencil needs a palette, unable to delete the last one"); return OPERATOR_CANCELLED; } -- cgit v1.2.3 From 7b78532950f69f82058d462e786e77128744c589 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 18 Aug 2016 12:53:33 +0200 Subject: Freestyle: fix wrong arg order, and cleanup confusing loop (both reported by coverity). Error: `origin` and `edge` args were swapped in final `FindOccludee()` call of `ViewMapBuilder::ComputeRayCastingVisibility()` Cleanup: main for loop in `Strip::createStrip()` was really confusing (though correct), generated a false positive in coverity scan, now should be cleaner how it loops over its vprev/v/v2 triplet of consecutive items. --- source/blender/freestyle/intern/stroke/StrokeRep.cpp | 14 ++++---------- .../blender/freestyle/intern/view_map/ViewMapBuilder.cpp | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.cpp b/source/blender/freestyle/intern/stroke/StrokeRep.cpp index ab06e207331..028127897ff 100644 --- a/source/blender/freestyle/intern/stroke/StrokeRep.cpp +++ b/source/blender/freestyle/intern/stroke/StrokeRep.cpp @@ -135,11 +135,11 @@ void Strip::createStrip (const vector& iStrokeVertices) int orientationErrors = 0; //special case of first vertex - v = iStrokeVertices.begin(); + v2 = v = iStrokeVertices.begin(); + ++v2; sv = *v; vPrev = v; //in case the stroke has only 2 vertices; - ++v; - sv2 = *v; + sv2 = *v2; Vec2r dir(sv2->getPoint() - sv->getPoint()); Vec2r orthDir(-dir[1], dir[0]); if (orthDir.norm() > ZERO) @@ -189,11 +189,7 @@ void Strip::createStrip (const vector& iStrokeVertices) int i = 2; // 2 because we have already processed the first vertex - for (vend = iStrokeVertices.end(); v != vend; ++v) { - v2 = v; - ++v2; - if (v2 == vend) - break; + for (vend = iStrokeVertices.end(), ++v, ++v2; v2 != vend; vPrev = v++, ++v2) { sv = (*v); sv2 = (*v2); svPrev = (*vPrev); @@ -289,8 +285,6 @@ void Strip::createStrip (const vector& iStrokeVertices) { _vertices[i - 1]->setPoint2d(p - thickness[0] * stripDir); } - - vPrev = v; } // end of for //special case of last vertex diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp index 77beb1d97d9..380bb0dd3ca 100644 --- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp +++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp @@ -2099,7 +2099,7 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe, Grid *iGrid, real eps } // Find occludee - FindOccludee(fe, iGrid, epsilon, oaPolygon, timestamp, u, center, edge, origin, faceVertices); + FindOccludee(fe, iGrid, epsilon, oaPolygon, timestamp, u, center, origin, edge, faceVertices); return qi; } -- cgit v1.2.3 From b4d36c77da7e0e545b61d96d49b8122b2f00003a Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 18 Aug 2016 15:13:58 +0200 Subject: Two fixes for optional ndof & fix bplayer for that... Seriuosly, guys... Please always check that kind of changes with and without affected option, and in full build case. --- source/blender/makesrna/intern/rna_wm.c | 2 +- source/blenderplayer/bad_level_call_stubs/CMakeLists.txt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index ba77e2a1768..1f991b2d11d 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -381,8 +381,8 @@ EnumPropertyItem rna_enum_event_type_items[] = { {NDOF_BUTTON_A, "NDOF_BUTTON_A", 0, "NDOF Button A", "NdofBA"}, {NDOF_BUTTON_B, "NDOF_BUTTON_B", 0, "NDOF Button B", "NdofBB"}, {NDOF_BUTTON_C, "NDOF_BUTTON_C", 0, "NDOF Button C", "NdofBC"}, - {0, NULL, 0, NULL, NULL} #endif /* WITH_INPUT_NDOF */ + {0, NULL, 0, NULL, NULL} }; EnumPropertyItem rna_enum_event_value_items[] = { diff --git a/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt b/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt index 1d681d28589..0e570e19258 100644 --- a/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt +++ b/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt @@ -70,4 +70,8 @@ if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) endif() +if(WITH_INPUT_NDOF) + add_definitions(-DWITH_INPUT_NDOF) +endif() + blender_add_lib_nolist(blenkernel_blc "${SRC}" "${INC}" "${INC_SYS}") -- cgit v1.2.3 From 7b4ba65a87a342ec0fba12a410950635c575d60f Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 18 Aug 2016 15:21:53 +0200 Subject: Cleanup for previous commit (nasty IDE replacing tads with spaces, tsst) Sorry for the noise :| --- source/blender/makesrna/intern/rna_wm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 1f991b2d11d..6902c379b59 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -382,7 +382,7 @@ EnumPropertyItem rna_enum_event_type_items[] = { {NDOF_BUTTON_B, "NDOF_BUTTON_B", 0, "NDOF Button B", "NdofBB"}, {NDOF_BUTTON_C, "NDOF_BUTTON_C", 0, "NDOF Button C", "NdofBC"}, #endif /* WITH_INPUT_NDOF */ - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL} }; EnumPropertyItem rna_enum_event_value_items[] = { -- cgit v1.2.3 From 2e6d4270cdd4dab1964af4427f833846e4aef4a7 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 18 Aug 2016 15:45:20 +0200 Subject: Cleanup/security fix: do not use strcpy (at least in new code). This function is only really secure in a very limited amount of cases, and can especially bite you later if you change some buffer sizes... So not worth bothering with it, just always use BLI_strncpy instead. --- source/blender/blenkernel/intern/gpencil.c | 2 +- source/blender/blenloader/intern/versioning_270.c | 2 +- source/blender/editors/gpencil/gpencil_data.c | 4 ++-- source/blender/editors/gpencil/gpencil_edit.c | 6 +++--- source/blender/editors/gpencil/gpencil_paint.c | 2 +- source/blender/makesrna/intern/rna_gpencil.c | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index e4bac0a947a..2242113b79b 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -1268,7 +1268,7 @@ void BKE_gpencil_palettecolor_changename(bGPdata *gpd, char *oldname, const char for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { for (gps = gpf->strokes.first; gps; gps = gps->next) { if (STREQ(gps->colorname, oldname)) { - strcpy(gps->colorname, newname); + BLI_strncpy(gps->colorname, newname, sizeof(gps->colorname)); } } } diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index d735f099dc0..f6ac42c1941 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -1318,7 +1318,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { /* set stroke to palette and force recalculation */ - strcpy(gps->colorname, gpl->info); + BLI_strncpy(gps->colorname, gpl->info, sizeof(gps->colorname)); gps->palcolor = NULL; gps->flag |= GP_STROKE_RECALC_COLOR; gps->thickness = gpl->thickness; diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 8733c7bf5a8..2aa6d30c114 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -883,7 +883,7 @@ static int gp_stroke_change_color_exec(bContext *C, wmOperator *UNUSED(op)) /* asign new color (only if different) */ if (STREQ(gps->colorname, color->info) == false) { - strcpy(gps->colorname, color->info); + BLI_strncpy(gps->colorname, color->info, sizeof(gps->colorname)); gps->flag |= GP_STROKE_RECALC_COLOR; } } @@ -1271,7 +1271,7 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op) /* if new, set current color */ if (type == GP_STROKE_JOINCOPY) { new_stroke->palcolor = palcolor; - strcpy(new_stroke->colorname, palcolor->info); + BLI_strncpy(new_stroke->colorname, palcolor->info, sizeof(new_stroke->colorname)); new_stroke->flag |= GP_STROKE_RECALC_COLOR; } } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index b298769c6dc..e58178bf2a7 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -207,7 +207,7 @@ static void gp_duplicate_points(const bGPDstroke *gps, ListBase *new_strokes, co /* make a stupid copy first of the entire stroke (to get the flags too) */ gpsd = MEM_dupallocN(gps); - strcpy(gpsd->tmp_layerinfo, layername); /* saves original layer name */ + BLI_strncpy(gpsd->tmp_layerinfo, layername, sizeof(gpsd->tmp_layerinfo)); /* saves original layer name */ /* initialize triangle memory - will be calculated on next redraw */ gpsd->triangles = NULL; @@ -266,7 +266,7 @@ static int gp_duplicate_exec(bContext *C, wmOperator *op) /* make direct copies of the stroke and its points */ gpsd = MEM_dupallocN(gps); - strcpy(gpsd->tmp_layerinfo, gpl->info); + BLI_strncpy(gpsd->tmp_layerinfo, gpl->info, sizeof(gpsd->tmp_layerinfo)); gpsd->points = MEM_dupallocN(gps->points); /* triangle information - will be calculated on next redraw */ @@ -386,7 +386,7 @@ static int gp_strokes_copy_exec(bContext *C, wmOperator *op) /* make direct copies of the stroke and its points */ gpsd = MEM_dupallocN(gps); - strcpy(gpsd->tmp_layerinfo, gpl->info); /* saves original layer name */ + BLI_strncpy(gpsd->tmp_layerinfo, gpl->info, sizeof(gpsd->tmp_layerinfo)); /* saves original layer name */ gpsd->points = MEM_dupallocN(gps->points); /* triangles cache - will be recalculated on next redraw */ diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index e7e39a85792..dacdc0cf777 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -924,7 +924,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) bGPDpalette *palette = BKE_gpencil_palette_getactive(p->gpd); bGPDpalettecolor *palcolor = BKE_gpencil_palettecolor_getactive(palette); gps->palcolor = palcolor; - strcpy(gps->colorname, palcolor->info); + BLI_strncpy(gps->colorname, palcolor->info, sizeof(gps->colorname)); /* add stroke to frame, usually on tail of the listbase, but if on back is enabled the stroke is added on listbase head * because the drawing order is inverse and the head stroke is the first to draw. This is very useful for artist diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 48d7dcfa2e4..3ecaec75c77 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -483,7 +483,7 @@ static bGPDstroke *rna_GPencil_stroke_new(bGPDframe *frame, const char *colornam { bGPDstroke *stroke = MEM_callocN(sizeof(bGPDstroke), "gp_stroke"); if (colorname) { - strcpy(stroke->colorname, colorname); + BLI_strncpy(stroke->colorname, colorname, sizeof(stroke->colorname)); } stroke->palcolor = NULL; stroke->flag |= GP_STROKE_RECALC_COLOR; -- cgit v1.2.3 From f4e4009afd700e049ebb9cb239b34a31db13329b Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 18 Aug 2016 16:18:58 +0200 Subject: Cleanup: some bad sizeof() usages. --- source/blender/bmesh/tools/bmesh_decimate_collapse.c | 2 +- source/blender/editors/mesh/editmesh_intersect.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/bmesh/tools/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c index 52a0df5b9d1..372d341f223 100644 --- a/source/blender/bmesh/tools/bmesh_decimate_collapse.c +++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c @@ -430,7 +430,7 @@ static int *bm_edge_symmetry_map(BMesh *bm, unsigned int symmetry_axis, float li tree = BLI_kdtree_new(bm->totedge); - etable = MEM_mallocN(sizeof(BMEdge **) * bm->totedge, __func__); + etable = MEM_mallocN(sizeof(*etable) * bm->totedge, __func__); edge_symmetry_map = MEM_mallocN(sizeof(*edge_symmetry_map) * bm->totedge, __func__); BM_ITER_MESH_INDEX (e, &iter, bm, BM_EDGES_OF_MESH, i) { diff --git a/source/blender/editors/mesh/editmesh_intersect.c b/source/blender/editors/mesh/editmesh_intersect.c index 281a8b2a02d..de93211bec4 100644 --- a/source/blender/editors/mesh/editmesh_intersect.c +++ b/source/blender/editors/mesh/editmesh_intersect.c @@ -439,7 +439,7 @@ static void bm_face_split_by_edges_island_connect( LinkNode *e_link, const int e_link_len, MemArena *mem_arena_edgenet) { - BMEdge **edge_arr = BLI_memarena_alloc(mem_arena_edgenet, sizeof(BMEdge **) * e_link_len); + BMEdge **edge_arr = BLI_memarena_alloc(mem_arena_edgenet, sizeof(*edge_arr) * e_link_len); int edge_arr_len = 0; while (e_link) { -- cgit v1.2.3 From ca5271e637cdf75b1739a18a27f86ea7610450b1 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 18 Aug 2016 20:47:14 +0200 Subject: Cycles: Fix wrong allocator used for spatial builder --- intern/cycles/bvh/bvh_build.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp index 67ffb6853d6..f2a735d12e3 100644 --- a/intern/cycles/bvh/bvh_build.cpp +++ b/intern/cycles/bvh/bvh_build.cpp @@ -713,14 +713,14 @@ BVHNode* BVHBuild::create_leaf_node(const BVHRange& range, * can not control. */ typedef StackAllocator<256, int> LeafStackAllocator; + typedef StackAllocator<256, BVHReference> LeafReferenceStackAllocator; vector p_type[PRIMITIVE_NUM_TOTAL]; vector p_index[PRIMITIVE_NUM_TOTAL]; vector p_object[PRIMITIVE_NUM_TOTAL]; - vector p_ref[PRIMITIVE_NUM_TOTAL]; + vector p_ref[PRIMITIVE_NUM_TOTAL]; /* TODO(sergey): In theory we should be able to store references. */ - typedef StackAllocator<256, BVHReference> LeafReferenceStackAllocator; vector object_references; uint visibility[PRIMITIVE_NUM_TOTAL] = {0}; -- cgit v1.2.3 From 4d8ac1eaa5dac249577bcda5df963b802812fc2d Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Fri, 19 Aug 2016 01:20:35 +0200 Subject: Cleanup: Remove redundant comment --- source/blender/blenkernel/intern/scene.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index c3c23756b70..e610c56b28f 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -162,7 +162,6 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type) if (type == SCE_COPY_EMPTY) { ListBase rl, rv; - /* XXX. main should become an arg */ scen = BKE_scene_add(bmain, sce->id.name + 2); rl = scen->r.layers; -- cgit v1.2.3 From bf4875001de10d0053fc9377fa98349bd6e1e8a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Fri, 19 Aug 2016 04:42:12 +0200 Subject: Fix T49111: Automatically add file path suffix for Alembic and Collada export. This aligns the behaviour of the file selection with the other exporters. The Alembic case would fail if the filepath did not have an extension set. Also set a default file name for the Alembic export operator in case the Blender file was not saved before exporting. --- source/blender/editors/io/io_alembic.c | 25 ++++++++++++++++++++++++- source/blender/editors/io/io_collada.c | 15 +++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.c index 63c6f3dfecf..96a3ef1f2f6 100644 --- a/source/blender/editors/io/io_alembic.c +++ b/source/blender/editors/io/io_alembic.c @@ -68,8 +68,16 @@ static int wm_alembic_export_invoke(bContext *C, wmOperator *op, const wmEvent *event) { if (!RNA_struct_property_is_set(op->ptr, "filepath")) { + Main *bmain = CTX_data_main(C); char filepath[FILE_MAX]; - BLI_strncpy(filepath, G.main->name, sizeof(filepath)); + + if (bmain->name[0] == '\0') { + BLI_strncpy(filepath, "untitled", sizeof(filepath)); + } + else { + BLI_strncpy(filepath, bmain->name, sizeof(filepath)); + } + BLI_replace_extension(filepath, sizeof(filepath), ".abc"); RNA_string_set(op->ptr, "filepath", filepath); } @@ -213,6 +221,20 @@ static void wm_alembic_export_draw(bContext *UNUSED(C), wmOperator *op) ui_alembic_export_settings(op->layout, &ptr); } +static bool wm_alembic_export_check(bContext *UNUSED(C), wmOperator *op) +{ + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + + if (!BLI_testextensie(filepath, ".abc")) { + BLI_ensure_extension(filepath, FILE_MAX, ".abc"); + RNA_string_set(op->ptr, "filepath", filepath); + return true; + } + + return false; +} + void WM_OT_alembic_export(wmOperatorType *ot) { ot->name = "Export Alembic"; @@ -223,6 +245,7 @@ void WM_OT_alembic_export(wmOperatorType *ot) ot->exec = wm_alembic_export_exec; ot->poll = WM_operator_winactive; ot->ui = wm_alembic_export_draw; + ot->check = wm_alembic_export_check; WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_ALEMBIC, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index d62651cef81..8659100df87 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -280,6 +280,20 @@ static void wm_collada_export_draw(bContext *UNUSED(C), wmOperator *op) uiCollada_exportSettings(op->layout, &ptr); } +static bool wm_collada_export_check(bContext *UNUSED(C), wmOperator *op) +{ + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + + if (!BLI_testextensie(filepath, ".dae")) { + BLI_ensure_extension(filepath, FILE_MAX, ".dae"); + RNA_string_set(op->ptr, "filepath", filepath); + return true; + } + + return false; +} + void WM_OT_collada_export(wmOperatorType *ot) { static EnumPropertyItem prop_bc_export_mesh_type[] = { @@ -302,6 +316,7 @@ void WM_OT_collada_export(wmOperatorType *ot) ot->invoke = wm_collada_export_invoke; ot->exec = wm_collada_export_exec; ot->poll = WM_operator_winactive; + ot->check = wm_collada_export_check; ot->flag |= OPTYPE_PRESET; -- cgit v1.2.3 From 5f7611a8f14e177b4d2d2391ebc4725eafdf4073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Fri, 19 Aug 2016 05:22:35 +0200 Subject: Alembic: fix crash accessing invalid objects. --- source/blender/alembic/intern/abc_util.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/alembic/intern/abc_util.h b/source/blender/alembic/intern/abc_util.h index 8cdfe21e43f..648570f5f27 100644 --- a/source/blender/alembic/intern/abc_util.h +++ b/source/blender/alembic/intern/abc_util.h @@ -86,8 +86,11 @@ void get_min_max_time(const Alembic::AbcGeom::IObject &object, const Schema &sch { get_min_max_time_ex(schema, min, max); - Alembic::AbcGeom::IXform parent(object.getParent(), Alembic::AbcGeom::kWrapExisting); - get_min_max_time_ex(parent.getSchema(), min, max); + const Alembic::AbcGeom::IObject &parent = object.getParent(); + if (parent.valid() && Alembic::AbcGeom::IXform::matches(parent.getMetaData())) { + Alembic::AbcGeom::IXform xform(parent, Alembic::AbcGeom::kWrapExisting); + get_min_max_time_ex(xform.getSchema(), min, max); + } } bool has_property(const Alembic::Abc::ICompoundProperty &prop, const std::string &name); -- cgit v1.2.3 From 793900d46c4caa695074bbaf9c467c0b0659f5cd Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 19 Aug 2016 12:21:13 +0200 Subject: 2D stabilization: Make interface more compact Joins some things to the same row and uses aligned columns to get minimum use of vertical space. Probably still some tweaks required, but getting there :) --- release/scripts/startup/bl_ui/space_clip.py | 67 +++++++++++++++-------------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 7dfa0693d20..8d581e84e25 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -916,7 +916,11 @@ class CLIP_PT_stabilization(CLIP_PT_reconstruction_panel, Panel): layout.prop(stab, "anchor_frame") - layout.prop(stab, "use_stabilize_rotation") + row = layout.row(align=True) + row.prop(stab, "use_stabilize_rotation", text="Rotation", toggle=True) + sub = row.row(align=True) + sub.active = stab.use_stabilize_rotation + sub.prop(stab, "use_stabilize_scale", text="Scale", toggle=True) box = layout.box() row = box.row(align=True) @@ -938,47 +942,46 @@ class CLIP_PT_stabilization(CLIP_PT_reconstruction_panel, Panel): sub.menu('CLIP_MT_stabilize_2d_specials', text="", icon='DOWNARROW_HLT') - col = box.column() - col.active = stab.use_stabilize_rotation - col.label(text="Tracks For Rotation / Scale") - row = col.row() - row.template_list("UI_UL_list", "stabilization_rotation_tracks", stab, "rotation_tracks", - stab, "active_rotation_track_index", rows=2) + # Usually we don't hide things from iterface, but here every pixel of + # vertical space is precious. + if stab.use_stabilize_rotation: + box.label(text="Tracks For Rotation / Scale") + row = box.row() + row.template_list("UI_UL_list", "stabilization_rotation_tracks", + stab, "rotation_tracks", + stab, "active_rotation_track_index", rows=2) - sub = row.column(align=True) + sub = row.column(align=True) - sub.operator("clip.stabilize_2d_rotation_add", icon='ZOOMIN', text="") - sub.operator("clip.stabilize_2d_rotation_remove", icon='ZOOMOUT', text="") + sub.operator("clip.stabilize_2d_rotation_add", icon='ZOOMIN', text="") + sub.operator("clip.stabilize_2d_rotation_remove", icon='ZOOMOUT', text="") - sub.menu('CLIP_MT_stabilize_2d_rotation_specials', text="", - icon='DOWNARROW_HLT') + sub.menu('CLIP_MT_stabilize_2d_rotation_specials', text="", + icon='DOWNARROW_HLT') row = layout.row() row.active = stab.use_stabilize_rotation - row.prop(stab, "use_stabilize_scale") - if stab.use_autoscale: - row = layout.row(align=True) - row.prop(stab, "use_autoscale") - row.prop(stab, "scale_max", text="Max") - else: - layout.prop(stab, "use_autoscale") + row.prop(stab, "use_autoscale") + sub = row.row() + sub.active = stab.use_autoscale + sub.prop(stab, "scale_max", text="Max") - layout.separator() - layout.label(text="Expected Position") - layout.prop(stab, "target_position", text="") - layout.prop(stab, "target_rotation") + col = layout.column(align=True) + row = col.row(align=True) + # Hrm, how to make it more obvious label? + row.prop(stab, "target_position", text="") + col.prop(stab, "target_rotation") if stab.use_autoscale: - layout.label(text="Auto Scale Factor: %5.3f" % (1.0 / stab.target_zoom)) + col.label(text="Auto Scale Factor: %5.3f" % (1.0 / stab.target_zoom)) else: - layout.prop(stab, "target_zoom") + col.prop(stab, "target_zoom") - layout.separator() - layout.prop(stab, "influence_location") - - col = layout.column() - col.active = stab.use_stabilize_rotation - col.prop(stab, "influence_rotation") - col.prop(stab, "influence_scale") + col = layout.column(align=True) + col.prop(stab, "influence_location") + sub = col.column(align=True) + sub.active = stab.use_stabilize_rotation + sub.prop(stab, "influence_rotation") + sub.prop(stab, "influence_scale") layout.prop(stab, "filter_type") -- cgit v1.2.3 From 33fbf9b7e0a3f7e1e78cd94c5dcaff1e0c562e6a Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 19 Aug 2016 15:51:44 +0200 Subject: Fix broken keymap loading with disabled ndof - revert part of recent rBb10d0058d72da30 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ifdef’ing out defines in DNA/RNA is not a good idea, was breaking alternative keymaps loading from splash screen e.g. (reported by Sergey over IRC, thanks). --- source/blender/makesrna/intern/rna_wm.c | 10 ---------- source/blender/windowmanager/wm_event_types.h | 10 +--------- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 6902c379b59..f97f194033c 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -118,7 +118,6 @@ static EnumPropertyItem event_textinput_type_items[] = { {0, NULL, 0, NULL, NULL} }; -#ifdef WITH_INPUT_NDOF static EnumPropertyItem event_ndof_type_items[] = { {NDOF_MOTION, "NDOF_MOTION", 0, "Motion", ""}, /* buttons on all 3dconnexion devices */ @@ -168,7 +167,6 @@ static EnumPropertyItem event_ndof_type_items[] = { {NDOF_BUTTON_C, "NDOF_BUTTON_C", 0, "Button C", ""}, {0, NULL, 0, NULL, NULL} }; -#endif /* WITH_INPUT_NDOF */ #endif /* RNA_RUNTIME */ /* not returned: CAPSLOCKKEY, UNKNOWNKEY */ @@ -334,7 +332,6 @@ EnumPropertyItem rna_enum_event_type_items[] = { {TIMERREPORT, "TIMER_REPORT", 0, "Timer Report", "TmrReport"}, {TIMERREGION, "TIMERREGION", 0, "Timer Region", "TmrReg"}, {0, "", 0, NULL, NULL}, -#ifdef WITH_INPUT_NDOF {NDOF_MOTION, "NDOF_MOTION", 0, "NDOF Motion", "NdofMov"}, /* buttons on all 3dconnexion devices */ {NDOF_BUTTON_MENU, "NDOF_BUTTON_MENU", 0, "NDOF Menu", "NdofMenu"}, @@ -381,7 +378,6 @@ EnumPropertyItem rna_enum_event_type_items[] = { {NDOF_BUTTON_A, "NDOF_BUTTON_A", 0, "NDOF Button A", "NdofBA"}, {NDOF_BUTTON_B, "NDOF_BUTTON_B", 0, "NDOF Button B", "NdofBB"}, {NDOF_BUTTON_C, "NDOF_BUTTON_C", 0, "NDOF Button C", "NdofBC"}, -#endif /* WITH_INPUT_NDOF */ {0, NULL, 0, NULL, NULL} }; @@ -705,12 +701,10 @@ static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value) kmi->type = TIMER; kmi->val = KM_NOTHING; break; -#ifdef WITH_INPUT_NDOF case KMI_TYPE_NDOF: kmi->type = NDOF_MOTION; kmi->val = KM_NOTHING; break; -#endif } } } @@ -744,9 +738,7 @@ static EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *UNUSED(C), PointerR if (map_type == KMI_TYPE_MOUSE) return event_mouse_type_items; if (map_type == KMI_TYPE_TWEAK) return event_tweak_type_items; if (map_type == KMI_TYPE_TIMER) return event_timer_type_items; -#ifdef WITH_INPUT_NDOF if (map_type == KMI_TYPE_NDOF) return event_ndof_type_items; -#endif if (map_type == KMI_TYPE_TEXTINPUT) return event_textinput_type_items; else return rna_enum_event_type_items; } @@ -2022,9 +2014,7 @@ static void rna_def_keyconfig(BlenderRNA *brna) {KMI_TYPE_KEYBOARD, "KEYBOARD", 0, "Keyboard", ""}, {KMI_TYPE_TWEAK, "TWEAK", 0, "Tweak", ""}, {KMI_TYPE_MOUSE, "MOUSE", 0, "Mouse", ""}, -#ifdef WITH_INPUT_NDOF {KMI_TYPE_NDOF, "NDOF", 0, "NDOF", ""}, -#endif {KMI_TYPE_TEXTINPUT, "TEXTINPUT", 0, "Text Input", ""}, {KMI_TYPE_TIMER, "TIMER", 0, "Timer", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index 0936b294d1b..3085f138846 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -40,9 +40,7 @@ enum { EVT_DATA_GESTURE = 1, EVT_DATA_TIMER = 2, EVT_DATA_DRAGDROP = 3, -#ifdef WITH_INPUT_NDOF EVT_DATA_NDOF_MOTION = 4, -#endif }; /* tablet active, matches GHOST_TTabletMode */ @@ -238,7 +236,6 @@ enum { /* *** End of keyboard codes. *** */ -#ifdef WITH_INPUT_NDOF /* NDOF (from SpaceNavigator & friends) * These should be kept in sync with GHOST_NDOFManager.h * Ordering matters, exact values do not. */ @@ -293,7 +290,6 @@ enum { NDOF_BUTTON_C, /* the end */ NDOF_LAST, -#endif /* WITH_INPUT_NDOF */ /* ********** End of Input devices. ********** */ @@ -373,12 +369,8 @@ enum { /* test whether the event is tweak event */ #define ISTWEAK(event_type) ((event_type) >= EVT_TWEAK_L && (event_type) <= EVT_GESTURE) -#ifdef WITH_INPUT_NDOF /* test whether the event is a NDOF event */ -# define ISNDOF(event_type) ((event_type) >= NDOF_MOTION && (event_type) < NDOF_LAST) -#else -# define ISNDOF(event_type) false -#endif +#define ISNDOF(event_type) ((event_type) >= NDOF_MOTION && (event_type) < NDOF_LAST) /* test whether event type is acceptable as hotkey, excluding modifiers */ #define ISHOTKEY(event_type) \ -- cgit v1.2.3 From 62e3849f401c64342aade0a85cca214ddd7f2e8b Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 19 Aug 2016 17:00:34 +0200 Subject: Fix T49105: Array modifier displayed in Edit mode crashes on selection, with End Cap enabled. Origindex can be invalid, code was not fully protected against it... --- source/blender/blenkernel/intern/cdderivedmesh.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index d257a1cfcae..2d06bc88aa7 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -687,20 +687,24 @@ static void cdDM_drawMappedFaces( const int orig = (index_mp_to_orig) ? index_mp_to_orig[i] : i; bool is_hidden; - if (use_hide) { - if (flag & DM_DRAW_SELECT_USE_EDITMODE) { - BMFace *efa = BM_face_at_index(bm, orig); - is_hidden = BM_elem_flag_test(efa, BM_ELEM_HIDDEN) != 0; + if (orig != ORIGINDEX_NONE) { + if (use_hide) { + if (flag & DM_DRAW_SELECT_USE_EDITMODE) { + BMFace *efa = BM_face_at_index(bm, orig); + is_hidden = BM_elem_flag_test(efa, BM_ELEM_HIDDEN) != 0; + } + else { + is_hidden = (me->mpoly[orig].flag & ME_HIDE) != 0; + } + + if (!is_hidden) { + GPU_select_index_get(orig + 1, &selcol); + } } else { - is_hidden = (me->mpoly[orig].flag & ME_HIDE) != 0; - } - - if ((orig != ORIGINDEX_NONE) && !is_hidden) GPU_select_index_get(orig + 1, &selcol); + } } - else if (orig != ORIGINDEX_NONE) - GPU_select_index_get(orig + 1, &selcol); for (j = 0; j < mpoly->totloop; j++) fi_map[start_element++] = selcol; -- cgit v1.2.3 From cf533894253f3ddd5067107725ae840bebad3fc2 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 19 Aug 2016 23:04:43 +0200 Subject: Fix T49090: color picking draws wrong when using subsurf in material draw mode. ccgDM_drawMappedFacesMat was missig a smooth shade model restore, some other functions were redundantly setting it since we can assume it to be the default state already. --- source/blender/blenkernel/intern/subsurf_ccg.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index e876bf43809..60f1eb6b98c 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -2707,7 +2707,6 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes) GPU_vertex_setup(dm); GPU_normal_setup(dm); GPU_triangle_setup(dm); - glShadeModel(GL_SMOOTH); for (a = 0; a < dm->drawObject->totmaterial; a++) { if (!setMaterial || setMaterial(dm->drawObject->materials[a].mat_nr + 1, NULL)) { GPU_buffer_draw_elements(dm->drawObject->triangles, GL_TRIANGLES, dm->drawObject->materials[a].start, @@ -2811,8 +2810,6 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, } #endif - glShadeModel(GL_SMOOTH); - CCG_key_top_level(&key, ss); ccgdm_pbvh_update(ccgdm); @@ -2965,6 +2962,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, } } + glShadeModel(GL_SMOOTH); #undef PASSATTRIB } else { @@ -3170,8 +3168,6 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, MEM_freeN(mat_orig_to_new); MEM_freeN(matconv); } - - glShadeModel(GL_SMOOTH); } static void ccgDM_drawFacesGLSL(DerivedMesh *dm, DMSetMaterial setMaterial) @@ -3369,6 +3365,7 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, } } + glShadeModel(GL_SMOOTH); #undef PASSATTRIB } @@ -3503,7 +3500,6 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm, next_actualFace = 0; - glShadeModel(GL_SMOOTH); /* lastFlag = 0; */ /* UNUSED */ for (mat_index = 0; mat_index < dm->drawObject->totmaterial; mat_index++) { GPUBufferMaterial *bufmat = dm->drawObject->materials + mat_index; @@ -3681,8 +3677,8 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm, if (do_draw) { glShadeModel(draw_smooth ? GL_SMOOTH : GL_FLAT); ccgSubSurf_drawGLMesh(ss, true, -1, -1); + glShadeModel(GL_SMOOTH); } - glShadeModel(GL_SMOOTH); return; } #endif @@ -3744,10 +3740,6 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm, GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_QUARTTONE); } - /* no need to set shading mode to flat because - * normals are already used to change shading */ - glShadeModel(GL_SMOOTH); - for (S = 0; S < numVerts; S++) { CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); if (ln) { -- cgit v1.2.3 From 36ab737ef79b669973e7f37b9f48ec6e2135da73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Sat, 20 Aug 2016 09:30:38 +0200 Subject: Alembic export UI: avoid displaying empty box. --- source/blender/editors/io/io_alembic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.c index 96a3ef1f2f6..cd75983e0a0 100644 --- a/source/blender/editors/io/io_alembic.c +++ b/source/blender/editors/io/io_alembic.c @@ -132,10 +132,11 @@ static int wm_alembic_export_exec(bContext *C, wmOperator *op) static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr) { - uiLayout *box = uiLayoutBox(layout); + uiLayout *box; uiLayout *row; #ifdef WITH_ALEMBIC_HDF5 + box = uiLayoutBox(layout); row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Archive Options:"), ICON_NONE); -- cgit v1.2.3 From 0e5e53c651effb6d33871f4a386c1b17c98aa9a1 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sat, 20 Aug 2016 12:03:40 +0300 Subject: Fix crash in OpenVDB highres smoke cache when seeking to frame 0. This code obviously should also use the cache_fields flag variable, like the code for reading the lowres data in the same function. This is because fluid_fields actually represents the old state before smoke was reallocated to match cache_fields read from the file, and if it has some fields enabled that aren't allocated any more, it crashes. This also fixes a reverse glitch: when a file was loaded with the current frame in the middle of a baked smoke+fire simulation, smoke appeared immediately, but the fire didn't until the frame was changed. The reason is the same: after file load no fields are initially allocated and thus fluid_fields is 0. --- source/blender/blenkernel/intern/pointcache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index d08814e3373..30eb8dcb287 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1137,13 +1137,13 @@ static int ptcache_smoke_openvdb_read(struct OpenVDBReader *reader, void *smoke_ OpenVDB_import_grid_fl(reader, "density", &dens, sds->res_wt); - if (fluid_fields & SM_ACTIVE_FIRE) { + if (cache_fields & SM_ACTIVE_FIRE) { OpenVDB_import_grid_fl(reader, "flame", &flame, sds->res_wt); OpenVDB_import_grid_fl(reader, "fuel", &fuel, sds->res_wt); OpenVDB_import_grid_fl(reader, "react", &react, sds->res_wt); } - if (fluid_fields & SM_ACTIVE_COLORS) { + if (cache_fields & SM_ACTIVE_COLORS) { OpenVDB_import_grid_vec(reader, "color", &r, &g, &b, sds->res_wt); } -- cgit v1.2.3 From 8e02b024c02db4580bc04c143a31dc3dff869385 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sat, 20 Aug 2016 13:48:29 +0300 Subject: Fix OpenSubdiv driver crash due to recently added uninitialized field. For some reason my NVidia linux driver crashes in glDeleteTextures when the ID is total garbage. --- intern/opensubdiv/opensubdiv_gpu_capi.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/opensubdiv/opensubdiv_gpu_capi.cc b/intern/opensubdiv/opensubdiv_gpu_capi.cc index 0cf6fcfef43..05bd3728f93 100644 --- a/intern/opensubdiv/opensubdiv_gpu_capi.cc +++ b/intern/opensubdiv/opensubdiv_gpu_capi.cc @@ -115,7 +115,7 @@ static Transform g_transform; struct OpenSubdiv_GLMeshFVarData { OpenSubdiv_GLMeshFVarData() : - texture_buffer(0) { + texture_buffer(0), offset_buffer(0) { } ~OpenSubdiv_GLMeshFVarData() -- cgit v1.2.3 From 67dcad4011bd78be8143d301dfbb22ca2b0a0efe Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 20 Aug 2016 14:48:33 +0200 Subject: Fix T49119: Batch-Generate Previews operator fails. previews render utils needed to be updated slightly against new behavior of maindata.remove. --- release/scripts/modules/bl_previews_utils/bl_previews_render.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/modules/bl_previews_utils/bl_previews_render.py b/release/scripts/modules/bl_previews_utils/bl_previews_render.py index 6c29223cf55..f7317184bd2 100644 --- a/release/scripts/modules/bl_previews_utils/bl_previews_render.py +++ b/release/scripts/modules/bl_previews_utils/bl_previews_render.py @@ -169,7 +169,7 @@ def do_previews(do_objects, do_groups, do_scenes, do_data_intern): scene.objects.unlink(bpy.data.objects[render_context.camera, None]) if render_context.lamp: scene.objects.unlink(bpy.data.objects[render_context.lamp, None]) - bpy.data.scenes.remove(scene) + bpy.data.scenes.remove(scene, do_unlink=True) scene = None else: rna_backup_restore(scene, render_context.backup_scene) -- cgit v1.2.3 From 43bb8f12f44415c91f07ab5864aee7da51ef4a09 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 20 Aug 2016 16:03:33 +0200 Subject: Fix T49060: crashes during render with no apparent reason... Was a concurrent access of pointcache from both particle system and UI (time space). Pointcache not being threadsafe is really an issue to be addressed for its next version, for now simply locking spacetime (like we already do with 3DView), not ideal fix but it's working and safe for release. --- source/blender/editors/space_time/space_time.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 021c4a54b0a..15eb154c757 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -813,6 +813,7 @@ void ED_spacetype_time(void) art->draw = time_main_region_draw; art->listener = time_main_region_listener; art->keymap = time_keymap; + art->lock = 1; /* Due to pointcache, see T4960. */ BLI_addhead(&st->regiontypes, art); /* regions: header */ -- cgit v1.2.3