From e400f4a53ec435b8c93c309896e63393c5b70bf3 Mon Sep 17 00:00:00 2001 From: Antonioya Date: Wed, 16 Nov 2016 21:33:47 +0100 Subject: Fix T50051: Avoid crash when render grease pencil from VSE The renderpasses for grease pencil are not necessary when render from sequencer. This fix solves the GPF but we need to rethink the complete render process for grease pencil and integrate better in the render and composition workflow. Thanks to Dalai Felinto por helping in the debug and fixing of the problem. --- source/blender/editors/render/render_opengl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 16842efb436..9097432a251 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -552,8 +552,11 @@ static void screen_opengl_render_apply(OGLRender *oglrender) BLI_assert(view_id < oglrender->views_len); RE_SetActiveRenderView(oglrender->re, rv->name); oglrender->view_id = view_id; - /* add grease pencil passes */ - add_gpencil_renderpass(oglrender, rr, rv); + /* add grease pencil passes. For sequencer, the render does not include renderpasses + * TODO: The sequencer render of grease pencil should be rethought */ + if (!oglrender->is_sequencer) { + add_gpencil_renderpass(oglrender, rr, rv); + } /* render composite */ screen_opengl_render_doit(oglrender, rr); } -- cgit v1.2.3 From 60409841a4b9308575b108933f5e4c0d96e64f7e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 17 Nov 2016 02:16:21 +0100 Subject: Fix T50001: auto tile size addon broken after Cycles GPU device changes. Adds a get_num_gpu_devices() utility function for the addon to use. --- intern/cycles/blender/addon/properties.py | 14 ++++++++++---- intern/cycles/blender/addon/ui.py | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 27c9b922042..a7dff1f79f3 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -1199,15 +1199,21 @@ class CyclesPreferences(bpy.types.AddonPreferences): return cuda_devices, opencl_devices - def has_active_device(self): + def get_num_gpu_devices(self): import _cycles device_list = _cycles.available_devices() + num = 0 for device in device_list: if device[1] != self.compute_device_type: continue - if any(dev.use and dev.id == device[2] for dev in self.devices): - return True - return False + for dev in self.devices: + if dev.use and dev.id == device[2]: + num += 1 + return num + + + def has_active_device(self): + return self.get_num_gpu_devices() > 0 def draw_impl(self, layout, context): diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index f28fa0d52ba..f435af178b5 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -1620,7 +1620,7 @@ def draw_device(self, context): sub = row.split(align=True) sub.active = show_device_selection(context) sub.prop(cscene, "device", text="") - row.operator("wm.addon_userpref_show", text="Preferences", icon='PREFERENCES').module = __package__ + row.operator("wm.addon_userpref_show", text="", icon='PREFERENCES').module = __package__ if engine.with_osl() and use_cpu(context): layout.prop(cscene, "shading_system") -- cgit v1.2.3 From 16e2c0ef3c08b3a5d81ab21a71fc3c4c37e47e81 Mon Sep 17 00:00:00 2001 From: lazydodo Date: Wed, 16 Nov 2016 20:13:58 -0700 Subject: [MSVC] Preliminary VS2017 support. --- build_files/cmake/platform/platform_win32_msvc.cmake | 6 ++++-- make.bat | 16 +++++++++++++++- source/creator/CMakeLists.txt | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/build_files/cmake/platform/platform_win32_msvc.cmake b/build_files/cmake/platform/platform_win32_msvc.cmake index 5efda52b2c5..6ca0568b5fd 100644 --- a/build_files/cmake/platform/platform_win32_msvc.cmake +++ b/build_files/cmake/platform/platform_win32_msvc.cmake @@ -129,8 +129,10 @@ if(NOT DEFINED LIBDIR) message(STATUS "32 bit compiler detected.") set(LIBDIR_BASE "windows") endif() - - if(MSVC_VERSION EQUAL 1900) + if(MSVC_VERSION EQUAL 1910) + message(STATUS "Visual Studio 2017 detected.") + set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc14) + elseif(MSVC_VERSION EQUAL 1900) message(STATUS "Visual Studio 2015 detected.") set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc14) else() diff --git a/make.bat b/make.bat index 74148e5599d..f3ec646dc8f 100644 --- a/make.bat +++ b/make.bat @@ -61,6 +61,9 @@ if NOT "%1" == "" ( set BUILD_ARCH=x86 ) else if "%1" == "x64" ( set BUILD_ARCH=x64 + ) else if "%1" == "2017" ( + set BUILD_VS_VER=15 + set BUILD_VS_YEAR=2017 ) else if "%1" == "2015" ( set BUILD_VS_VER=14 set BUILD_VS_YEAR=2015 @@ -140,7 +143,7 @@ if "%target%"=="Release" ( ) :DetectMSVC -REM Detect MSVC Installation +REM Detect MSVC Installation for 2013-2015 if DEFINED VisualStudioVersion goto msvc_detect_finally set VALUE_NAME=ProductDir REM Check 64 bits @@ -153,7 +156,18 @@ for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAM if DEFINED MSVC_VC_DIR goto msvc_detect_finally :msvc_detect_finally if DEFINED MSVC_VC_DIR call "%MSVC_VC_DIR%\vcvarsall.bat" +if DEFINED MSVC_VC_DIR goto sanity_checks +rem MSVC Build environment 2017 and up. +for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SXS\VS7" /v %BUILD_VS_VER%.0 2^>nul`) DO set MSVC_VS_DIR=%%C +if DEFINED MSVC_VS_DIR goto msvc_detect_finally_2017 +REM Check 32 bits +for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\sxs\vs7" /v %BUILD_VS_VER%.0 2^>nul`) DO set MSVC_VS_DIR=%%C +if DEFINED MSVC_VS_DIR goto msvc_detect_finally_2017 +:msvc_detect_finally_2017 +if DEFINED MSVC_VS_DIR call "%MSVC_VS_DIR%\Common7\Tools\VsDevCmd.bat" + +:sanity_checks REM Sanity Checks where /Q msbuild if %ERRORLEVEL% NEQ 0 ( diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 10af0d5489e..aa0a213cf64 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -714,7 +714,7 @@ elseif(WIN32) if(WITH_PYTHON_INSTALL_NUMPY) set(PYTHON_NUMPY_VERSION 1.9) - if(MSVC_VERSION EQUAL 1900) + if((MSVC_VERSION EQUAL 1900) OR (MSVC_VERSION EQUAL 1910)) set(PYTHON_NUMPY_VERSION 1.11) endif() add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages -- cgit v1.2.3 From 0c322c3000a0ddd7ac58c650f30b29d55afd1a97 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 17 Nov 2016 14:34:46 +0100 Subject: Depsgraph: Move rig builder functions to own files Those routines are rather big and started to be annoying to have one big file. Should be no functional changes. --- source/blender/depsgraph/CMakeLists.txt | 2 + .../depsgraph/intern/builder/deg_builder_nodes.cc | 209 ---------- .../intern/builder/deg_builder_nodes_rig.cc | 275 +++++++++++++ .../intern/builder/deg_builder_relations.cc | 385 ----------------- .../intern/builder/deg_builder_relations_rig.cc | 458 +++++++++++++++++++++ 5 files changed, 735 insertions(+), 594 deletions(-) create mode 100644 source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc create mode 100644 source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt index ab12a8d5b3e..ea839d11071 100644 --- a/source/blender/depsgraph/CMakeLists.txt +++ b/source/blender/depsgraph/CMakeLists.txt @@ -43,9 +43,11 @@ set(SRC intern/builder/deg_builder.cc intern/builder/deg_builder_cycle.cc intern/builder/deg_builder_nodes.cc + intern/builder/deg_builder_nodes_rig.cc intern/builder/deg_builder_pchanmap.cc intern/builder/deg_builder_relations.cc intern/builder/deg_builder_relations_keys.cc + intern/builder/deg_builder_relations_rig.cc intern/builder/deg_builder_transitive.cc intern/debug/deg_debug_graphviz.cc intern/eval/deg_eval.cc diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 12050e3e003..1eaacea69eb 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -626,14 +626,6 @@ void DepsgraphNodeBuilder::build_object_constraints(Scene *scene, Object *ob) DEG_OPCODE_TRANSFORM_CONSTRAINTS); } -void DepsgraphNodeBuilder::build_pose_constraints(Object *ob, bPoseChannel *pchan) -{ - /* create node for constraint stack */ - add_operation_node(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, - DEPSOP_TYPE_EXEC, function_bind(BKE_pose_constraints_evaluate, _1, ob, pchan), - DEG_OPCODE_BONE_CONSTRAINTS); -} - /** * Build graph nodes for AnimData block * \param id: ID-Block which hosts the AnimData @@ -829,207 +821,6 @@ void DepsgraphNodeBuilder::build_particles(Scene *scene, Object *ob) // TODO... } -/* IK Solver Eval Steps */ -void DepsgraphNodeBuilder::build_ik_pose(Scene *scene, Object *ob, bPoseChannel *pchan, bConstraint *con) -{ - bKinematicConstraint *data = (bKinematicConstraint *)con->data; - - /* Find the chain's root. */ - bPoseChannel *rootchan = BKE_armature_ik_solver_find_root(pchan, data); - - if (has_operation_node(&ob->id, DEPSNODE_TYPE_EVAL_POSE, rootchan->name, - DEG_OPCODE_POSE_IK_SOLVER)) - { - return; - } - - /* Operation node for evaluating/running IK Solver. */ - add_operation_node(&ob->id, DEPSNODE_TYPE_EVAL_POSE, rootchan->name, - DEPSOP_TYPE_SIM, function_bind(BKE_pose_iktree_evaluate, _1, scene, ob, rootchan), - DEG_OPCODE_POSE_IK_SOLVER); -} - -/* Spline IK Eval Steps */ -void DepsgraphNodeBuilder::build_splineik_pose(Scene *scene, Object *ob, bPoseChannel *pchan, bConstraint *con) -{ - bSplineIKConstraint *data = (bSplineIKConstraint *)con->data; - - /* Find the chain's root. */ - bPoseChannel *rootchan = BKE_armature_splineik_solver_find_root(pchan, data); - - /* Operation node for evaluating/running Spline IK Solver. - * Store the "root bone" of this chain in the solver, so it knows where to start. - */ - add_operation_node(&ob->id, DEPSNODE_TYPE_EVAL_POSE, rootchan->name, - DEPSOP_TYPE_SIM, function_bind(BKE_pose_splineik_evaluate, _1, scene, ob, rootchan), - DEG_OPCODE_POSE_SPLINE_IK_SOLVER); -} - -/* Pose/Armature Bones Graph */ -void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *ob) -{ - bArmature *arm = (bArmature *)ob->data; - - /* animation and/or drivers linking posebones to base-armature used to define them - * NOTE: AnimData here is really used to control animated deform properties, - * which ideally should be able to be unique across different instances. - * Eventually, we need some type of proxy/isolation mechanism in-between here - * to ensure that we can use same rig multiple times in same scene... - */ - build_animdata(&arm->id); - - /* Rebuild pose if not up to date. */ - if (ob->pose == NULL || (ob->pose->flag & POSE_RECALC)) { - BKE_pose_rebuild_ex(ob, arm, false); - /* XXX: Without this animation gets lost in certain circumstances - * after loading file. Need to investigate further since it does - * not happen with simple scenes.. - */ - if (ob->adt) { - ob->adt->recalc |= ADT_RECALC_ANIM; - } - } - - /* speed optimization for animation lookups */ - if (ob->pose) { - BKE_pose_channels_hash_make(ob->pose); - if (ob->pose->flag & POSE_CONSTRAINTS_NEED_UPDATE_FLAGS) { - BKE_pose_update_constraint_flags(ob->pose); - } - } - - /* Make sure pose is up-to-date with armature updates. */ - add_operation_node(&arm->id, - DEPSNODE_TYPE_PARAMETERS, - DEPSOP_TYPE_EXEC, - NULL, - DEG_OPCODE_PLACEHOLDER, - "Armature Eval"); - - /** - * Pose Rig Graph - * ============== - * - * Pose Component: - * - Mainly used for referencing Bone components. - * - This is where the evaluation operations for init/exec/cleanup - * (ik) solvers live, and are later hooked up (so that they can be - * interleaved during runtime) with bone-operations they depend on/affect. - * - init_pose_eval() and cleanup_pose_eval() are absolute first and last - * steps of pose eval process. ALL bone operations must be performed - * between these two... - * - * Bone Component: - * - Used for representing each bone within the rig - * - Acts to encapsulate the evaluation operations (base matrix + parenting, - * and constraint stack) so that they can be easily found. - * - Everything else which depends on bone-results hook up to the component only - * so that we can redirect those to point at either the the post-IK/ - * post-constraint/post-matrix steps, as needed. - */ - - /* pose eval context */ - add_operation_node(&ob->id, DEPSNODE_TYPE_EVAL_POSE, - DEPSOP_TYPE_INIT, function_bind(BKE_pose_eval_init, _1, scene, ob, ob->pose), DEG_OPCODE_POSE_INIT); - - add_operation_node(&ob->id, DEPSNODE_TYPE_EVAL_POSE, - DEPSOP_TYPE_POST, function_bind(BKE_pose_eval_flush, _1, scene, ob, ob->pose), DEG_OPCODE_POSE_DONE); - - /* bones */ - for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = pchan->next) { - /* node for bone eval */ - add_operation_node(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, - DEPSOP_TYPE_INIT, NULL, // XXX: BKE_pose_eval_bone_local - DEG_OPCODE_BONE_LOCAL); - - add_operation_node(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, - DEPSOP_TYPE_EXEC, function_bind(BKE_pose_eval_bone, _1, scene, ob, pchan), // XXX: BKE_pose_eval_bone_pose - DEG_OPCODE_BONE_POSE_PARENT); - - add_operation_node(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, - DEPSOP_TYPE_OUT, NULL, /* NOTE: dedicated noop for easier relationship construction */ - DEG_OPCODE_BONE_READY); - - add_operation_node(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, - DEPSOP_TYPE_POST, function_bind(BKE_pose_bone_done, _1, pchan), - DEG_OPCODE_BONE_DONE); - - /* constraints */ - if (pchan->constraints.first != NULL) { - build_pose_constraints(ob, pchan); - } - - /** - * IK Solvers... - * - * - These require separate processing steps are pose-level - * to be executed between chains of bones (i.e. once the - * base transforms of a bunch of bones is done) - * - * Unsolved Issues: - * - Care is needed to ensure that multi-headed trees work out the same as in ik-tree building - * - Animated chain-lengths are a problem... - */ - for (bConstraint *con = (bConstraint *)pchan->constraints.first; con; con = con->next) { - switch (con->type) { - case CONSTRAINT_TYPE_KINEMATIC: - build_ik_pose(scene, ob, pchan, con); - break; - - case CONSTRAINT_TYPE_SPLINEIK: - build_splineik_pose(scene, ob, pchan, con); - break; - - default: - break; - } - } - } -} - -void DepsgraphNodeBuilder::build_proxy_rig(Object *ob) -{ - ID *obdata = (ID *)ob->data; - build_animdata(obdata); - - BLI_assert(ob->pose != NULL); - - /* speed optimization for animation lookups */ - BKE_pose_channels_hash_make(ob->pose); - if (ob->pose->flag & POSE_CONSTRAINTS_NEED_UPDATE_FLAGS) { - BKE_pose_update_constraint_flags(ob->pose); - } - - add_operation_node(&ob->id, - DEPSNODE_TYPE_EVAL_POSE, - DEPSOP_TYPE_INIT, - function_bind(BKE_pose_eval_proxy_copy, _1, ob), - DEG_OPCODE_POSE_INIT); - - for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; - pchan != NULL; - pchan = pchan->next) - { - add_operation_node(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, - DEPSOP_TYPE_INIT, NULL, - DEG_OPCODE_BONE_LOCAL); - - add_operation_node(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, - DEPSOP_TYPE_EXEC, NULL, - DEG_OPCODE_BONE_READY); - - add_operation_node(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, - DEPSOP_TYPE_POST, NULL, - DEG_OPCODE_BONE_DONE); - } - - add_operation_node(&ob->id, - DEPSNODE_TYPE_EVAL_POSE, - DEPSOP_TYPE_POST, - NULL, - DEG_OPCODE_POSE_DONE); -} - /* Shapekeys */ void DepsgraphNodeBuilder::build_shapekeys(Key *key) { diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc new file mode 100644 index 00000000000..b9c7c3c7f92 --- /dev/null +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc @@ -0,0 +1,275 @@ +/* + * ***** 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) 2013 Blender Foundation. + * All rights reserved. + * + * Original Author: Joshua Leung + * Contributor(s): Based on original depsgraph.c code - Blender Foundation (2005-2013) + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/depsgraph/intern/builder/deg_builder_nodes.cc + * \ingroup depsgraph + * + * Methods for constructing depsgraph's nodes + */ + +#include "intern/builder/deg_builder_nodes.h" + +#include +#include + +#include "MEM_guardedalloc.h" + +extern "C" { +#include "BLI_blenlib.h" +#include "BLI_string.h" +#include "BLI_utildefines.h" + +#include "DNA_anim_types.h" +#include "DNA_armature_types.h" +#include "DNA_constraint_types.h" +#include "DNA_object_types.h" + +#include "BKE_action.h" +#include "BKE_armature.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" +} /* extern "C" */ + +#include "intern/builder/deg_builder.h" +#include "intern/nodes/deg_node.h" +#include "intern/nodes/deg_node_component.h" +#include "intern/nodes/deg_node_operation.h" +#include "intern/depsgraph_types.h" +#include "intern/depsgraph_intern.h" + +namespace DEG { + +void DepsgraphNodeBuilder::build_pose_constraints(Object *ob, bPoseChannel *pchan) +{ + /* create node for constraint stack */ + add_operation_node(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, + DEPSOP_TYPE_EXEC, function_bind(BKE_pose_constraints_evaluate, _1, ob, pchan), + DEG_OPCODE_BONE_CONSTRAINTS); +} + +/* IK Solver Eval Steps */ +void DepsgraphNodeBuilder::build_ik_pose(Scene *scene, Object *ob, bPoseChannel *pchan, bConstraint *con) +{ + bKinematicConstraint *data = (bKinematicConstraint *)con->data; + + /* Find the chain's root. */ + bPoseChannel *rootchan = BKE_armature_ik_solver_find_root(pchan, data); + + if (has_operation_node(&ob->id, DEPSNODE_TYPE_EVAL_POSE, rootchan->name, + DEG_OPCODE_POSE_IK_SOLVER)) + { + return; + } + + /* Operation node for evaluating/running IK Solver. */ + add_operation_node(&ob->id, DEPSNODE_TYPE_EVAL_POSE, rootchan->name, + DEPSOP_TYPE_SIM, function_bind(BKE_pose_iktree_evaluate, _1, scene, ob, rootchan), + DEG_OPCODE_POSE_IK_SOLVER); +} + +/* Spline IK Eval Steps */ +void DepsgraphNodeBuilder::build_splineik_pose(Scene *scene, Object *ob, bPoseChannel *pchan, bConstraint *con) +{ + bSplineIKConstraint *data = (bSplineIKConstraint *)con->data; + + /* Find the chain's root. */ + bPoseChannel *rootchan = BKE_armature_splineik_solver_find_root(pchan, data); + + /* Operation node for evaluating/running Spline IK Solver. + * Store the "root bone" of this chain in the solver, so it knows where to start. + */ + add_operation_node(&ob->id, DEPSNODE_TYPE_EVAL_POSE, rootchan->name, + DEPSOP_TYPE_SIM, function_bind(BKE_pose_splineik_evaluate, _1, scene, ob, rootchan), + DEG_OPCODE_POSE_SPLINE_IK_SOLVER); +} + +/* Pose/Armature Bones Graph */ +void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *ob) +{ + bArmature *arm = (bArmature *)ob->data; + + /* animation and/or drivers linking posebones to base-armature used to define them + * NOTE: AnimData here is really used to control animated deform properties, + * which ideally should be able to be unique across different instances. + * Eventually, we need some type of proxy/isolation mechanism in-between here + * to ensure that we can use same rig multiple times in same scene... + */ + build_animdata(&arm->id); + + /* Rebuild pose if not up to date. */ + if (ob->pose == NULL || (ob->pose->flag & POSE_RECALC)) { + BKE_pose_rebuild_ex(ob, arm, false); + /* XXX: Without this animation gets lost in certain circumstances + * after loading file. Need to investigate further since it does + * not happen with simple scenes.. + */ + if (ob->adt) { + ob->adt->recalc |= ADT_RECALC_ANIM; + } + } + + /* speed optimization for animation lookups */ + if (ob->pose) { + BKE_pose_channels_hash_make(ob->pose); + if (ob->pose->flag & POSE_CONSTRAINTS_NEED_UPDATE_FLAGS) { + BKE_pose_update_constraint_flags(ob->pose); + } + } + + /* Make sure pose is up-to-date with armature updates. */ + add_operation_node(&arm->id, + DEPSNODE_TYPE_PARAMETERS, + DEPSOP_TYPE_EXEC, + NULL, + DEG_OPCODE_PLACEHOLDER, + "Armature Eval"); + + /** + * Pose Rig Graph + * ============== + * + * Pose Component: + * - Mainly used for referencing Bone components. + * - This is where the evaluation operations for init/exec/cleanup + * (ik) solvers live, and are later hooked up (so that they can be + * interleaved during runtime) with bone-operations they depend on/affect. + * - init_pose_eval() and cleanup_pose_eval() are absolute first and last + * steps of pose eval process. ALL bone operations must be performed + * between these two... + * + * Bone Component: + * - Used for representing each bone within the rig + * - Acts to encapsulate the evaluation operations (base matrix + parenting, + * and constraint stack) so that they can be easily found. + * - Everything else which depends on bone-results hook up to the component only + * so that we can redirect those to point at either the the post-IK/ + * post-constraint/post-matrix steps, as needed. + */ + + /* pose eval context */ + add_operation_node(&ob->id, DEPSNODE_TYPE_EVAL_POSE, + DEPSOP_TYPE_INIT, function_bind(BKE_pose_eval_init, _1, scene, ob, ob->pose), DEG_OPCODE_POSE_INIT); + + add_operation_node(&ob->id, DEPSNODE_TYPE_EVAL_POSE, + DEPSOP_TYPE_POST, function_bind(BKE_pose_eval_flush, _1, scene, ob, ob->pose), DEG_OPCODE_POSE_DONE); + + /* bones */ + for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = pchan->next) { + /* node for bone eval */ + add_operation_node(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, + DEPSOP_TYPE_INIT, NULL, // XXX: BKE_pose_eval_bone_local + DEG_OPCODE_BONE_LOCAL); + + add_operation_node(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, + DEPSOP_TYPE_EXEC, function_bind(BKE_pose_eval_bone, _1, scene, ob, pchan), // XXX: BKE_pose_eval_bone_pose + DEG_OPCODE_BONE_POSE_PARENT); + + add_operation_node(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, + DEPSOP_TYPE_OUT, NULL, /* NOTE: dedicated noop for easier relationship construction */ + DEG_OPCODE_BONE_READY); + + add_operation_node(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, + DEPSOP_TYPE_POST, function_bind(BKE_pose_bone_done, _1, pchan), + DEG_OPCODE_BONE_DONE); + + /* constraints */ + if (pchan->constraints.first != NULL) { + build_pose_constraints(ob, pchan); + } + + /** + * IK Solvers... + * + * - These require separate processing steps are pose-level + * to be executed between chains of bones (i.e. once the + * base transforms of a bunch of bones is done) + * + * Unsolved Issues: + * - Care is needed to ensure that multi-headed trees work out the same as in ik-tree building + * - Animated chain-lengths are a problem... + */ + for (bConstraint *con = (bConstraint *)pchan->constraints.first; con; con = con->next) { + switch (con->type) { + case CONSTRAINT_TYPE_KINEMATIC: + build_ik_pose(scene, ob, pchan, con); + break; + + case CONSTRAINT_TYPE_SPLINEIK: + build_splineik_pose(scene, ob, pchan, con); + break; + + default: + break; + } + } + } +} + +void DepsgraphNodeBuilder::build_proxy_rig(Object *ob) +{ + ID *obdata = (ID *)ob->data; + build_animdata(obdata); + + BLI_assert(ob->pose != NULL); + + /* speed optimization for animation lookups */ + BKE_pose_channels_hash_make(ob->pose); + if (ob->pose->flag & POSE_CONSTRAINTS_NEED_UPDATE_FLAGS) { + BKE_pose_update_constraint_flags(ob->pose); + } + + add_operation_node(&ob->id, + DEPSNODE_TYPE_EVAL_POSE, + DEPSOP_TYPE_INIT, + function_bind(BKE_pose_eval_proxy_copy, _1, ob), + DEG_OPCODE_POSE_INIT); + + for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; + pchan != NULL; + pchan = pchan->next) + { + add_operation_node(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, + DEPSOP_TYPE_INIT, NULL, + DEG_OPCODE_BONE_LOCAL); + + add_operation_node(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, + DEPSOP_TYPE_EXEC, NULL, + DEG_OPCODE_BONE_READY); + + add_operation_node(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, + DEPSOP_TYPE_POST, NULL, + DEG_OPCODE_BONE_DONE); + } + + add_operation_node(&ob->id, + DEPSNODE_TYPE_EVAL_POSE, + DEPSOP_TYPE_POST, + NULL, + DEG_OPCODE_POSE_DONE); +} + +} // namespace DEG diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index fe75de5e350..1497a16e47f 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -1345,391 +1345,6 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob) // TODO... } -/* IK Solver Eval Steps */ -void DepsgraphRelationBuilder::build_ik_pose(Object *ob, - bPoseChannel *pchan, - bConstraint *con, - RootPChanMap *root_map) -{ - bKinematicConstraint *data = (bKinematicConstraint *)con->data; - - /* attach owner to IK Solver too - * - assume that owner is always part of chain - * - see notes on direction of rel below... - */ - bPoseChannel *rootchan = BKE_armature_ik_solver_find_root(pchan, data); - OperationKey solver_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, rootchan->name, DEG_OPCODE_POSE_IK_SOLVER); - - /* IK target */ - // XXX: this should get handled as part of the constraint code - if (data->tar != NULL) { - /* TODO(sergey): For until we'll store partial matricies in the depsgraph, - * we create dependency between target object and pose eval component. - * - * This way we ensuring the whole subtree is updated from scratch without - * need of intermediate matricies. This is an overkill, but good enough for - * testing IK solver. - */ - // FIXME: geometry targets... - ComponentKey pose_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE); - if ((data->tar->type == OB_ARMATURE) && (data->subtarget[0])) { - /* TODO(sergey): This is only for until granular update stores intermediate result. */ - if (data->tar != ob) { - /* different armature - can just read the results */ - ComponentKey target_key(&data->tar->id, DEPSNODE_TYPE_BONE, data->subtarget); - add_relation(target_key, pose_key, DEPSREL_TYPE_TRANSFORM, con->name); - } - else { - /* same armature - we'll use the ready state only, just in case this bone is in the chain we're solving */ - OperationKey target_key(&data->tar->id, DEPSNODE_TYPE_BONE, data->subtarget, DEG_OPCODE_BONE_DONE); - add_relation(target_key, solver_key, DEPSREL_TYPE_TRANSFORM, con->name); - } - } - else if (ELEM(data->tar->type, OB_MESH, OB_LATTICE) && (data->subtarget[0])) { - /* vertex group target */ - /* NOTE: for now, we don't need to represent vertex groups separately... */ - ComponentKey target_key(&data->tar->id, DEPSNODE_TYPE_GEOMETRY); - add_relation(target_key, solver_key, DEPSREL_TYPE_GEOMETRY_EVAL, con->name); - - if (data->tar->type == OB_MESH) { - OperationDepsNode *node2 = find_operation_node(target_key); - if (node2 != NULL) { - node2->customdata_mask |= CD_MASK_MDEFORMVERT; - } - } - } - else { - /* Standard Object Target */ - ComponentKey target_key(&data->tar->id, DEPSNODE_TYPE_TRANSFORM); - add_relation(target_key, pose_key, DEPSREL_TYPE_TRANSFORM, con->name); - } - - if ((data->tar == ob) && (data->subtarget[0])) { - /* Prevent target's constraints from linking to anything from same - * chain that it controls. - */ - root_map->add_bone(data->subtarget, rootchan->name); - } - } - - /* Pole Target */ - // XXX: this should get handled as part of the constraint code - if (data->poletar != NULL) { - if ((data->poletar->type == OB_ARMATURE) && (data->polesubtarget[0])) { - // XXX: same armature issues - ready vs done? - ComponentKey target_key(&data->poletar->id, DEPSNODE_TYPE_BONE, data->polesubtarget); - add_relation(target_key, solver_key, DEPSREL_TYPE_TRANSFORM, con->name); - } - else if (ELEM(data->poletar->type, OB_MESH, OB_LATTICE) && (data->polesubtarget[0])) { - /* vertex group target */ - /* NOTE: for now, we don't need to represent vertex groups separately... */ - ComponentKey target_key(&data->poletar->id, DEPSNODE_TYPE_GEOMETRY); - add_relation(target_key, solver_key, DEPSREL_TYPE_GEOMETRY_EVAL, con->name); - - if (data->poletar->type == OB_MESH) { - OperationDepsNode *node2 = find_operation_node(target_key); - if (node2 != NULL) { - node2->customdata_mask |= CD_MASK_MDEFORMVERT; - } - } - } - else { - ComponentKey target_key(&data->poletar->id, DEPSNODE_TYPE_TRANSFORM); - add_relation(target_key, solver_key, DEPSREL_TYPE_TRANSFORM, con->name); - } - } - - DEG_DEBUG_PRINTF("\nStarting IK Build: pchan = %s, target = (%s, %s), segcount = %d\n", - pchan->name, data->tar->id.name, data->subtarget, data->rootbone); - - bPoseChannel *parchan = pchan; - /* exclude tip from chain? */ - if (!(data->flag & CONSTRAINT_IK_TIP)) { - OperationKey tip_transforms_key(&ob->id, DEPSNODE_TYPE_BONE, - parchan->name, DEG_OPCODE_BONE_LOCAL); - add_relation(solver_key, tip_transforms_key, - DEPSREL_TYPE_TRANSFORM, "IK Solver Result"); - parchan = pchan->parent; - } - - root_map->add_bone(parchan->name, rootchan->name); - - OperationKey parchan_transforms_key(&ob->id, DEPSNODE_TYPE_BONE, - parchan->name, DEG_OPCODE_BONE_READY); - add_relation(parchan_transforms_key, solver_key, - DEPSREL_TYPE_TRANSFORM, "IK Solver Owner"); - - /* Walk to the chain's root */ - //size_t segcount = 0; - int segcount = 0; - - while (parchan) { - /* Make IK-solver dependent on this bone's result, - * since it can only run after the standard results - * of the bone are know. Validate links step on the - * bone will ensure that users of this bone only - * grab the result with IK solver results... - */ - if (parchan != pchan) { - OperationKey parent_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_READY); - add_relation(parent_key, solver_key, DEPSREL_TYPE_TRANSFORM, "IK Chain Parent"); - - OperationKey done_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_DONE); - add_relation(solver_key, done_key, DEPSREL_TYPE_TRANSFORM, "IK Chain Result"); - } - else { - OperationKey final_transforms_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_DONE); - add_relation(solver_key, final_transforms_key, DEPSREL_TYPE_TRANSFORM, "IK Solver Result"); - } - parchan->flag |= POSE_DONE; - - - root_map->add_bone(parchan->name, rootchan->name); - - /* continue up chain, until we reach target number of items... */ - DEG_DEBUG_PRINTF(" %d = %s\n", segcount, parchan->name); - segcount++; - if ((segcount == data->rootbone) || (segcount > 255)) break; /* 255 is weak */ - - parchan = parchan->parent; - } - - OperationKey flush_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_DONE); - add_relation(solver_key, flush_key, DEPSREL_TYPE_OPERATION, "PoseEval Result-Bone Link"); -} - -/* Spline IK Eval Steps */ -void DepsgraphRelationBuilder::build_splineik_pose(Object *ob, - bPoseChannel *pchan, - bConstraint *con, - RootPChanMap *root_map) -{ - bSplineIKConstraint *data = (bSplineIKConstraint *)con->data; - bPoseChannel *rootchan = BKE_armature_splineik_solver_find_root(pchan, data); - OperationKey transforms_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_READY); - OperationKey solver_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, rootchan->name, DEG_OPCODE_POSE_SPLINE_IK_SOLVER); - - /* attach owner to IK Solver too - * - assume that owner is always part of chain - * - see notes on direction of rel below... - */ - add_relation(transforms_key, solver_key, DEPSREL_TYPE_TRANSFORM, "Spline IK Solver Owner"); - - /* attach path dependency to solver */ - if (data->tar) { - /* TODO(sergey): For until we'll store partial matricies in the depsgraph, - * we create dependency between target object and pose eval component. - * See IK pose for a bit more information. - */ - // TODO: the bigggest point here is that we need the curve PATH and not just the general geometry... - ComponentKey target_key(&data->tar->id, DEPSNODE_TYPE_GEOMETRY); - ComponentKey pose_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE); - add_relation(target_key, pose_key, DEPSREL_TYPE_TRANSFORM, "[Curve.Path -> Spline IK] DepsRel"); - } - - pchan->flag |= POSE_DONE; - OperationKey final_transforms_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_DONE); - add_relation(solver_key, final_transforms_key, DEPSREL_TYPE_TRANSFORM, "Spline IK Result"); - - root_map->add_bone(pchan->name, rootchan->name); - - /* Walk to the chain's root */ - //size_t segcount = 0; - int segcount = 0; - - for (bPoseChannel *parchan = pchan->parent; parchan; parchan = parchan->parent) { - /* Make Spline IK solver dependent on this bone's result, - * since it can only run after the standard results - * of the bone are know. Validate links step on the - * bone will ensure that users of this bone only - * grab the result with IK solver results... - */ - if (parchan != pchan) { - OperationKey parent_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_READY); - add_relation(parent_key, solver_key, DEPSREL_TYPE_TRANSFORM, "Spline IK Solver Update"); - - OperationKey done_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_DONE); - add_relation(solver_key, done_key, DEPSREL_TYPE_TRANSFORM, "IK Chain Result"); - } - parchan->flag |= POSE_DONE; - - OperationKey final_transforms_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_DONE); - add_relation(solver_key, final_transforms_key, DEPSREL_TYPE_TRANSFORM, "Spline IK Solver Result"); - - root_map->add_bone(parchan->name, rootchan->name); - - /* continue up chain, until we reach target number of items... */ - segcount++; - if ((segcount == data->chainlen) || (segcount > 255)) break; /* 255 is weak */ - } - - OperationKey flush_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_DONE); - add_relation(solver_key, flush_key, DEPSREL_TYPE_OPERATION, "PoseEval Result-Bone Link"); -} - -/* Pose/Armature Bones Graph */ -void DepsgraphRelationBuilder::build_rig(Scene *scene, Object *ob) -{ - /* Armature-Data */ - bArmature *arm = (bArmature *)ob->data; - - // TODO: selection status? - - /* attach links between pose operations */ - OperationKey init_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_INIT); - OperationKey flush_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_DONE); - - add_relation(init_key, flush_key, DEPSREL_TYPE_COMPONENT_ORDER, "[Pose Init -> Pose Cleanup]"); - - /* Make sure pose is up-to-date with armature updates. */ - OperationKey armature_key(&arm->id, - DEPSNODE_TYPE_PARAMETERS, - DEG_OPCODE_PLACEHOLDER, - "Armature Eval"); - add_relation(armature_key, init_key, DEPSREL_TYPE_COMPONENT_ORDER, "Data dependency"); - - if (needs_animdata_node(&ob->id)) { - ComponentKey animation_key(&ob->id, DEPSNODE_TYPE_ANIMATION); - add_relation(animation_key, init_key, DEPSREL_TYPE_OPERATION, "Rig Animation"); - } - - /* IK Solvers... - * - These require separate processing steps are pose-level - * to be executed between chains of bones (i.e. once the - * base transforms of a bunch of bones is done) - * - * - We build relations for these before the dependencies - * between ops in the same component as it is necessary - * to check whether such bones are in the same IK chain - * (or else we get weird issues with either in-chain - * references, or with bones being parented to IK'd bones) - * - * Unsolved Issues: - * - Care is needed to ensure that multi-headed trees work out the same as in ik-tree building - * - Animated chain-lengths are a problem... - */ - RootPChanMap root_map; - bool pose_depends_on_local_transform = false; - for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = pchan->next) { - for (bConstraint *con = (bConstraint *)pchan->constraints.first; con; con = con->next) { - switch (con->type) { - case CONSTRAINT_TYPE_KINEMATIC: - build_ik_pose(ob, pchan, con, &root_map); - pose_depends_on_local_transform = true; - break; - - case CONSTRAINT_TYPE_SPLINEIK: - build_splineik_pose(ob, pchan, con, &root_map); - pose_depends_on_local_transform = true; - break; - - /* Constraints which needs world's matrix for transform. - * TODO(sergey): More constraints here? - */ - case CONSTRAINT_TYPE_ROTLIKE: - case CONSTRAINT_TYPE_SIZELIKE: - case CONSTRAINT_TYPE_LOCLIKE: - case CONSTRAINT_TYPE_TRANSLIKE: - /* TODO(sergey): Add used space check. */ - pose_depends_on_local_transform = true; - break; - - default: - break; - } - } - } - //root_map.print_debug(); - - if (pose_depends_on_local_transform) { - /* TODO(sergey): Once partial updates are possible use relation between - * object transform and solver itself in it's build function. - */ - ComponentKey pose_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE); - ComponentKey local_transform_key(&ob->id, DEPSNODE_TYPE_TRANSFORM); - add_relation(local_transform_key, pose_key, DEPSREL_TYPE_TRANSFORM, "Local Transforms"); - } - - - /* links between operations for each bone */ - for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = pchan->next) { - OperationKey bone_local_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_LOCAL); - OperationKey bone_pose_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_POSE_PARENT); - OperationKey bone_ready_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_READY); - OperationKey bone_done_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_DONE); - - pchan->flag &= ~POSE_DONE; - - /* pose init to bone local */ - add_relation(init_key, bone_local_key, DEPSREL_TYPE_OPERATION, "PoseEval Source-Bone Link"); - - /* local to pose parenting operation */ - add_relation(bone_local_key, bone_pose_key, DEPSREL_TYPE_OPERATION, "Bone Local - PoseSpace Link"); - - /* parent relation */ - if (pchan->parent != NULL) { - eDepsOperation_Code parent_key_opcode; - - /* NOTE: this difference in handling allows us to prevent lockups while ensuring correct poses for separate chains */ - if (root_map.has_common_root(pchan->name, pchan->parent->name)) { - parent_key_opcode = DEG_OPCODE_BONE_READY; - } - else { - parent_key_opcode = DEG_OPCODE_BONE_DONE; - } - - OperationKey parent_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->parent->name, parent_key_opcode); - add_relation(parent_key, bone_pose_key, DEPSREL_TYPE_TRANSFORM, "[Parent Bone -> Child Bone]"); - } - - /* constraints */ - if (pchan->constraints.first != NULL) { - /* constraints stack and constraint dependencies */ - build_constraints(scene, &ob->id, DEPSNODE_TYPE_BONE, pchan->name, &pchan->constraints, &root_map); - - /* pose -> constraints */ - OperationKey constraints_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_CONSTRAINTS); - add_relation(bone_pose_key, constraints_key, DEPSREL_TYPE_OPERATION, "Constraints Stack"); - - /* constraints -> ready */ - // TODO: when constraint stack is exploded, this step should occur before the first IK solver - add_relation(constraints_key, bone_ready_key, DEPSREL_TYPE_OPERATION, "Constraints -> Ready"); - } - else { - /* pose -> ready */ - add_relation(bone_pose_key, bone_ready_key, DEPSREL_TYPE_OPERATION, "Pose -> Ready"); - } - - /* bone ready -> done - * NOTE: For bones without IK, this is all that's needed. - * For IK chains however, an additional rel is created from IK to done, - * with transitive reduction removing this one... - */ - add_relation(bone_ready_key, bone_done_key, DEPSREL_TYPE_OPERATION, "Ready -> Done"); - - /* assume that all bones must be done for the pose to be ready (for deformers) */ - add_relation(bone_done_key, flush_key, DEPSREL_TYPE_OPERATION, "PoseEval Result-Bone Link"); - } -} - -void DepsgraphRelationBuilder::build_proxy_rig(Object *ob) -{ - OperationKey pose_init_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_INIT); - OperationKey pose_done_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_DONE); - for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; - pchan != NULL; - pchan = pchan->next) - { - OperationKey bone_local_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_LOCAL); - OperationKey bone_ready_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_READY); - OperationKey bone_done_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_DONE); - add_relation(pose_init_key, bone_local_key, DEPSREL_TYPE_OPERATION, "Pose Init -> Bone Local"); - add_relation(bone_local_key, bone_ready_key, DEPSREL_TYPE_OPERATION, "Local -> Ready"); - add_relation(bone_ready_key, bone_done_key, DEPSREL_TYPE_OPERATION, "Ready -> Done"); - add_relation(bone_done_key, pose_done_key, DEPSREL_TYPE_OPERATION, "Bone Done -> Pose Done"); - } -} - /* Shapekeys */ void DepsgraphRelationBuilder::build_shapekeys(ID *obdata, Key *key) { diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc new file mode 100644 index 00000000000..3edb2b7acb7 --- /dev/null +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc @@ -0,0 +1,458 @@ +/* + * ***** 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) 2013 Blender Foundation. + * All rights reserved. + * + * Original Author: Joshua Leung + * Contributor(s): Based on original depsgraph.c code - Blender Foundation (2005-2013) + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/depsgraph/intern/builder/deg_builder_relations.cc + * \ingroup depsgraph + * + * Methods for constructing depsgraph + */ + +#include "intern/builder/deg_builder_relations.h" + +#include +#include +#include /* required for STREQ later on. */ + +#include "MEM_guardedalloc.h" + +extern "C" { +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" + +#include "DNA_action_types.h" +#include "DNA_anim_types.h" +#include "DNA_armature_types.h" +#include "DNA_constraint_types.h" +#include "DNA_customdata_types.h" +#include "DNA_object_types.h" + +#include "BKE_action.h" +#include "BKE_armature.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" +} /* extern "C" */ + +#include "intern/builder/deg_builder.h" +#include "intern/builder/deg_builder_pchanmap.h" + +#include "intern/nodes/deg_node.h" +#include "intern/nodes/deg_node_component.h" +#include "intern/nodes/deg_node_operation.h" + +#include "intern/depsgraph_intern.h" +#include "intern/depsgraph_types.h" + +#include "util/deg_util_foreach.h" + +namespace DEG { + +/* IK Solver Eval Steps */ +void DepsgraphRelationBuilder::build_ik_pose(Object *ob, + bPoseChannel *pchan, + bConstraint *con, + RootPChanMap *root_map) +{ + bKinematicConstraint *data = (bKinematicConstraint *)con->data; + + /* attach owner to IK Solver too + * - assume that owner is always part of chain + * - see notes on direction of rel below... + */ + bPoseChannel *rootchan = BKE_armature_ik_solver_find_root(pchan, data); + OperationKey solver_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, rootchan->name, DEG_OPCODE_POSE_IK_SOLVER); + + /* IK target */ + // XXX: this should get handled as part of the constraint code + if (data->tar != NULL) { + /* TODO(sergey): For until we'll store partial matricies in the depsgraph, + * we create dependency between target object and pose eval component. + * + * This way we ensuring the whole subtree is updated from scratch without + * need of intermediate matricies. This is an overkill, but good enough for + * testing IK solver. + */ + // FIXME: geometry targets... + ComponentKey pose_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE); + if ((data->tar->type == OB_ARMATURE) && (data->subtarget[0])) { + /* TODO(sergey): This is only for until granular update stores intermediate result. */ + if (data->tar != ob) { + /* different armature - can just read the results */ + ComponentKey target_key(&data->tar->id, DEPSNODE_TYPE_BONE, data->subtarget); + add_relation(target_key, pose_key, DEPSREL_TYPE_TRANSFORM, con->name); + } + else { + /* same armature - we'll use the ready state only, just in case this bone is in the chain we're solving */ + OperationKey target_key(&data->tar->id, DEPSNODE_TYPE_BONE, data->subtarget, DEG_OPCODE_BONE_DONE); + add_relation(target_key, solver_key, DEPSREL_TYPE_TRANSFORM, con->name); + } + } + else if (ELEM(data->tar->type, OB_MESH, OB_LATTICE) && (data->subtarget[0])) { + /* vertex group target */ + /* NOTE: for now, we don't need to represent vertex groups separately... */ + ComponentKey target_key(&data->tar->id, DEPSNODE_TYPE_GEOMETRY); + add_relation(target_key, solver_key, DEPSREL_TYPE_GEOMETRY_EVAL, con->name); + + if (data->tar->type == OB_MESH) { + OperationDepsNode *node2 = find_operation_node(target_key); + if (node2 != NULL) { + node2->customdata_mask |= CD_MASK_MDEFORMVERT; + } + } + } + else { + /* Standard Object Target */ + ComponentKey target_key(&data->tar->id, DEPSNODE_TYPE_TRANSFORM); + add_relation(target_key, pose_key, DEPSREL_TYPE_TRANSFORM, con->name); + } + + if ((data->tar == ob) && (data->subtarget[0])) { + /* Prevent target's constraints from linking to anything from same + * chain that it controls. + */ + root_map->add_bone(data->subtarget, rootchan->name); + } + } + + /* Pole Target */ + // XXX: this should get handled as part of the constraint code + if (data->poletar != NULL) { + if ((data->poletar->type == OB_ARMATURE) && (data->polesubtarget[0])) { + // XXX: same armature issues - ready vs done? + ComponentKey target_key(&data->poletar->id, DEPSNODE_TYPE_BONE, data->polesubtarget); + add_relation(target_key, solver_key, DEPSREL_TYPE_TRANSFORM, con->name); + } + else if (ELEM(data->poletar->type, OB_MESH, OB_LATTICE) && (data->polesubtarget[0])) { + /* vertex group target */ + /* NOTE: for now, we don't need to represent vertex groups separately... */ + ComponentKey target_key(&data->poletar->id, DEPSNODE_TYPE_GEOMETRY); + add_relation(target_key, solver_key, DEPSREL_TYPE_GEOMETRY_EVAL, con->name); + + if (data->poletar->type == OB_MESH) { + OperationDepsNode *node2 = find_operation_node(target_key); + if (node2 != NULL) { + node2->customdata_mask |= CD_MASK_MDEFORMVERT; + } + } + } + else { + ComponentKey target_key(&data->poletar->id, DEPSNODE_TYPE_TRANSFORM); + add_relation(target_key, solver_key, DEPSREL_TYPE_TRANSFORM, con->name); + } + } + + DEG_DEBUG_PRINTF("\nStarting IK Build: pchan = %s, target = (%s, %s), segcount = %d\n", + pchan->name, data->tar->id.name, data->subtarget, data->rootbone); + + bPoseChannel *parchan = pchan; + /* exclude tip from chain? */ + if (!(data->flag & CONSTRAINT_IK_TIP)) { + OperationKey tip_transforms_key(&ob->id, DEPSNODE_TYPE_BONE, + parchan->name, DEG_OPCODE_BONE_LOCAL); + add_relation(solver_key, tip_transforms_key, + DEPSREL_TYPE_TRANSFORM, "IK Solver Result"); + parchan = pchan->parent; + } + + root_map->add_bone(parchan->name, rootchan->name); + + OperationKey parchan_transforms_key(&ob->id, DEPSNODE_TYPE_BONE, + parchan->name, DEG_OPCODE_BONE_READY); + add_relation(parchan_transforms_key, solver_key, + DEPSREL_TYPE_TRANSFORM, "IK Solver Owner"); + + /* Walk to the chain's root */ + //size_t segcount = 0; + int segcount = 0; + + while (parchan) { + /* Make IK-solver dependent on this bone's result, + * since it can only run after the standard results + * of the bone are know. Validate links step on the + * bone will ensure that users of this bone only + * grab the result with IK solver results... + */ + if (parchan != pchan) { + OperationKey parent_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_READY); + add_relation(parent_key, solver_key, DEPSREL_TYPE_TRANSFORM, "IK Chain Parent"); + + OperationKey done_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_DONE); + add_relation(solver_key, done_key, DEPSREL_TYPE_TRANSFORM, "IK Chain Result"); + } + else { + OperationKey final_transforms_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_DONE); + add_relation(solver_key, final_transforms_key, DEPSREL_TYPE_TRANSFORM, "IK Solver Result"); + } + parchan->flag |= POSE_DONE; + + + root_map->add_bone(parchan->name, rootchan->name); + + /* continue up chain, until we reach target number of items... */ + DEG_DEBUG_PRINTF(" %d = %s\n", segcount, parchan->name); + segcount++; + if ((segcount == data->rootbone) || (segcount > 255)) break; /* 255 is weak */ + + parchan = parchan->parent; + } + + OperationKey flush_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_DONE); + add_relation(solver_key, flush_key, DEPSREL_TYPE_OPERATION, "PoseEval Result-Bone Link"); +} + +/* Spline IK Eval Steps */ +void DepsgraphRelationBuilder::build_splineik_pose(Object *ob, + bPoseChannel *pchan, + bConstraint *con, + RootPChanMap *root_map) +{ + bSplineIKConstraint *data = (bSplineIKConstraint *)con->data; + bPoseChannel *rootchan = BKE_armature_splineik_solver_find_root(pchan, data); + OperationKey transforms_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_READY); + OperationKey solver_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, rootchan->name, DEG_OPCODE_POSE_SPLINE_IK_SOLVER); + + /* attach owner to IK Solver too + * - assume that owner is always part of chain + * - see notes on direction of rel below... + */ + add_relation(transforms_key, solver_key, DEPSREL_TYPE_TRANSFORM, "Spline IK Solver Owner"); + + /* attach path dependency to solver */ + if (data->tar) { + /* TODO(sergey): For until we'll store partial matricies in the depsgraph, + * we create dependency between target object and pose eval component. + * See IK pose for a bit more information. + */ + // TODO: the bigggest point here is that we need the curve PATH and not just the general geometry... + ComponentKey target_key(&data->tar->id, DEPSNODE_TYPE_GEOMETRY); + ComponentKey pose_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE); + add_relation(target_key, pose_key, DEPSREL_TYPE_TRANSFORM, "[Curve.Path -> Spline IK] DepsRel"); + } + + pchan->flag |= POSE_DONE; + OperationKey final_transforms_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_DONE); + add_relation(solver_key, final_transforms_key, DEPSREL_TYPE_TRANSFORM, "Spline IK Result"); + + root_map->add_bone(pchan->name, rootchan->name); + + /* Walk to the chain's root */ + //size_t segcount = 0; + int segcount = 0; + + for (bPoseChannel *parchan = pchan->parent; parchan; parchan = parchan->parent) { + /* Make Spline IK solver dependent on this bone's result, + * since it can only run after the standard results + * of the bone are know. Validate links step on the + * bone will ensure that users of this bone only + * grab the result with IK solver results... + */ + if (parchan != pchan) { + OperationKey parent_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_READY); + add_relation(parent_key, solver_key, DEPSREL_TYPE_TRANSFORM, "Spline IK Solver Update"); + + OperationKey done_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_DONE); + add_relation(solver_key, done_key, DEPSREL_TYPE_TRANSFORM, "IK Chain Result"); + } + parchan->flag |= POSE_DONE; + + OperationKey final_transforms_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_DONE); + add_relation(solver_key, final_transforms_key, DEPSREL_TYPE_TRANSFORM, "Spline IK Solver Result"); + + root_map->add_bone(parchan->name, rootchan->name); + + /* continue up chain, until we reach target number of items... */ + segcount++; + if ((segcount == data->chainlen) || (segcount > 255)) break; /* 255 is weak */ + } + + OperationKey flush_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_DONE); + add_relation(solver_key, flush_key, DEPSREL_TYPE_OPERATION, "PoseEval Result-Bone Link"); +} + +/* Pose/Armature Bones Graph */ +void DepsgraphRelationBuilder::build_rig(Scene *scene, Object *ob) +{ + /* Armature-Data */ + bArmature *arm = (bArmature *)ob->data; + + // TODO: selection status? + + /* attach links between pose operations */ + OperationKey init_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_INIT); + OperationKey flush_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_DONE); + + add_relation(init_key, flush_key, DEPSREL_TYPE_COMPONENT_ORDER, "[Pose Init -> Pose Cleanup]"); + + /* Make sure pose is up-to-date with armature updates. */ + OperationKey armature_key(&arm->id, + DEPSNODE_TYPE_PARAMETERS, + DEG_OPCODE_PLACEHOLDER, + "Armature Eval"); + add_relation(armature_key, init_key, DEPSREL_TYPE_COMPONENT_ORDER, "Data dependency"); + + if (needs_animdata_node(&ob->id)) { + ComponentKey animation_key(&ob->id, DEPSNODE_TYPE_ANIMATION); + add_relation(animation_key, init_key, DEPSREL_TYPE_OPERATION, "Rig Animation"); + } + + /* IK Solvers... + * - These require separate processing steps are pose-level + * to be executed between chains of bones (i.e. once the + * base transforms of a bunch of bones is done) + * + * - We build relations for these before the dependencies + * between ops in the same component as it is necessary + * to check whether such bones are in the same IK chain + * (or else we get weird issues with either in-chain + * references, or with bones being parented to IK'd bones) + * + * Unsolved Issues: + * - Care is needed to ensure that multi-headed trees work out the same as in ik-tree building + * - Animated chain-lengths are a problem... + */ + RootPChanMap root_map; + bool pose_depends_on_local_transform = false; + for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (bConstraint *con = (bConstraint *)pchan->constraints.first; con; con = con->next) { + switch (con->type) { + case CONSTRAINT_TYPE_KINEMATIC: + build_ik_pose(ob, pchan, con, &root_map); + pose_depends_on_local_transform = true; + break; + + case CONSTRAINT_TYPE_SPLINEIK: + build_splineik_pose(ob, pchan, con, &root_map); + pose_depends_on_local_transform = true; + break; + + /* Constraints which needs world's matrix for transform. + * TODO(sergey): More constraints here? + */ + case CONSTRAINT_TYPE_ROTLIKE: + case CONSTRAINT_TYPE_SIZELIKE: + case CONSTRAINT_TYPE_LOCLIKE: + case CONSTRAINT_TYPE_TRANSLIKE: + /* TODO(sergey): Add used space check. */ + pose_depends_on_local_transform = true; + break; + + default: + break; + } + } + } + //root_map.print_debug(); + + if (pose_depends_on_local_transform) { + /* TODO(sergey): Once partial updates are possible use relation between + * object transform and solver itself in it's build function. + */ + ComponentKey pose_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE); + ComponentKey local_transform_key(&ob->id, DEPSNODE_TYPE_TRANSFORM); + add_relation(local_transform_key, pose_key, DEPSREL_TYPE_TRANSFORM, "Local Transforms"); + } + + + /* links between operations for each bone */ + for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = pchan->next) { + OperationKey bone_local_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_LOCAL); + OperationKey bone_pose_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_POSE_PARENT); + OperationKey bone_ready_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_READY); + OperationKey bone_done_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_DONE); + + pchan->flag &= ~POSE_DONE; + + /* pose init to bone local */ + add_relation(init_key, bone_local_key, DEPSREL_TYPE_OPERATION, "PoseEval Source-Bone Link"); + + /* local to pose parenting operation */ + add_relation(bone_local_key, bone_pose_key, DEPSREL_TYPE_OPERATION, "Bone Local - PoseSpace Link"); + + /* parent relation */ + if (pchan->parent != NULL) { + eDepsOperation_Code parent_key_opcode; + + /* NOTE: this difference in handling allows us to prevent lockups while ensuring correct poses for separate chains */ + if (root_map.has_common_root(pchan->name, pchan->parent->name)) { + parent_key_opcode = DEG_OPCODE_BONE_READY; + } + else { + parent_key_opcode = DEG_OPCODE_BONE_DONE; + } + + OperationKey parent_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->parent->name, parent_key_opcode); + add_relation(parent_key, bone_pose_key, DEPSREL_TYPE_TRANSFORM, "[Parent Bone -> Child Bone]"); + } + + /* constraints */ + if (pchan->constraints.first != NULL) { + /* constraints stack and constraint dependencies */ + build_constraints(scene, &ob->id, DEPSNODE_TYPE_BONE, pchan->name, &pchan->constraints, &root_map); + + /* pose -> constraints */ + OperationKey constraints_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_CONSTRAINTS); + add_relation(bone_pose_key, constraints_key, DEPSREL_TYPE_OPERATION, "Constraints Stack"); + + /* constraints -> ready */ + // TODO: when constraint stack is exploded, this step should occur before the first IK solver + add_relation(constraints_key, bone_ready_key, DEPSREL_TYPE_OPERATION, "Constraints -> Ready"); + } + else { + /* pose -> ready */ + add_relation(bone_pose_key, bone_ready_key, DEPSREL_TYPE_OPERATION, "Pose -> Ready"); + } + + /* bone ready -> done + * NOTE: For bones without IK, this is all that's needed. + * For IK chains however, an additional rel is created from IK to done, + * with transitive reduction removing this one... + */ + add_relation(bone_ready_key, bone_done_key, DEPSREL_TYPE_OPERATION, "Ready -> Done"); + + /* assume that all bones must be done for the pose to be ready (for deformers) */ + add_relation(bone_done_key, flush_key, DEPSREL_TYPE_OPERATION, "PoseEval Result-Bone Link"); + } +} + +void DepsgraphRelationBuilder::build_proxy_rig(Object *ob) +{ + OperationKey pose_init_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_INIT); + OperationKey pose_done_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_DONE); + for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; + pchan != NULL; + pchan = pchan->next) + { + OperationKey bone_local_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_LOCAL); + OperationKey bone_ready_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_READY); + OperationKey bone_done_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_DONE); + add_relation(pose_init_key, bone_local_key, DEPSREL_TYPE_OPERATION, "Pose Init -> Bone Local"); + add_relation(bone_local_key, bone_ready_key, DEPSREL_TYPE_OPERATION, "Local -> Ready"); + add_relation(bone_ready_key, bone_done_key, DEPSREL_TYPE_OPERATION, "Ready -> Done"); + add_relation(bone_done_key, pose_done_key, DEPSREL_TYPE_OPERATION, "Bone Done -> Pose Done"); + } +} + +} // namespace DEG -- cgit v1.2.3 From 0a08d8c892d595eab9aaec46739ef697bcee5cef Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 17 Nov 2016 15:11:55 +0100 Subject: Depsgraph: Use utility macro to iterate over linked list This will be compiled into same exact code, just saves us from doing annoying type casts all over the place. --- .../depsgraph/intern/builder/deg_builder_nodes.cc | 73 +++++++++------------- .../intern/builder/deg_builder_nodes_rig.cc | 10 ++- .../intern/builder/deg_builder_relations.cc | 51 +++++++-------- .../intern/builder/deg_builder_relations_rig.cc | 11 ++-- source/blender/depsgraph/util/deg_util_foreach.h | 5 ++ 5 files changed, 65 insertions(+), 85 deletions(-) diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 1eaacea69eb..89b9fc98e33 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -105,6 +105,7 @@ extern "C" { #include "intern/nodes/deg_node_operation.h" #include "intern/depsgraph_types.h" #include "intern/depsgraph_intern.h" +#include "util/deg_util_foreach.h" namespace DEG { @@ -347,7 +348,7 @@ void DepsgraphNodeBuilder::build_scene(Main *bmain, Scene *scene) } /* scene objects */ - for (Base *base = (Base *)scene->base.first; base; base = base->next) { + LINKLIST_FOREACH (Base *, base, &scene->base) { Object *ob = base->object; /* object itself */ @@ -395,10 +396,7 @@ void DepsgraphNodeBuilder::build_scene(Main *bmain, Scene *scene) } /* cache files */ - for (CacheFile *cachefile = static_cast(bmain->cachefiles.first); - cachefile; - cachefile = static_cast(cachefile->id.next)) - { + LINKLIST_FOREACH (CacheFile *, cachefile, &bmain->cachefiles) { build_cachefile(cachefile); } } @@ -413,10 +411,7 @@ void DepsgraphNodeBuilder::build_group(Scene *scene, } group_id->tag |= LIB_TAG_DOIT; - for (GroupObject *go = (GroupObject *)group->gobject.first; - go != NULL; - go = go->next) - { + LINKLIST_FOREACH (GroupObject *, go, &group->gobject) { build_object(scene, base, go->ob); } } @@ -433,10 +428,7 @@ SubgraphDepsNode *DepsgraphNodeBuilder::build_subgraph(Group *group) DepsgraphNodeBuilder subgraph_builder(m_bmain, subgraph); /* add group objects */ - for (GroupObject *go = (GroupObject *)group->gobject.first; - go != NULL; - go = go->next) - { + LINKLIST_FOREACH (GroupObject *, go, &group->gobject) { /*Object *ob = go->ob;*/ /* Each "group object" is effectively a separate instance of the @@ -653,7 +645,7 @@ void DepsgraphNodeBuilder::build_animdata(ID *id) } /* drivers */ - for (FCurve *fcu = (FCurve *)adt->drivers.first; fcu; fcu = fcu->next) { + LINKLIST_FOREACH (FCurve *, fcu, &adt->drivers) { /* create driver */ build_driver(id, fcu); } @@ -766,7 +758,7 @@ void DepsgraphNodeBuilder::build_rigidbody(Scene *scene) /* objects - simulation participants */ if (rbw->group) { - for (GroupObject *go = (GroupObject *)rbw->group->gobject.first; go; go = go->next) { + LINKLIST_FOREACH (GroupObject *, go, &rbw->group->gobject) { Object *ob = go->ob; if (!ob || (ob->type != OB_MESH)) @@ -802,7 +794,7 @@ void DepsgraphNodeBuilder::build_particles(Scene *scene, Object *ob) ComponentDepsNode *psys_comp = add_component_node(&ob->id, DEPSNODE_TYPE_EVAL_PARTICLES); /* particle systems */ - for (ParticleSystem *psys = (ParticleSystem *)ob->particlesystem.first; psys; psys = psys->next) { + LINKLIST_FOREACH (ParticleSystem *, psys, &ob->particlesystem) { ParticleSettings *part = psys->part; /* particle settings */ @@ -812,7 +804,11 @@ void DepsgraphNodeBuilder::build_particles(Scene *scene, Object *ob) /* this particle system */ // TODO: for now, this will just be a placeholder "ubereval" node add_operation_node(psys_comp, - DEPSOP_TYPE_EXEC, function_bind(BKE_particle_system_eval, _1, scene, ob, psys), + DEPSOP_TYPE_EXEC, function_bind(BKE_particle_system_eval, + _1, + scene, + ob, + psys), DEG_OPCODE_PSYS_EVAL, psys->name); } @@ -871,33 +867,26 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob) // TODO: "Done" operation /* Modifiers */ - if (ob->modifiers.first) { - for (ModifierData *md = (ModifierData *)ob->modifiers.first; - md != NULL; - md = md->next) - { - add_operation_node(&ob->id, - DEPSNODE_TYPE_GEOMETRY, - DEPSOP_TYPE_EXEC, - function_bind(BKE_object_eval_modifier, - _1, - scene, - ob, - md), - DEG_OPCODE_GEOMETRY_MODIFIER, - md->name); - } + LINKLIST_FOREACH (ModifierData *, md, &ob->modifiers) { + add_operation_node(&ob->id, + DEPSNODE_TYPE_GEOMETRY, + DEPSOP_TYPE_EXEC, + function_bind(BKE_object_eval_modifier, + _1, + scene, + ob, + md), + DEG_OPCODE_GEOMETRY_MODIFIER, + md->name); } /* materials */ - if (ob->totcol) { - for (int a = 1; a <= ob->totcol; a++) { - Material *ma = give_current_material(ob, a); - if (ma != NULL) { - // XXX?! - ComponentDepsNode *geom_node = add_component_node(&ob->id, DEPSNODE_TYPE_GEOMETRY); - build_material(geom_node, ma); - } + for (int a = 1; a <= ob->totcol; a++) { + Material *ma = give_current_material(ob, a); + if (ma != NULL) { + // XXX?! + ComponentDepsNode *geom_node = add_component_node(&ob->id, DEPSNODE_TYPE_GEOMETRY); + build_material(geom_node, ma); } } @@ -1091,7 +1080,7 @@ void DepsgraphNodeBuilder::build_nodetree(DepsNode *owner_node, bNodeTree *ntree DEG_OPCODE_PLACEHOLDER, "Parameters Eval"); /* nodetree's nodes... */ - for (bNode *bnode = (bNode *)ntree->nodes.first; bnode; bnode = bnode->next) { + LINKLIST_FOREACH (bNode *, bnode, &ntree->nodes) { ID *id = bnode->id; if (id != NULL) { short id_type = GS(id->name); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc index b9c7c3c7f92..8ba41a4b4b1 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc @@ -60,6 +60,7 @@ extern "C" { #include "intern/nodes/deg_node_operation.h" #include "intern/depsgraph_types.h" #include "intern/depsgraph_intern.h" +#include "util/deg_util_foreach.h" namespace DEG { @@ -178,7 +179,7 @@ void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *ob) DEPSOP_TYPE_POST, function_bind(BKE_pose_eval_flush, _1, scene, ob, ob->pose), DEG_OPCODE_POSE_DONE); /* bones */ - for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = pchan->next) { + LINKLIST_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { /* node for bone eval */ add_operation_node(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEPSOP_TYPE_INIT, NULL, // XXX: BKE_pose_eval_bone_local @@ -212,7 +213,7 @@ void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *ob) * - Care is needed to ensure that multi-headed trees work out the same as in ik-tree building * - Animated chain-lengths are a problem... */ - for (bConstraint *con = (bConstraint *)pchan->constraints.first; con; con = con->next) { + LINKLIST_FOREACH (bConstraint *, con, &pchan->constraints) { switch (con->type) { case CONSTRAINT_TYPE_KINEMATIC: build_ik_pose(scene, ob, pchan, con); @@ -248,10 +249,7 @@ void DepsgraphNodeBuilder::build_proxy_rig(Object *ob) function_bind(BKE_pose_eval_proxy_copy, _1, ob), DEG_OPCODE_POSE_INIT); - for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; - pchan != NULL; - pchan = pchan->next) - { + LINKLIST_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { add_operation_node(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEPSOP_TYPE_INIT, NULL, DEG_OPCODE_BONE_LOCAL); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 1497a16e47f..d8477358dad 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -356,7 +356,7 @@ void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene) } /* scene objects */ - for (Base *base = (Base *)scene->base.first; base; base = base->next) { + LINKLIST_FOREACH (Base *, base, &scene->base) { Object *ob = base->object; /* object itself */ @@ -429,10 +429,7 @@ void DepsgraphRelationBuilder::build_group(Main *bmain, OperationKey object_local_transform_key(&object->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_LOCAL); - for (GroupObject *go = (GroupObject *)group->gobject.first; - go != NULL; - go = go->next) - { + LINKLIST_FOREACH (GroupObject *, go, &group->gobject) { if (!group_done) { build_object(bmain, scene, go->ob); } @@ -709,9 +706,10 @@ void DepsgraphRelationBuilder::build_constraints(Scene *scene, ID *id, eDepsNode ListBase targets = {NULL, NULL}; cti->get_constraint_targets(con, &targets); - for (bConstraintTarget *ct = (bConstraintTarget *)targets.first; ct; ct = ct->next) { - if (!ct->tar) + LINKLIST_FOREACH (bConstraintTarget *, ct, &targets) { + if (ct->tar == NULL) { continue; + } if (ELEM(con->type, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_SPLINEIK)) { /* ignore IK constraints - these are handled separately (on pose level) */ @@ -838,7 +836,7 @@ void DepsgraphRelationBuilder::build_animdata(ID *id) } /* drivers */ - for (FCurve *fcu = (FCurve *)adt->drivers.first; fcu; fcu = fcu->next) { + LINKLIST_FOREACH (FCurve *, fcu, &adt->drivers) { OperationKey driver_key(id, DEPSNODE_TYPE_PARAMETERS, DEG_OPCODE_DRIVER, @@ -862,10 +860,7 @@ void DepsgraphRelationBuilder::build_animdata(ID *id) */ if (fcu->array_index > 0) { FCurve *fcu_prev = NULL; - for (FCurve *fcu_candidate = (FCurve *)adt->drivers.first; - fcu_candidate != NULL; - fcu_candidate = fcu_candidate->next) - { + LINKLIST_FOREACH (FCurve *, fcu_candidate, &adt->drivers) { /* Writing to different RNA paths is */ if (!STREQ(fcu_candidate->rna_path, fcu->rna_path)) { continue; @@ -1029,7 +1024,7 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu) // XXX: the data itself could also set this, if it were to be truly initialised later? /* loop over variables to get the target relationships */ - for (DriverVar *dvar = (DriverVar *)driver->variables.first; dvar; dvar = dvar->next) { + LINKLIST_FOREACH (DriverVar *, dvar, &driver->variables) { /* only used targets */ DRIVER_TARGETS_USED_LOOPER(dvar) { @@ -1149,10 +1144,11 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene) /* objects - simulation participants */ if (rbw->group) { - for (GroupObject *go = (GroupObject *)rbw->group->gobject.first; go; go = go->next) { + LINKLIST_FOREACH (GroupObject *, go, &rbw->group->gobject) { Object *ob = go->ob; - if (!ob || ob->type != OB_MESH) + if (ob == NULL || ob->type != OB_MESH) { continue; + } /* hook up evaluation order... * 1) flushing rigidbody results follows base transforms being applied @@ -1200,10 +1196,11 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene) /* constraints */ if (rbw->constraints) { - for (GroupObject *go = (GroupObject *)rbw->constraints->gobject.first; go; go = go->next) { + LINKLIST_FOREACH (GroupObject *, go, &rbw->constraints->gobject) { Object *ob = go->ob; - if (!ob || !ob->rigidbody_constraint) + if (ob == NULL || !ob->rigidbody_constraint) { continue; + } RigidBodyCon *rbc = ob->rigidbody_constraint; @@ -1232,7 +1229,7 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob) DEG_OPCODE_GEOMETRY_UBEREVAL); /* particle systems */ - for (ParticleSystem *psys = (ParticleSystem *)ob->particlesystem.first; psys; psys = psys->next) { + LINKLIST_FOREACH (ParticleSystem *, psys, &ob->particlesystem) { ParticleSettings *part = psys->part; /* particle settings */ @@ -1263,9 +1260,7 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob) #if 0 if (ELEM(part->phystype, PART_PHYS_KEYED, PART_PHYS_BOIDS)) { - ParticleTarget *pt; - - for (pt = psys->targets.first; pt; pt = pt->next) { + LINKLIST_FOREACH (ParticleTarget *, pt, &psys->targets) { if (pt->ob && BLI_findlink(&pt->ob->particlesystem, pt->psys - 1)) { node2 = dag_get_node(dag, pt->ob); dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Particle Targets"); @@ -1284,7 +1279,7 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob) } if (part->ren_as == PART_DRAW_GR && part->dup_group) { - for (go = part->dup_group->gobject.first; go; go = go->next) { + LINKLIST_FOREACH (GroupObject *, go, &part->dup_group->gobject) { node2 = dag_get_node(dag, go->ob); dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Particle Group Visualization"); } @@ -1301,11 +1296,8 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob) /* boids */ if (part->boids) { - BoidRule *rule = NULL; - BoidState *state = NULL; - - for (state = (BoidState *)part->boids->states.first; state; state = state->next) { - for (rule = (BoidRule *)state->rules.first; rule; rule = rule->next) { + LINKLIST_FOREACH (BoidState *, state, &part->boids->states) { + LINKLIST_FOREACH (BoidRule *, rule, &state->rules) { Object *ruleob = NULL; if (rule->type == eBoidRuleType_Avoid) ruleob = ((BoidRuleGoalAvoid *)rule)->ob; @@ -1405,10 +1397,9 @@ void DepsgraphRelationBuilder::build_obdata_geom(Main *bmain, Scene *scene, Obje /* Modifiers */ if (ob->modifiers.first) { - ModifierData *md; OperationKey prev_mod_key; - for (md = (ModifierData *)ob->modifiers.first; md; md = md->next) { + LINKLIST_FOREACH (ModifierData *, md, &ob->modifiers) { const ModifierTypeInfo *mti = modifierType_getInfo((ModifierType)md->type); OperationKey mod_key(&ob->id, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_GEOMETRY_MODIFIER, md->name); @@ -1643,7 +1634,7 @@ void DepsgraphRelationBuilder::build_nodetree(ID *owner, bNodeTree *ntree) "Parameters Eval"); /* nodetree's nodes... */ - for (bNode *bnode = (bNode *)ntree->nodes.first; bnode; bnode = bnode->next) { + LINKLIST_FOREACH (bNode *, bnode, &ntree->nodes) { if (bnode->id) { if (GS(bnode->id->name) == ID_MA) { build_material(owner, (Material *)bnode->id); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc index 3edb2b7acb7..0fa7a5b1830 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc @@ -335,8 +335,8 @@ void DepsgraphRelationBuilder::build_rig(Scene *scene, Object *ob) */ RootPChanMap root_map; bool pose_depends_on_local_transform = false; - for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = pchan->next) { - for (bConstraint *con = (bConstraint *)pchan->constraints.first; con; con = con->next) { + LINKLIST_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { + LINKLIST_FOREACH (bConstraint *, con, &pchan->constraints) { switch (con->type) { case CONSTRAINT_TYPE_KINEMATIC: build_ik_pose(ob, pchan, con, &root_map); @@ -377,7 +377,7 @@ void DepsgraphRelationBuilder::build_rig(Scene *scene, Object *ob) /* links between operations for each bone */ - for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = pchan->next) { + LINKLIST_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { OperationKey bone_local_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_LOCAL); OperationKey bone_pose_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_POSE_PARENT); OperationKey bone_ready_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_READY); @@ -441,10 +441,7 @@ void DepsgraphRelationBuilder::build_proxy_rig(Object *ob) { OperationKey pose_init_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_INIT); OperationKey pose_done_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_DONE); - for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; - pchan != NULL; - pchan = pchan->next) - { + LINKLIST_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { OperationKey bone_local_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_LOCAL); OperationKey bone_ready_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_READY); OperationKey bone_done_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_DONE); diff --git a/source/blender/depsgraph/util/deg_util_foreach.h b/source/blender/depsgraph/util/deg_util_foreach.h index 14cf4fc11ed..87d37168d51 100644 --- a/source/blender/depsgraph/util/deg_util_foreach.h +++ b/source/blender/depsgraph/util/deg_util_foreach.h @@ -66,3 +66,8 @@ #define GSET_FOREACH_END() \ } \ } while(0) + +#define LINKLIST_FOREACH(type, var, list) \ + for (type var = (type)((list)->first); \ + var != NULL; \ + var = (type)(((Link*)(var))->next)) -- cgit v1.2.3 From 1f8762bb8e2783ec3943894eaaf2ae8df08c5e02 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 17 Nov 2016 15:29:22 +0100 Subject: Fix T50060: New depsgraph does not update mask animation --- .../depsgraph/intern/builder/deg_builder_nodes.cc | 16 ++++++++++++++-- .../depsgraph/intern/builder/deg_builder_nodes.h | 2 ++ .../depsgraph/intern/builder/deg_builder_relations.cc | 17 +++++++++++++++++ .../depsgraph/intern/builder/deg_builder_relations.h | 4 ++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 89b9fc98e33..011eec9e0c1 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -55,6 +55,7 @@ extern "C" { #include "DNA_key_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" +#include "DNA_mask_types.h" #include "DNA_mesh_types.h" #include "DNA_meta_types.h" #include "DNA_node_types.h" @@ -395,10 +396,15 @@ void DepsgraphNodeBuilder::build_scene(Main *bmain, Scene *scene) build_gpencil(scene->gpd); } - /* cache files */ + /* Cache file. */ LINKLIST_FOREACH (CacheFile *, cachefile, &bmain->cachefiles) { build_cachefile(cachefile); } + + /* Masks. */ + LINKLIST_FOREACH (Mask *, mask, &bmain->mask) { + build_mask(mask); + } } void DepsgraphNodeBuilder::build_group(Scene *scene, @@ -1211,7 +1217,6 @@ void DepsgraphNodeBuilder::build_cachefile(CacheFile *cache_file) ID *cache_file_id = &cache_file->id; add_component_node(cache_file_id, DEPSNODE_TYPE_CACHE); - add_operation_node(cache_file_id, DEPSNODE_TYPE_CACHE, DEPSOP_TYPE_EXEC, NULL, DEG_OPCODE_PLACEHOLDER, "Cache File Update"); @@ -1220,4 +1225,11 @@ void DepsgraphNodeBuilder::build_cachefile(CacheFile *cache_file) build_animdata(cache_file_id); } +void DepsgraphNodeBuilder::build_mask(Mask *mask) +{ + ID *mask_id = &mask->id; + add_id_node(mask_id); + build_animdata(mask_id); +} + } // namespace DEG diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h index 72dc73357bf..0cfddeed6ef 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h @@ -44,6 +44,7 @@ struct Group; struct Key; struct Main; struct Material; +struct Mask; struct MTex; struct bNodeTree; struct Object; @@ -154,6 +155,7 @@ struct DepsgraphNodeBuilder { void build_compositor(Scene *scene); void build_gpencil(bGPdata *gpd); void build_cachefile(CacheFile *cache_file); + void build_mask(Mask *mask); protected: Main *m_bmain; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index d8477358dad..293c14e5dde 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -55,6 +55,7 @@ extern "C" { #include "DNA_key_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" +#include "DNA_mask_types.h" #include "DNA_mesh_types.h" #include "DNA_meta_types.h" #include "DNA_node_types.h" @@ -405,6 +406,11 @@ void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene) build_gpencil(&scene->id, scene->gpd); } + /* Masks. */ + LINKLIST_FOREACH (Mask *, mask, &bmain->mask) { + build_mask(mask); + } + for (Depsgraph::OperationNodes::const_iterator it_op = m_graph->operations.begin(); it_op != m_graph->operations.end(); ++it_op) @@ -1738,4 +1744,15 @@ bool DepsgraphRelationBuilder::needs_animdata_node(ID *id) return false; } +void DepsgraphRelationBuilder::build_cachefile(CacheFile *cache_file) { + /* Animation. */ + build_animdata(&cache_file->id); +} + +void DepsgraphRelationBuilder::build_mask(Mask *mask) +{ + /* Animation. */ + build_animdata(&mask->id); +} + } // namespace DEG diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h index 8d8ad6772b8..1c293aa1508 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h @@ -47,6 +47,7 @@ struct Base; struct bGPdata; +struct CacheFile; struct ListBase; struct GHash; struct ID; @@ -54,6 +55,7 @@ struct FCurve; struct Group; struct Key; struct Main; +struct Mask; struct Material; struct MTex; struct bNodeTree; @@ -220,6 +222,8 @@ struct DepsgraphRelationBuilder void build_texture_stack(ID *owner, MTex **texture_stack); void build_compositor(Scene *scene); void build_gpencil(ID *owner, bGPdata *gpd); + void build_cachefile(CacheFile *cache_file); + void build_mask(Mask *mask); 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); -- cgit v1.2.3 From 4dbd61cc64bfa5a545ce07cd6e06f1cfa2f3bd28 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 17 Nov 2016 15:38:03 +0100 Subject: Depsgraph: Move scene builder function to own file This way it's much easier to grasp what the graph actually contains. --- source/blender/depsgraph/CMakeLists.txt | 2 + .../depsgraph/intern/builder/deg_builder_nodes.cc | 88 ------------ .../intern/builder/deg_builder_nodes_rig.cc | 2 +- .../intern/builder/deg_builder_nodes_scene.cc | 154 ++++++++++++++++++++ .../intern/builder/deg_builder_relations_keys.cc | 2 +- .../intern/builder/deg_builder_relations_rig.cc | 2 +- .../intern/builder/deg_builder_relations_scene.cc | 157 +++++++++++++++++++++ 7 files changed, 316 insertions(+), 91 deletions(-) create mode 100644 source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc create mode 100644 source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt index ea839d11071..e635256cda6 100644 --- a/source/blender/depsgraph/CMakeLists.txt +++ b/source/blender/depsgraph/CMakeLists.txt @@ -44,10 +44,12 @@ set(SRC intern/builder/deg_builder_cycle.cc intern/builder/deg_builder_nodes.cc intern/builder/deg_builder_nodes_rig.cc + intern/builder/deg_builder_nodes_scene.cc intern/builder/deg_builder_pchanmap.cc intern/builder/deg_builder_relations.cc intern/builder/deg_builder_relations_keys.cc intern/builder/deg_builder_relations_rig.cc + intern/builder/deg_builder_relations_scene.cc intern/builder/deg_builder_transitive.cc intern/debug/deg_debug_graphviz.cc intern/eval/deg_eval.cc diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 011eec9e0c1..4e6ab73b353 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -319,94 +319,6 @@ OperationDepsNode *DepsgraphNodeBuilder::find_operation_node( /* **** Build functions for entity nodes **** */ -void DepsgraphNodeBuilder::build_scene(Main *bmain, Scene *scene) -{ - /* LIB_TAG_DOIT is used to indicate whether node for given ID was already - * created or not. This flag is being set in add_id_node(), so functions - * shouldn't bother with setting it, they only might query this flag when - * needed. - */ - BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); - /* XXX nested node trees are not included in tag-clearing above, - * so we need to do this manually. - */ - FOREACH_NODETREE(bmain, nodetree, id) { - if (id != (ID *)nodetree) - nodetree->id.tag &= ~LIB_TAG_DOIT; - } FOREACH_NODETREE_END - - /* scene ID block */ - add_id_node(&scene->id); - - /* timesource */ - add_time_source(NULL); - - /* build subgraph for set, and link this in... */ - // XXX: depending on how this goes, that scene itself could probably store its - // own little partial depsgraph? - if (scene->set) { - build_scene(bmain, scene->set); - } - - /* scene objects */ - LINKLIST_FOREACH (Base *, base, &scene->base) { - Object *ob = base->object; - - /* object itself */ - build_object(scene, base, ob); - - /* object that this is a proxy for */ - // XXX: the way that proxies work needs to be completely reviewed! - if (ob->proxy) { - ob->proxy->proxy_from = ob; - build_object(scene, base, ob->proxy); - } - - /* Object dupligroup. */ - if (ob->dup_group) { - build_group(scene, base, ob->dup_group); - } - } - - /* rigidbody */ - if (scene->rigidbody_world) { - build_rigidbody(scene); - } - - /* scene's animation and drivers */ - if (scene->adt) { - build_animdata(&scene->id); - } - - /* world */ - if (scene->world) { - build_world(scene->world); - } - - /* compo nodes */ - if (scene->nodetree) { - build_compositor(scene); - } - - /* sequencer */ - // XXX... - - /* grease pencil */ - if (scene->gpd) { - build_gpencil(scene->gpd); - } - - /* Cache file. */ - LINKLIST_FOREACH (CacheFile *, cachefile, &bmain->cachefiles) { - build_cachefile(cachefile); - } - - /* Masks. */ - LINKLIST_FOREACH (Mask *, mask, &bmain->mask) { - build_mask(mask); - } -} - void DepsgraphNodeBuilder::build_group(Scene *scene, Base *base, Group *group) diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc index 8ba41a4b4b1..4a5f3dc8664 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc @@ -24,7 +24,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/depsgraph/intern/builder/deg_builder_nodes.cc +/** \file blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc * \ingroup depsgraph * * Methods for constructing depsgraph's nodes diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc new file mode 100644 index 00000000000..fb243ab0672 --- /dev/null +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc @@ -0,0 +1,154 @@ +/* + * ***** 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) 2013 Blender Foundation. + * All rights reserved. + * + * Original Author: Joshua Leung + * Contributor(s): Based on original depsgraph.c code - Blender Foundation (2005-2013) + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc + * \ingroup depsgraph + * + * Methods for constructing depsgraph's nodes + */ + +#include "intern/builder/deg_builder_nodes.h" + +#include +#include + +#include "MEM_guardedalloc.h" + +extern "C" { +#include "BLI_blenlib.h" +#include "BLI_string.h" +#include "BLI_utildefines.h" + +#include "DNA_node_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "BKE_main.h" +#include "BKE_node.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" +} /* extern "C" */ + +#include "intern/builder/deg_builder.h" +#include "intern/nodes/deg_node.h" +#include "intern/nodes/deg_node_component.h" +#include "intern/nodes/deg_node_operation.h" +#include "intern/depsgraph_types.h" +#include "intern/depsgraph_intern.h" +#include "util/deg_util_foreach.h" + +namespace DEG { + +void DepsgraphNodeBuilder::build_scene(Main *bmain, Scene *scene) +{ + /* LIB_TAG_DOIT is used to indicate whether node for given ID was already + * created or not. This flag is being set in add_id_node(), so functions + * shouldn't bother with setting it, they only might query this flag when + * needed. + */ + BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); + /* XXX nested node trees are not included in tag-clearing above, + * so we need to do this manually. + */ + FOREACH_NODETREE(bmain, nodetree, id) { + if (id != (ID *)nodetree) + nodetree->id.tag &= ~LIB_TAG_DOIT; + } FOREACH_NODETREE_END + + /* scene ID block */ + add_id_node(&scene->id); + + /* timesource */ + add_time_source(NULL); + + /* build subgraph for set, and link this in... */ + // XXX: depending on how this goes, that scene itself could probably store its + // own little partial depsgraph? + if (scene->set) { + build_scene(bmain, scene->set); + } + + /* scene objects */ + LINKLIST_FOREACH (Base *, base, &scene->base) { + Object *ob = base->object; + + /* object itself */ + build_object(scene, base, ob); + + /* object that this is a proxy for */ + // XXX: the way that proxies work needs to be completely reviewed! + if (ob->proxy) { + ob->proxy->proxy_from = ob; + build_object(scene, base, ob->proxy); + } + + /* Object dupligroup. */ + if (ob->dup_group) { + build_group(scene, base, ob->dup_group); + } + } + + /* rigidbody */ + if (scene->rigidbody_world) { + build_rigidbody(scene); + } + + /* scene's animation and drivers */ + if (scene->adt) { + build_animdata(&scene->id); + } + + /* world */ + if (scene->world) { + build_world(scene->world); + } + + /* compo nodes */ + if (scene->nodetree) { + build_compositor(scene); + } + + /* sequencer */ + // XXX... + + /* grease pencil */ + if (scene->gpd) { + build_gpencil(scene->gpd); + } + + /* Cache file. */ + LINKLIST_FOREACH (CacheFile *, cachefile, &bmain->cachefiles) { + build_cachefile(cachefile); + } + + /* Masks. */ + LINKLIST_FOREACH (Mask *, mask, &bmain->mask) { + build_mask(mask); + } +} + +} // namespace DEG diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc index 7ada04e8f74..feae8bca303 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc @@ -24,7 +24,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/depsgraph/intern/builder/deg_builder_relations.cc +/** \file blender/depsgraph/intern/builder/deg_builder_relations_keys.cc * \ingroup depsgraph * * Methods for constructing depsgraph diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc index 0fa7a5b1830..2b4c000f483 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc @@ -24,7 +24,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/depsgraph/intern/builder/deg_builder_relations.cc +/** \file blender/depsgraph/intern/builder/deg_builder_relations_rig.cc * \ingroup depsgraph * * Methods for constructing depsgraph diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc new file mode 100644 index 00000000000..946c9da6cab --- /dev/null +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc @@ -0,0 +1,157 @@ +/* + * ***** 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) 2013 Blender Foundation. + * All rights reserved. + * + * Original Author: Joshua Leung + * Contributor(s): Based on original depsgraph.c code - Blender Foundation (2005-2013) + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/depsgraph/intern/builder/deg_builder_relations_scene.cc + * \ingroup depsgraph + * + * Methods for constructing depsgraph + */ + +#include "intern/builder/deg_builder_relations.h" + +#include +#include +#include /* required for STREQ later on. */ + +#include "MEM_guardedalloc.h" + +extern "C" { +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" + +#include "DNA_node_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "BKE_main.h" +#include "BKE_node.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" +} /* extern "C" */ + +#include "intern/builder/deg_builder.h" +#include "intern/builder/deg_builder_pchanmap.h" + +#include "intern/nodes/deg_node.h" +#include "intern/nodes/deg_node_component.h" +#include "intern/nodes/deg_node_operation.h" + +#include "intern/depsgraph_intern.h" +#include "intern/depsgraph_types.h" + +#include "util/deg_util_foreach.h" + +namespace DEG { + +void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene) +{ + /* LIB_TAG_DOIT is used to indicate whether node for given ID was already + * created or not. + */ + BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); + /* XXX nested node trees are not included in tag-clearing above, + * so we need to do this manually. + */ + FOREACH_NODETREE(bmain, nodetree, id) { + if (id != (ID *)nodetree) + nodetree->id.tag &= ~LIB_TAG_DOIT; + } FOREACH_NODETREE_END + + if (scene->set) { + // TODO: link set to scene, especially our timesource... + } + + /* scene objects */ + LINKLIST_FOREACH (Base *, base, &scene->base) { + Object *ob = base->object; + + /* object itself */ + build_object(bmain, scene, ob); + + /* object that this is a proxy for */ + if (ob->proxy) { + ob->proxy->proxy_from = ob; + build_object(bmain, scene, ob->proxy); + /* TODO(sergey): This is an inverted relation, matches old depsgraph + * behavior and need to be investigated if it still need to be inverted. + */ + ComponentKey ob_pose_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE); + ComponentKey proxy_pose_key(&ob->proxy->id, DEPSNODE_TYPE_EVAL_POSE); + add_relation(ob_pose_key, proxy_pose_key, DEPSREL_TYPE_TRANSFORM, "Proxy"); + } + + /* Object dupligroup. */ + if (ob->dup_group) { + build_group(bmain, scene, ob, ob->dup_group); + } + } + + /* rigidbody */ + if (scene->rigidbody_world) { + build_rigidbody(scene); + } + + /* scene's animation and drivers */ + if (scene->adt) { + build_animdata(&scene->id); + } + + /* world */ + if (scene->world) { + build_world(scene->world); + } + + /* compo nodes */ + if (scene->nodetree) { + build_compositor(scene); + } + + /* grease pencil */ + if (scene->gpd) { + build_gpencil(&scene->id, scene->gpd); + } + + /* Masks. */ + LINKLIST_FOREACH (Mask *, mask, &bmain->mask) { + build_mask(mask); + } + + for (Depsgraph::OperationNodes::const_iterator it_op = m_graph->operations.begin(); + it_op != m_graph->operations.end(); + ++it_op) + { + OperationDepsNode *node = *it_op; + IDDepsNode *id_node = node->owner->owner; + ID *id = id_node->id; + if (GS(id->name) == ID_OB) { + Object *object = (Object *)id; + object->customdata_mask |= node->customdata_mask; + } + } +} + +} // namespace DEG -- cgit v1.2.3 From d294509dd845a1cab07cccd2bdcb7797b01cae32 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 17 Nov 2016 16:37:25 +0100 Subject: Depsgrpah: Fix missing animation update in movie clips --- .../depsgraph/intern/builder/deg_builder_nodes.cc | 7 ++ .../depsgraph/intern/builder/deg_builder_nodes.h | 2 + .../intern/builder/deg_builder_nodes_scene.cc | 5 ++ .../intern/builder/deg_builder_relations.cc | 94 ++-------------------- .../intern/builder/deg_builder_relations.h | 2 + .../intern/builder/deg_builder_relations_scene.cc | 5 ++ 6 files changed, 28 insertions(+), 87 deletions(-) diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 4e6ab73b353..f986d5dea46 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -58,6 +58,7 @@ extern "C" { #include "DNA_mask_types.h" #include "DNA_mesh_types.h" #include "DNA_meta_types.h" +#include "DNA_movieclip_types.h" #include "DNA_node_types.h" #include "DNA_particle_types.h" #include "DNA_object_types.h" @@ -1144,4 +1145,10 @@ void DepsgraphNodeBuilder::build_mask(Mask *mask) build_animdata(mask_id); } +void DepsgraphNodeBuilder::build_movieclip(MovieClip *clip) { + ID *clip_id = &clip->id; + add_id_node(clip_id); + build_animdata(clip_id); +} + } // namespace DEG diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h index 0cfddeed6ef..9cb8bc5d45c 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h @@ -46,6 +46,7 @@ struct Main; struct Material; struct Mask; struct MTex; +struct MovieClip; struct bNodeTree; struct Object; struct bPoseChannel; @@ -156,6 +157,7 @@ struct DepsgraphNodeBuilder { void build_gpencil(bGPdata *gpd); void build_cachefile(CacheFile *cache_file); void build_mask(Mask *mask); + void build_movieclip(MovieClip *clip); protected: Main *m_bmain; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc index fb243ab0672..bcd4bc51448 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc @@ -149,6 +149,11 @@ void DepsgraphNodeBuilder::build_scene(Main *bmain, Scene *scene) LINKLIST_FOREACH (Mask *, mask, &bmain->mask) { build_mask(mask); } + + /* Movie clips. */ + LINKLIST_FOREACH (MovieClip *, clip, &bmain->movieclip) { + build_movieclip(clip); + } } } // namespace DEG diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 293c14e5dde..dadb7f8917f 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -58,6 +58,7 @@ extern "C" { #include "DNA_mask_types.h" #include "DNA_mesh_types.h" #include "DNA_meta_types.h" +#include "DNA_movieclip_types.h" #include "DNA_node_types.h" #include "DNA_particle_types.h" #include "DNA_object_types.h" @@ -338,93 +339,6 @@ void DepsgraphRelationBuilder::add_forcefield_relations(const OperationKey &key, /* **** Functions to build relations between entities **** */ -void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene) -{ - /* LIB_TAG_DOIT is used to indicate whether node for given ID was already - * created or not. - */ - BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); - /* XXX nested node trees are not included in tag-clearing above, - * so we need to do this manually. - */ - FOREACH_NODETREE(bmain, nodetree, id) { - if (id != (ID *)nodetree) - nodetree->id.tag &= ~LIB_TAG_DOIT; - } FOREACH_NODETREE_END - - if (scene->set) { - // TODO: link set to scene, especially our timesource... - } - - /* scene objects */ - LINKLIST_FOREACH (Base *, base, &scene->base) { - Object *ob = base->object; - - /* object itself */ - build_object(bmain, scene, ob); - - /* object that this is a proxy for */ - if (ob->proxy) { - ob->proxy->proxy_from = ob; - build_object(bmain, scene, ob->proxy); - /* TODO(sergey): This is an inverted relation, matches old depsgraph - * behavior and need to be investigated if it still need to be inverted. - */ - ComponentKey ob_pose_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE); - ComponentKey proxy_pose_key(&ob->proxy->id, DEPSNODE_TYPE_EVAL_POSE); - add_relation(ob_pose_key, proxy_pose_key, DEPSREL_TYPE_TRANSFORM, "Proxy"); - } - - /* Object dupligroup. */ - if (ob->dup_group) { - build_group(bmain, scene, ob, ob->dup_group); - } - } - - /* rigidbody */ - if (scene->rigidbody_world) { - build_rigidbody(scene); - } - - /* scene's animation and drivers */ - if (scene->adt) { - build_animdata(&scene->id); - } - - /* world */ - if (scene->world) { - build_world(scene->world); - } - - /* compo nodes */ - if (scene->nodetree) { - build_compositor(scene); - } - - /* grease pencil */ - if (scene->gpd) { - build_gpencil(&scene->id, scene->gpd); - } - - /* Masks. */ - LINKLIST_FOREACH (Mask *, mask, &bmain->mask) { - build_mask(mask); - } - - for (Depsgraph::OperationNodes::const_iterator it_op = m_graph->operations.begin(); - it_op != m_graph->operations.end(); - ++it_op) - { - OperationDepsNode *node = *it_op; - IDDepsNode *id_node = node->owner->owner; - ID *id = id_node->id; - if (GS(id->name) == ID_OB) { - Object *object = (Object *)id; - object->customdata_mask |= node->customdata_mask; - } - } -} - void DepsgraphRelationBuilder::build_group(Main *bmain, Scene *scene, Object *object, @@ -1755,4 +1669,10 @@ void DepsgraphRelationBuilder::build_mask(Mask *mask) build_animdata(&mask->id); } +void DepsgraphRelationBuilder::build_movieclip(MovieClip *clip) +{ + /* Animation. */ + build_animdata(&clip->id); +} + } // namespace DEG diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h index 1c293aa1508..6e8485bee30 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h @@ -58,6 +58,7 @@ struct Main; struct Mask; struct Material; struct MTex; +struct MovieClip; struct bNodeTree; struct Object; struct bPoseChannel; @@ -224,6 +225,7 @@ struct DepsgraphRelationBuilder void build_gpencil(ID *owner, bGPdata *gpd); void build_cachefile(CacheFile *cache_file); void build_mask(Mask *mask); + void build_movieclip(MovieClip *clip); 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); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc index 946c9da6cab..6b51a957da0 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc @@ -140,6 +140,11 @@ void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene) build_mask(mask); } + /* Movie clips. */ + LINKLIST_FOREACH (MovieClip *, clip, &bmain->movieclip) { + build_movieclip(clip); + } + for (Depsgraph::OperationNodes::const_iterator it_op = m_graph->operations.begin(); it_op != m_graph->operations.end(); ++it_op) -- cgit v1.2.3 From a1a8343281354d2dfb192e7b9262921ee132a287 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 18 Nov 2016 06:08:51 +1100 Subject: Cleanup: redundant index loop for monkey-create Also rename face vars (the faces aren't temp), and quiet old-style-definition warning. --- source/blender/blenkernel/intern/blender_undo.c | 2 +- source/blender/bmesh/intern/bmesh_queries.h | 2 +- source/blender/bmesh/operators/bmo_primitive.c | 23 +++++++++++------------ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/source/blender/blenkernel/intern/blender_undo.c b/source/blender/blenkernel/intern/blender_undo.c index ce6d29bbfee..bc98d6f6805 100644 --- a/source/blender/blenkernel/intern/blender_undo.c +++ b/source/blender/blenkernel/intern/blender_undo.c @@ -320,7 +320,7 @@ const char *BKE_undo_get_name(int nr, bool *r_active) } /* return the name of the last item */ -const char *BKE_undo_get_name_last() +const char *BKE_undo_get_name_last(void) { UndoElem *uel = undobase.last; return (uel ? uel->name : NULL); diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h index a6a37767ee9..903fdc59cb8 100644 --- a/source/blender/bmesh/intern/bmesh_queries.h +++ b/source/blender/bmesh/intern/bmesh_queries.h @@ -135,7 +135,7 @@ BMLoop *BM_face_find_longest_loop(BMFace *f) ATTR_WARN_UNUSED_RESULT ATTR_NONNUL BMEdge *BM_edge_exists(BMVert *v1, BMVert *v2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); BMEdge *BM_edge_find_double(BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); -BMFace* BM_face_exists(BMVert **varr, int len) ATTR_NONNULL(1); +BMFace *BM_face_exists(BMVert **varr, int len) ATTR_NONNULL(1); bool BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); bool BM_face_exists_multi_edge(BMEdge **earr, int len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c index 7b32921f8cf..8408169d85e 100644 --- a/source/blender/bmesh/operators/bmo_primitive.c +++ b/source/blender/bmesh/operators/bmo_primitive.c @@ -1174,7 +1174,7 @@ void BM_mesh_calc_uvs_sphere(BMesh *bm, const short oflag) } BMIter iter2; - BMLoop* l; + BMLoop *l; int loop_index; float minx = 1.0f; @@ -1236,14 +1236,14 @@ void bmo_create_monkey_exec(BMesh *bm, BMOperator *op) int uvi = 0; const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); for (i = 0; i < monkeynf; i++) { - BMFace* temp1 = BM_face_create_quad_tri(bm, + BMFace *f_new_a = BM_face_create_quad_tri(bm, tv[monkeyf[i][0] + i - monkeyo], tv[monkeyf[i][1] + i - monkeyo], tv[monkeyf[i][2] + i - monkeyo], (monkeyf[i][3] != monkeyf[i][2]) ? tv[monkeyf[i][3] + i - monkeyo] : NULL, NULL, BM_CREATE_NOP); - BMFace* temp2 = BM_face_create_quad_tri(bm, + BMFace *f_new_b = BM_face_create_quad_tri(bm, tv[monkeynv + monkeyf[i][2] + i - monkeyo], tv[monkeynv + monkeyf[i][1] + i - monkeyo], tv[monkeynv + monkeyf[i][0] + i - monkeyo], @@ -1252,20 +1252,19 @@ void bmo_create_monkey_exec(BMesh *bm, BMOperator *op) /* Set the UVs here, the iteration order of the faces is not guaranteed, * so it's best to set the UVs right after the face is created. */ - if(calc_uvs) { - BMLoop* l; + if (calc_uvs) { + BMLoop *l; BMIter liter; - int loop_index; - BM_ITER_ELEM_INDEX (l, &liter, temp1, BM_LOOPS_OF_FACE, loop_index) { + BM_ITER_ELEM (l, &liter, f_new_a, BM_LOOPS_OF_FACE) { MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - luv->uv[0] = monkeyuvs[uvi*2 + 0]; - luv->uv[1] = monkeyuvs[uvi*2 + 1]; + luv->uv[0] = monkeyuvs[uvi * 2 + 0]; + luv->uv[1] = monkeyuvs[uvi * 2 + 1]; uvi++; } - BM_ITER_ELEM_INDEX (l, &liter, temp2, BM_LOOPS_OF_FACE, loop_index) { + BM_ITER_ELEM (l, &liter, f_new_b, BM_LOOPS_OF_FACE) { MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - luv->uv[0] = monkeyuvs[uvi*2 + 0]; - luv->uv[1] = monkeyuvs[uvi*2 + 1]; + luv->uv[0] = monkeyuvs[uvi * 2 + 0]; + luv->uv[1] = monkeyuvs[uvi * 2 + 1]; uvi++; } -- cgit v1.2.3 From 46739f1e5ceee43f6e7313dcb4c21829a13789d6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Nov 2016 03:22:49 +1100 Subject: BMesh: minor cleanup Comment & don't use dummy pointer. --- source/blender/bmesh/intern/bmesh_core.c | 4 +++- source/blender/bmesh/intern/bmesh_mods.c | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index 0cd91107171..d1178a198dc 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -2682,8 +2682,10 @@ BMVert *bmesh_urmv_loop(BMesh *bm, BMLoop *l_sep) /** * A version of #bmesh_urmv_loop that disconnects multiple loops at once. + * The loops must all share the same vertex, can be in any order + * and are all moved to use a single new vertex - which is returned. * - * Handles the task of finding fans boundaries. + * This function handles the details of finding fans boundaries. */ BMVert *bmesh_urmv_loop_multi( BMesh *bm, BMLoop **larr, int larr_len) diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index 03165beb329..500da6b8788 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -346,7 +346,7 @@ BMFace *BM_face_split_n( BMLoop **r_l, BMEdge *example) { BMFace *f_new, *f_tmp; - BMLoop *l_dummy; + BMLoop *l_new; BMEdge *e, *e_new; BMVert *v_new; // BMVert *v_a = l_a->v; /* UNUSED */ @@ -368,24 +368,21 @@ BMFace *BM_face_split_n( } f_tmp = BM_face_copy(bm, bm, f, true, true); - - if (!r_l) - r_l = &l_dummy; #ifdef USE_BMESH_HOLES - f_new = bmesh_sfme(bm, f, l_a, l_b, r_l, NULL, example, false); + f_new = bmesh_sfme(bm, f, l_a, l_b, &l_new, NULL, example, false); #else - f_new = bmesh_sfme(bm, f, l_a, l_b, r_l, example, false); + f_new = bmesh_sfme(bm, f, l_a, l_b, &l_new, example, false); #endif - /* bmesh_sfme returns in r_l a Loop for f_new going from v_a to v_b. - * The radial_next is for f and goes from v_b to v_a */ + /* bmesh_sfme returns in 'l_new' a Loop for f_new going from 'v_a' to 'v_b'. + * The radial_next is for 'f' and goes from 'v_b' to 'v_a' */ if (f_new) { - e = (*r_l)->e; + e = l_new->e; for (i = 0; i < n; i++) { v_new = bmesh_semv(bm, v_b, e, &e_new); BLI_assert(v_new != NULL); - /* bmesh_semv returns in e_new the edge going from v_new to tv */ + /* bmesh_semv returns in 'e_new' the edge going from 'v_new' to 'v_b' */ copy_v3_v3(v_new->co, cos[i]); /* interpolate the loop data for the loops with (v == v_new), using orig face */ @@ -405,6 +402,10 @@ BMFace *BM_face_split_n( BM_face_verts_kill(bm, f_tmp); + if (r_l) { + *r_l = l_new; + } + return f_new; } -- cgit v1.2.3 From 03a395766aee1b19d42360edaca2fdd03acebb7b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 18 Nov 2016 05:55:37 +1100 Subject: BMesh: avoid using temp array for face-area --- source/blender/bmesh/intern/bmesh_polygon.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index c500d7b9ec2..6acd790fc0c 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -225,24 +225,16 @@ void BM_face_calc_point_in_face(const BMFace *f, float r_co[3]) */ float BM_face_calc_area(const BMFace *f) { + /* inline 'area_poly_v3' logic, avoid creating a temp array */ const BMLoop *l_iter, *l_first; - float (*verts)[3] = BLI_array_alloca(verts, f->len); - float area; - unsigned int i = 0; + float n[3]; + zero_v3(n); l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { - copy_v3_v3(verts[i++], l_iter->v->co); + add_newell_cross_v3_v3v3(n, l_iter->v->co, l_iter->next->v->co); } while ((l_iter = l_iter->next) != l_first); - - if (f->len == 3) { - area = area_tri_v3(verts[0], verts[1], verts[2]); - } - else { - area = area_poly_v3((const float (*)[3])verts, f->len); - } - - return area; + return len_v3(n) * 0.5f; } /** -- cgit v1.2.3 From b859fef67016cb67222380d4145781d822183e71 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 18 Nov 2016 11:55:28 +0100 Subject: Fix copy/paste typo in new depsgraph object geometry builder (found by coverity). --- source/blender/depsgraph/intern/builder/deg_builder_nodes.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index f986d5dea46..4de82dd63e4 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -901,7 +901,7 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob) build_object(scene, NULL, cu->bevobj); } if (cu->taperobj != NULL) { - build_object(scene, NULL, cu->bevobj); + build_object(scene, NULL, cu->taperobj); } if (ob->type == OB_FONT && cu->textoncurve != NULL) { build_object(scene, NULL, cu->textoncurve); -- cgit v1.2.3 From 841c4deed7a8a98761cb3f154a6581f10841eb35 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 18 Nov 2016 12:03:12 +0100 Subject: Fix potential NULL dereference in mesh sequence cache modifier. Reported by coverity. --- source/blender/modifiers/intern/MOD_meshsequencecache.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c index d25e8e38de3..72644d56323 100644 --- a/source/blender/modifiers/intern/MOD_meshsequencecache.c +++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c @@ -114,6 +114,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, mcmd->reader, ob, mcmd->object_path); + if (!mcmd->reader) { + modifier_setError(md, "Could not create Alembic reader for file %s", cache_file->filepath); + return dm; + } } DerivedMesh *result = ABC_read_mesh(mcmd->reader, -- cgit v1.2.3 From fffb1a4cfbd25cccc5df2a113907b6aa29d0f204 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 18 Nov 2016 12:37:39 +0100 Subject: Implement multi-view stereo support for image empties Empty images were implemented to expand (and eventually replace) the background images functionalities. If we are ever to drop background images "image empties" should support stereo/multi-view as well. --- source/blender/editors/space_view3d/drawobject.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index dd282c427f6..90d33dc5995 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -631,10 +631,20 @@ void drawaxes(const float viewmat_local[4][4], float size, char drawtype) /* Function to draw an Image on an empty Object */ -static void draw_empty_image(Object *ob, const short dflag, const unsigned char ob_wire_col[4]) +static void draw_empty_image(Object *ob, const short dflag, const unsigned char ob_wire_col[4], StereoViews sview) { Image *ima = ob->data; - ImBuf *ibuf = BKE_image_acquire_ibuf(ima, ob->iuser, NULL); + ImBuf *ibuf; + ImageUser iuser = *ob->iuser; + + /* Support multi-view */ + if (ima && (sview == STEREO_RIGHT_ID)) { + iuser.multiview_eye = sview; + iuser.flag |= IMA_SHOW_STEREO; + BKE_image_multiview_index(ima, &iuser); + } + + ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL); if (ibuf && (ibuf->rect == NULL) && (ibuf->rect_float != NULL)) { IMB_rect_from_float(ibuf); @@ -7708,7 +7718,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short case OB_EMPTY: if (!render_override) { if (ob->empty_drawtype == OB_EMPTY_IMAGE) { - draw_empty_image(ob, dflag, ob_wire_col); + draw_empty_image(ob, dflag, ob_wire_col, v3d->multiview_eye); } else { drawaxes(rv3d->viewmatob, ob->empty_drawsize, ob->empty_drawtype); @@ -8488,7 +8498,7 @@ void draw_object_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object case OB_EMPTY: if (ob->empty_drawtype == OB_EMPTY_IMAGE) { /* CONSTCOLOR == no wire outline */ - draw_empty_image(ob, DRAW_CONSTCOLOR, NULL); + draw_empty_image(ob, DRAW_CONSTCOLOR, NULL, v3d->multiview_eye); } else { drawaxes(rv3d->viewmatob, ob->empty_drawsize, ob->empty_drawtype); -- cgit v1.2.3 From 3fb11061bad7c76ea53925ed599ee155b0d4222f Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Fri, 18 Nov 2016 13:37:04 +0100 Subject: Fix T50063: Editing driver's expression eliminates "Zero" number Disables trimming of trailing zeros in case button contains an expression. --- source/blender/editors/interface/interface_anim.c | 8 +++++++- source/blender/editors/interface/interface_handlers.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index 991cd54fecf..5da294302e9 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -99,6 +99,10 @@ void ui_but_anim_flag(uiBut *but, float cfra) } } +/** + * \a str can be NULL to only perform check if \a but has an expression at all. + * \return if button has an expression. + */ bool ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen) { FCurve *fcu; @@ -111,7 +115,9 @@ bool ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen) driver = fcu->driver; if (driver && driver->type == DRIVER_TYPE_PYTHON) { - BLI_strncpy(str, driver->expression, maxlen); + if (str) { + BLI_strncpy(str, driver->expression, maxlen); + } return true; } } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index f3eeadb6604..fc511d61e2b 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3067,7 +3067,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) data->str = ui_but_string_get_dynamic(but, &data->maxlen); } - if (ui_but_is_float(but) && !ui_but_is_unit(but)) { + if (ui_but_is_float(but) && !ui_but_is_unit(but) && !ui_but_anim_expression_get(but, NULL, 0)) { BLI_str_rstrip_float_zero(data->str, '\0'); } -- cgit v1.2.3 From 8f0dc3cef6c3f3e02a0a4322cd241cf379e52552 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 18 Nov 2016 15:14:22 +0100 Subject: Fix T50052: bpy.utils.unregister_module doesn't unregister classes of submodules in reload scenario. reload case would clear TypeMap before unregistering addons, which made all calls to unregister_module() to do absolutely nothing. --- release/scripts/modules/bpy/utils/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/release/scripts/modules/bpy/utils/__init__.py b/release/scripts/modules/bpy/utils/__init__.py index 66974dedc24..31dd836e034 100644 --- a/release/scripts/modules/bpy/utils/__init__.py +++ b/release/scripts/modules/bpy/utils/__init__.py @@ -154,8 +154,6 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): original_modules = _sys.modules.values() if reload_scripts: - _bpy_types.TypeMap.clear() - # just unload, don't change user defaults, this means we can sync # to reload. note that they will only actually reload of the # modification time changes. This `won't` work for packages so... @@ -163,6 +161,9 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): for module_name in [ext.module for ext in _user_preferences.addons]: _addon_utils.disable(module_name) + # *AFTER* unregistering all add-ons, otherwise all calls to unregister_module() will silently fail (do nothing). + _bpy_types.TypeMap.clear() + def register_module_call(mod): register = getattr(mod, "register", None) if register: -- cgit v1.2.3 From f6083b7bcd6901ae8d8452e34d1230afaa8da3fb Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 18 Nov 2016 15:32:50 +0100 Subject: Fix (unreported) bad handling of brush's fill threshold value. '1' threshold value would only allow to access a third of the basic 'color space' (from black to white, from 0.0 to 1.0 component values), when you expect it to access the whole range. Unfortunately, this needs a subversion bump to allow already defined brushes to keep exact same behavior! Also, did not change default value (0.2) for new brushes, think here keeping current one makes more sense. Thanks to @LucaRood for confirming the issue. --- source/blender/blenkernel/BKE_blender_version.h | 2 +- source/blender/blenloader/intern/versioning_270.c | 7 +++++++ source/blender/editors/sculpt_paint/paint_image_2d.c | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index baf8510dd0d..4f4787f9da5 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -28,7 +28,7 @@ * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 278 -#define BLENDER_SUBVERSION 3 +#define BLENDER_SUBVERSION 4 /* Several breakages with 270, e.g. constraint deg vs rad */ #define BLENDER_MINVERSION 270 #define BLENDER_MINSUBVERSION 6 diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 8133d0496fa..25d78b73d59 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -1466,4 +1466,11 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } } + + if (!MAIN_VERSION_ATLEAST(main, 278, 4)) { + const float sqrt_3 = (float)M_SQRT3; + for (Brush *br = main->brush.first; br; br = br->id.next) { + br->fill_threshold /= sqrt_3; + } + } } diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index 9474a46d716..4f93c12385d 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -1489,7 +1489,8 @@ void paint_2d_bucket_fill( float image_init[2]; int minx = ibuf->x, miny = ibuf->y, maxx = 0, maxy = 0; float pixel_color[4]; - float threshold_sq = br->fill_threshold * br->fill_threshold; + /* We are comparing to sum of three squared values (assumed in range [0,1]), so need to multiply... */ + float threshold_sq = br->fill_threshold * br->fill_threshold * 3; UI_view2d_region_to_view(s->v2d, mouse_init[0], mouse_init[1], &image_init[0], &image_init[1]); -- cgit v1.2.3 From 27de0c40c594b9a2e853ec2c3c913d5a16e68e84 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 18 Nov 2016 15:49:41 +0100 Subject: Fix T50035: Minor interface bug: UV/ImageEditor - Paint Mode - Fill Brush Patch by @LucaRood, added some cleanup of DRAW/FILL conditions in this code too... --- release/scripts/startup/bl_ui/properties_paint_common.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py index cca142b645c..09a3a19cbce 100644 --- a/release/scripts/startup/bl_ui/properties_paint_common.py +++ b/release/scripts/startup/bl_ui/properties_paint_common.py @@ -119,16 +119,14 @@ def brush_texpaint_common(panel, context, layout, brush, settings, projpaint=Fal col.label("Gradient Colors") col.template_color_ramp(brush, "gradient", expand=True) - if brush.image_tool != 'FILL': + if brush.image_tool == 'DRAW': col.label("Background Color") row = col.row(align=True) panel.prop_unified_color(row, context, brush, "secondary_color", text="") - - if brush.image_tool == 'DRAW': col.prop(brush, "gradient_stroke_mode", text="Mode") if brush.gradient_stroke_mode in {'SPACING_REPEAT', 'SPACING_CLAMP'}: col.prop(brush, "grad_spacing") - elif brush.image_tool == 'FILL': + else: # if brush.image_tool == 'FILL': col.prop(brush, "gradient_fill_mode") else: row = col.row(align=True) @@ -139,6 +137,9 @@ def brush_texpaint_common(panel, context, layout, brush, settings, projpaint=Fal panel.prop_unified_color(row, context, brush, "secondary_color", text="") row.separator() row.operator("paint.brush_colors_flip", icon='FILE_REFRESH', text="") + else: + if brush.image_tool == 'FILL' and not projpaint: + col.prop(brush, "fill_threshold") elif brush.image_tool == 'SOFTEN': col = layout.column(align=True) -- cgit v1.2.3 From ba7c11aa055f01f9a3cdcec07fea8fb7355b0e95 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 18 Nov 2016 17:47:17 +0100 Subject: Depsgraph: Fix residue of debug-only code --- source/blender/depsgraph/intern/builder/deg_builder.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc index 8939e4cc93a..8a0bec5ed1d 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder.cc @@ -85,7 +85,7 @@ void deg_graph_build_finalize(Depsgraph *graph) */ GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, graph->id_hash) { - if (id_node->layers == 0 || 1) { + if (id_node->layers == 0) { ID *id = id_node->id; if (GS(id->name) == ID_OB) { Object *object = (Object *)id; -- cgit v1.2.3 From 0f8e5f4fb463289be1b69b1cb5eaad495ae720c6 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 18 Nov 2016 18:23:45 +0100 Subject: Cycles: Different noise seed for stereoscopic rendering (Fix #T50024) Patch by Sergey Sharybin. --- intern/cycles/blender/blender_session.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index c250a54f259..171153dd440 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -32,6 +32,7 @@ #include "util_color.h" #include "util_foreach.h" #include "util_function.h" +#include "util_hash.h" #include "util_logging.h" #include "util_progress.h" #include "util_time.h" @@ -498,7 +499,8 @@ void BlenderSession::render() scene->film->tag_update(scene); scene->integrator->tag_update(scene); - for(b_rr.views.begin(b_view_iter); b_view_iter != b_rr.views.end(); ++b_view_iter) { + int view_index = 0; + for(b_rr.views.begin(b_view_iter); b_view_iter != b_rr.views.end(); ++b_view_iter, ++view_index) { b_rview_name = b_view_iter->name(); /* set the current view */ @@ -514,6 +516,12 @@ void BlenderSession::render() &python_thread_state, b_rlay_name.c_str()); + /* Make sure all views have different noise patterns. - hardcoded value just to make it random */ + if(view_index != 0) { + scene->integrator->seed += hash_int_2d(scene->integrator->seed, hash_int(view_index * 0xdeadbeef)); + scene->integrator->tag_update(scene); + } + /* Update number of samples per layer. */ int samples = sync->get_layer_samples(); bool bound_samples = sync->get_layer_bound_samples(); -- cgit v1.2.3 From a90644ed19afbd84d422208772c4a970484b4248 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 18 Nov 2016 18:46:10 +0100 Subject: Minor debug-report tweak to autosave code. Print in cosole a warning when we skip autosave due to runnning modal op. Related to T49974. --- source/blender/windowmanager/intern/wm_files.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index fe257cc4c41..05d63869074 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1144,6 +1144,9 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w for (handler = win->modalhandlers.first; handler; handler = handler->next) { if (handler->op) { wm->autosavetimer = WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, 10.0); + if (G.debug) { + printf("Skipping auto-save, modal operator running, retrying in ten seconds...\n"); + } return; } } @@ -1161,7 +1164,7 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w ED_editors_flush_edits(C, false); - /* no error reporting to console */ + /* Error reporting into console */ BLO_write_file(CTX_data_main(C), filepath, fileflags, NULL, NULL); } /* do timer after file write, just in case file write takes a long time */ -- cgit v1.2.3 From 39be226e93c4fe133065fb56ef5191fcc2ff8c9c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 19 Nov 2016 06:26:25 +1100 Subject: BMesh: invalid return from BM_mesh_validate Returned value was always false, even for valid meshes, note that this is a debug-only function. Also set internal-tag cleared. --- source/blender/bmesh/intern/bmesh_mesh_validate.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_mesh_validate.c b/source/blender/bmesh/intern/bmesh_mesh_validate.c index 478194735f3..7c9ebc800a3 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_validate.c +++ b/source/blender/bmesh/intern/bmesh_mesh_validate.c @@ -64,7 +64,7 @@ bool BM_mesh_validate(BMesh *bm) int i, j; - errtot = -1; + errtot = -1; /* 'ERRMSG' next line will set at zero */ fprintf(stderr, "\n"); ERRMSG("This is a debugging function and not intended for general use, running slow test!"); @@ -187,15 +187,22 @@ bool BM_mesh_validate(BMesh *bm) } while ((l_iter = l_iter->next) != l_first); if (j != f->len) { - ERRMSG("face %d: has length if %d but should be %d", i, f->len, j); + ERRMSG("face %d: has length of %d but should be %d", i, f->len, j); } + + /* leave elements un-tagged, not essential but nice to avoid unintended dirty tag use later. */ + do { + BM_elem_flag_disable(l_iter, BM_ELEM_INTERNAL_TAG); + BM_elem_flag_disable(l_iter->v, BM_ELEM_INTERNAL_TAG); + BM_elem_flag_disable(l_iter->e, BM_ELEM_INTERNAL_TAG); + } while ((l_iter = l_iter->next) != l_first); } BLI_edgehash_free(edge_hash, NULL); + const bool is_valid = (errtot == 0); ERRMSG("Finished - errors %d", errtot); - - return (errtot == 0); + return is_valid; } -- cgit v1.2.3 From 40990d52d143b1698580986405134429b5a4899f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 19 Nov 2016 06:57:13 +1100 Subject: Add Torus: avoid excessive attr access --- .../scripts/startup/bl_operators/add_mesh_torus.py | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/release/scripts/startup/bl_operators/add_mesh_torus.py b/release/scripts/startup/bl_operators/add_mesh_torus.py index 303a8b01192..f12e7484e64 100644 --- a/release/scripts/startup/bl_operators/add_mesh_torus.py +++ b/release/scripts/startup/bl_operators/add_mesh_torus.py @@ -84,26 +84,27 @@ def add_torus(major_rad, minor_rad, major_seg, minor_seg): def add_uvs(mesh, minor_seg, major_seg): mesh.uv_textures.new() - uv_layer = mesh.uv_layers.active - u_step = 1.0/major_seg - v_step = 1.0/minor_seg + uv_data = mesh.uv_layers.active.data + polygons = mesh.polygons + u_step = 1.0 / major_seg + v_step = 1.0 / minor_seg vertex_index = 0 u = 0.5 for major_index in range(major_seg): v = 0.5 for minor_index in range(minor_seg): - loops = mesh.polygons[vertex_index].loop_indices - if minor_index == minor_seg-1 and major_index == 0: - uv_layer.data[loops[1]].uv = (u, v) - uv_layer.data[loops[2]].uv = (u + u_step, v) - uv_layer.data[loops[0]].uv = (u, v + v_step) - uv_layer.data[loops[3]].uv = (u + u_step, v + v_step) + loops = polygons[vertex_index].loop_indices + if minor_index == minor_seg - 1 and major_index == 0: + uv_data[loops[1]].uv = (u, v) + uv_data[loops[2]].uv = (u + u_step, v) + uv_data[loops[0]].uv = (u, v + v_step) + uv_data[loops[3]].uv = (u + u_step, v + v_step) else: - uv_layer.data[loops[0]].uv = (u, v) - uv_layer.data[loops[1]].uv = (u + u_step, v) - uv_layer.data[loops[3]].uv = (u, v + v_step) - uv_layer.data[loops[2]].uv = (u + u_step, v + v_step) + uv_data[loops[0]].uv = (u, v) + uv_data[loops[1]].uv = (u + u_step, v) + uv_data[loops[3]].uv = (u, v + v_step) + uv_data[loops[2]].uv = (u + u_step, v + v_step) v = (v + v_step) % 1.0 vertex_index += 1 u = (u + u_step) % 1.0 -- cgit v1.2.3 From b8710e1468a3ce523c35260e47332393e2b967a3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 19 Nov 2016 06:57:55 +1100 Subject: Fix UV layer bug in object_utils.object_data_add() Adding a torus in edit-mode, with 'Generate UVs' for example would either create another UV layer with the default name or switch to the default UV layer name if it exists. Now use the existing UV layer if present. --- release/scripts/modules/bpy_extras/object_utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/release/scripts/modules/bpy_extras/object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py index 88cd7398fe0..c48f03c133d 100644 --- a/release/scripts/modules/bpy_extras/object_utils.py +++ b/release/scripts/modules/bpy_extras/object_utils.py @@ -189,6 +189,14 @@ def object_data_add(context, obdata, operator=None, use_active_layer=True, name= scene.update() # apply location # scene.objects.active = obj_new + # Match up UV layers, this is needed so adding an object with UV's + # doesn't create new layers when there happens to be a naming mis-match. + uv_new = obdata.uv_layers.active + if uv_new is not None: + uv_act = obj_act.data.uv_layers.active + if uv_act is not None: + uv_new.name = uv_act.name + bpy.ops.object.join() # join into the active. if obdata: bpy.data.meshes.remove(obdata) -- cgit v1.2.3 From b6c0edcb0932d7001968dccfa94fce4e71876b06 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 18 Nov 2016 22:34:04 +0100 Subject: Fix T50071: Radience HDR fomat does not support alpha at all. --- source/blender/blenkernel/intern/image.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index df3a7630bb0..c9bad2160ff 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1244,7 +1244,6 @@ char BKE_imtype_valid_channels(const char imtype, bool write_file) case R_IMF_IMTYPE_RAWTGA: case R_IMF_IMTYPE_IRIS: case R_IMF_IMTYPE_PNG: - case R_IMF_IMTYPE_RADHDR: case R_IMF_IMTYPE_TIFF: case R_IMF_IMTYPE_OPENEXR: case R_IMF_IMTYPE_MULTILAYER: -- cgit v1.2.3 From 884693b42ae1d630349727519f6868b94f448643 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 18 Nov 2016 22:36:52 +0100 Subject: Fix Node space ID remap callback not handling node trees. Yep. Kinda ridiculous, but forgot to handle the very node trees data-blocks in that editor! Related (but not fixing) to T49991. --- source/blender/editors/space_node/space_node.c | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 4ef703c8994..bbdf6feef01 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -855,6 +855,42 @@ static void node_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID id_us_plus(new_id); } } + else if (GS(old_id->name) == ID_NT) { + bNodeTreePath *path, *path_next; + + for (path = snode->treepath.first; path; path = path->next) { + if ((ID *)path->nodetree == old_id) { + path->nodetree = (bNodeTree *)new_id; + id_us_min(old_id); + id_us_plus(new_id); + } + if (path == snode->treepath.first) { + /* first nodetree in path is same as snode->nodetree */ + snode->nodetree = path->nodetree; + } + if (path->nodetree == NULL) { + break; + } + } + + /* remaining path entries are invalid, remove */ + for (; path; path = path_next) { + path_next = path->next; + + BLI_remlink(&snode->treepath, path); + MEM_freeN(path); + } + + /* edittree is just the last in the path, + * set this directly since the path may have been shortened above */ + if (snode->treepath.last) { + path = snode->treepath.last; + snode->edittree = path->nodetree; + } + else { + snode->edittree = NULL; + } + } } /* only called once, from space/spacetypes.c */ -- cgit v1.2.3 From 5a6534a5bb62492af2bae8cff0880c3da19ac4d6 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 18 Nov 2016 22:41:56 +0100 Subject: Fix forward-compat Nodes write code being executed also for undo steps writing. Forward compatibility code should never, ever be run during undo saving. Note: related to T49991 (but does not fix it either, crash now happens when doing a real file save...). --- source/blender/blenloader/intern/writefile.c | 30 +++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index d104fc85eb7..ad1999c0bc7 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -914,20 +914,22 @@ static void write_curvemapping(WriteData *wd, CurveMapping *cumap) static void write_node_socket(WriteData *wd, bNodeTree *UNUSED(ntree), bNode *node, bNodeSocket *sock) { #ifdef USE_NODE_COMPAT_CUSTOMNODES - /* forward compatibility code, so older blenders still open */ - sock->stack_type = 1; - - if (node->type == NODE_GROUP) { - bNodeTree *ngroup = (bNodeTree *)node->id; - if (ngroup) { - /* for node groups: look up the deprecated groupsock pointer */ - sock->groupsock = ntreeFindSocketInterface(ngroup, sock->in_out, sock->identifier); - BLI_assert(sock->groupsock != NULL); - - /* node group sockets now use the generic identifier string to verify group nodes, - * old blender uses the own_index. - */ - sock->own_index = sock->groupsock->own_index; + /* forward compatibility code, so older blenders still open (not for undo) */ + if (wd->current == NULL) { + sock->stack_type = 1; + + if (node->type == NODE_GROUP) { + bNodeTree *ngroup = (bNodeTree *)node->id; + if (ngroup) { + /* for node groups: look up the deprecated groupsock pointer */ + sock->groupsock = ntreeFindSocketInterface(ngroup, sock->in_out, sock->identifier); + BLI_assert(sock->groupsock != NULL); + + /* node group sockets now use the generic identifier string to verify group nodes, + * old blender uses the own_index. + */ + sock->own_index = sock->groupsock->own_index; + } } } #endif -- cgit v1.2.3 From bd6a9fd7341f5573451abe5924df94a06f9f168b Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 19 Nov 2016 12:16:14 +0100 Subject: Fix (unreported) nodeRemoveAllSockets() not clearing inputs/outputs sockets lists. Nice crasher (though seems to not be much used so far)! Related to T49991. --- source/blender/blenkernel/intern/node.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 2b88ae4823c..a227228ceb5 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -736,11 +736,14 @@ void nodeRemoveAllSockets(bNodeTree *ntree, bNode *node) node_socket_free(ntree, sock, node); MEM_freeN(sock); } + BLI_listbase_clear(&node->inputs); + for (sock = node->outputs.first; sock; sock = sock_next) { sock_next = sock->next; node_socket_free(ntree, sock, node); MEM_freeN(sock); } + BLI_listbase_clear(&node->outputs); node->update |= NODE_UPDATE; } -- cgit v1.2.3 From fa6a62fac2a394e66e779c0dc4aef0f9d840ab87 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 19 Nov 2016 12:18:32 +0100 Subject: Fix NodeGroup generic verify function crashing if node's ID pointer is NULL. Another nice crasher - in this case, we just want to nuke all sockets... Related to T49991. --- source/blender/nodes/intern/node_common.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c index fbc036435f0..736f17f1d70 100644 --- a/source/blender/nodes/intern/node_common.c +++ b/source/blender/nodes/intern/node_common.c @@ -178,9 +178,14 @@ void node_group_verify(struct bNodeTree *ntree, struct bNode *node, struct ID *i { /* check inputs and outputs, and remove or insert them */ if (id == node->id) { - bNodeTree *ngroup = (bNodeTree *)node->id; - group_verify_socket_list(ntree, node, &ngroup->inputs, &node->inputs, SOCK_IN); - group_verify_socket_list(ntree, node, &ngroup->outputs, &node->outputs, SOCK_OUT); + if (id == NULL) { + nodeRemoveAllSockets(ntree, node); + } + else { + bNodeTree *ngroup = (bNodeTree *)node->id; + group_verify_socket_list(ntree, node, &ngroup->inputs, &node->inputs, SOCK_IN); + group_verify_socket_list(ntree, node, &ngroup->outputs, &node->outputs, SOCK_OUT); + } } } -- cgit v1.2.3 From 369872a2c50e95eee822512018cc282ef5fcfdd1 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 19 Nov 2016 12:20:29 +0100 Subject: Fix T49991: reloading librairies doesn't update node groups. We need to check node tree links are still valid, after we remapped some NodeGroup. Note: In fact, we have to run that for *all* ID types, since nodes may use any kind of data-block (in theory)... :/ --- source/blender/blenkernel/intern/library_remap.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c index 40441034171..62f59832481 100644 --- a/source/blender/blenkernel/intern/library_remap.c +++ b/source/blender/blenkernel/intern/library_remap.c @@ -378,6 +378,18 @@ static void libblock_remap_data_postprocess_obdata_relink(Main *UNUSED(bmain), O } } +static void libblock_remap_data_postprocess_nodetree_update(Main *bmain, ID *new_id) +{ + /* Verify all nodetree user nodes. */ + ntreeVerifyNodes(bmain, new_id); + + /* Update node trees as necessary. */ + FOREACH_NODETREE(bmain, ntree, id) { + /* make an update call for the tree */ + ntreeUpdateTree(bmain, ntree); + } FOREACH_NODETREE_END +} + /** * Execute the 'data' part of the remapping (that is, all ID pointers from other ID datablocks). * @@ -551,6 +563,8 @@ void BKE_libblock_remap_locked( default: break; } + /* Node trees may virtually use any kind of data-block... */ + libblock_remap_data_postprocess_nodetree_update(bmain, new_id); /* Full rebuild of DAG! */ DAG_relations_tag_update(bmain); -- cgit v1.2.3