Pass EvaluationContext argument everywhere
authorLuca Rood <dev@lucarood.com>
Fri, 21 Jul 2017 09:53:13 +0000 (11:53 +0200)
committerLuca Rood <dev@lucarood.com>
Fri, 21 Jul 2017 12:47:26 +0000 (14:47 +0200)
Note that some little parts of code have been dissabled because eval_ctx
was not available there. This should be resolved once DerivedMesh is
replaced.

281 files changed:
intern/cycles/blender/blender_curves.cpp
intern/cycles/blender/blender_mesh.cpp
intern/cycles/blender/blender_session.cpp
intern/cycles/blender/blender_session.h
intern/cycles/blender/blender_shader.cpp
intern/cycles/blender/blender_sync.cpp
intern/cycles/blender/blender_sync.h
intern/cycles/blender/blender_texture.cpp
intern/cycles/blender/blender_texture.h
intern/cycles/blender/blender_util.h
intern/itasc/FixedObject.hpp
intern/itasc/MovingFrame.cpp
intern/itasc/MovingFrame.hpp
intern/itasc/Scene.cpp
intern/itasc/Scene.hpp
intern/itasc/UncontrolledObject.hpp
intern/itasc/WorldObject.hpp
source/blender/alembic/intern/abc_camera.cc
source/blender/alembic/intern/abc_camera.h
source/blender/alembic/intern/abc_curves.cc
source/blender/alembic/intern/abc_curves.h
source/blender/alembic/intern/abc_exporter.cc
source/blender/alembic/intern/abc_exporter.h
source/blender/alembic/intern/abc_hair.cc
source/blender/alembic/intern/abc_hair.h
source/blender/alembic/intern/abc_mesh.cc
source/blender/alembic/intern/abc_mesh.h
source/blender/alembic/intern/abc_nurbs.cc
source/blender/alembic/intern/abc_nurbs.h
source/blender/alembic/intern/abc_object.cc
source/blender/alembic/intern/abc_object.h
source/blender/alembic/intern/abc_points.cc
source/blender/alembic/intern/abc_points.h
source/blender/alembic/intern/abc_transform.cc
source/blender/alembic/intern/abc_transform.h
source/blender/alembic/intern/alembic_capi.cc
source/blender/blenkernel/BKE_DerivedMesh.h
source/blender/blenkernel/BKE_anim.h
source/blender/blenkernel/BKE_armature.h
source/blender/blenkernel/BKE_cloth.h
source/blender/blenkernel/BKE_constraint.h
source/blender/blenkernel/BKE_context.h
source/blender/blenkernel/BKE_crazyspace.h
source/blender/blenkernel/BKE_curve.h
source/blender/blenkernel/BKE_data_transfer.h
source/blender/blenkernel/BKE_displist.h
source/blender/blenkernel/BKE_dynamicpaint.h
source/blender/blenkernel/BKE_editmesh.h
source/blender/blenkernel/BKE_effect.h
source/blender/blenkernel/BKE_fluidsim.h
source/blender/blenkernel/BKE_lattice.h
source/blender/blenkernel/BKE_mesh.h
source/blender/blenkernel/BKE_modifier.h
source/blender/blenkernel/BKE_multires.h
source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/BKE_paint.h
source/blender/blenkernel/BKE_particle.h
source/blender/blenkernel/BKE_rigidbody.h
source/blender/blenkernel/BKE_sequencer.h
source/blender/blenkernel/BKE_smoke.h
source/blender/blenkernel/BKE_softbody.h
source/blender/blenkernel/BKE_tracking.h
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/armature_update.c
source/blender/blenkernel/intern/boids.c
source/blender/blenkernel/intern/cloth.c
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/context.c
source/blender/blenkernel/intern/crazyspace.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/data_transfer.c
source/blender/blenkernel/intern/displist.c
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/editderivedmesh.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/fluidsim.c
source/blender/blenkernel/intern/lattice.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/modifier.c
source/blender/blenkernel/intern/multires.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/object_dupli.c
source/blender/blenkernel/intern/object_update.c
source/blender/blenkernel/intern/paint.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_child.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenkernel/intern/rigidbody.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/smoke.c
source/blender/blenkernel/intern/softbody.c
source/blender/collada/ArmatureExporter.cpp
source/blender/collada/ArmatureExporter.h
source/blender/collada/DocumentExporter.cpp
source/blender/collada/DocumentExporter.h
source/blender/collada/SceneExporter.cpp
source/blender/collada/SceneExporter.h
source/blender/collada/SkinInfo.cpp
source/blender/collada/TransformWriter.cpp
source/blender/collada/TransformWriter.h
source/blender/collada/collada.cpp
source/blender/collada/collada.h
source/blender/collada/collada_utils.cpp
source/blender/depsgraph/DEG_depsgraph.h
source/blender/depsgraph/DEG_depsgraph_build.h
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/depsgraph/intern/depsgraph_build.cc
source/blender/depsgraph/intern/eval/deg_eval.cc
source/blender/draw/engines/eevee/eevee_effects.c
source/blender/draw/modes/sculpt_mode.c
source/blender/editors/armature/armature_select.c
source/blender/editors/armature/armature_skinning.c
source/blender/editors/armature/editarmature_sketch.c
source/blender/editors/armature/pose_edit.c
source/blender/editors/armature/pose_lib.c
source/blender/editors/armature/pose_transform.c
source/blender/editors/armature/pose_utils.c
source/blender/editors/curve/editcurve.c
source/blender/editors/curve/editcurve_paint.c
source/blender/editors/curve/editfont.c
source/blender/editors/gpencil/gpencil_edit.c
source/blender/editors/gpencil/gpencil_paint.c
source/blender/editors/gpencil/gpencil_utils.c
source/blender/editors/include/ED_armature.h
source/blender/editors/include/ED_manipulator_library.h
source/blender/editors/include/ED_mesh.h
source/blender/editors/include/ED_object.h
source/blender/editors/include/ED_particle.h
source/blender/editors/include/ED_transform.h
source/blender/editors/include/ED_transform_snap_object_context.h
source/blender/editors/include/ED_view3d.h
source/blender/editors/interface/interface_eyedropper.c
source/blender/editors/io/io_collada.c
source/blender/editors/manipulator_library/manipulator_library_presets.c
source/blender/editors/mesh/editface.c
source/blender/editors/mesh/editmesh_knife.c
source/blender/editors/mesh/editmesh_knife_project.c
source/blender/editors/mesh/editmesh_loopcut.c
source/blender/editors/mesh/editmesh_path.c
source/blender/editors/mesh/editmesh_select.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/mesh_navmesh.c
source/blender/editors/mesh/meshtools.c
source/blender/editors/metaball/mball_edit.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_bake_api.c
source/blender/editors/object/object_constraint.c
source/blender/editors/object/object_data_transfer.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_hook.c
source/blender/editors/object/object_modifier.c
source/blender/editors/object/object_relations.c
source/blender/editors/object/object_transform.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/physics/dynamicpaint_ops.c
source/blender/editors/physics/particle_edit.c
source/blender/editors/physics/particle_object.c
source/blender/editors/physics/physics_fluid.c
source/blender/editors/render/render_opengl.c
source/blender/editors/render/render_shading.c
source/blender/editors/sculpt_paint/paint_hide.c
source/blender/editors/sculpt_paint/paint_image_proj.c
source/blender/editors/sculpt_paint/paint_intern.h
source/blender/editors/sculpt_paint/paint_mask.c
source/blender/editors/sculpt_paint/paint_utils.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/paint_vertex_proj.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/sculpt_paint/sculpt_undo.c
source/blender/editors/space_clip/tracking_ops_orient.c
source/blender/editors/space_outliner/outliner_edit.c
source/blender/editors/space_view3d/drawarmature.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_camera_control.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_draw_legacy.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_fly.c
source/blender/editors/space_view3d/view3d_intern.h
source/blender/editors/space_view3d/view3d_iterators.c
source/blender/editors/space_view3d/view3d_ruler.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/space_view3d/view3d_snap.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/space_view3d/view3d_walk.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_generics.c
source/blender/editors/transform/transform_snap.c
source/blender/editors/transform/transform_snap_object.c
source/blender/ikplugin/BIK_api.h
source/blender/ikplugin/intern/ikplugin_api.c
source/blender/ikplugin/intern/ikplugin_api.h
source/blender/ikplugin/intern/iksolver_plugin.c
source/blender/ikplugin/intern/iksolver_plugin.h
source/blender/ikplugin/intern/itasc_plugin.cpp
source/blender/ikplugin/intern/itasc_plugin.h
source/blender/makesrna/intern/rna_depsgraph.c
source/blender/makesrna/intern/rna_internal.h
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_object_api.c
source/blender/makesrna/intern/rna_particle.c
source/blender/makesrna/intern/rna_pose.c
source/blender/makesrna/intern/rna_render.c
source/blender/makesrna/intern/rna_scene_api.c
source/blender/makesrna/intern/rna_space_api.c
source/blender/makesrna/intern/rna_wm_manipulator_api.c
source/blender/modifiers/intern/MOD_armature.c
source/blender/modifiers/intern/MOD_array.c
source/blender/modifiers/intern/MOD_bevel.c
source/blender/modifiers/intern/MOD_boolean.c
source/blender/modifiers/intern/MOD_build.c
source/blender/modifiers/intern/MOD_cast.c
source/blender/modifiers/intern/MOD_cloth.c
source/blender/modifiers/intern/MOD_collision.c
source/blender/modifiers/intern/MOD_correctivesmooth.c
source/blender/modifiers/intern/MOD_curve.c
source/blender/modifiers/intern/MOD_datatransfer.c
source/blender/modifiers/intern/MOD_decimate.c
source/blender/modifiers/intern/MOD_displace.c
source/blender/modifiers/intern/MOD_dynamicpaint.c
source/blender/modifiers/intern/MOD_edgesplit.c
source/blender/modifiers/intern/MOD_explode.c
source/blender/modifiers/intern/MOD_fluidsim.c
source/blender/modifiers/intern/MOD_hook.c
source/blender/modifiers/intern/MOD_laplaciandeform.c
source/blender/modifiers/intern/MOD_laplaciansmooth.c
source/blender/modifiers/intern/MOD_lattice.c
source/blender/modifiers/intern/MOD_mask.c
source/blender/modifiers/intern/MOD_meshcache.c
source/blender/modifiers/intern/MOD_meshdeform.c
source/blender/modifiers/intern/MOD_meshsequencecache.c
source/blender/modifiers/intern/MOD_mirror.c
source/blender/modifiers/intern/MOD_multires.c
source/blender/modifiers/intern/MOD_normal_edit.c
source/blender/modifiers/intern/MOD_ocean.c
source/blender/modifiers/intern/MOD_particleinstance.c
source/blender/modifiers/intern/MOD_particlesystem.c
source/blender/modifiers/intern/MOD_remesh.c
source/blender/modifiers/intern/MOD_screw.c
source/blender/modifiers/intern/MOD_shapekey.c
source/blender/modifiers/intern/MOD_shrinkwrap.c
source/blender/modifiers/intern/MOD_simpledeform.c
source/blender/modifiers/intern/MOD_skin.c
source/blender/modifiers/intern/MOD_smoke.c
source/blender/modifiers/intern/MOD_smooth.c
source/blender/modifiers/intern/MOD_softbody.c
source/blender/modifiers/intern/MOD_solidify.c
source/blender/modifiers/intern/MOD_subsurf.c
source/blender/modifiers/intern/MOD_surface.c
source/blender/modifiers/intern/MOD_surfacedeform.c
source/blender/modifiers/intern/MOD_triangulate.c
source/blender/modifiers/intern/MOD_uvproject.c
source/blender/modifiers/intern/MOD_uvwarp.c
source/blender/modifiers/intern/MOD_warp.c
source/blender/modifiers/intern/MOD_wave.c
source/blender/modifiers/intern/MOD_weightvgmix.c
source/blender/modifiers/intern/MOD_weightvgproximity.c
source/blender/modifiers/intern/MOD_wireframe.c
source/blender/python/bmesh/bmesh_py_types.c
source/blender/python/intern/gpu_offscreen.c
source/blender/python/mathutils/mathutils_bvhtree.c
source/blender/render/extern/include/RE_engine.h
source/blender/render/extern/include/RE_pipeline.h
source/blender/render/extern/include/RE_render_ext.h
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/external_engine.c
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/pointdensity.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
source/blenderplayer/bad_level_call_stubs/stubs.c
source/gameengine/Converter/BL_ArmatureObject.cpp
source/gameengine/Converter/BL_BlenderDataConversion.cpp
source/gameengine/Converter/BL_ModifierDeformer.cpp
source/gameengine/Ketsji/KX_NavMeshObject.cpp

index 42b985305ea1f7e530c809473b8514f0087777f3..63b07936426d8ef778c76e4bcf2eca6227b0c4e9 100644 (file)
@@ -325,14 +325,14 @@ static bool ObtainCacheParticleVcol(Mesh *mesh,
        return true;
 }
 
-static void set_resolution(BL::Object *b_ob, BL::Scene *scene, bool render)
+static void set_resolution(BL::Object *b_ob, BL::Scene *scene, BL::SceneLayer *sl, bool render)
 {
        BL::Object::modifiers_iterator b_mod;
        for(b_ob->modifiers.begin(b_mod); b_mod != b_ob->modifiers.end(); ++b_mod) {
                if((b_mod->type() == b_mod->type_PARTICLE_SYSTEM) && ((b_mod->show_viewport()) || (b_mod->show_render()))) {
                        BL::ParticleSystemModifier psmd((const PointerRNA)b_mod->ptr);
                        BL::ParticleSystem b_psys((const PointerRNA)psmd.particle_system().ptr);
-                       b_psys.set_resolution(*scene, *b_ob, (render)? 2: 1);
+                       b_psys.set_resolution(*scene, *sl, *b_ob, (render)? 2: 1);
                }
        }
 }
@@ -912,7 +912,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
        ParticleCurveData CData;
 
        if(!preview)
-               set_resolution(&b_ob, &b_scene, true);
+               set_resolution(&b_ob, &b_scene, &b_scene_layer, true);
 
        ObtainCacheParticleData(mesh, &b_mesh, &b_ob, &CData, !preview);
 
@@ -1057,7 +1057,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
        }
 
        if(!preview)
-               set_resolution(&b_ob, &b_scene, false);
+               set_resolution(&b_ob, &b_scene, &b_scene_layer, false);
 
        mesh->compute_bounds();
 }
index f86b75f6643080ef4c2e3c734a64fe9fb719c2b5..2e3271c735fa62c53c3933ba0ec61ed0febdb41d 100644 (file)
@@ -1053,6 +1053,7 @@ Mesh *BlenderSync::sync_mesh(BL::Object& b_ob,
                BL::Mesh b_mesh = object_to_mesh(b_data,
                                                 b_ob,
                                                 b_scene,
+                                                b_scene_layer,
                                                 true,
                                                 !preview,
                                                 need_undeformed,
@@ -1184,6 +1185,7 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
                b_mesh = object_to_mesh(b_data,
                                        b_ob,
                                        b_scene,
+                                       b_scene_layer,
                                        true,
                                        !preview,
                                        false,
index bdc254d199514b6753e2a4a59b7eb2da631d62db..f4e9da4345479ff80a581948d6d3931e93aa1f54 100644 (file)
@@ -60,6 +60,7 @@ BlenderSession::BlenderSession(BL::RenderEngine& b_engine,
   b_render(b_engine.render()),
   b_depsgraph(b_depsgraph),
   b_scene(b_scene),
+  b_scene_layer(b_engine.scene_layer()),
   b_v3d(PointerRNA_NULL),
   b_rv3d(PointerRNA_NULL),
   python_thread_state(NULL)
@@ -89,6 +90,7 @@ BlenderSession::BlenderSession(BL::RenderEngine& b_engine,
   b_render(b_scene.render()),
   b_depsgraph(b_depsgraph),
   b_scene(b_scene),
+  b_scene_layer(b_engine.scene_layer()),
   b_v3d(b_v3d),
   b_rv3d(b_rv3d),
   width(width),
@@ -1301,7 +1303,7 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
                        BL::ShaderNodeTexPointDensity b_point_density_node(b_node);
                        int length;
                        int settings = background ? 1 : 0;  /* 1 - render settings, 0 - vewport settings. */
-                       b_point_density_node.calc_point_density(b_scene, settings, &length, &pixels);
+                       b_point_density_node.calc_point_density(b_scene, b_scene_layer, settings, &length, &pixels);
                }
        }
 
index 5edf44d087e2ba6f8a26b6f314fbb35896c59e27..7ae7bde1737038694e753535d8163e0917f83557 100644 (file)
@@ -108,6 +108,7 @@ public:
        BL::RenderSettings b_render;
        BL::Depsgraph b_depsgraph;
        BL::Scene b_scene;
+       BL::SceneLayer b_scene_layer;
        BL::SpaceView3D b_v3d;
        BL::RegionView3D b_rv3d;
        string b_rlay_name;
index 17e451807dc66d093541d0c10cb889b4d956b0b7..50202c3f2727fa00c54346709d642f7dfcce52b3 100644 (file)
@@ -243,6 +243,7 @@ static ShaderNode *add_node(Scene *scene,
                             BL::RenderEngine& b_engine,
                             BL::BlendData& b_data,
                             BL::Scene& b_scene,
+                            BL::SceneLayer b_scene_layer,
                             const bool background,
                             ShaderGraph *graph,
                             BL::ShaderNodeTree& b_ntree,
@@ -839,7 +840,7 @@ static ShaderNode *add_node(Scene *scene,
 
                /* TODO(sergey): Use more proper update flag. */
                if(true) {
-                       b_point_density_node.cache_point_density(b_scene, settings);
+                       b_point_density_node.cache_point_density(b_scene, b_scene_layer, settings);
                        scene->image_manager->tag_reload_image(
                                point_density->filename.string(),
                                point_density->builtin_data,
@@ -857,7 +858,7 @@ static ShaderNode *add_node(Scene *scene,
                BL::Object b_ob(b_point_density_node.object());
                if(b_ob) {
                        float3 loc, size;
-                       point_density_texture_space(b_scene,
+                       point_density_texture_space(b_scene, b_scene_layer,
                                                    b_point_density_node,
                                                    settings,
                                                    loc,
@@ -954,6 +955,7 @@ static void add_nodes(Scene *scene,
                       BL::RenderEngine& b_engine,
                       BL::BlendData& b_data,
                       BL::Scene& b_scene,
+                      BL::SceneLayer& b_scene_layer,
                       const bool background,
                       ShaderGraph *graph,
                       BL::ShaderNodeTree& b_ntree,
@@ -1044,6 +1046,7 @@ static void add_nodes(Scene *scene,
                                          b_engine,
                                          b_data,
                                          b_scene,
+                                         b_scene_layer,
                                          background,
                                          graph,
                                          b_group_ntree,
@@ -1093,6 +1096,7 @@ static void add_nodes(Scene *scene,
                                                b_engine,
                                                b_data,
                                                b_scene,
+                                               b_scene_layer,
                                                background,
                                                graph,
                                                b_ntree,
@@ -1156,6 +1160,7 @@ static void add_nodes(Scene *scene,
                       BL::RenderEngine& b_engine,
                       BL::BlendData& b_data,
                       BL::Scene& b_scene,
+                      BL::SceneLayer& b_scene_layer,
                       const bool background,
                       ShaderGraph *graph,
                       BL::ShaderNodeTree& b_ntree)
@@ -1165,6 +1170,7 @@ static void add_nodes(Scene *scene,
                  b_engine,
                  b_data,
                  b_scene,
+                 b_scene_layer,
                  background,
                  graph,
                  b_ntree,
@@ -1203,7 +1209,7 @@ void BlenderSync::sync_materials(bool update_all)
                        if(b_mat->use_nodes() && b_mat->node_tree()) {
                                BL::ShaderNodeTree b_ntree(b_mat->node_tree());
 
-                               add_nodes(scene, b_engine, b_data, b_scene, !preview, graph, b_ntree);
+                               add_nodes(scene, b_engine, b_data, b_scene, b_scene_layer, !preview, graph, b_ntree);
                        }
                        else {
                                DiffuseBsdfNode *diffuse = new DiffuseBsdfNode();
@@ -1274,7 +1280,7 @@ void BlenderSync::sync_world(bool update_all)
                if(b_world && b_world.use_nodes() && b_world.node_tree()) {
                        BL::ShaderNodeTree b_ntree(b_world.node_tree());
 
-                       add_nodes(scene, b_engine, b_data, b_scene, !preview, graph, b_ntree);
+                       add_nodes(scene, b_engine, b_data, b_scene, b_scene_layer, !preview, graph, b_ntree);
 
                        /* volume */
                        PointerRNA cworld = RNA_pointer_get(&b_world.ptr, "cycles");
@@ -1369,7 +1375,7 @@ void BlenderSync::sync_lamps(bool update_all)
 
                                BL::ShaderNodeTree b_ntree(b_lamp->node_tree());
 
-                               add_nodes(scene, b_engine, b_data, b_scene, !preview, graph, b_ntree);
+                               add_nodes(scene, b_engine, b_data, b_scene, b_scene_layer, !preview, graph, b_ntree);
                        }
                        else {
                                float strength = 1.0f;
index ab986766211796b1c121b75bef7f5949bdf7ce68..fd4498afdafccf8674876781e36a89aaf5ee69b5 100644 (file)
@@ -54,6 +54,7 @@ BlenderSync::BlenderSync(BL::RenderEngine& b_engine,
   b_data(b_data),
   b_depsgraph(b_depsgraph),
   b_scene(b_scene),
+  b_scene_layer(b_engine.scene_layer()),
   shader_map(&scene->shaders),
   object_map(&scene->objects),
   mesh_map(&scene->meshes),
index fda8cb390c2895af1bab96115dd7db29d943d136..69fee9551dd720ca10030a06833ef1e5815c7023 100644 (file)
@@ -43,6 +43,7 @@ class Mesh;
 class Object;
 class ParticleSystem;
 class Scene;
+class SceneLayer;
 class Shader;
 class ShaderGraph;
 class ShaderNode;
@@ -165,6 +166,7 @@ private:
        BL::BlendData b_data;
        BL::Depsgraph b_depsgraph;
        BL::Scene b_scene;
+       BL::SceneLayer b_scene_layer;
 
        id_map<void*, Shader> shader_map;
        id_map<ObjectKey, Object> object_map;
index b2e27b761897268b64104cf6bbd7284ca5557747..dd08be3ddc9b85fe0f09d4861c8a5f4dc262f12d 100644 (file)
@@ -34,7 +34,7 @@ void density_texture_space_invert(float3& loc,
 
 }  /* namespace */
 
-void point_density_texture_space(BL::Scene& b_scene,
+void point_density_texture_space(BL::Scene& b_scene, BL::SceneLayer& b_scene_layer,
                                  BL::ShaderNodeTexPointDensity& b_point_density_node,
                                  int settings,
                                  float3& loc,
@@ -48,6 +48,7 @@ void point_density_texture_space(BL::Scene& b_scene,
        }
        float3 min, max;
        b_point_density_node.calc_point_density_minmax(b_scene,
+                                                      b_scene_layer,
                                                       settings,
                                                       &min[0],
                                                       &max[0]);
index 734231a85ec2b8a536ba6aa774c4852530776d7a..c343d5dab92e04418ebab4c889e4678e23a7fdc1 100644 (file)
@@ -22,7 +22,7 @@
 
 CCL_NAMESPACE_BEGIN
 
-void point_density_texture_space(BL::Scene& b_scene,
+void point_density_texture_space(BL::Scene& b_scene, BL::SceneLayer& b_scene_layer,
                                  BL::ShaderNodeTexPointDensity& b_point_density_node,
                                  const int settings,
                                  float3& loc,
index 363e19f7a20b6585961d537cec4c5f05f2be3398..314bcaf23c4051b37cb62249e8e32c8c000819f1 100644 (file)
@@ -46,6 +46,7 @@ void python_thread_state_restore(void **python_thread_state);
 static inline BL::Mesh object_to_mesh(BL::BlendData& data,
                                       BL::Object& object,
                                       BL::Scene& scene,
+                                      BL::SceneLayer scene_layer,
                                       bool apply_modifiers,
                                       bool render,
                                       bool calc_undeformed,
@@ -64,7 +65,7 @@ static inline BL::Mesh object_to_mesh(BL::BlendData& data,
                subsurf_mod.show_viewport(false);
        }
 
-       BL::Mesh me = data.meshes.new_from_object(scene, object, apply_modifiers, (render)? 2: 1, false, calc_undeformed);
+       BL::Mesh me = data.meshes.new_from_object(scene, scene_layer, object, apply_modifiers, (render)? 2: 1, false, calc_undeformed);
 
        if(subdivision_type != Mesh::SUBDIVISION_NONE) {
                BL::Modifier subsurf_mod = object.modifiers[object.modifiers.length()-1];
index ad26e7cb2d605431ea9d764fb96e219f0fceb669..02c1804073c4e1f37ad0b051c4768de372b075e3 100644 (file)
@@ -21,7 +21,7 @@ public:
 
        int addFrame(const std::string& name, const Frame& frame);
 
-       virtual void updateCoordinates(const Timestamp& timestamp) {};
+       virtual void updateCoordinates(struct EvaluationContext *eval_ctx, const Timestamp& timestamp) {};
        virtual int addEndEffector(const std::string& name);
        virtual bool finalize();
        virtual const Frame& getPose(const unsigned int frameIndex);
index 90ebe091eb53f730bdaf9a5e48cb8826cb3f2fb7..b1815ddd0de175477e3acab4650a886d178060c2 100644 (file)
@@ -90,7 +90,7 @@ bool MovingFrame::setCallback(MovingFrameCallback _function, void* _param)
        return true;
 }
 
-void MovingFrame::updateCoordinates(const Timestamp& timestamp)
+void MovingFrame::updateCoordinates(struct EvaluationContext *eval_ctx, const Timestamp& timestamp)
 {
        // don't compute the velocity during substepping, it is assumed constant.
        if (!timestamp.substep) {
@@ -98,7 +98,7 @@ void MovingFrame::updateCoordinates(const Timestamp& timestamp)
                if (!timestamp.reiterate) {
                        cacheAvail = popInternalFrame(timestamp.cacheTimestamp);
                        if (m_function)
-                               (*m_function)(timestamp, m_internalPose, m_nextPose, m_param);
+                               (*m_function)(eval_ctx, timestamp, m_internalPose, m_nextPose, m_param);
                }
                // only compute velocity if we have a previous pose
                if (cacheAvail && timestamp.interpolate) {
index d2a956d73122b7b37abfd4e81d0ee9d2aa954aef..89519832840dacfe5aa980c4e51c0dcf323f74d8 100644 (file)
 #include "UncontrolledObject.hpp"
 #include <vector>
 
+struct EvaluationContext;
 
 namespace iTaSC{
 
-typedef bool (*MovingFrameCallback)(const Timestamp& timestamp, const Frame& _current, Frame& _next, void *param);
+typedef bool (*MovingFrameCallback)(struct EvaluationContext *eval_ctx, const Timestamp& timestamp, const Frame& _current, Frame& _next, void *param);
 
 class MovingFrame: public UncontrolledObject {
 public:
@@ -24,7 +25,7 @@ public:
        bool setFrame(const Frame& frame);
        bool setCallback(MovingFrameCallback _function, void* _param);
 
-       virtual void updateCoordinates(const Timestamp& timestamp);
+       virtual void updateCoordinates(struct EvaluationContext *eval_ctx, const Timestamp& timestamp);
        virtual void updateKinematics(const Timestamp& timestamp);
     virtual void pushCache(const Timestamp& timestamp);
        virtual void initCache(Cache *_cache);
index 5768a994970fe989b220e0ae84fd752fb89841d3..fd8b006d19c40ead041e0c65de72fe81ba1df255 100644 (file)
@@ -257,7 +257,7 @@ bool Scene::getConstraintPose(ConstraintSet* constraint, void *_param, KDL::Fram
        return true;
 }
 
-bool Scene::update(double timestamp, double timestep, unsigned int numsubstep, bool reiterate, bool cache, bool interpolate)
+bool Scene::update(struct EvaluationContext *eval_ctx, double timestamp, double timestep, unsigned int numsubstep, bool reiterate, bool cache, bool interpolate)
 {
        // we must have valid timestep and timestamp
        if (timestamp < KDL::epsilon || timestep < 0.0)
@@ -316,7 +316,7 @@ bool Scene::update(double timestamp, double timestep, unsigned int numsubstep, b
                                }
                        }
                        if (os->object->getType()==Object::UnControlled && ((UncontrolledObject*)os->object)->getNrOfCoordinates() != 0) {
-                   ((UncontrolledObject*)(os->object))->updateCoordinates(ts);
+                   ((UncontrolledObject*)(os->object))->updateCoordinates(eval_ctx, ts);
                                if (!ts.substep) {
                                        // velocity of uncontrolled object remains constant during substepping
                                        project(m_xdot,os->coordinaterange) = ((UncontrolledObject*)(os->object))->getXudot();
index 5ed031b543e829e944a4374ad29f76f9ba22ddee..0039be07584451b8309e3fb2afc14308683e1362 100644 (file)
@@ -39,7 +39,7 @@ public:
     bool addSolver(Solver* _solver);
     bool addCache(Cache* _cache);
     bool initialize();
-    bool update(double timestamp, double timestep, unsigned int numsubstep=1, bool reiterate=false, bool cache=true, bool interpolate=true);
+    bool update(struct EvaluationContext *eval_ctx, double timestamp, double timestep, unsigned int numsubstep=1, bool reiterate=false, bool cache=true, bool interpolate=true);
        bool setParam(SceneParam paramId, double value);
 
        EIGEN_MAKE_ALIGNED_OPERATOR_NEW
index 81445538fa651320288c311fd56fd84ecb8ced03..889bc742c6da1a82b1aebefebc6513912a31afd6 100644 (file)
@@ -11,6 +11,9 @@
 #include "eigen_types.hpp"
 
 #include "Object.hpp"
+
+struct EvaluationContext;
+
 namespace iTaSC{
 
 class UncontrolledObject: public Object {
@@ -26,7 +29,7 @@ public:
        virtual void initialize(unsigned int _nu, unsigned int _nf);
        virtual const e_matrix& getJu(unsigned int frameIndex) const;
     virtual const e_vector& getXudot() const {return m_xudot;}
-       virtual void updateCoordinates(const Timestamp& timestamp)=0;
+       virtual void updateCoordinates(struct EvaluationContext *eval_ctx, const Timestamp& timestamp)=0;
     virtual const unsigned int getNrOfCoordinates(){return m_nu;};
     virtual const unsigned int getNrOfFrames(){return m_nf;};
 
index 99756dcd6847a38ff8a615475b25d53b48aab99a..b992445ab10afdf836ad5fd291dbad0490bc6162 100644 (file)
@@ -16,7 +16,7 @@ public:
     WorldObject();
     virtual ~WorldObject();
 
-       virtual void updateCoordinates(const Timestamp& timestamp) {};
+       virtual void updateCoordinates(struct EvaluationContext *eval_ctx, const Timestamp& timestamp) {};
        virtual void updateKinematics(const Timestamp& timestamp) {};
        virtual void pushCache(const Timestamp& timestamp) {};
        virtual void initCache(Cache *_cache) {};
index 16416205983a88425380f2cf7443cbb917c30707..aa5d77ce4ec85ed01e8ac4dc70653c21e2712e98 100644 (file)
@@ -49,12 +49,13 @@ using Alembic::AbcGeom::kWrapExisting;
 
 /* ************************************************************************** */
 
-AbcCameraWriter::AbcCameraWriter(Scene *scene,
+AbcCameraWriter::AbcCameraWriter(EvaluationContext *eval_ctx,
+                                 Scene *scene,
                                  Object *ob,
                                  AbcTransformWriter *parent,
                                  uint32_t time_sampling,
                                  ExportSettings &settings)
-    : AbcObjectWriter(scene, ob, time_sampling, settings, parent)
+    : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
 {
        OCamera camera(parent->alembicXform(), m_name, m_time_sampling);
        m_camera_schema = camera.getSchema();
index 16c5cccd5ea51bab098046bfcc5395b16e0ebfa7..772b7a6aec63aeec4a4429a314893644147db5a5 100644 (file)
@@ -35,7 +35,8 @@ class AbcCameraWriter : public AbcObjectWriter {
        Alembic::AbcGeom::OFloatProperty m_eye_separation;
 
 public:
-       AbcCameraWriter(Scene *scene,
+       AbcCameraWriter(EvaluationContext *eval_ctx,
+                       Scene *scene,
                        Object *ob,
                        AbcTransformWriter *parent,
                        uint32_t time_sampling,
index f73fe957fea8a7a278ed4f75a1f8998a6c62d537..5328c4710933b335091bce3d3ea01474b8934fd5 100644 (file)
@@ -71,12 +71,13 @@ using Alembic::AbcGeom::OV2fGeomParam;
 
 /* ************************************************************************** */
 
-AbcCurveWriter::AbcCurveWriter(Scene *scene,
+AbcCurveWriter::AbcCurveWriter(EvaluationContext *eval_ctx,
+                               Scene *scene,
                                Object *ob,
                                AbcTransformWriter *parent,
                                uint32_t time_sampling,
                                ExportSettings &settings)
-    : AbcObjectWriter(scene, ob, time_sampling, settings, parent)
+    : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
 {
        OCurves curves(parent->alembicXform(), m_name, m_time_sampling);
        m_schema = curves.getSchema();
index a9231f947b23d0f869ce1d1555c87d687b2bc337..73cc8b35e279f5ba023daa19988f6715cf061feb 100644 (file)
@@ -36,7 +36,8 @@ class AbcCurveWriter : public AbcObjectWriter {
        Alembic::AbcGeom::OCurvesSchema::Sample m_sample;
 
 public:
-       AbcCurveWriter(Scene *scene,
+       AbcCurveWriter(EvaluationContext *eval_ctx,
+                      Scene *scene,
                       Object *ob,
                       AbcTransformWriter *parent,
                       uint32_t time_sampling,
index 680913e45eae564e6ba0aa0a591a13f3a9352674..df2bc52aa2c42f4f5e13861308b95b170a126e7f 100644 (file)
@@ -163,11 +163,12 @@ static bool export_object(const ExportSettings * const settings, const Base * co
 
 /* ************************************************************************** */
 
-AbcExporter::AbcExporter(Scene *scene, const char *filename, ExportSettings &settings)
+AbcExporter::AbcExporter(EvaluationContext *eval_ctx, Scene *scene, const char *filename, ExportSettings &settings)
     : m_settings(settings)
     , m_filename(filename)
     , m_trans_sampling_index(0)
     , m_shape_sampling_index(0)
+    , m_eval_ctx(eval_ctx)
     , m_scene(scene)
     , m_writer(NULL)
 {}
@@ -383,7 +384,7 @@ void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, O
        }
 
        if (object_type_is_exportable(ob)) {
-               createTransformWriter(ob, parent, dupliObParent);
+               createTransformWriter(eval_ctx, ob, parent, dupliObParent);
        }
 
        ListBase *lb = object_duplilist(eval_ctx, m_scene, ob);
@@ -415,7 +416,7 @@ void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, O
        free_object_duplilist(lb);
 }
 
-AbcTransformWriter * AbcExporter::createTransformWriter(Object *ob, Object *parent, Object *dupliObParent)
+AbcTransformWriter * AbcExporter::createTransformWriter(EvaluationContext *eval_ctx, Object *ob, Object *parent, Object *dupliObParent)
 {
        /* An object should not be its own parent, or we'll get infinite loops. */
        BLI_assert(ob != parent);
@@ -450,29 +451,29 @@ AbcTransformWriter * AbcExporter::createTransformWriter(Object *ob, Object *pare
                 * return the parent's AbcTransformWriter pointer. */
                if (parent->parent) {
                        if (parent == dupliObParent) {
-                               parent_writer = createTransformWriter(parent, parent->parent, NULL);
+                               parent_writer = createTransformWriter(eval_ctx, parent, parent->parent, NULL);
                        }
                        else {
-                               parent_writer = createTransformWriter(parent, parent->parent, dupliObParent);
+                               parent_writer = createTransformWriter(eval_ctx, parent, parent->parent, dupliObParent);
                        }
                }
                else if (parent == dupliObParent) {
                        if (dupliObParent->parent == NULL) {
-                               parent_writer = createTransformWriter(parent, NULL, NULL);
+                               parent_writer = createTransformWriter(eval_ctx, parent, NULL, NULL);
                        }
                        else {
-                               parent_writer = createTransformWriter(parent, dupliObParent->parent, dupliObParent->parent);
+                               parent_writer = createTransformWriter(eval_ctx, parent, dupliObParent->parent, dupliObParent->parent);
                        }
                }
                else {
-                       parent_writer = createTransformWriter(parent, dupliObParent, dupliObParent);
+                       parent_writer = createTransformWriter(eval_ctx, parent, dupliObParent, dupliObParent);
                }
 
                BLI_assert(parent_writer);
                alembic_parent = parent_writer->alembicXform();
        }
 
-       my_writer = new AbcTransformWriter(ob, alembic_parent, parent_writer,
+       my_writer = new AbcTransformWriter(eval_ctx, ob, alembic_parent, parent_writer,
                                           m_trans_sampling_index, m_settings);
 
        /* When flattening, the matrix of the dupliobject has to be added. */
@@ -540,10 +541,10 @@ void AbcExporter::createParticleSystemsWriters(Object *ob, AbcTransformWriter *x
 
                if (m_settings.export_hair && psys->part->type == PART_HAIR) {
                        m_settings.export_child_hairs = true;
-                       m_shapes.push_back(new AbcHairWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
+                       m_shapes.push_back(new AbcHairWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
                }
                else if (m_settings.export_particles && psys->part->type == PART_EMITTER) {
-                       m_shapes.push_back(new AbcPointsWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
+                       m_shapes.push_back(new AbcPointsWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
                }
        }
 }
@@ -583,7 +584,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
                                return;
                        }
 
-                       m_shapes.push_back(new AbcMeshWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings));
+                       m_shapes.push_back(new AbcMeshWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings));
                        break;
                }
                case OB_SURF:
@@ -594,7 +595,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
                                return;
                        }
 
-                       m_shapes.push_back(new AbcNurbsWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings));
+                       m_shapes.push_back(new AbcNurbsWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings));
                        break;
                }
                case OB_CURVE:
@@ -605,7 +606,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
                                return;
                        }
 
-                       m_shapes.push_back(new AbcCurveWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings));
+                       m_shapes.push_back(new AbcCurveWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings));
                        break;
                }
                case OB_CAMERA:
@@ -613,7 +614,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
                        Camera *cam = static_cast<Camera *>(ob->data);
 
                        if (cam->type == CAM_PERSP) {
-                               m_shapes.push_back(new AbcCameraWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings));
+                               m_shapes.push_back(new AbcCameraWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings));
                        }
 
                        break;
index 15158a9ef51eebf60b55a27403cbb9244cb05708..9c5fb69234c323f30deb791302b3dcda6aa84300 100644 (file)
@@ -90,6 +90,7 @@ class AbcExporter {
 
        unsigned int m_trans_sampling_index, m_shape_sampling_index;
 
+       EvaluationContext *m_eval_ctx;
        Scene *m_scene;
 
        ArchiveWriter *m_writer;
@@ -101,7 +102,7 @@ class AbcExporter {
        std::vector<AbcObjectWriter *> m_shapes;
 
 public:
-       AbcExporter(Scene *scene, const char *filename, ExportSettings &settings);
+       AbcExporter(EvaluationContext *eval_ctx, Scene *scene, const char *filename, ExportSettings &settings);
        ~AbcExporter();
 
        void operator()(Main *bmain, float &progress, bool &was_canceled);
@@ -116,7 +117,7 @@ private:
        Alembic::Abc::TimeSamplingPtr createTimeSampling(double step);
 
        void createTransformWritersHierarchy(EvaluationContext *eval_ctx);
-       AbcTransformWriter * createTransformWriter(Object *ob,  Object *parent, Object *dupliObParent);
+       AbcTransformWriter * createTransformWriter(EvaluationContext *eval_ctx, Object *ob,  Object *parent, Object *dupliObParent);
        void exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, Object *parent, Object *dupliObParent);
        void exploreObject(EvaluationContext *eval_ctx, Base *ob_base, Object *dupliObParent);
        void createShapeWriters(EvaluationContext *eval_ctx);
index 8f8ed2019d5dd0bbd3e32c8c378cb52e7912af3c..2579aa3cc3640af4bd88199a47ba22e1eb3ebb57 100644 (file)
@@ -49,13 +49,14 @@ using Alembic::AbcGeom::OV2fGeomParam;
 
 /* ************************************************************************** */
 
-AbcHairWriter::AbcHairWriter(Scene *scene,
+AbcHairWriter::AbcHairWriter(EvaluationContext *eval_ctx,
+                             Scene *scene,
                              Object *ob,
                              AbcTransformWriter *parent,
                              uint32_t time_sampling,
                              ExportSettings &settings,
                              ParticleSystem *psys)
-    : AbcObjectWriter(scene, ob, time_sampling, settings, parent)
+    : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
     , m_uv_warning_shown(false)
 {
        m_psys = psys;
@@ -76,7 +77,7 @@ void AbcHairWriter::do_write()
                return;
        }
 
-       DerivedMesh *dm = mesh_create_derived_render(m_scene, m_object, CD_MASK_MESH);
+       DerivedMesh *dm = mesh_create_derived_render(m_eval_ctx, m_scene, m_object, CD_MASK_MESH);
        DM_ensure_tessface(dm);
 
        std::vector<Imath::V3f> verts;
index 61f5fe361f851c3d645aa9b4769e32bad7e916be..8190c449205539438bee52c2ff4e95919c3a0cca 100644 (file)
@@ -40,7 +40,8 @@ class AbcHairWriter : public AbcObjectWriter {
        bool m_uv_warning_shown;
 
 public:
-       AbcHairWriter(Scene *scene,
+       AbcHairWriter(EvaluationContext *eval_ctx,
+                     Scene *scene,
                      Object *ob,
                      AbcTransformWriter *parent,
                      uint32_t time_sampling,
index bc62db5702c0874a950f7719ae0ad189aef3cbd7..25cf5f49b14d64c174db022d12e0ac1d72579a28 100644 (file)
@@ -286,12 +286,13 @@ static ModifierData *get_liquid_sim_modifier(Scene *scene, Object *ob)
 
 /* ************************************************************************** */
 
-AbcMeshWriter::AbcMeshWriter(Scene *scene,
+AbcMeshWriter::AbcMeshWriter(EvaluationContext *eval_ctx,
+                             Scene *scene,
                              Object *ob,
                              AbcTransformWriter *parent,
                              uint32_t time_sampling,
                              ExportSettings &settings)
-    : AbcObjectWriter(scene, ob, time_sampling, settings, parent)
+    : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
 {
        m_is_animated = isAnimated();
        m_subsurf_mod = NULL;
@@ -519,7 +520,7 @@ DerivedMesh *AbcMeshWriter::getFinalMesh()
                m_subsurf_mod->mode |= eModifierMode_DisableTemporary;
        }
 
-       DerivedMesh *dm = mesh_create_derived_render(m_scene, m_object, CD_MASK_MESH);
+       DerivedMesh *dm = mesh_create_derived_render(m_eval_ctx, m_scene, m_object, CD_MASK_MESH);
 
        if (m_subsurf_mod) {
                m_subsurf_mod->mode &= ~eModifierMode_DisableTemporary;
index 6bf1dde3d1dc47ce629ea24fea5d424fdd418305..941407d220858a8c535be8a86c121fc4a6825831 100644 (file)
@@ -50,7 +50,8 @@ class AbcMeshWriter : public AbcObjectWriter {
        bool m_is_subd;
 
 public:
-       AbcMeshWriter(Scene *scene,
+       AbcMeshWriter(EvaluationContext *eval_ctx,
+                     Scene *scene,
                      Object *ob,
                      AbcTransformWriter *parent,
                      uint32_t time_sampling,
index eaef06fd6d11022a6ba358dab7a5d77c83b47e9f..0532191a28dd6324debda0311ec7a5f1c1e094d0 100644 (file)
@@ -60,12 +60,13 @@ using Alembic::AbcGeom::ONuPatchSchema;
 
 /* ************************************************************************** */
 
-AbcNurbsWriter::AbcNurbsWriter(Scene *scene,
+AbcNurbsWriter::AbcNurbsWriter(EvaluationContext *eval_ctx,
+                               Scene *scene,
                                Object *ob,
                                AbcTransformWriter *parent,
                                uint32_t time_sampling,
                                ExportSettings &settings)
-    : AbcObjectWriter(scene, ob, time_sampling, settings, parent)
+    : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
 {
        m_is_animated = isAnimated();
 
index abe460a89882027a415851740dc0dda68aedaca6..3d20c5c60bb9af263081bec263bff6aa260c4bb0 100644 (file)
@@ -32,7 +32,8 @@ class AbcNurbsWriter : public AbcObjectWriter {
        bool m_is_animated;
 
 public:
-       AbcNurbsWriter(Scene *scene,
+       AbcNurbsWriter(EvaluationContext *eval_ctx,
+                      Scene *scene,
                       Object *ob,
                       AbcTransformWriter *parent,
                       uint32_t time_sampling,
index 9f8960c827fe708898c2f0fd67d00cb040b2c42c..98ebcf6debb23e8821fc2d3e225084373bed8114 100644 (file)
@@ -58,13 +58,15 @@ using Alembic::AbcGeom::OStringProperty;
 
 /* ************************************************************************** */
 
-AbcObjectWriter::AbcObjectWriter(Scene *scene,
+AbcObjectWriter::AbcObjectWriter(EvaluationContext *eval_ctx,
+                                 Scene *scene,
                                  Object *ob,
                                  uint32_t time_sampling,
                                  ExportSettings &settings,
                                  AbcObjectWriter *parent)
     : m_object(ob)
     , m_settings(settings)
+    , m_eval_ctx(eval_ctx)
     , m_scene(scene)
     , m_time_sampling(time_sampling)
     , m_first_frame(true)
index 852ef451f236f50aac42e5c7d031b43940f58d22..6aa6224f8d5d41d0866ab89927679e13965c3d23 100644 (file)
@@ -44,6 +44,7 @@ protected:
        Object *m_object;
        ExportSettings &m_settings;
 
+       EvaluationContext *m_eval_ctx;
        Scene *m_scene;
        uint32_t m_time_sampling;
 
@@ -56,7 +57,8 @@ protected:
        std::string m_name;
 
 public:
-       AbcObjectWriter(Scene *scene,
+       AbcObjectWriter(EvaluationContext *eval_ctx,
+                       Scene *scene,
                        Object *ob,
                        uint32_t time_sampling,
                        ExportSettings &settings,
index 80567cd6bf0ac81b43629827322a385717880698..feb2eff5b9d0723222ee6c944dbaabf93cabf945 100644 (file)
@@ -58,13 +58,14 @@ using Alembic::AbcGeom::OPointsSchema;
 
 /* ************************************************************************** */
 
-AbcPointsWriter::AbcPointsWriter(Scene *scene,
+AbcPointsWriter::AbcPointsWriter(EvaluationContext *eval_ctx,
+                                 Scene *scene,
                                  Object *ob,
                                     AbcTransformWriter *parent,
                                     uint32_t time_sampling,
                                     ExportSettings &settings,
                                     ParticleSystem *psys)
-    : AbcObjectWriter(scene, ob, time_sampling, settings, parent)
+    : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
 {
        m_psys = psys;
 
@@ -86,6 +87,7 @@ void AbcPointsWriter::do_write()
        ParticleKey state;
 
        ParticleSimulationData sim;
+       sim.eval_ctx = m_eval_ctx;
        sim.scene = m_scene;
        sim.ob = m_object;
        sim.psys = m_psys;
index 369a802d763caecbf236441c1eab9e4ba0ee633a..b60f1997aa8cf01750b60087205969fe63bae1d6 100644 (file)
@@ -38,7 +38,8 @@ class AbcPointsWriter : public AbcObjectWriter {
        ParticleSystem *m_psys;
 
 public:
-       AbcPointsWriter(Scene *scene,
+       AbcPointsWriter(EvaluationContext *eval_ctx,
+                       Scene *scene,
                        Object *ob,
                        AbcTransformWriter *parent,
                        uint32_t time_sampling,
index 5392387663ff63b7ea05d34fd3cf1d1bb74fee25..0a1480e62b06a5c46bc3b8af9496a4453d4ccc35 100644 (file)
@@ -57,12 +57,13 @@ static bool has_parent_camera(Object *ob)
 
 /* ************************************************************************** */
 
-AbcTransformWriter::AbcTransformWriter(Object *ob,
+AbcTransformWriter::AbcTransformWriter(EvaluationContext *eval_ctx,
+                                       Object *ob,
                                        const OObject &abc_parent,
                                        AbcTransformWriter *parent,
                                        unsigned int time_sampling,
                                        ExportSettings &settings)
-    : AbcObjectWriter(NULL, ob, time_sampling, settings, parent)
+    : AbcObjectWriter(eval_ctx, NULL, ob, time_sampling, settings, parent)
     , m_proxy_from(NULL)
 {
        m_is_animated = hasAnimation(m_object);
index 753a4247e9fa3a1cb01aaa5da5c2ac85b7f0b496..e82765cb169d89967d45e9dd2c185893e19189be 100644 (file)
@@ -44,7 +44,8 @@ public:
        Object *m_proxy_from;
 
 public:
-       AbcTransformWriter(Object *ob,
+       AbcTransformWriter(EvaluationContext *eval_ctx,
+                          Object *ob,
                           const Alembic::AbcGeom::OObject &abc_parent,
                           AbcTransformWriter *parent,
                           unsigned int time_sampling,
index 692fc203706ddd0f07bb0c01291122e31d97a62c..97a269b8fc0f033f5662e027d3321612e5ae1d8d 100644 (file)
@@ -230,6 +230,7 @@ static void find_iobject(const IObject &object, IObject &ret,
 }
 
 struct ExportJobData {
+       EvaluationContext eval_ctx;
        Scene *scene;
        Main *bmain;
 
@@ -262,7 +263,7 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo
 
        try {
                Scene *scene = data->scene;
-               AbcExporter exporter(scene, data->filename, data->settings);
+               AbcExporter exporter(&data->eval_ctx, scene, data->filename, data->settings);
 
                const int orig_frame = CFRA;
 
@@ -310,6 +311,9 @@ bool ABC_export(
         bool as_background_job)
 {
        ExportJobData *job = static_cast<ExportJobData *>(MEM_mallocN(sizeof(ExportJobData), "ExportJobData"));
+
+       CTX_data_eval_ctx(C, &job->eval_ctx);
+
        job->scene = scene;
        job->bmain = CTX_data_main(C);
        job->export_ok = false;
index 78c2efcc8a277edcafb76fcbe00ced5205169b86..63b5dc68875d24b01c2f6a148d2521da1c40ff40 100644 (file)
@@ -98,6 +98,7 @@ struct ColorBand;
 struct GPUVertexAttribs;
 struct GPUDrawObject;
 struct PBVH;
+struct EvaluationContext;
 
 /* number of sub-elements each mesh element has (for interpolation) */
 #define SUB_ELEMS_VERT 0
@@ -658,56 +659,56 @@ void mesh_get_mapped_verts_coords(DerivedMesh *dm, float (*r_cos)[3], const int
 
 /* */
 DerivedMesh *mesh_get_derived_final(
-        struct Scene *scene, struct Object *ob,
-        CustomDataMask dataMask);
+        struct EvaluationContext *eval_ctx, struct Scene *scene,
+        struct Object *ob, CustomDataMask dataMask);
 DerivedMesh *mesh_get_derived_deform(
-        struct Scene *scene, struct Object *ob,
-        CustomDataMask dataMask);
+        struct EvaluationContext *eval_ctx, struct Scene *scene,
+        struct Object *ob, CustomDataMask dataMask);
 
 DerivedMesh *mesh_create_derived_for_modifier(
-        struct Scene *scene, struct Object *ob,
+        struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
         struct ModifierData *md, int build_shapekey_layers);
 
 DerivedMesh *mesh_create_derived_render(
-        struct Scene *scene, struct Object *ob,
-        CustomDataMask dataMask);
+        struct EvaluationContext *eval_ctx, struct Scene *scene,
+        struct Object *ob, CustomDataMask dataMask);
 
 DerivedMesh *getEditDerivedBMesh(
         struct BMEditMesh *em, struct Object *ob, CustomDataMask data_mask,
         float (*vertexCos)[3]);
 
 DerivedMesh *mesh_create_derived_index_render(
-        struct Scene *scene, struct Object *ob,
-        CustomDataMask dataMask, int index);
+        struct EvaluationContext *eval_ctx, struct Scene *scene,
+        struct Object *ob, CustomDataMask dataMask, int index);
 
 /* same as above but wont use render settings */
 DerivedMesh *mesh_create_derived(struct Mesh *me, float (*vertCos)[3]);
 DerivedMesh *mesh_create_derived_view(
-        struct Scene *scene, struct Object *ob,
-        CustomDataMask dataMask);
+        struct EvaluationContext *eval_ctx, struct Scene *scene,
+        struct Object *ob, CustomDataMask dataMask);
 DerivedMesh *mesh_create_derived_no_deform(
-        struct Scene *scene, struct Object *ob,
-        float (*vertCos)[3],
+        struct EvaluationContext *eval_ctx, struct Scene *scene,
+        struct Object *ob, float (*vertCos)[3],
         CustomDataMask dataMask);
 DerivedMesh *mesh_create_derived_no_deform_render(
-        struct Scene *scene, struct Object *ob,
-        float (*vertCos)[3],
+        struct EvaluationContext *eval_ctx, struct Scene *scene,
+        struct Object *ob, float (*vertCos)[3],
         CustomDataMask dataMask);
 /* for gameengine */
 DerivedMesh *mesh_create_derived_no_virtual(
-        struct Scene *scene, struct Object *ob, float (*vertCos)[3],
-        CustomDataMask dataMask);
+        struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
+        float (*vertCos)[3], CustomDataMask dataMask);
 DerivedMesh *mesh_create_derived_physics(
-        struct Scene *scene, struct Object *ob, float (*vertCos)[3],
-        CustomDataMask dataMask);
+        struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
+        float (*vertCos)[3], CustomDataMask dataMask);
 
 DerivedMesh *editbmesh_get_derived_base(
         struct Object *ob, struct BMEditMesh *em, CustomDataMask data_mask);
 DerivedMesh *editbmesh_get_derived_cage(
-        struct Scene *scene, struct Object *,
+        struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *,
         struct BMEditMesh *em, CustomDataMask dataMask);
 DerivedMesh *editbmesh_get_derived_cage_and_final(
-        struct Scene *scene, struct Object *,
+        struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *,
         struct BMEditMesh *em, CustomDataMask dataMask,
         DerivedMesh **r_final);
 
@@ -716,7 +717,7 @@ DerivedMesh *object_get_derived_final(struct Object *ob, const bool for_render);
 float (*editbmesh_get_vertex_cos(struct BMEditMesh *em, int *r_numVerts))[3];
 bool editbmesh_modifier_is_enabled(struct Scene *scene, struct ModifierData *md, DerivedMesh *dm);
 void makeDerivedMesh(
-        struct Scene *scene, struct Object *ob, struct BMEditMesh *em,
+        struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct BMEditMesh *em,
         CustomDataMask dataMask, const bool build_shapekey_layers);
 
 void weight_to_rgb(float r_rgb[3], const float weight);
index 584f0da323aef29aa7bd9d9434b21cb10fee7710..ef8a1c7e417cdbbfd534bbeb3736135af055ee8d 100644 (file)
@@ -41,6 +41,7 @@ struct bAnimVizSettings;
 struct bMotionPath;
 struct bPoseChannel;
 struct ReportList;
+struct bContext;
 
 /* ---------------------------------------------------- */
 /* Animation Visualization */
@@ -53,7 +54,7 @@ void animviz_free_motionpath(struct bMotionPath *mpath);
 struct bMotionPath *animviz_verify_motionpaths(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan);
 
 void animviz_get_object_motionpaths(struct Object *ob, ListBase *targets);
-void animviz_calc_motionpaths(struct Scene *scene, ListBase *targets);
+void animviz_calc_motionpaths(struct bContext *C, struct Scene *scene, ListBase *targets);
 
 /* ---------------------------------------------------- */
 /* Curve Paths */
@@ -80,7 +81,7 @@ typedef struct DupliApplyData {
        DupliExtraData *extra;
 } DupliApplyData;
 
-DupliApplyData *duplilist_apply(struct Object *ob, struct Scene *scene, struct ListBase *duplilist);
+DupliApplyData *duplilist_apply(struct EvaluationContext *eval_ctx, struct Object *ob, struct Scene *scene, struct ListBase *duplilist);
 void duplilist_restore(struct ListBase *duplilist, DupliApplyData *apply_data);
 void duplilist_free_apply_data(DupliApplyData *apply_data);
 
index fa3bf0e79c92df90273f25f600c67100144ee3dc..41783700bf6b78a5600200aedf137fc4e9ed8f55 100644 (file)
@@ -35,6 +35,7 @@
 
 struct bPose;
 struct Bone;
+struct EvaluationContext;
 struct GHash;
 struct Main;
 struct bArmature;
@@ -98,8 +99,8 @@ void BKE_armature_where_is(struct bArmature *arm);
 void BKE_armature_where_is_bone(struct Bone *bone, struct Bone *prevbone, const bool use_recursion);
 void BKE_pose_clear_pointers(struct bPose *pose);
 void BKE_pose_rebuild(struct Object *ob, struct bArmature *arm);
-void BKE_pose_where_is(struct Scene *scene, struct Object *ob);
-void BKE_pose_where_is_bone(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, bool do_extra);
+void BKE_pose_where_is(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
+void BKE_pose_where_is_bone(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, bool do_extra);
 void BKE_pose_where_is_bone_tail(struct bPoseChannel *pchan);
 
 /* get_objectspace_bone_matrix has to be removed still */
@@ -116,7 +117,7 @@ void BKE_armature_loc_pose_to_bone(struct bPoseChannel *pchan, const float inloc
 void BKE_armature_mat_bone_to_pose(struct bPoseChannel *pchan, float inmat[4][4], float outmat[4][4]);
 void BKE_armature_mat_pose_to_delta(float delta_mat[4][4], float pose_mat[4][4], float arm_mat[4][4]);
 
-void BKE_armature_mat_pose_to_bone_ex(struct Object *ob, struct bPoseChannel *pchan, float inmat[4][4], float outmat[4][4]);
+void BKE_armature_mat_pose_to_bone_ex(struct EvaluationContext *eval_ctx, struct Object *ob, struct bPoseChannel *pchan, float inmat[4][4], float outmat[4][4]);
 
 void BKE_pchan_mat3_to_rot(struct bPoseChannel *pchan, float mat[3][3], bool use_compat);
 void BKE_pchan_apply_mat4(struct bPoseChannel *pchan, float mat[4][4], bool use_comat);
@@ -154,7 +155,6 @@ void b_bone_spline_setup(struct bPoseChannel *pchan, int rest, Mat4 result_array
 struct bKinematicConstraint;
 struct bPose;
 struct bSplineIKConstraint;
-struct EvaluationContext;
 
 struct bPoseChannel *BKE_armature_ik_solver_find_root(
         struct bPoseChannel *pchan,
@@ -164,7 +164,7 @@ struct bPoseChannel *BKE_armature_splineik_solver_find_root(
         struct bSplineIKConstraint *data);
 
 void BKE_pose_splineik_init_tree(struct Scene *scene, struct Object *ob, float ctime);
-void BKE_splineik_execute_tree(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan_root, float ctime);
+void BKE_splineik_execute_tree(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan_root, float ctime);
 
 void BKE_pose_eval_init(struct EvaluationContext *eval_ctx,
                         struct Scene *scene,
index 6c517bd02df0282dae54e7eff4264453e8fb67bc..67723209e75b79c0c5c1211f8fbc05a707f6fca3 100644 (file)
@@ -41,6 +41,7 @@ struct MFace;
 struct DerivedMesh;
 struct ClothModifierData;
 struct CollisionModifierData;
+struct EvaluationContext;
 
 #define DO_INLINE MALWAYS_INLINE
 
@@ -226,7 +227,7 @@ void cloth_free_contacts(ColliderContacts *collider_contacts, int totcolliders);
 void cloth_free_modifier_extern (struct ClothModifierData *clmd );
 void cloth_free_modifier (struct ClothModifierData *clmd );
 void cloth_init (struct ClothModifierData *clmd );
-void clothModifier_do (struct ClothModifierData *clmd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, float (*vertexCos)[3]);
+void clothModifier_do (struct ClothModifierData *clmd, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, float (*vertexCos)[3]);
 
 int cloth_uses_vgroup(struct ClothModifierData *clmd);
 
index 047d1787f76896dc7c4e9174d86a422bcc02e325..6490418edbe40a732ec3b3d53ff5499ba37493b0 100644 (file)
@@ -40,6 +40,7 @@ struct ListBase;
 struct Object;
 struct Scene;
 struct bPoseChannel;
+struct EvaluationContext;
 
 /* ---------------------------------------------------------------------------- */
 #ifdef __cplusplus
@@ -102,7 +103,7 @@ typedef struct bConstraintTypeInfo {
        
        /* evaluation */
        /* set the ct->matrix for the given constraint target (at the given ctime) */
-       void (*get_target_matrix)(struct bConstraint *con, struct bConstraintOb *cob, struct bConstraintTarget *ct, float ctime);
+       void (*get_target_matrix)(struct EvaluationContext *eval_ctx, struct bConstraint *con, struct bConstraintOb *cob, struct bConstraintTarget *ct, float ctime);
        /* evaluate the constraint for the given time */
        void (*evaluate_constraint)(struct bConstraint *con, struct bConstraintOb *cob, struct ListBase *targets);
 } bConstraintTypeInfo;
@@ -146,9 +147,10 @@ void                  BKE_constraints_clear_evalob(struct bConstraintOb *cob);
 void BKE_constraint_mat_convertspace(
         struct Object *ob, struct bPoseChannel *pchan, float mat[4][4], short from, short to, const bool keep_scale);
 
-void BKE_constraint_target_matrix_get(struct Scene *scene, struct bConstraint *con, int n, short ownertype, void *ownerdata, float mat[4][4], float ctime);
-void BKE_constraint_targets_for_solving_get(struct bConstraint *con, struct bConstraintOb *ob, struct ListBase *targets, float ctime);
-void BKE_constraints_solve(struct ListBase *conlist, struct bConstraintOb *cob, float ctime);
+void BKE_constraint_target_matrix_get(struct EvaluationContext *eval_ctx, struct Scene *scene, struct bConstraint *con,
+                                      int n, short ownertype, void *ownerdata, float mat[4][4], float ctime);
+void BKE_constraint_targets_for_solving_get(struct EvaluationContext *eval_ctx, struct bConstraint *con, struct bConstraintOb *ob, struct ListBase *targets, float ctime);
+void BKE_constraints_solve(struct EvaluationContext *eval_ctx, struct ListBase *conlist, struct bConstraintOb *cob, float ctime);
 
 #ifdef __cplusplus
 }
index b71f5a4aa8e54109131c26445d30bebb6cc78d95..2552e6fe1f6304d0a7f533292fda6b19c6557e29 100644 (file)
@@ -73,6 +73,7 @@ struct SpaceText;
 struct SpaceImage;
 struct SpaceClip;
 struct ID;
+struct EvaluationContext;
 
 /* Structs */
 
@@ -308,6 +309,8 @@ int CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list);
 
 struct Depsgraph *CTX_data_depsgraph(const bContext *C);
 
+void CTX_data_eval_ctx(const bContext *C, struct EvaluationContext *eval_ctx);
+
 #ifdef __cplusplus
 }
 #endif
index ee6c5c57678f815df6acf97fdc3a900bd3898a39..4fe52370f4718291cac135542c8f57c55137c862 100644 (file)
@@ -38,23 +38,24 @@ struct Scene;
 struct Object;
 struct BMEditMesh;
 struct Mesh;
+struct EvaluationContext;
 
 /* crazyspace.c */
 float (*BKE_crazyspace_get_mapped_editverts(
-        struct Scene *scene, struct Object *obedit))[3];
+        struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *obedit))[3];
 void BKE_crazyspace_set_quats_editmesh(
         struct BMEditMesh *em, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4],
         const bool use_select);
 void BKE_crazyspace_set_quats_mesh(
         struct Mesh *me, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4]);
 int BKE_crazyspace_get_first_deform_matrices_editbmesh(
-        struct Scene *, struct Object *, struct BMEditMesh *em,
+        struct EvaluationContext *eval_ctx, struct Scene *, struct Object *, struct BMEditMesh *em,
         float (**deformmats)[3][3], float (**deformcos)[3]);
 int BKE_sculpt_get_first_deform_matrices(
-        struct Scene *scene, struct Object *ob,
+        struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
         float (**deformmats)[3][3], float (**deformcos)[3]);
 void BKE_crazyspace_build_sculpt(
-        struct Scene *scene, struct Object *ob,
+        struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
         float (**deformmats)[3][3], float (**deformcos)[3]);
 
 #ifdef __cplusplus
index 5a65646efe024d570d14a96bb60fc4c1c8fa20f2..501a623aceaf61e481485f9b5051603997af8e6a 100644 (file)
@@ -36,6 +36,7 @@
 struct BezTriple;
 struct Curve;
 struct EditNurb;
+struct EvaluationContext;
 struct GHash;
 struct ListBase;
 struct Main;
@@ -121,12 +122,12 @@ void BKE_curve_editNurb_keyIndex_free(struct GHash **keyindex);
 void BKE_curve_editNurb_free(struct Curve *cu);
 struct ListBase *BKE_curve_editNurbs_get(struct Curve *cu);
 
-float *BKE_curve_make_orco(struct Scene *scene, struct Object *ob, int *r_numVerts);
+float *BKE_curve_make_orco(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, int *r_numVerts);
 float *BKE_curve_surf_make_orco(struct Object *ob);
 
 void BKE_curve_bevelList_free(struct ListBase *bev);
 void BKE_curve_bevelList_make(struct Object *ob, struct ListBase *nurbs, bool for_render);
-void BKE_curve_bevel_make(struct Scene *scene, struct Object *ob,  struct ListBase *disp,
+void BKE_curve_bevel_make(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,  struct ListBase *disp,
                           const bool for_render, const bool use_render_resolution);
 
 void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride);
@@ -212,8 +213,6 @@ void BKE_nurb_handles_test(struct Nurb *nu, const bool use_handles);
 
 /* **** Depsgraph evaluation **** */
 
-struct EvaluationContext;
-
 void BKE_curve_eval_geometry(struct EvaluationContext *eval_ctx,
                              struct Curve *curve);
 
index 2ee9d8d240878d3e34e553943e5898023078ae8b..497319819de476dccbe4c8fd8fb5c6ad2659dac0 100644 (file)
@@ -42,6 +42,7 @@ struct Object;
 struct Scene;
 struct SpaceTransform;
 struct ReportList;
+struct EvaluationContext;
 
 /* Warning, those def are stored in files (TransferData modifier), *DO NOT* modify those values. */
 enum {
@@ -129,11 +130,12 @@ enum {
 };
 
 void BKE_object_data_transfer_layout(
-        struct Scene *scene, struct Object *ob_src, struct Object *ob_dst, const int data_types, const bool use_delete,
+        struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob_src,
+        struct Object *ob_dst, const int data_types, const bool use_delete,
         const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX]);
 
 bool BKE_object_data_transfer_mesh(
-        struct Scene *scene,
+        struct EvaluationContext *eval_ctx, struct Scene *scene,
         struct Object *ob_src, struct Object *ob_dst, const int data_types, const bool use_create,
         const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode,
         struct SpaceTransform *space_transform, const bool auto_transform,
@@ -142,7 +144,7 @@ bool BKE_object_data_transfer_mesh(
         const int mix_mode, const float mix_factor, const char *vgroup_name, const bool invert_vgroup,
         struct ReportList *reports);
 bool BKE_object_data_transfer_dm(
-        struct Scene *scene,
+        struct EvaluationContext *eval_ctx, struct Scene *scene,
         struct Object *ob_src, struct Object *ob_dst, struct DerivedMesh *dm_dst,
         const int data_types, bool use_create,
         const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode,
index 9625f05192aaa621abfdd356013d7997df791d16..641abc54216f915a41504bb2febfa20d99179855 100644 (file)
@@ -86,22 +86,22 @@ void BKE_displist_count(struct ListBase *lb, int *totvert, int *totface, int *to
 void BKE_displist_free(struct ListBase *lb);
 bool BKE_displist_has_faces(struct ListBase *lb);
 
-void BKE_displist_make_surf(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **r_dm_final,
-                            const bool for_render, const bool for_orco, const bool use_render_resolution);
-void BKE_displist_make_curveTypes(struct Scene *scene, struct Object *ob, const bool for_orco);
-void BKE_displist_make_curveTypes_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **r_dm_final,
-                                            const bool for_orco, const bool use_render_resolution);
-void BKE_displist_make_curveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
+void BKE_displist_make_surf(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase,
+                            struct DerivedMesh **r_dm_final, const bool for_render, const bool for_orco, const bool use_render_resolution);
+void BKE_displist_make_curveTypes(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, const bool for_orco);
+void BKE_displist_make_curveTypes_forRender(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase,
+                                            struct DerivedMesh **r_dm_final, const bool for_orco, const bool use_render_resolution);
+void BKE_displist_make_curveTypes_forOrco(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
 void BKE_displist_make_mball(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
 void BKE_displist_make_mball_forRender(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
 
 bool BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4);
 void BKE_displist_fill(struct ListBase *dispbase, struct ListBase *to, const float normal_proj[3], const bool flipnormal);
 
-float BKE_displist_calc_taper(struct Scene *scene, struct Object *taperobj, int cur, int tot);
+float BKE_displist_calc_taper(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *taperobj, int cur, int tot);
 
 /* add Orco layer to the displist object which has got derived mesh and return orco */
-float *BKE_displist_make_orco(struct Scene *scene, struct Object *ob, struct DerivedMesh *dm_final,
+float *BKE_displist_make_orco(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm_final,
                               const bool for_render, const bool use_render_resolution);
 
 void BKE_displist_minmax(struct ListBase *dispbase, float min[3], float max[3]);
index b22f5fa7630e337a27d27fd2c502d1fd006f6719..1360d0c730fb9bfd1c5aecbbd7040c1f4a46c3ea 100644 (file)
@@ -29,6 +29,7 @@
 
 struct Scene;
 struct SceneLayer;
+struct EvaluationContext;
 
 /* Actual surface point        */
 typedef struct PaintSurfaceData {
@@ -61,8 +62,8 @@ typedef struct PaintWavePoint {
        short state;
 } PaintWavePoint;
 
-struct DerivedMesh *dynamicPaint_Modifier_do(struct DynamicPaintModifierData *pmd, struct Scene *scene,
-                                             struct SceneLayer *sl, struct Object *ob, struct DerivedMesh *dm);
+struct DerivedMesh *dynamicPaint_Modifier_do(struct DynamicPaintModifierData *pmd, struct EvaluationContext *eval_ctx, struct Scene *scene,
+                                             struct Object *ob, struct DerivedMesh *dm);
 void dynamicPaint_Modifier_free(struct DynamicPaintModifierData *pmd);
 void dynamicPaint_Modifier_copy(struct DynamicPaintModifierData *pmd, struct DynamicPaintModifierData *tsmd);
 
@@ -85,7 +86,7 @@ struct DynamicPaintSurface *get_activeSurface(struct DynamicPaintCanvasSettings
 
 /* image sequence baking */
 int dynamicPaint_createUVSurface(struct Scene *scene, struct DynamicPaintSurface *surface, float *progress, short *do_update);
-int dynamicPaint_calculateFrame(struct DynamicPaintSurface *surface, struct Scene *scene, struct SceneLayer *sl, struct Object *cObject, int frame);
+int dynamicPaint_calculateFrame(struct DynamicPaintSurface *surface, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *cObject, int frame);
 void dynamicPaint_outputSurfaceImage(struct DynamicPaintSurface *surface, char *filename, short output_layer);
 
 /* PaintPoint state */
index 9ee1bcf2d376f7bf70bf19a1f90f187a145a8da8..02ad8777e60f9555aa7c4816bbf23792a841da6f 100644 (file)
@@ -40,6 +40,7 @@ struct Mesh;
 struct Scene;
 struct DerivedMesh;
 struct MeshStatVis;
+struct EvaluationContext;
 
 /**
  * This structure is used for mesh edit-mode.
@@ -98,6 +99,6 @@ float     (*BKE_editmesh_vertexCos_get_orco(BMEditMesh *em, int *r_numVerts))[3]
 void        BKE_editmesh_statvis_calc(BMEditMesh *em, struct DerivedMesh *dm,
                                       const struct MeshStatVis *statvis);
 
-float (*BKE_editmesh_vertexCos_get(struct BMEditMesh *em, struct Scene *scene, int *r_numVerts))[3];
+float (*BKE_editmesh_vertexCos_get(struct EvaluationContext *eval_ctx, struct BMEditMesh *em, struct Scene *scene, int *r_numVerts))[3];
 
 #endif /* __BKE_EDITMESH_H__ */
index aa45132cbe988e25534ac4a1acb7c9a80fc37374..383e6d0cb6297ea8a97efedceb1eb815db7069a5 100644 (file)
@@ -44,6 +44,7 @@ struct Group;
 struct ParticleSimulationData;
 struct ParticleData;
 struct ParticleKey;
+struct EvaluationContext;
 
 struct EffectorWeights *BKE_add_effector_weights(struct Group *group);
 struct PartDeflect *object_add_collision_fields(int type);
@@ -93,6 +94,7 @@ typedef struct EffectorData {
 typedef struct EffectorCache {
        struct EffectorCache *next, *prev;
 
+       struct EvaluationContext *eval_ctx;
        struct Scene *scene;
        struct Object *ob;
        struct ParticleSystem *psys;
@@ -110,9 +112,10 @@ typedef struct EffectorCache {
 } EffectorCache;
 
 void            free_partdeflect(struct PartDeflect *pd);
-struct ListBase *pdInitEffectors(struct Scene *scene, struct Object *ob_src, struct ParticleSystem *psys_src, struct EffectorWeights *weights, bool for_simulation);
+struct ListBase *pdInitEffectors(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob_src, struct ParticleSystem *psys_src,
+                                 struct EffectorWeights *weights, bool for_simulation);
 void            pdEndEffectors(struct ListBase **effectors);
-void            pdPrecalculateEffectors(struct ListBase *effectors);
+void            pdPrecalculateEffectors(struct EvaluationContext *eval_ctx, struct ListBase *effectors);
 void            pdDoEffectors(struct ListBase *effectors, struct ListBase *colliders, struct EffectorWeights *weights, struct EffectedPoint *point, float *force, float *impulse);
 
 void pd_point_from_particle(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, struct EffectedPoint *point);
index 6501c968abccebf038af0f9cfa7fae2e4719e122..0345382271b9d389a6e0764ca1a1adeac0e7bc58 100644 (file)
@@ -36,10 +36,11 @@ struct Object;
 struct Scene;
 struct FluidsimSettings;
 struct MVert;
+struct EvaluationContext;
 
 /* old interface */
 
-void initElbeemMesh(struct Scene *scene, struct Object *ob,
+void initElbeemMesh(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
                     int *numVertices, float **vertices,
                     int *numTriangles, int **triangles,
                     int useGlobalCoords, int modifierIndex);
index 3c66d29e6ac9dbd30a4491d6ce3cca16745fb9e4..fe3d388178edbbc496eb933d89886e790b2512d5 100644 (file)
@@ -43,6 +43,7 @@ struct Scene;
 struct DerivedMesh;
 struct BPoint;
 struct MDeformVert;
+struct EvaluationContext;
 
 void BKE_lattice_resize(struct Lattice *lt, int u, int v, int w, struct Object *ltOb);
 void BKE_lattice_init(struct Lattice *lt);
@@ -60,10 +61,10 @@ void end_latt_deform(struct LatticeDeformData *lattice_deform_data);
 bool object_deform_mball(struct Object *ob, struct ListBase *dispbase);
 void outside_lattice(struct Lattice *lt);
 
-void curve_deform_verts(struct Scene *scene, struct Object *cuOb, struct Object *target,
+void curve_deform_verts(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *cuOb, struct Object *target,
                         struct DerivedMesh *dm, float (*vertexCos)[3],
                         int numVerts, const char *vgroup, short defaxis);
-void curve_deform_vector(struct Scene *scene, struct Object *cuOb, struct Object *target,
+void curve_deform_vector(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *cuOb, struct Object *target,
                          float orco[3], float vec[3], float mat[3][3], int no_rot_axis);
 
 void lattice_deform_verts(struct Object *laOb, struct Object *target,
@@ -76,7 +77,7 @@ void armature_deform_verts(struct Object *armOb, struct Object *target,
 
 float (*BKE_lattice_vertexcos_get(struct Object *ob, int *r_numVerts))[3];
 void    BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3]);
-void    BKE_lattice_modifiers_calc(struct Scene *scene, struct Object *ob);
+void    BKE_lattice_modifiers_calc(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
 
 struct MDeformVert *BKE_lattice_deform_verts_get(struct Object *lattice);
 struct BPoint *BKE_lattice_active_point_get(struct Lattice *lt);
index bc56d2a210fdfa13f60ed542bbad2e687bb73786..4766f1d37ebd654f64db05ddb3dbe6cdd2fb6f0c 100644 (file)
@@ -35,6 +35,7 @@ struct ID;
 struct BMeshCreateParams;
 struct BoundBox;
 struct EdgeHash;
+struct EvaluationContext;
 struct ListBase;
 struct LinkNode;
 struct BLI_Stack;
@@ -117,7 +118,7 @@ void BKE_mesh_from_nurbs_displist(
         struct Object *ob, struct ListBase *dispbase, const bool use_orco_uv, const char *obdata_name);
 void BKE_mesh_from_nurbs(struct Object *ob);
 void BKE_mesh_to_curve_nurblist(struct DerivedMesh *dm, struct ListBase *nurblist, const int edge_users_test);
-void BKE_mesh_to_curve(struct Scene *scene, struct Object *ob);
+void BKE_mesh_to_curve(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
 void BKE_mesh_material_index_remove(struct Mesh *me, short index);
 void BKE_mesh_material_index_clear(struct Mesh *me);
 void BKE_mesh_material_remap(struct Mesh *me, const unsigned int *remap, unsigned int remap_len);
@@ -138,7 +139,7 @@ float (*BKE_mesh_vertexCos_get(const struct Mesh *me, int *r_numVerts))[3];
 
 void BKE_mesh_split_faces(struct Mesh *mesh, bool free_loop_normals);
 
-struct Mesh *BKE_mesh_new_from_object(struct Main *bmain, struct Scene *sce, struct Object *ob,
+struct Mesh *BKE_mesh_new_from_object(struct EvaluationContext *eval_ctx, struct Main *bmain, struct Scene *sce, struct Object *ob,
                                       int apply_modifiers, int settings, int calc_tessface, int calc_undeformed);
 
 /* vertex level transformations & checks (no derived mesh) */
@@ -399,8 +400,6 @@ void BKE_mesh_calc_edges(struct Mesh *mesh, bool update, const bool select);
 
 /* **** Depsgraph evaluation **** */
 
-struct EvaluationContext;
-
 void BKE_mesh_eval_geometry(struct EvaluationContext *eval_ctx,
                             struct Mesh *mesh);
 
index 95f28f8fa6f71dde788f4e759c093f7435863de5..ca74993156d7dedd6a8e6ab11b787cb716021a22 100644 (file)
@@ -36,6 +36,7 @@ struct ID;
 struct DerivedMesh;
 struct DagForest;
 struct DagNode;
+struct EvaluationContext;
 struct Object;
 struct Scene;
 struct SceneLayer;
@@ -158,25 +159,27 @@ typedef struct ModifierTypeInfo {
         * the object it can obtain it from the derivedData argument if non-NULL,
         * and otherwise the ob argument.
         */
-       void (*deformVerts)(struct ModifierData *md, struct Object *ob,
-                           struct DerivedMesh *derivedData,
+       void (*deformVerts)(struct ModifierData *md, struct EvaluationContext *eval_ctx,
+                           struct Object *ob, struct DerivedMesh *derivedData,
                            float (*vertexCos)[3], int numVerts,
                            ModifierApplyFlag flag);
 
        /* Like deformMatricesEM but called from object mode (for supporting modifiers in sculpt mode) */
-       void (*deformMatrices)(struct ModifierData *md, struct Object *ob,
-                              struct DerivedMesh *derivedData,
+       void (*deformMatrices)(struct ModifierData *md, struct EvaluationContext *eval_ctx,
+                              struct Object *ob, struct DerivedMesh *derivedData,
                               float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
 
        /* Like deformVerts but called during editmode (for supporting modifiers)
         */
-       void (*deformVertsEM)(struct ModifierData *md, struct Object *ob,
-                             struct BMEditMesh *editData, struct DerivedMesh *derivedData,
+       void (*deformVertsEM)(struct ModifierData *md, struct EvaluationContext *eval_ctx,
+                             struct Object *ob, struct BMEditMesh *editData,
+                             struct DerivedMesh *derivedData,
                              float (*vertexCos)[3], int numVerts);
 
        /* Set deform matrix per vertex for crazyspace correction */
-       void (*deformMatricesEM)(struct ModifierData *md, struct Object *ob,
-                                struct BMEditMesh *editData, struct DerivedMesh *derivedData,
+       void (*deformMatricesEM)(struct ModifierData *md, struct EvaluationContext *eval_ctx,
+                                struct Object *ob, struct BMEditMesh *editData,
+                                struct DerivedMesh *derivedData,
                                 float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
 
        /********************* Non-deform modifier functions *********************/
@@ -200,8 +203,8 @@ typedef struct ModifierTypeInfo {
         * The modifier may reuse the derivedData argument (i.e. return it in
         * modified form), but must not release it.
         */
-       struct DerivedMesh *(*applyModifier)(struct ModifierData *md, struct Object *ob,
-                                            struct DerivedMesh *derivedData,
+       struct DerivedMesh *(*applyModifier)(struct ModifierData *md, struct EvaluationContext *eval_ctx,
+                                            struct Object *ob, struct DerivedMesh *derivedData,
                                             ModifierApplyFlag flag);
 
        /* Like applyModifier but called during editmode (for supporting
@@ -211,10 +214,9 @@ typedef struct ModifierTypeInfo {
         * are expected from editmode objects. The same qualifications regarding
         * derivedData apply as for applyModifier.
         */
-       struct DerivedMesh *(*applyModifierEM)(struct ModifierData *md, struct Object *ob,
-                                              struct BMEditMesh *editData,
-                                              struct DerivedMesh *derivedData,
-                                              ModifierApplyFlag flag);
+       struct DerivedMesh *(*applyModifierEM)(struct ModifierData *md, struct EvaluationContext *eval_ctx,
+                                              struct Object *ob, struct BMEditMesh *editData,
+                                              struct DerivedMesh *derivedData, ModifierApplyFlag flag);
 
 
        /********************* Optional functions *********************/
@@ -417,24 +419,24 @@ const char *modifier_path_relbase(struct Object *ob);
 /* wrappers for modifier callbacks */
 
 struct DerivedMesh *modwrap_applyModifier(
-        ModifierData *md, struct Object *ob,
-        struct DerivedMesh *dm,
+        ModifierData *md, struct EvaluationContext *eval_ctx,
+        struct Object *ob, struct DerivedMesh *dm,
         ModifierApplyFlag flag);
 
 struct DerivedMesh *modwrap_applyModifierEM(
-        ModifierData *md, struct Object *ob,
-        struct BMEditMesh *em,
+        ModifierData *md, struct EvaluationContext *eval_ctx,
+        struct Object *ob, struct BMEditMesh *em,
         struct DerivedMesh *dm,
         ModifierApplyFlag flag);
 
 void modwrap_deformVerts(
-        ModifierData *md, struct Object *ob,
-        struct DerivedMesh *dm,
+        ModifierData *md, struct EvaluationContext *eval_ctx,
+        struct Object *ob, struct DerivedMesh *dm,
         float (*vertexCos)[3], int numVerts,
         ModifierApplyFlag flag);
 
 void modwrap_deformVertsEM(
-        ModifierData *md, struct Object *ob,
+        ModifierData *md, struct EvaluationContext *eval_ctx, struct Object *ob,
         struct BMEditMesh *em, struct DerivedMesh *dm,
         float (*vertexCos)[3], int numVerts);
 
index 178751d1640488a31cb2c938403466def1444c0f..5ddc67b7a8cd4bf69e4355b2e602792544e15176 100644 (file)
@@ -34,6 +34,7 @@
 
 enum MultiresModifiedFlags;
 struct DerivedMesh;
+struct EvaluationContext;
 struct MDisps;
 struct Mesh;
 struct ModifierData;
@@ -80,18 +81,18 @@ struct DerivedMesh *multires_make_derived_from_derived(struct DerivedMesh *dm,
 struct MultiresModifierData *find_multires_modifier_before(struct Scene *scene,
                                                            struct ModifierData *lastmd);
 struct MultiresModifierData *get_multires_modifier(struct Scene *scene, struct Object *ob, bool use_first);
-struct DerivedMesh *get_multires_dm(struct Scene *scene, struct MultiresModifierData *mmd,
+struct DerivedMesh *get_multires_dm(struct EvaluationContext *eval_ctx, struct Scene *scene, struct MultiresModifierData *mmd,
                                     struct Object *ob);
 void multiresModifier_del_levels(struct MultiresModifierData *, struct Object *, int direction);
 void multiresModifier_base_apply(struct MultiresModifierData *mmd, struct Object *ob);
 void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Object *ob, int updateblock, int simple);
 void multiresModifier_sync_levels_ex(
         struct Object *ob_dst, struct MultiresModifierData *mmd_src, struct MultiresModifierData *mmd_dst);
-int multiresModifier_reshape(struct Scene *scene, struct MultiresModifierData *mmd,
+int multiresModifier_reshape(struct EvaluationContext *eval_ctx, struct Scene *scene, struct MultiresModifierData *mmd,
                              struct Object *dst, struct Object *src);
-int multiresModifier_reshapeFromDM(struct Scene *scene, struct MultiresModifierData *mmd,
+int multiresModifier_reshapeFromDM(struct EvaluationContext *eval_ctx, struct Scene *scene, struct MultiresModifierData *mmd,
                                    struct Object *ob, struct DerivedMesh *srcdm);
-int multiresModifier_reshapeFromDeformMod(struct Scene *scene, struct MultiresModifierData *mmd,
+int multiresModifier_reshapeFromDeformMod(struct EvaluationContext *eval_ctx, struct Scene *scene, struct MultiresModifierData *mmd,
                                           struct Object *ob, struct ModifierData *md);
 
 void multires_stitch_grids(struct Object *);
@@ -109,8 +110,8 @@ void multires_free(struct Multires *mr);
 void multires_load_old(struct Object *ob, struct Mesh *me);
 void multires_load_old_250(struct Mesh *);
 
-void multiresModifier_scale_disp(struct Scene *scene, struct Object *ob);
-void multiresModifier_prepare_join(struct Scene *scene, struct Object *ob, struct Object *to_ob);
+void multiresModifier_scale_disp(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
+void multiresModifier_prepare_join(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct Object *to_ob);
 
 int multires_mdisp_corners(struct MDisps *s);
 
index c3de20d70890cf08f5ea9e761342284fe885f7b4..d763b33b88f7f31edb561ef42d457dc42c279eb6 100644 (file)
@@ -51,7 +51,7 @@ struct HookModifierData;
 struct ModifierData;
 
 void BKE_object_workob_clear(struct Object *workob);
-void BKE_object_workob_calc_parent(struct Scene *scene, struct Object *ob, struct Object *workob);
+void BKE_object_workob_calc_parent(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct Object *workob);
 
 void BKE_object_transform_copy(struct Object *ob_tar, const struct Object *ob_src);
 struct SoftBody *copy_softbody(const struct SoftBody *sb, bool copy_caches);
@@ -126,11 +126,12 @@ void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4]);
 bool BKE_object_pose_context_check(struct Object *ob);
 struct Object *BKE_object_pose_armature_get(struct Object *ob);
 
-void BKE_object_get_parent_matrix(struct Scene *scene, struct Object *ob, struct Object *par, float parentmat[4][4]);
-void BKE_object_where_is_calc(struct Scene *scene, struct Object *ob);
-void BKE_object_where_is_calc_ex(struct Scene *scene, struct RigidBodyWorld *rbw, struct Object *ob, float r_originmat[3][3]);
-void BKE_object_where_is_calc_time(struct Scene *scene, struct Object *ob, float ctime);
-void BKE_object_where_is_calc_time_ex(struct Scene *scene, struct Object *ob, float ctime,
+void BKE_object_get_parent_matrix(struct Scene *scene, struct Object *ob,
+                                  struct Object *par, float parentmat[4][4]);
+void BKE_object_where_is_calc(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
+void BKE_object_where_is_calc_ex(struct EvaluationContext *eval_ctx, struct Scene *scene, struct RigidBodyWorld *rbw, struct Object *ob, float r_originmat[3][3]);
+void BKE_object_where_is_calc_time(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, float ctime);
+void BKE_object_where_is_calc_time_ex(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, float ctime,
                                       struct RigidBodyWorld *rbw, float r_originmat[3][3]);
 void BKE_object_where_is_calc_mat4(struct Scene *scene, struct Object *ob, float obmat[4][4]);
 
@@ -261,9 +262,8 @@ struct KDTree *BKE_object_as_kdtree(struct Object *ob, int *r_tot);
 
 bool BKE_object_modifier_use_time(struct Object *ob, struct ModifierData *md);
 
-bool BKE_object_modifier_update_subframe(struct Scene *scene, struct Object *ob, bool update_mesh,
-                                         int parent_recursion, float frame,
-                                         int type);
+bool BKE_object_modifier_update_subframe(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
+                                         bool update_mesh, int parent_recursion, float frame, int type);
 
 #ifdef __cplusplus
 }
index 787a67170c22b4604e3c0b8cb54d2a0569e38345..e928746552867487eeee0944842ace09e2ec85b1 100644 (file)
@@ -58,6 +58,7 @@ struct StrokeCache;
 struct Tex;
 struct ImagePool;
 struct UnifiedPaintSettings;
+struct EvaluationContext;
 
 enum OverlayFlags;
 
@@ -208,7 +209,7 @@ void BKE_sculptsession_free(struct Object *ob);
 void BKE_sculptsession_free_deformMats(struct SculptSession *ss);
 void BKE_sculptsession_bm_to_me(struct Object *ob, bool reorder);
 void BKE_sculptsession_bm_to_me_for_render(struct Object *object);
-void BKE_sculpt_update_mesh_elements(struct Scene *scene, struct Sculpt *sd, struct Object *ob,
+void BKE_sculpt_update_mesh_elements(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Sculpt *sd, struct Object *ob,
                                      bool need_pmap, bool need_mask);
 struct MultiresModifierData *BKE_sculpt_multires_active(struct Scene *scene, struct Object *ob);
 int BKE_sculpt_mask_layers_ensure(struct Object *ob,
index 22a0290f364a6ffe414767e1149207b21f20d9ff..f8b1bc2a52abbe9962a0d616c00cfb9c5a39a427 100644 (file)
@@ -62,6 +62,7 @@ struct RNG;
 struct BVHTreeRay;
 struct BVHTreeRayHit; 
 struct EdgeHash;
+struct EvaluationContext;
 
 #define PARTICLE_COLLISION_MAX_COLLISIONS 10
 
@@ -77,6 +78,7 @@ struct EdgeHash;
 
 /* common stuff that many particle functions need */
 typedef struct ParticleSimulationData {
+       struct EvaluationContext *eval_ctx;
        struct Scene *scene;
        struct Object *ob;
        struct ParticleSystem *psys;
@@ -332,9 +334,9 @@ void psys_reset(struct ParticleSystem *psys, int mode);
 void psys_find_parents(struct ParticleSimulationData *sim, const bool use_render_params);
 
 void psys_cache_paths(struct ParticleSimulationData *sim, float cfra, const bool use_render_params);
-void psys_cache_edit_paths(struct Scene *scene, struct Object *ob, struct PTCacheEdit *edit, float cfra, const bool use_render_params);
+void psys_cache_edit_paths(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct PTCacheEdit *edit, float cfra, const bool use_render_params);
 void psys_cache_child_paths(struct ParticleSimulationData *sim, float cfra, const bool editupdate, const bool use_render_params);
-int do_guides(struct ParticleSettings *part, struct ListBase *effectors, ParticleKey *state, int pa_num, float time);
+int do_guides(struct EvaluationContext *eval_ctx, struct ParticleSettings *part, struct ListBase *effectors, ParticleKey *state, int pa_num, float time);
 void precalc_guides(struct ParticleSimulationData *sim, struct ListBase *effectors);
 float psys_get_timestep(struct ParticleSimulationData *sim);
 float psys_get_child_time(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *birthtime, float *dietime);
@@ -366,7 +368,7 @@ void psys_tasks_create(struct ParticleThreadContext *ctx, int startpart, int end
 void psys_tasks_free(struct ParticleTask *tasks, int numtasks);
 
 void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3], float zvec[3], float center[3]);
-void psys_apply_hair_lattice(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys);
+void psys_apply_hair_lattice(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys);
 
 /* particle_system.c */
 struct ParticleSystem *psys_get_target_system(struct Object *ob, struct ParticleTarget *pt);
@@ -381,7 +383,7 @@ void psys_check_boid_data(struct ParticleSystem *psys);
 
 void psys_get_birth_coords(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, float dtime, float cfra);
 
-void particle_system_update(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, const bool use_render_params);
+void particle_system_update(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, const bool use_render_params);
 
 /* Callback format for performing operations on ID-pointers for particle systems */
 typedef void (*ParticleSystemIDFunc)(struct ParticleSystem *psys, struct ID **idpoin, void *userdata, int cb_flag);
index c72f067a11149b96c603d49ea8a8f87171cacac9..41e2a117eeb1d2081c753ce88d1b7078b2e338fd 100644 (file)
@@ -37,6 +37,7 @@
 struct RigidBodyWorld;
 struct RigidBodyOb;
 
+struct EvaluationContext;
 struct Scene;
 struct Object;
 
@@ -99,14 +100,12 @@ void BKE_rigidbody_aftertrans_update(struct Object *ob, float loc[3], float rot[
 void BKE_rigidbody_sync_transforms(struct RigidBodyWorld *rbw, struct Object *ob, float ctime);
 bool BKE_rigidbody_check_sim_running(struct RigidBodyWorld *rbw, float ctime);
 void BKE_rigidbody_cache_reset(struct RigidBodyWorld *rbw);
-void BKE_rigidbody_rebuild_world(struct Scene *scene, float ctime);
-void BKE_rigidbody_do_simulation(struct Scene *scene, float ctime);
+void BKE_rigidbody_rebuild_world(struct EvaluationContext *eval_ctx, struct Scene *scene, float ctime);
+void BKE_rigidbody_do_simulation(struct EvaluationContext *eval_ctx, struct Scene *scene, float ctime);
 
 /* -------------------- */
 /* Depsgraph evaluation */
 
-struct EvaluationContext;
-
 void BKE_rigidbody_rebuild_sim(struct EvaluationContext *eval_ctx,
                                struct Scene *scene);
 
index 7c09cafaf645e9612c517d8067745a649674e94a..5a2c49f55276eaa7e1e105088a970a61883347fa 100644 (file)
@@ -421,7 +421,7 @@ struct Sequence *BKE_sequencer_add_movie_strip(struct bContext *C, ListBase *seq
 
 /* view3d draw callback, run when not in background view */
 typedef struct ImBuf *(*SequencerDrawView)(
-        struct Scene *, struct SceneLayer *sl, struct Object *, int, int,
+        struct EvaluationContext *eval_ctx, struct Scene *, struct SceneLayer *sl, struct Object *, int, int,
         unsigned int, int, bool, bool, bool,
         int, int, bool, const char *,
         struct GPUFX *, struct GPUOffScreen *, char[256]);
index 33d7acdd8643f96c2eff0ae52adbf6c2a730b870..40b349c9cbce44ad4ab573449a9426070dfc3d5f 100644 (file)
@@ -35,7 +35,9 @@
 
 typedef float (*bresenham_callback)(float *result, float *input, int res[3], int *pixel, float *tRay, float correct);
 
-struct DerivedMesh *smokeModifier_do(struct SmokeModifierData *smd, struct Scene *scene, struct SceneLayer *sl, struct Object *ob, struct DerivedMesh *dm);
+struct DerivedMesh *smokeModifier_do(struct SmokeModifierData *smd, struct EvaluationContext *eval_ctx,
+                                     struct Scene *scene,
+                                     struct Object *ob, struct DerivedMesh *dm);
 
 void smoke_reallocate_fluid(struct SmokeDomainSettings *sds, float dx, int res[3], int free_old);
 void smoke_reallocate_highres_fluid(struct SmokeDomainSettings *sds, float dx, int res[3], int free_old);
index 75c5faf4088d53aa18150eb8a6cdd97ef65f208b..89aaf4b39ec1a46da46cc55539f3c3f584ddb168 100644 (file)
@@ -34,6 +34,7 @@
 struct Object;
 struct Scene;
 struct SoftBody;
+struct EvaluationContext;
 
 typedef struct BodyPoint {
        float origS[3], origE[3], origT[3], pos[3], vec[3], force[3];
@@ -59,7 +60,7 @@ extern void             sbFree(struct SoftBody *sb);
 extern void             sbFreeSimulation(struct SoftBody *sb);
 
 /* do one simul step, reading and writing vertex locs from given array */
-extern void             sbObjectStep(struct Scene *scene, struct SceneLayer *sl, struct Object *ob,
+extern void             sbObjectStep(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
                                      float framnr, float (*vertexCos)[3], int numVerts);
 
 /* makes totally fresh start situation, resets time */
index b48be38207356f73c40a4c849fea39b65a73e056..d149654fc826a2d347c1ac49d283ccc06a4ab89b 100644 (file)
@@ -47,6 +47,7 @@ struct MovieDistortion;
 struct Camera;
 struct Object;
 struct Scene;
+struct EvaluationContext;
 struct rcti;
 
 /* **** Common functions **** */
index a26fdd85d52458b46b8748e5e09061dc34f93898..7b3eebb45dc6613c3f853be2270e4ca4b06b82f2 100644 (file)
@@ -1126,7 +1126,7 @@ DerivedMesh *mesh_create_derived(Mesh *me, float (*vertCos)[3])
 }
 
 DerivedMesh *mesh_create_derived_for_modifier(
-        Scene *scene, Object *ob,
+        struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
         ModifierData *md, int build_shapekey_layers)
 {
        Mesh *me = ob->data;
@@ -1152,7 +1152,7 @@ DerivedMesh *mesh_create_derived_for_modifier(
                int numVerts;
                float (*deformedVerts)[3] = BKE_mesh_vertexCos_get(me, &numVerts);
 
-               modwrap_deformVerts(md, ob, NULL, deformedVerts, numVerts, 0);
+               modwrap_deformVerts(md, eval_ctx, ob, NULL, deformedVerts, numVerts, 0);
                dm = mesh_create_derived(me, deformedVerts);
 
                if (build_shapekey_layers)
@@ -1166,7 +1166,7 @@ DerivedMesh *mesh_create_derived_for_modifier(
                if (build_shapekey_layers)
                        add_shapekey_layers(tdm, me, ob);
                
-               dm = modwrap_applyModifier(md, ob, tdm, 0);
+               dm = modwrap_applyModifier(md, eval_ctx, ob, tdm, 0);
                ASSERT_IS_VALID_DM(dm);
 
                if (tdm != dm) tdm->release(tdm);
@@ -1732,7 +1732,7 @@ static void dm_ensure_display_normals(DerivedMesh *dm)
  * - apply deform modifiers and input vertexco
  */
 static void mesh_calc_modifiers(
-        Scene *scene, Object *ob, float (*inputVertexCos)[3],
+        struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float (*inputVertexCos)[3],
         const bool useRenderParams, int useDeform,
         const bool need_mapping, CustomDataMask dataMask,
         const int index, const bool useCache, const bool build_shapekey_layers,
@@ -1843,7 +1843,7 @@ static void mesh_calc_modifiers(
                                if (!deformedVerts)
                                        deformedVerts = BKE_mesh_vertexCos_get(me, &numVerts);
 
-                               modwrap_deformVerts(md, ob, NULL, deformedVerts, numVerts, deform_app_flags);
+                               modwrap_deformVerts(md, eval_ctx, ob, NULL, deformedVerts, numVerts, deform_app_flags);
                        }
                        else {
                                break;
@@ -1984,7 +1984,7 @@ static void mesh_calc_modifiers(
                                }
                        }
 
-                       modwrap_deformVerts(md, ob, dm, deformedVerts, numVerts, deform_app_flags);
+                       modwrap_deformVerts(md, eval_ctx, ob, dm, deformedVerts, numVerts, deform_app_flags);
                }
                else {
                        DerivedMesh *ndm;
@@ -2059,7 +2059,7 @@ static void mesh_calc_modifiers(
                                }
                        }
 
-                       ndm = modwrap_applyModifier(md, ob, dm, app_flags);
+                       ndm = modwrap_applyModifier(md, eval_ctx, ob, dm, app_flags);
                        ASSERT_IS_VALID_DM(ndm);
 
                        if (ndm) {
@@ -2086,7 +2086,7 @@ static void mesh_calc_modifiers(
                                                 (mti->requiredDataMask ?
                                                  mti->requiredDataMask(ob, md) : 0));
 
-                               ndm = modwrap_applyModifier(md, ob, orcodm, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO);
+                               ndm = modwrap_applyModifier(md, eval_ctx, ob, orcodm, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO);
                                ASSERT_IS_VALID_DM(ndm);
 
                                if (ndm) {
@@ -2104,7 +2104,7 @@ static void mesh_calc_modifiers(
                                nextmask &= ~CD_MASK_CLOTH_ORCO;
                                DM_set_only_copy(clothorcodm, nextmask | CD_MASK_ORIGINDEX);
 
-                               ndm = modwrap_applyModifier(md, ob, clothorcodm, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO);
+                               ndm = modwrap_applyModifier(md, eval_ctx, ob, clothorcodm, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO);
                                ASSERT_IS_VALID_DM(ndm);
 
                                if (ndm) {
@@ -2288,8 +2288,8 @@ bool editbmesh_modifier_is_enabled(Scene *scene, ModifierData *md, DerivedMesh *
 }
 
 static void editbmesh_calc_modifiers(
-        Scene *scene, Object *ob, BMEditMesh *em,
-        CustomDataMask dataMask,
+        struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
+        BMEditMesh *em, CustomDataMask dataMask,
         /* return args */
         DerivedMesh **r_cage, DerivedMesh **r_final)
 {
@@ -2376,9 +2376,9 @@ static void editbmesh_calc_modifiers(
                        }
 
                        if (mti->deformVertsEM)
-                               modwrap_deformVertsEM(md, ob, em, dm, deformedVerts, numVerts);
+                               modwrap_deformVertsEM(md, eval_ctx, ob, em, dm, deformedVerts, numVerts);
                        else
-                               modwrap_deformVerts(md, ob, dm, deformedVerts, numVerts, 0);
+                               modwrap_deformVerts(md, eval_ctx, ob, dm, deformedVerts, numVerts, 0);
                }
                else {
                        DerivedMesh *ndm;
@@ -2423,10 +2423,10 @@ static void editbmesh_calc_modifiers(
                                DM_set_only_copy(orcodm, mask | CD_MASK_ORIGINDEX);
 
                                if (mti->applyModifierEM) {
-                                       ndm = modwrap_applyModifierEM(md, ob, em, orcodm, MOD_APPLY_ORCO);
+                                       ndm = modwrap_applyModifierEM(md, eval_ctx, ob, em, orcodm, MOD_APPLY_ORCO);
                                }
                                else {
-                                       ndm = modwrap_applyModifier(md, ob, orcodm, MOD_APPLY_ORCO);
+                                       ndm = modwrap_applyModifier(md, eval_ctx, ob, orcodm, MOD_APPLY_ORCO);
                                }
                                ASSERT_IS_VALID_DM(ndm);
 
@@ -2451,9 +2451,9 @@ static void editbmesh_calc_modifiers(
                        }
 
                        if (mti->applyModifierEM)
-                               ndm = modwrap_applyModifierEM(md, ob, em, dm, MOD_APPLY_USECACHE | MOD_APPLY_ALLOW_GPU);
+                               ndm = modwrap_applyModifierEM(md, eval_ctx, ob, em, dm, MOD_APPLY_USECACHE | MOD_APPLY_ALLOW_GPU);
                        else
-                               ndm = modwrap_applyModifier(md, ob, dm, MOD_APPLY_USECACHE | MOD_APPLY_ALLOW_GPU);
+                               ndm = modwrap_applyModifier(md, eval_ctx, ob, dm, MOD_APPLY_USECACHE | MOD_APPLY_ALLOW_GPU);
                        ASSERT_IS_VALID_DM(ndm);
 
                        if (ndm) {
@@ -2618,7 +2618,7 @@ static bool calc_modifiers_skip_orco(Scene *scene,
 #endif
 
 static void mesh_build_data(
-        Scene *scene, Object *ob, CustomDataMask dataMask,
+        struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask,
         const bool build_shapekey_layers, const bool need_mapping)
 {
        BLI_assert(ob->type == OB_MESH);
@@ -2633,7 +2633,7 @@ static void mesh_build_data(
 #endif
 
        mesh_calc_modifiers(
-               scene, ob, NULL, false, 1, need_mapping, dataMask, -1, true, build_shapekey_layers,
+               eval_ctx, scene, ob, NULL, false, 1, need_mapping, dataMask, -1, true, build_shapekey_layers,
                true,
                &ob->derivedDeform, &ob->derivedFinal);
 
@@ -2648,13 +2648,13 @@ static void mesh_build_data(
                /* create PBVH immediately (would be created on the fly too,
                 * but this avoids waiting on first stroke) */
 
-               BKE_sculpt_update_mesh_elements(scene, scene->toolsettings->sculpt, ob, false, false);
+               BKE_sculpt_update_mesh_elements(eval_ctx, scene, scene->toolsettings->sculpt, ob, false, false);
        }
 
        BLI_assert(!(ob->derivedFinal->dirty & DM_DIRTY_NORMALS));
 }
 
-static void editbmesh_build_data(Scene *scene, Object *obedit, BMEditMesh *em, CustomDataMask dataMask)
+static void editbmesh_build_data(struct EvaluationContext *eval_ctx, Scene *scene, Object *obedit, BMEditMesh *em, CustomDataMask dataMask)
 {
        BKE_object_free_derived_caches(obedit);
        BKE_object_sculpt_modifiers_changed(obedit);
@@ -2668,7 +2668,7 @@ static void editbmesh_build_data(Scene *scene, Object *obedit, BMEditMesh *em, C
 #endif
 
        editbmesh_calc_modifiers(
-               scene, obedit, em, dataMask,
+               eval_ctx, scene, obedit, em, dataMask,
                &em->derivedCage, &em->derivedFinal);
 
        DM_set_object_boundbox(obedit, em->derivedFinal);
@@ -2721,23 +2721,23 @@ static CustomDataMask object_get_datamask(const Scene *scene, Object *ob, bool *
 }
 
 void makeDerivedMesh(
-        Scene *scene, Object *ob, BMEditMesh *em,
+        struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, BMEditMesh *em,
         CustomDataMask dataMask, const bool build_shapekey_layers)
 {
        bool need_mapping;
        dataMask |= object_get_datamask(scene, ob, &need_mapping);
 
        if (em) {
-               editbmesh_build_data(scene, ob, em, dataMask);
+               editbmesh_build_data(eval_ctx, scene, ob, em, dataMask);
        }
        else {
-               mesh_build_data(scene, ob, dataMask, build_shapekey_layers, need_mapping);
+               mesh_build_data(eval_ctx, scene, ob, dataMask, build_shapekey_layers, need_mapping);
        }
 }
 
 /***/
 
-DerivedMesh *mesh_get_derived_final(Scene *scene, Object *ob, CustomDataMask dataMask)
+DerivedMesh *mesh_get_derived_final(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask)
 {
        /* if there's no derived mesh or the last data mask used doesn't include
         * the data we need, rebuild the derived mesh
@@ -2749,14 +2749,14 @@ DerivedMesh *mesh_get_derived_final(Scene *scene, Object *ob, CustomDataMask dat
            ((dataMask & ob->lastDataMask) != dataMask) ||
            (need_mapping != ob->lastNeedMapping))
        {
-               mesh_build_data(scene, ob, dataMask, false, need_mapping);
+               mesh_build_data(eval_ctx, scene, ob, dataMask, false, need_mapping);
        }
 
        if (ob->derivedFinal) { BLI_assert(!(ob->derivedFinal->dirty & DM_DIRTY_NORMALS)); }
        return ob->derivedFinal;
 }
 
-DerivedMesh *mesh_get_derived_deform(Scene *scene, Object *ob, CustomDataMask dataMask)
+DerivedMesh *mesh_get_derived_deform(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask)
 {
        /* if there's no derived mesh or the last data mask used doesn't include
         * the data we need, rebuild the derived mesh
@@ -2769,37 +2769,37 @@ DerivedMesh *mesh_get_derived_deform(Scene *scene, Object *ob, CustomDataMask da
            ((dataMask & ob->lastDataMask) != dataMask) ||
            (need_mapping != ob->lastNeedMapping))
        {
-               mesh_build_data(scene, ob, dataMask, false, need_mapping);
+               mesh_build_data(eval_ctx, scene, ob, dataMask, false, need_mapping);
        }
 
        return ob->derivedDeform;
 }
 
-DerivedMesh *mesh_create_derived_render(Scene *scene, Object *ob, CustomDataMask dataMask)
+DerivedMesh *mesh_create_derived_render(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask)
 {
        DerivedMesh *final;
        
        mesh_calc_modifiers(
-               scene, ob, NULL, true, 1, false, dataMask, -1, false, false, false,
+               eval_ctx, scene, ob, NULL, true, 1, false, dataMask, -1, false, false, false,
                NULL, &final);
 
        return final;
 }
 
-DerivedMesh *mesh_create_derived_index_render(Scene *scene, Object *ob, CustomDataMask dataMask, int index)
+DerivedMesh *mesh_create_derived_index_render(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask, int index)
 {
        DerivedMesh *final;
 
        mesh_calc_modifiers(
-               scene, ob, NULL, true, 1, false, dataMask, index, false, false, false,
+               eval_ctx, scene, ob, NULL, true, 1, false, dataMask, index, false, false, false,
                NULL, &final);
 
        return final;
 }
 
 DerivedMesh *mesh_create_derived_view(
-        Scene *scene, Object *ob,
-        CustomDataMask dataMask)
+        struct EvaluationContext *eval_ctx, Scene *scene,
+        Object *ob, CustomDataMask dataMask)
 {
        DerivedMesh *final;
 
@@ -2810,7 +2810,7 @@ DerivedMesh *mesh_create_derived_view(
        ob->transflag |= OB_NO_PSYS_UPDATE;
 
        mesh_calc_modifiers(
-               scene, ob, NULL, false, 1, false, dataMask, -1, false, false, false,
+               eval_ctx, scene, ob, NULL, false, 1, false, dataMask, -1, false, false, false,
                NULL, &final);
 
        ob->transflag &= ~OB_NO_PSYS_UPDATE;
@@ -2819,53 +2819,53 @@ DerivedMesh *mesh_create_derived_view(
 }
 
 DerivedMesh *mesh_create_derived_no_deform(
-        Scene *scene, Object *ob, float (*vertCos)[3],
-        CustomDataMask dataMask)
+        struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
+        float (*vertCos)[3], CustomDataMask dataMask)
 {
        DerivedMesh *final;
        
        mesh_calc_modifiers(
-               scene, ob, vertCos, false, 0, false, dataMask, -1, false, false, false,
+               eval_ctx, scene, ob, vertCos, false, 0, false, dataMask, -1, false, false, false,
                NULL, &final);
 
        return final;
 }
 
 DerivedMesh *mesh_create_derived_no_virtual(
-        Scene *scene, Object *ob, float (*vertCos)[3],
-        CustomDataMask dataMask)
+        struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
+        float (*vertCos)[3], CustomDataMask dataMask)
 {
        DerivedMesh *final;
        
        mesh_calc_modifiers(
-               scene, ob, vertCos, false, -1, false, dataMask, -1, false, false, false,
+               eval_ctx, scene, ob, vertCos, false, -1, false, dataMask, -1, false, false, false,
                NULL, &final);
 
        return final;
 }
 
 DerivedMesh *mesh_create_derived_physics(
-        Scene *scene, Object *ob, float (*vertCos)[3],
-        CustomDataMask dataMask)
+        struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
+        float (*vertCos)[3], CustomDataMask dataMask)
 {
        DerivedMesh *final;
        
        mesh_calc_modifiers(
-               scene, ob, vertCos, false, -1, true, dataMask, -1, false, false, false,
+               eval_ctx, scene, ob, vertCos, false, -1, true, dataMask, -1, false, false, false,
                NULL, &final);
 
        return final;
 }
 
 DerivedMesh *mesh_create_derived_no_deform_render(
-        Scene *scene, Object *ob,
-        float (*vertCos)[3],
+        struct EvaluationContext *eval_ctx, Scene *scene,
+        Object *ob, float (*vertCos)[3],
         CustomDataMask dataMask)
 {
        DerivedMesh *final;
 
        mesh_calc_modifiers(
-               scene, ob, vertCos, true, 0, false, dataMask, -1, false, false, false,
+               eval_ctx, scene, ob, vertCos, true, 0, false, dataMask, -1, false, false, false,
                NULL, &final);
 
        return final;
@@ -2874,7 +2874,7 @@ DerivedMesh *mesh_create_derived_no_deform_render(
 /***/
 
 DerivedMesh *editbmesh_get_derived_cage_and_final(
-        Scene *scene, Object *obedit, BMEditMesh *em,
+        struct EvaluationContext *eval_ctx, Scene *scene, Object *obedit, BMEditMesh *em,
         CustomDataMask dataMask,
         /* return args */
         DerivedMesh **r_final)
@@ -2887,7 +2887,7 @@ DerivedMesh *editbmesh_get_derived_cage_and_final(
        if (!em->derivedCage ||
            (em->lastDataMask & dataMask) != dataMask)
        {
-               editbmesh_build_data(scene, obedit, em, dataMask);
+               editbmesh_build_data(eval_ctx, scene, obedit, em, dataMask);
        }
 
        *r_final = em->derivedFinal;
@@ -2895,7 +2895,7 @@ DerivedMesh *editbmesh_get_derived_cage_and_final(
        return em->derivedCage;
 }
 
-DerivedMesh *editbmesh_get_derived_cage(Scene *scene, Object *obedit, BMEditMesh *em, CustomDataMask dataMask)
+DerivedMesh *editbmesh_get_derived_cage(struct EvaluationContext *eval_ctx, Scene *scene, Object *obedit, BMEditMesh *em, CustomDataMask dataMask)
 {
        /* if there's no derived mesh or the last data mask used doesn't include
         * the data we need, rebuild the derived mesh
@@ -2905,7 +2905,7 @@ DerivedMesh *editbmesh_get_derived_cage(Scene *scene, Object *obedit, BMEditMesh
        if (!em->derivedCage ||
            (em->lastDataMask & dataMask) != dataMask)
        {
-               editbmesh_build_data(scene, obedit, em, dataMask);
+               editbmesh_build_data(eval_ctx, scene, obedit, em, dataMask);
        }
 
        return em->derivedCage;
index 59484724aee032bda457bb55085a5e1bf69144ad..34ab8a064d424a9a5dff439971c9f2ab41f0e401 100644 (file)
@@ -43,6 +43,7 @@
 #include "DNA_key_types.h"
 #include "DNA_scene_types.h"
 
+#include "BKE_context.h"
 #include "BKE_curve.h"
 #include "BKE_global.h"
 #include "BKE_key.h"
@@ -282,10 +283,11 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets)
  */
 
 /* tweak the object ordering to trick depsgraph into making MotionPath calculations run faster */
-static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets)
+static void motionpaths_calc_optimise_depsgraph(bContext *C, Scene *scene, ListBase *targets)
 {
        BaseLegacy *base, *baseNext;
        MPathTarget *mpt;
+       Main *bmain = CTX_data_main(C);
        
        /* make sure our temp-tag isn't already in use */
        for (base = scene->base.first; base; base = base->next)
@@ -309,7 +311,7 @@ static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets)
        }
        
        /* "brew me a list that's sorted a bit faster now depsy" */
-       DEG_scene_relations_rebuild(G.main, scene);
+       DEG_scene_relations_rebuild(bmain, scene);
 }
 
 /* update scene for current frame */
@@ -373,7 +375,7 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
  *     - recalc: whether we need to
  */
 /* TODO: include reports pointer? */
-void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
+void animviz_calc_motionpaths(bContext *C, Scene *scene, ListBase *targets)
 {
        MPathTarget *mpt;
        int sfra, efra;
@@ -399,7 +401,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
        
        /* optimize the depsgraph for faster updates */
        /* TODO: whether this is used should depend on some setting for the level of optimizations used */
-       motionpaths_calc_optimise_depsgraph(scene, targets);
+       motionpaths_calc_optimise_depsgraph(C, scene, targets);
        
        /* calculate path over requested range */
        for (CFRA = sfra; CFRA <= efra; CFRA++) {
index 38b98f1eee6c697fcc9b1a9a9ac03fd4f36f915b..81796683761957e6f62b16c8ea89aba65f2ee7f3 100644 (file)
@@ -1445,13 +1445,13 @@ void BKE_armature_loc_pose_to_bone(bPoseChannel *pchan, const float inloc[3], fl
        copy_v3_v3(outloc, nLocMat[3]);
 }
 
-void BKE_armature_mat_pose_to_bone_ex(Object *ob, bPoseChannel *pchan, float inmat[4][4], float outmat[4][4])
+void BKE_armature_mat_pose_to_bone_ex(struct EvaluationContext *eval_ctx, Object *ob, bPoseChannel *pchan, float inmat[4][4], float outmat[4][4])
 {
        bPoseChannel work_pchan = *pchan;
 
        /* recalculate pose matrix with only parent transformations,
         * bone loc/sca/rot is ignored, scene and frame are not used. */
-       BKE_pose_where_is_bone(NULL, ob, &work_pchan, 0.0f, false);
+       BKE_pose_where_is_bone(eval_ctx, NULL, ob, &work_pchan, 0.0f, false);
 
        /* find the matrix, need to remove the bone transforms first so this is
         * calculated as a matrix to set rather then a difference ontop of whats
@@ -2178,7 +2178,7 @@ void BKE_pose_where_is_bone_tail(bPoseChannel *pchan)
 /* pchan is validated, as having bone and parent pointer
  * 'do_extra': when zero skips loc/size/rot, constraints and strip modifiers.
  */
-void BKE_pose_where_is_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float ctime, bool do_extra)
+void BKE_pose_where_is_bone(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, bPoseChannel *pchan, float ctime, bool do_extra)
 {
        /* This gives a chan_mat with actions (ipos) results. */
        if (do_extra)
@@ -2217,7 +2217,7 @@ void BKE_pose_where_is_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float
                        cob = BKE_constraints_make_evalob(scene, ob, pchan, CONSTRAINT_OBTYPE_BONE);
 
                        /* Solve PoseChannel's Constraints */
-                       BKE_constraints_solve(&pchan->constraints, cob, ctime); /* ctime doesnt alter objects */
+                       BKE_constraints_solve(eval_ctx, &pchan->constraints, cob, ctime); /* ctime doesnt alter objects */
 
                        /* cleanup after Constraint Solving
                         * - applies matrix back to pchan, and frees temporary struct used
@@ -2239,7 +2239,7 @@ void BKE_pose_where_is_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float
 
 /* This only reads anim data from channels, and writes to channels */
 /* This is the only function adding poses */
-void BKE_pose_where_is(Scene *scene, Object *ob)
+void BKE_pose_where_is(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob)
 {
        bArmature *arm;
        Bone *bone;
@@ -2278,7 +2278,7 @@ void BKE_pose_where_is(Scene *scene, Object *ob)
                }
 
                /* 2a. construct the IK tree (standard IK) */
-               BIK_initialize_tree(scene, ob, ctime);
+               BIK_initialize_tree(eval_ctx, scene, ob, ctime);
 
                /* 2b. construct the Spline IK trees
                 *  - this is not integrated as an IK plugin, since it should be able
@@ -2290,15 +2290,15 @@ void BKE_pose_where_is(Scene *scene, Object *ob)
                for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
                        /* 4a. if we find an IK root, we handle it separated */
                        if (pchan->flag & POSE_IKTREE) {
-                               BIK_execute_tree(scene, ob, pchan, ctime);
+                               BIK_execute_tree(eval_ctx, scene, ob, pchan, ctime);
                        }
                        /* 4b. if we find a Spline IK root, we handle it separated too */
                        else if (pchan->flag & POSE_IKSPLINE) {
-                               BKE_splineik_execute_tree(scene, ob, pchan, ctime);
+                               BKE_splineik_execute_tree(eval_ctx, scene, ob, pchan, ctime);
                        }
                        /* 5. otherwise just call the normal solver */
                        else if (!(pchan->flag & POSE_DONE)) {
-                               BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1);
+                               BKE_pose_where_is_bone(eval_ctx, scene, ob, pchan, ctime, 1);
                        }
                }
                /* 6. release the IK tree */
index 73e9f5d077469b3da06e6db0953b5dc135ca0116..f60476c21684c0323abad6ec4fa5c28d97f7042d 100644 (file)
@@ -113,9 +113,11 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos
                 *       currently for paths to work it needs to go through the bevlist/displist system (ton)
                 */
 
+               /* TODO: Make sure this doesn't crash. */
+#if 0
                /* only happens on reload file, but violates depsgraph still... fix! */
                if (ELEM(NULL,  ikData->tar->curve_cache, ikData->tar->curve_cache->path, ikData->tar->curve_cache->path->data)) {
-                       BKE_displist_make_curveTypes(scene, ikData->tar, 0);
+                       BKE_displist_make_curveTypes(eval_ctx, scene, ikData->tar, 0);
                        
                        /* path building may fail in EditMode after removing verts [#33268]*/
                        if (ELEM(NULL, ikData->tar->curve_cache->path, ikData->tar->curve_cache->path->data)) {
@@ -123,6 +125,7 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos
                                return;
                        }
                }
+#endif
        }
 
        /* find the root bone and the chain of bones from the root to the tip
@@ -261,7 +264,7 @@ static void splineik_init_tree(Scene *scene, Object *ob, float UNUSED(ctime))
 /* ----------- */
 
 /* Evaluate spline IK for a given bone */
-static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *ob, bPoseChannel *pchan,
+static void splineik_evaluate_bone(struct EvaluationContext *eval_ctx, tSplineIK_Tree *tree, Scene *scene, Object *ob, bPoseChannel *pchan,
                                    int index, float ctime)
 {
        bSplineIKConstraint *ikData = tree->ikData;
@@ -269,7 +272,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
        float splineVec[3], scaleFac, radius = 1.0f;
 
        /* firstly, calculate the bone matrix the standard way, since this is needed for roll control */
-       BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1);
+       BKE_pose_where_is_bone(eval_ctx, scene, ob, pchan, ctime, 1);
 
        copy_v3_v3(poseHead, pchan->pose_head);
        copy_v3_v3(poseTail, pchan->pose_tail);
@@ -511,7 +514,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
 }
 
 /* Evaluate the chain starting from the nominated bone */
-static void splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
+static void splineik_execute_tree(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
 {
        tSplineIK_Tree *tree;
 
@@ -525,7 +528,7 @@ static void splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_
                 */
                for (i = tree->chainlen - 1; i >= 0; i--) {
                        bPoseChannel *pchan = tree->chain[i];
-                       splineik_evaluate_bone(tree, scene, ob, pchan, i, ctime);
+                       splineik_evaluate_bone(eval_ctx, tree, scene, ob, pchan, i, ctime);
                }
 
                /* free the tree info specific to SplineIK trees now */
@@ -544,14 +547,14 @@ void BKE_pose_splineik_init_tree(Scene *scene, Object *ob, float ctime)
        splineik_init_tree(scene, ob, ctime);
 }
 
-void BKE_splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
+void BKE_splineik_execute_tree(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
 {
-       splineik_execute_tree(scene, ob, pchan_root, ctime);
+       splineik_execute_tree(eval_ctx, scene, ob, pchan_root, ctime);
 }
 
 /* *************** Depsgraph evaluation callbacks ************ */
 
-void BKE_pose_eval_init(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_pose_eval_init(struct EvaluationContext *eval_ctx,
                         Scene *scene,
                         Object *ob,
                         bPose *pose)
@@ -576,7 +579,7 @@ void BKE_pose_eval_init(struct EvaluationContext *UNUSED(eval_ctx),
        }
 
        /* 2a. construct the IK tree (standard IK) */
-       BIK_initialize_tree(scene, ob, ctime);
+       BIK_initialize_tree(eval_ctx, scene, ob, ctime);
 
        /* 2b. construct the Spline IK trees
         *  - this is not integrated as an IK plugin, since it should be able
@@ -585,7 +588,7 @@ void BKE_pose_eval_init(struct EvaluationContext *UNUSED(eval_ctx),
        BKE_pose_splineik_init_tree(scene, ob, ctime);
 }
 
-void BKE_pose_eval_bone(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_pose_eval_bone(struct EvaluationContext *eval_ctx,
                         Scene *scene,
                         Object *ob,
                         bPoseChannel *pchan)
@@ -613,14 +616,14 @@ void BKE_pose_eval_bone(struct EvaluationContext *UNUSED(eval_ctx),
                                if ((pchan->flag & POSE_DONE) == 0) {
                                        /* TODO(sergey): Use time source node for time. */
                                        float ctime = BKE_scene_frame_get(scene); /* not accurate... */
-                                       BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1);
+                                       BKE_pose_where_is_bone(eval_ctx, scene, ob, pchan, ctime, 1);
                                }
                        }
                }
        }
 }
 
-void BKE_pose_constraints_evaluate(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_pose_constraints_evaluate(struct EvaluationContext *eval_ctx,
                                    Scene *scene,
                                    Object *ob,
                                    bPoseChannel *pchan)
@@ -636,7 +639,7 @@ void BKE_pose_constraints_evaluate(struct EvaluationContext *UNUSED(eval_ctx),
        else {
                if ((pchan->flag & POSE_DONE) == 0) {
                        float ctime = BKE_scene_frame_get(scene); /* not accurate... */
-                       BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1);
+                       BKE_pose_where_is_bone(eval_ctx, scene, ob, pchan, ctime, 1);
                }
        }
 }
@@ -652,24 +655,24 @@ void BKE_pose_bone_done(struct EvaluationContext *UNUSED(eval_ctx),
        }
 }
 
-void BKE_pose_iktree_evaluate(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_pose_iktree_evaluate(struct EvaluationContext *eval_ctx,
                               Scene *scene,
                               Object *ob,
                               bPoseChannel *rootchan)
 {
        float ctime = BKE_scene_frame_get(scene); /* not accurate... */
        DEBUG_PRINT("%s on %s pchan %s\n", __func__, ob->id.name, rootchan->name);
-       BIK_execute_tree(scene, ob, rootchan, ctime);
+       BIK_execute_tree(eval_ctx, scene, ob, rootchan, ctime);
 }
 
-void BKE_pose_splineik_evaluate(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_pose_splineik_evaluate(struct EvaluationContext *eval_ctx,
                                 Scene *scene,
                                 Object *ob,
                                 bPoseChannel *rootchan)
 {
        float ctime = BKE_scene_frame_get(scene); /* not accurate... */
        DEBUG_PRINT("%s on %s pchan %s\n", __func__, ob->id.name, rootchan->name);
-       BKE_splineik_execute_tree(scene, ob, rootchan, ctime);
+       BKE_splineik_execute_tree(eval_ctx, scene, ob, rootchan, ctime);
 }
 
 void BKE_pose_eval_flush(struct EvaluationContext *UNUSED(eval_ctx),
index 7ca4e07076d095f478c6458dbb4d7ad5166e5c93..8c78787c25996516eb7fc1de3990833eca1789b5 100644 (file)
@@ -132,6 +132,7 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
        if (eff == NULL && gabr->ob) {
                memset(&temp_eff, 0, sizeof(EffectorCache));
                temp_eff.ob = gabr->ob;
+               temp_eff.eval_ctx = bbd->sim->eval_ctx;
                temp_eff.scene = bbd->sim->scene;
                eff = &temp_eff;
                get_effector_data(eff, &efd, &epoint, 0);
index 6d0ad3255a2e30a872e59393f2cce88db66168a4..05e92613c625e91b854836ed90960b244b4b9fd5 100644 (file)
@@ -345,7 +345,7 @@ static int do_init_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
        return 1;
 }
 
-static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *result, int framenr)
+static int do_step_cloth(struct EvaluationContext *eval_ctx, Object *ob, ClothModifierData *clmd, DerivedMesh *result, int framenr)
 {
        ClothVertex *verts = NULL;
        Cloth *cloth;
@@ -370,7 +370,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
                mul_m4_v3(ob->obmat, verts->xconst);
        }
 
-       effectors = pdInitEffectors(clmd->scene, ob, NULL, clmd->sim_parms->effector_weights, true);
+       effectors = pdInitEffectors(eval_ctx, clmd->scene, ob, NULL, clmd->sim_parms->effector_weights, true);
 
        if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH )
                cloth_update_verts ( ob, clmd, result );
@@ -400,7 +400,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
 /************************************************
  * clothModifier_do - main simulation function
  ************************************************/
-void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, DerivedMesh *dm, float (*vertexCos)[3])
+void clothModifier_do(ClothModifierData *clmd, struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm, float (*vertexCos)[3])
 {
        PointCache *cache;
        PTCacheID pid;
@@ -489,7 +489,7 @@ void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, Derived
        /* do simulation */
        BKE_ptcache_validate(cache, framenr);
 
-       if (!do_step_cloth(ob, clmd, dm, framenr)) {
+       if (!do_step_cloth(eval_ctx, ob, clmd, dm, framenr)) {
                BKE_ptcache_invalidate(cache);
        }
        else
index 07a6b304dffc75bbebad784dbca325890cee6b25..ac7168b6561faade658497bd722571a14668654e 100644 (file)
@@ -689,7 +689,7 @@ static bConstraintTypeInfo CTI_CONSTRNAME = {
 /* This function should be used for the get_target_matrix member of all 
  * constraints that are not picky about what happens to their target matrix.
  */
-static void default_get_tarmat(bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime))
+static void default_get_tarmat(struct EvaluationContext *UNUSED(eval_ctx), bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime))
 {
        if (VALID_CONS_TARGET(ct))
                constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->flag, con->headtail);
@@ -1155,7 +1155,7 @@ static void kinematic_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
        }
 }
 
-static void kinematic_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
+static void kinematic_get_tarmat(struct EvaluationContext *UNUSED(eval_ctx), bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
 {
        bKinematicConstraint *data = con->data;
        
@@ -1242,7 +1242,7 @@ static void followpath_flush_tars(bConstraint *con, ListBase *list, bool no_copy
        }
 }
 
-static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
+static void followpath_get_tarmat(struct EvaluationContext *eval_ctx, bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
 {
        bFollowPathConstraint *data = con->data;
        
@@ -1259,7 +1259,7 @@ static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstra
 
 #ifdef CYCLIC_DEPENDENCY_WORKAROUND
                if (ct->tar->curve_cache == NULL) {
-                       BKE_displist_make_curveTypes(cob->scene, ct->tar, false);
+                       BKE_displist_make_curveTypes(eval_ctx, cob->scene, ct->tar, false);
                }
 #endif
 
@@ -2024,7 +2024,7 @@ static void pycon_id_looper(bConstraint *con, ConstraintIDFunc func, void *userd
 }
 
 /* Whether this approach is maintained remains to be seen (aligorith) */
-static void pycon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
+static void pycon_get_tarmat(struct EvaluationContext *eval_ctx, bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
 {
 #ifdef WITH_PYTHON
        bPythonConstraint *data = con->data;
@@ -2035,7 +2035,7 @@ static void pycon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTa
                /* special exception for curves - depsgraph issues */
                if (ct->tar->type == OB_CURVE) {
                        if (ct->tar->curve_cache == NULL) {
-                               BKE_displist_make_curveTypes(cob->scene, ct->tar, false);
+                               BKE_displist_make_curveTypes(eval_ctx, cob->scene, ct->tar, false);
                        }
                }
 #endif
@@ -2142,7 +2142,7 @@ static void actcon_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
        }
 }
 
-static void actcon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
+static void actcon_get_tarmat(struct EvaluationContext *UNUSED(eval_ctx), bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
 {
        bActionConstraint *data = con->data;
        
@@ -3131,12 +3131,12 @@ static void clampto_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
        }
 }
 
-static void clampto_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
+static void clampto_get_tarmat(struct EvaluationContext *eval_ctx, bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
 {
 #ifdef CYCLIC_DEPENDENCY_WORKAROUND
        if (VALID_CONS_TARGET(ct)) {
                if (ct->tar->curve_cache == NULL) {
-                       BKE_displist_make_curveTypes(cob->scene, ct->tar, false);
+                       BKE_displist_make_curveTypes(eval_ctx, cob->scene, ct->tar, false);
                }
        }
 #endif
@@ -3474,7 +3474,7 @@ static void shrinkwrap_flush_tars(bConstraint *con, ListBase *list, bool no_copy
 }
 
 
-static void shrinkwrap_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
+static void shrinkwrap_get_tarmat(struct EvaluationContext *UNUSED(eval_ctx), bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
 {
        bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data;
        
@@ -3806,12 +3806,12 @@ static void splineik_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
        }
 }
 
-static void splineik_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
+static void splineik_get_tarmat(struct EvaluationContext *eval_ctx, bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
 {
 #ifdef CYCLIC_DEPENDENCY_WORKAROUND
        if (VALID_CONS_TARGET(ct)) {
                if (ct->tar->curve_cache == NULL) {
-                       BKE_displist_make_curveTypes(cob->scene, ct->tar, false);
+                       BKE_displist_make_curveTypes(eval_ctx, cob->scene, ct->tar, false);
                }
        }
 #endif
@@ -4858,7 +4858,7 @@ bool BKE_constraints_proxylocked_owner(Object *ob, bPoseChannel *pchan)
  * None of the actual calculations of the matrices should be done here! Also, this function is
  * not to be used by any new constraints, particularly any that have multiple targets.
  */
-void BKE_constraint_target_matrix_get(Scene *scene, bConstraint *con, int index, short ownertype, void *ownerdata, float mat[4][4], float ctime)
+void BKE_constraint_target_matrix_get(struct EvaluationContext *eval_ctx, Scene *scene, bConstraint *con, int index, short ownertype, void *ownerdata, float mat[4][4], float ctime)
 {
        const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
        ListBase targets = {NULL, NULL};
@@ -4909,7 +4909,7 @@ void BKE_constraint_target_matrix_get(Scene *scene, bConstraint *con, int index,
                
                if (ct) {
                        if (cti->get_target_matrix)
-                               cti->get_target_matrix(con, cob, ct, ctime);
+                               cti->get_target_matrix(eval_ctx, con, cob, ct, ctime);
                        copy_m4_m4(mat, ct->matrix);
                }
                
@@ -4925,7 +4925,7 @@ void BKE_constraint_target_matrix_get(Scene *scene, bConstraint *con, int index,
 }
 
 /* Get the list of targets required for solving a constraint */
-void BKE_constraint_targets_for_solving_get(bConstraint *con, bConstraintOb *cob, ListBase *targets, float ctime)
+void BKE_constraint_targets_for_solving_get(struct EvaluationContext *eval_ctx, bConstraint *con, bConstraintOb *cob, ListBase *targets, float ctime)
 {
        const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
        
@@ -4943,7 +4943,7 @@ void BKE_constraint_targets_for_solving_get(bConstraint *con, bConstraintOb *cob
                 */
                if (cti->get_target_matrix) {
                        for (ct = targets->first; ct; ct = ct->next)
-                               cti->get_target_matrix(con, cob, ct, ctime);
+                               cti->get_target_matrix(eval_ctx, con, cob, ct, ctime);
                }
                else {
                        for (ct = targets->first; ct; ct = ct->next)
@@ -4960,7 +4960,7 @@ void BKE_constraint_targets_for_solving_get(bConstraint *con, bConstraintOb *cob
  * BKE_constraints_make_evalob and BKE_constraints_clear_evalob should be called before and 
  * after running this function, to sort out cob
  */
-void BKE_constraints_solve(ListBase *conlist, bConstraintOb *cob, float ctime)
+void BKE_constraints_solve(struct EvaluationContext *eval_ctx, ListBase *conlist, bConstraintOb *cob, float ctime)
 {
        bConstraint *con;
        float oldmat[4][4];
@@ -4995,7 +4995,7 @@ void BKE_constraints_solve(ListBase *conlist, bConstraintOb *cob, float ctime)
                BKE_constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, CONSTRAINT_SPACE_WORLD, con->ownspace, false);
                
                /* prepare targets for constraint solving */
-               BKE_constraint_targets_for_solving_get(con, cob, &targets, ctime);
+               BKE_constraint_targets_for_solving_get(eval_ctx, con, cob, &targets, ctime);
                
                /* Solve the constraint and put result in cob->matrix */
                cti->evaluate_constraint(con, cob, &targets);
index ba06eae1940bb26cff06d9a86acf2fb205e432df..27dd516c166b4d803f227448fd117810376fa085 100644 (file)
@@ -1229,3 +1229,11 @@ Depsgraph *CTX_data_depsgraph(const bContext *C)
        SceneLayer *scene_layer = CTX_data_scene_layer(C);
        return BKE_scene_get_depsgraph(scene, scene_layer);
 }
+
+void CTX_data_eval_ctx(const bContext *C, EvaluationContext *eval_ctx)
+{
+       BLI_assert(C);
+
+       *eval_ctx = *CTX_data_main(C)->eval_ctx;
+       eval_ctx->scene_layer = CTX_data_scene_layer(C);
+}
index 56df8e51eba786062a1957d5a976e0e11068b614..da05c05a694e951fa1c3dc83505e2d6496936530 100644 (file)
@@ -99,7 +99,7 @@ static int modifiers_disable_subsurf_temporary(Object *ob)
 }
 
 /* disable subsurf temporal, get mapped cos, and enable it */
-float (*BKE_crazyspace_get_mapped_editverts(Scene *scene, Object *obedit))[3]
+float (*BKE_crazyspace_get_mapped_editverts(struct EvaluationContext *eval_ctx, Scene *scene, Object *obedit))[3]
 {
        Mesh *me = obedit->data;
        DerivedMesh *dm;
@@ -109,13 +109,13 @@ float (*BKE_crazyspace_get_mapped_editverts(Scene *scene, Object *obedit))[3]
        /* disable subsurf temporal, get mapped cos, and enable it */
        if (modifiers_disable_subsurf_temporary(obedit)) {
                /* need to make new derivemesh */
-               makeDerivedMesh(scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH, false);
+               makeDerivedMesh(eval_ctx, scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH, false);
        }
 
        /* now get the cage */
        vertexcos = MEM_mallocN(sizeof(*vertexcos) * nverts, "vertexcos map");
 
-       dm = editbmesh_get_derived_cage(scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH);
+       dm = editbmesh_get_derived_cage(eval_ctx, scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH);
 
        mesh_get_mapped_verts_coords(dm, vertexcos, nverts);
 
@@ -250,7 +250,7 @@ void BKE_crazyspace_set_quats_mesh(Mesh *me, float (*origcos)[3], float (*mapped
 
 /** returns an array of deform matrices for crazyspace correction, and the
  * number of modifiers left */
-int BKE_crazyspace_get_first_deform_matrices_editbmesh(Scene *scene, Object *ob, BMEditMesh *em,
+int BKE_crazyspace_get_first_deform_matrices_editbmesh(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, BMEditMesh *em,
                                         float (**deformmats)[3][3], float (**deformcos)[3])
 {
        ModifierData *md;
@@ -290,7 +290,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(Scene *scene, Object *ob,
                                        unit_m3(defmats[a]);
                        }
 
-                       mti->deformMatricesEM(md, ob, em, dm, deformedVerts, defmats,
+                       mti->deformMatricesEM(md, eval_ctx, ob, em, dm, deformedVerts, defmats,
                                              numVerts);
                }
                else
@@ -310,7 +310,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(Scene *scene, Object *ob,
        return numleft;
 }
 
-int BKE_sculpt_get_first_deform_matrices(Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
+int BKE_sculpt_get_first_deform_matrices(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
 {
        ModifierData *md;
        DerivedMesh *dm;
@@ -346,7 +346,7 @@ int BKE_sculpt_get_first_deform_matrices(Scene *scene, Object *ob, float (**defo
                                        unit_m3(defmats[a]);
                        }
 
-                       if (mti->deformMatrices) mti->deformMatrices(md, ob, dm, deformedVerts, defmats, numVerts);
+                       if (mti->deformMatrices) mti->deformMatrices(md, eval_ctx, ob, dm, deformedVerts, defmats, numVerts);
                        else break;
                }
        }
@@ -369,9 +369,9 @@ int BKE_sculpt_get_first_deform_matrices(Scene *scene, Object *ob, float (**defo
        return numleft;
 }
 
-void BKE_crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
+void BKE_crazyspace_build_sculpt(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
 {
-       int totleft = BKE_sculpt_get_first_deform_matrices(scene, ob, deformmats, deformcos);
+       int totleft = BKE_sculpt_get_first_deform_matrices(eval_ctx, scene, ob, deformmats, deformcos);
 
        if (totleft) {
                /* there are deformation modifier which doesn't support deformation matrices
@@ -396,7 +396,7 @@ void BKE_crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[
                                if (mti->deformMatrices && !deformed)
                                        continue;
 
-                               mti->deformVerts(md, ob, NULL, deformedVerts, me->totvert, 0);
+                               mti->deformVerts(md, eval_ctx, ob, NULL, deformedVerts, me->totvert, 0);
                                deformed = 1;
                        }
                }
index 2863a9250004b28a3853f73a4b631eef4a7be585..6018c07835b6ad4247050b129010f787cc051035 100644 (file)
@@ -1625,7 +1625,7 @@ float *BKE_curve_surf_make_orco(Object *ob)
 /* NOTE: This routine is tied to the order of vertex
  * built by displist and as passed to the renderer.
  */
-float *BKE_curve_make_orco(Scene *scene, Object *ob, int *r_numVerts)
+float *BKE_curve_make_orco(EvaluationContext *eval_ctx, Scene *scene, Object *ob, int *r_numVerts)
 {
        Curve *cu = ob->data;
        DispList *dl;
@@ -1633,7 +1633,7 @@ float *BKE_curve_make_orco(Scene *scene, Object *ob, int *r_numVerts)
        float *fp, *coord_array;
        ListBase disp = {NULL, NULL};
 
-       BKE_displist_make_curveTypes_forOrco(scene, ob, &disp);
+       BKE_displist_make_curveTypes_forOrco(eval_ctx, scene, ob, &disp);
 
        numVerts = 0;
        for (dl = disp.first; dl; dl = dl->next) {
@@ -1724,7 +1724,7 @@ float *BKE_curve_make_orco(Scene *scene, Object *ob, int *r_numVerts)
 
 /* ***************** BEVEL ****************** */
 
-void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp,
+void BKE_curve_bevel_make(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *disp,
                           const bool for_render, const bool use_render_resolution)
 {
        DispList *dl, *dlnew;
@@ -1749,7 +1749,7 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp,
                        facy = cu->bevobj->size[1];
 
                        if (for_render) {
-                               BKE_displist_make_curveTypes_forRender(scene, cu->bevobj, &bevdisp, NULL, false, use_render_resolution);
+                               BKE_displist_make_curveTypes_forRender(eval_ctx, scene, cu->bevobj, &bevdisp, NULL, false, use_render_resolution);
                                dl = bevdisp.first;
                        }
                        else if (cu->bevobj->curve_cache) {
@@ -4706,4 +4706,4 @@ void BKE_curve_batch_cache_free(Curve *cu)
        if (cu->batch_cache) {
                BKE_curve_batch_cache_free_cb(cu);
        }
-}
\ No newline at end of file
+}
index a83ec8f0486061ead11b74b77edb2e222919fc49..0b88cc48a96085305b216d5bac29b5b3fa2bc671 100644 (file)
@@ -1010,7 +1010,7 @@ static bool data_transfer_layersmapping_generate(
  * to get (as much as possible) exact copy of source data layout.
  */
 void BKE_object_data_transfer_layout(
-        Scene *scene, Object *ob_src, Object *ob_dst, const int data_types, const bool use_delete,
+        struct EvaluationContext *eval_ctx, Scene *scene, Object *ob_src, Object *ob_dst, const int data_types, const bool use_delete,
         const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX])
 {
        DerivedMesh *dm_src;
@@ -1027,7 +1027,7 @@ void BKE_object_data_transfer_layout(
 
        /* Get source DM.*/
        dm_src_mask |= BKE_object_data_transfer_dttypes_to_cdmask(data_types);
-       dm_src = mesh_get_derived_final(scene, ob_src, dm_src_mask);
+       dm_src = mesh_get_derived_final(eval_ctx, scene, ob_src, dm_src_mask);
        if (!dm_src) {
                return;
        }
@@ -1085,9 +1085,9 @@ void BKE_object_data_transfer_layout(
 }
 
 bool BKE_object_data_transfer_dm(
-        Scene *scene, Object *ob_src, Object *ob_dst, DerivedMesh *dm_dst, const int data_types, bool use_create,
-        const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode,
-        SpaceTransform *space_transform, const bool auto_transform,
+        struct EvaluationContext *eval_ctx, Scene *scene, Object *ob_src, Object *ob_dst, DerivedMesh *dm_dst,
+        const int data_types, bool use_create, const int map_vert_mode, const int map_edge_mode,
+        const int map_loop_mode, const int map_poly_mode, SpaceTransform *space_transform, const bool auto_transform,
         const float max_distance, const float ray_radius, const float islands_handling_precision,
         const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX],
         const int mix_mode, const float mix_factor, const char *vgroup_name, const bool invert_vgroup,
@@ -1149,7 +1149,7 @@ bool BKE_object_data_transfer_dm(
         *     Also, we need to make a local copy of dm_src, otherwise we may end with concurrent creation
         *     of data in it (multi-threaded evaluation of the modifier stack, see T46672).
         */
-       dm_src = dm_dst ? ob_src->derivedFinal : mesh_get_derived_final(scene, ob_src, dm_src_mask);
+       dm_src = dm_dst ? ob_src->derivedFinal : mesh_get_derived_final(eval_ctx, scene, ob_src, dm_src_mask);
        if (!dm_src) {
                return changed;
        }
@@ -1457,16 +1457,16 @@ bool BKE_object_data_transfer_dm(
 }
 
 bool BKE_object_data_transfer_mesh(
-        Scene *scene, Object *ob_src, Object *ob_dst, const int data_types, const bool use_create,
-        const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode,
-        SpaceTransform *space_transform, const bool auto_transform,
+        struct EvaluationContext *eval_ctx, Scene *scene, Object *ob_src, Object *ob_dst, const int data_types,
+        const bool use_create, const int map_vert_mode, const int map_edge_mode, const int map_loop_mode,
+        const int map_poly_mode, SpaceTransform *space_transform, const bool auto_transform,
         const float max_distance, const float ray_radius, const float islands_handling_precision,
         const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX],
         const int mix_mode, const float mix_factor, const char *vgroup_name, const bool invert_vgroup,
         ReportList *reports)
 {
        return BKE_object_data_transfer_dm(
-               scene, ob_src, ob_dst, NULL, data_types, use_create,
+               eval_ctx, scene, ob_src, ob_dst, NULL, data_types, use_create,
                map_vert_mode, map_edge_mode, map_loop_mode, map_poly_mode,
                space_transform, auto_transform,
                max_distance, ray_radius, islands_handling_precision,
index 25f50056c427a854971247b48f70a33ab52b1c04..fd22aaa291bc020a1b4e635d9fe1bfb461d29b49 100644 (file)
@@ -678,7 +678,7 @@ static void curve_to_filledpoly(Curve *cu, ListBase *UNUSED(nurb), ListBase *dis
  * - first point left, last point right
  * - based on subdivided points in original curve, not on points in taper curve (still)
  */
-static float displist_calc_taper(Scene *scene, Object *taperobj, float fac)
+static float displist_calc_taper(EvaluationContext *eval_ctx, Scene *scene, Object *taperobj, float fac)
 {
        DispList *dl;
 
@@ -687,7 +687,7 @@ static float displist_calc_taper(Scene *scene, Object *taperobj, float fac)
 
        dl = taperobj->curve_cache ? taperobj->curve_cache->disp.first : NULL;
        if (dl == NULL) {
-               BKE_displist_make_curveTypes(scene, taperobj, 0);
+               BKE_displist_make_curveTypes(eval_ctx, scene, taperobj, 0);
                dl = taperobj->curve_cache->disp.first;
        }
        if (dl) {
@@ -718,11 +718,11 @@ static float displist_calc_taper(Scene *scene, Object *taperobj, float fac)
        return 1.0;
 }
 
-float BKE_displist_calc_taper(Scene *scene, Object *taperobj, int cur, int tot)
+float BKE_displist_calc_taper(EvaluationContext *eval_ctx, Scene *scene, Object *taperobj, int cur, int tot)
 {
        float fac = ((float)cur) / (float)(tot - 1);
 
-       return displist_calc_taper(scene, taperobj, fac);
+       return displist_calc_taper(eval_ctx, scene, taperobj, fac);
 }
 
 void BKE_displist_make_mball(EvaluationContext *eval_ctx, Scene *scene, Object *ob)
@@ -798,7 +798,7 @@ static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob,
        return pretessellatePoint;
 }
 
-static void curve_calc_modifiers_pre(Scene *scene, Object *ob, ListBase *nurb,
+static void curve_calc_modifiers_pre(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *nurb,
                                      const bool for_render, const bool use_render_resolution)
 {
        VirtualModifierData virtualModifierData;
@@ -856,7 +856,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, ListBase *nurb,
                                deformedVerts = BKE_curve_nurbs_vertexCos_get(nurb, &numVerts);
                        }
 
-                       mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, app_flag);
+                       mti->deformVerts(md, eval_ctx, ob, NULL, deformedVerts, numVerts, app_flag);
 
                        if (md == pretessellatePoint)
                                break;
@@ -908,7 +908,7 @@ static void displist_apply_allverts(ListBase *dispbase, float (*allverts)[3])
        }
 }
 
-static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *nurb,
+static void curve_calc_modifiers_post(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *nurb,
                                       ListBase *dispbase, DerivedMesh **r_dm_final,
                                       const bool for_render, const bool use_render_resolution)
 {
@@ -964,14 +964,14 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *nurb,
                                        dm->getVertCos(dm, vertCos);
                                }
 
-                               mti->deformVerts(md, ob, dm, vertCos, totvert, appf);
+                               mti->deformVerts(md, eval_ctx, ob, dm, vertCos, totvert, appf);
                        }
                        else {
                                if (!vertCos) {
                                        vertCos = displist_get_allverts(dispbase, &totvert);
                                }
 
-                               mti->deformVerts(md, ob, NULL, vertCos, totvert, appf);
+                               mti->deformVerts(md, eval_ctx, ob, NULL, vertCos, totvert, appf);
                        }
                }
                else {
@@ -1013,7 +1013,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *nurb,
                        if (useCache)
                                appf |= MOD_APPLY_USECACHE;
 
-                       ndm = modwrap_applyModifier(md, ob, dm, appf);
+                       ndm = modwrap_applyModifier(md, eval_ctx, ob, dm, appf);
 
                        if (ndm) {
                                /* Modifier returned a new derived mesh */
@@ -1090,13 +1090,13 @@ static void displist_surf_indices(DispList *dl)
        }
 }
 
-static DerivedMesh *create_orco_dm(Scene *scene, Object *ob)
+static DerivedMesh *create_orco_dm(EvaluationContext *eval_ctx, Scene *scene, Object *ob)
 {
        DerivedMesh *dm;
        ListBase disp = {NULL, NULL};
 
        /* OrcoDM should be created from underformed disp lists */
-       BKE_displist_make_curveTypes_forOrco(scene, ob, &disp);
+       BKE_displist_make_curveTypes_forOrco(eval_ctx, scene, ob, &disp);
        dm = CDDM_from_curve_displist(ob, &disp);
 
        BKE_displist_free(&disp);
@@ -1134,7 +1134,7 @@ static void add_orco_dm(Object *ob, DerivedMesh *dm, DerivedMesh *orcodm)
                DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, orco);
 }
 
-static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *dm_final,
+static void curve_calc_orcodm(EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm_final,
                               const bool for_render, const bool use_render_resolution)
 {
        /* this function represents logic of mesh's orcodm calculation
@@ -1172,7 +1172,7 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *dm_final,
         * This means we can create ORCO DM in advance and assume it's
         * never NULL.
         */
-       orcodm = create_orco_dm(scene, ob);
+       orcodm = create_orco_dm(eval_ctx, scene, ob);
 
        for (; md; md = md->next) {
                const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -1184,7 +1184,7 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *dm_final,
                if (mti->type != eModifierTypeType_Constructive)
                        continue;
 
-               ndm = modwrap_applyModifier(md, ob, orcodm, app_flag);
+               ndm = modwrap_applyModifier(md, eval_ctx, ob, orcodm, app_flag);
 
                if (ndm) {
                        /* if the modifier returned a new dm, release the old one */
@@ -1201,7 +1201,7 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *dm_final,
        orcodm->release(orcodm);
 }
 
-void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase,
+void BKE_displist_make_surf(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase,
                             DerivedMesh **r_dm_final,
                             const bool for_render, const bool for_orco, const bool use_render_resolution)
 {
@@ -1220,7 +1220,7 @@ void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase,
        }
 
        if (!for_orco)
-               curve_calc_modifiers_pre(scene, ob, &nubase, for_render, use_render_resolution);
+               curve_calc_modifiers_pre(eval_ctx, scene, ob, &nubase, for_render, use_render_resolution);
 
        for (nu = nubase.first; nu; nu = nu->next) {
                if ((for_render || nu->hide == 0) && BKE_nurb_check_valid_uv(nu)) {
@@ -1287,7 +1287,7 @@ void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase,
 
        if (!for_orco) {
                BKE_nurbList_duplicate(&ob->curve_cache->deformed_nurbs, &nubase);
-               curve_calc_modifiers_post(scene, ob, &nubase, dispbase, r_dm_final,
+               curve_calc_modifiers_post(eval_ctx, scene, ob, &nubase, dispbase, r_dm_final,
                                          for_render, use_render_resolution);
        }
 
@@ -1513,7 +1513,7 @@ static void calc_bevfac_mapping(Curve *cu, BevList *bl, Nurb *nu,
        }
 }
 
-static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispbase,
+static void do_makeDispListCurveTypes(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase,
                                       DerivedMesh **r_dm_final,
                                       const bool for_render, const bool for_orco, const bool use_render_resolution)
 {
@@ -1523,7 +1523,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
        if (!ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return;
 
        if (ob->type == OB_SURF) {
-               BKE_displist_make_surf(scene, ob, dispbase, r_dm_final, for_render, for_orco, use_render_resolution);
+               BKE_displist_make_surf(eval_ctx, scene, ob, dispbase, r_dm_final, for_render, for_orco, use_render_resolution);
        }
        else if (ELEM(ob->type, OB_CURVE, OB_FONT)) {
                ListBase dlbev;
@@ -1548,12 +1548,12 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
                }
 
                if (!for_orco)
-                       curve_calc_modifiers_pre(scene, ob, &nubase, for_render, use_render_resolution);
+                       curve_calc_modifiers_pre(eval_ctx, scene, ob, &nubase, for_render, use_render_resolution);
 
                BKE_curve_bevelList_make(ob, &nubase, for_render != false);
 
                /* If curve has no bevel will return nothing */
-               BKE_curve_bevel_make(scene, ob, &dlbev, for_render, use_render_resolution);
+               BKE_curve_bevel_make(eval_ctx, scene, ob, &dlbev, for_render, use_render_resolution);
 
                /* no bevel or extrude, and no width correction? */
                if (!dlbev.first && cu->width == 1.0f) {
@@ -1688,7 +1688,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
                                                                                        taper_fac -= (1.0f - lastblend) / len;
                                                                        }
 
-                                                                       fac = displist_calc_taper(scene, cu->taperobj, taper_fac);
+                                                                       fac = displist_calc_taper(eval_ctx, scene, cu->taperobj, taper_fac);
                                                                }
 
                                                                if (bevp->split_tag) {
@@ -1750,7 +1750,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
 
                if (!for_orco) {
                        BKE_nurbList_duplicate(&ob->curve_cache->deformed_nurbs, &nubase);
-                       curve_calc_modifiers_post(scene, ob, &nubase, dispbase, r_dm_final, for_render, use_render_resolution);
+                       curve_calc_modifiers_post(eval_ctx, scene, ob, &nubase, dispbase, r_dm_final, for_render, use_render_resolution);
                }
 
                if (cu->flag & CU_DEFORM_FILL && !ob->derivedFinal) {
@@ -1761,7 +1761,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
        }
 }
 
-void BKE_displist_make_curveTypes(Scene *scene, Object *ob, const bool for_orco)
+void BKE_displist_make_curveTypes(EvaluationContext *eval_ctx, Scene *scene, Object *ob, const bool for_orco)
 {
        ListBase *dispbase;
 
@@ -1779,12 +1779,12 @@ void BKE_displist_make_curveTypes(Scene *scene, Object *ob, const bool for_orco)
 
        dispbase = &(ob->curve_cache->disp);
 
-       do_makeDispListCurveTypes(scene, ob, dispbase, &ob->derivedFinal, 0, for_orco, 0);
+       do_makeDispListCurveTypes(eval_ctx, scene, ob, dispbase, &ob->derivedFinal, 0, for_orco, 0);
 
        boundbox_displist_object(ob);
 }
 
-void BKE_displist_make_curveTypes_forRender(Scene *scene, Object *ob, ListBase *dispbase,
+void BKE_displist_make_curveTypes_forRender(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase,
                                             DerivedMesh **r_dm_final, const bool for_orco,
                                             const bool use_render_resolution)
 {
@@ -1792,20 +1792,20 @@ void BKE_displist_make_curveTypes_forRender(Scene *scene, Object *ob, ListBase *
                ob->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve");
        }
 
-       do_makeDispListCurveTypes(scene, ob, dispbase, r_dm_final, true, for_orco, use_render_resolution);
+       do_makeDispListCurveTypes(eval_ctx, scene, ob, dispbase, r_dm_final, true, for_orco, use_render_resolution);
 }
 
-void BKE_displist_make_curveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase)
+void BKE_displist_make_curveTypes_forOrco(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase)
 {
        if (ob->curve_cache == NULL) {
                ob->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve");
        }
 
-       do_makeDispListCurveTypes(scene, ob, dispbase, NULL, 1, 1, 1);
+       do_makeDispListCurveTypes(eval_ctx, scene, ob, dispbase, NULL, 1, 1, 1);
 }
 
 /* add Orco layer to the displist object which has got derived mesh and return orco */
-float *BKE_displist_make_orco(Scene *scene, Object *ob, DerivedMesh *dm_final,
+float *BKE_displist_make_orco(EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm_final,
                               const bool for_render,
                               const bool use_render_resolution)
 {
@@ -1815,7 +1815,7 @@ float *BKE_displist_make_orco(Scene *scene, Object *ob, DerivedMesh *dm_final,
                dm_final = ob->derivedFinal;
 
        if (!dm_final->getVertDataArray(dm_final, CD_ORCO)) {
-               curve_calc_orcodm(scene, ob, dm_final, for_render, use_render_resolution);
+               curve_calc_orcodm(eval_ctx, scene, ob, dm_final, for_render, use_render_resolution);
        }
 
        orco = dm_final->getVertDataArray(dm_final, CD_ORCO);
index fb5ef403218f55b140909c04a873aaf8a27ef49d..6ac284d6b73bc8ff4783e141d5f0542fe9fe517f 100644 (file)
@@ -74,6 +74,8 @@
 #include "BKE_scene.h"
 #include "BKE_texture.h"
 
+#include "DEG_depsgraph.h"
+
 /* for image output    */
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"
@@ -1973,7 +1975,7 @@ static void canvas_copyDerivedMesh(DynamicPaintCanvasSettings *canvas, DerivedMe
 /*
  *     Updates derived mesh copy and processes dynamic paint step / caches.
  */
-static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene, SceneLayer *sl, Object *ob, DerivedMesh *dm)
+static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm)
 {
        if (pmd->canvas) {
                DynamicPaintCanvasSettings *canvas = pmd->canvas;
@@ -2036,7 +2038,7 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
                                else if (can_simulate) {
                                        /* calculate surface frame */
                                        canvas->flags |= MOD_DPAINT_BAKING;
-                                       dynamicPaint_calculateFrame(surface, scene, sl, ob, current_frame);
+                                       dynamicPaint_calculateFrame(surface, eval_ctx, scene, ob, current_frame);
                                        canvas->flags &= ~MOD_DPAINT_BAKING;
 
                                        /* restore canvas derivedmesh if required */
@@ -2055,7 +2057,7 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
 }
 
 /* Modifier call. Processes dynamic paint modifier step. */
-DerivedMesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd, Scene *scene, SceneLayer *sl, Object *ob, DerivedMesh *dm)
+DerivedMesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd, struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm)
 {
        if (pmd->canvas) {
                DerivedMesh *ret;
@@ -2064,7 +2066,7 @@ DerivedMesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd, Scene *scen
                DM_ensure_looptri(dm);
 
                /* Update canvas data for a new frame */
-               dynamicPaint_frameUpdate(pmd, scene, sl, ob, dm);
+               dynamicPaint_frameUpdate(pmd, eval_ctx, scene, ob, dm);
 
                /* Return output mesh */
                ret = dynamicPaint_Modifier_apply(pmd, ob, dm);
@@ -2076,7 +2078,7 @@ DerivedMesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd, Scene *scen
                DM_ensure_looptri(dm);
 
                /* Update canvas data for a new frame */
-               dynamicPaint_frameUpdate(pmd, scene, sl, ob, dm);
+               dynamicPaint_frameUpdate(pmd, eval_ctx, scene, ob, dm);
 
                /* Return output mesh */
                return dynamicPaint_Modifier_apply(pmd, ob, dm);
@@ -3582,7 +3584,7 @@ static void dynamic_paint_brush_velocity_compute_cb(void *userdata, const int i)
 }
 
 static void dynamicPaint_brushMeshCalculateVelocity(
-        Scene *scene, Object *ob, DynamicPaintBrushSettings *brush, Vec3f **brushVel, float timescale)
+        struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DynamicPaintBrushSettings *brush, Vec3f **brushVel, float timescale)
 {
        float prev_obmat[4][4];
        DerivedMesh *dm_p, *dm_c;
@@ -3604,7 +3606,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(
        scene->r.subframe = prev_sfra;
 
        BKE_object_modifier_update_subframe(
-                   scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
+                   eval_ctx, scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
        dm_p = CDDM_copy(brush->dm);
        numOfVerts_p = dm_p->getNumVerts(dm_p);
        mvert_p = dm_p->getVertArray(dm_p);
@@ -3615,7 +3617,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(
        scene->r.subframe = cur_sfra;
 
        BKE_object_modifier_update_subframe(
-                   scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
+                   eval_ctx, scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
        dm_c = brush->dm;
        numOfVerts_c = dm_c->getNumVerts(dm_c);
        mvert_c = dm_p->getVertArray(dm_c);
@@ -3640,7 +3642,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(
 }
 
 /* calculate velocity for object center point */
-static void dynamicPaint_brushObjectCalculateVelocity(Scene *scene, Object *ob, Vec3f *brushVel, float timescale)
+static void dynamicPaint_brushObjectCalculateVelocity(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, Vec3f *brushVel, float timescale)
 {
        float prev_obmat[4][4];
        float cur_loc[3] = {0.0f}, prev_loc[3] = {0.0f};
@@ -3659,14 +3661,14 @@ static void dynamicPaint_brushObjectCalculateVelocity(Scene *scene, Object *ob,
        scene->r.cfra = prev_fra;
        scene->r.subframe = prev_sfra;
        BKE_object_modifier_update_subframe(
-                   scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
+                   eval_ctx, scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
        copy_m4_m4(prev_obmat, ob->obmat);
 
        /* current frame dm */
        scene->r.cfra = cur_fra;
        scene->r.subframe = cur_sfra;
        BKE_object_modifier_update_subframe(
-                   scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
+                   eval_ctx, scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
 
        /* calculate speed */
        mul_m4_v3(prev_obmat, prev_loc);
@@ -4036,7 +4038,7 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(
        }
 }
 
-static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
+static int dynamicPaint_paintMesh(struct EvaluationContext *eval_ctx, DynamicPaintSurface *surface,
                                   DynamicPaintBrushSettings *brush,
                                   Object *brushOb,
                                   BrushMaterials *bMats,
@@ -4052,7 +4054,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
        const MLoop *mloop = NULL;
 
        if (brush->flags & MOD_DPAINT_USES_VELOCITY)
-               dynamicPaint_brushMeshCalculateVelocity(scene, brushOb, brush, &brushVelocity, timescale);
+               dynamicPaint_brushMeshCalculateVelocity(eval_ctx, scene, brushOb, brush, &brushVelocity, timescale);
 
        if (!brush->dm)
                return 0;
@@ -4530,7 +4532,7 @@ static void dynamic_paint_paint_single_point_cb_ex(
 }
 
 static int dynamicPaint_paintSinglePoint(
-        DynamicPaintSurface *surface, float *pointCoord, DynamicPaintBrushSettings *brush,
+        struct EvaluationContext *eval_ctx, DynamicPaintSurface *surface, float *pointCoord, DynamicPaintBrushSettings *brush,
         Object *brushOb, BrushMaterials *bMats, Scene *scene, float timescale)
 {
        PaintSurfaceData *sData = surface->data;
@@ -4538,7 +4540,7 @@ static int dynamicPaint_paintSinglePoint(
        Vec3f brushVel;
 
        if (brush->flags & MOD_DPAINT_USES_VELOCITY)
-               dynamicPaint_brushObjectCalculateVelocity(scene, brushOb, &brushVel, timescale);
+               dynamicPaint_brushObjectCalculateVelocity(eval_ctx, scene, brushOb, &brushVel, timescale);
 
        const MVert *mvert = brush->dm->getVertArray(brush->dm);
 
@@ -4845,7 +4847,7 @@ static void dynamic_paint_prepare_effect_cb(void *userdata, const int index)
 }
 
 static int dynamicPaint_prepareEffectStep(
-        DynamicPaintSurface *surface, Scene *scene, Object *ob, float **force, float timescale)
+        struct EvaluationContext *eval_ctx, DynamicPaintSurface *surface, Scene *scene, Object *ob, float **force, float timescale)
 {
        double average_force = 0.0f;
        float shrink_speed = 0.0f, spread_speed = 0.0f;
@@ -4856,7 +4858,7 @@ static int dynamicPaint_prepareEffectStep(
 
        /* Init force data if required */
        if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) {
-               ListBase *effectors = pdInitEffectors(scene, ob, NULL, surface->effector_weights, true);
+               ListBase *effectors = pdInitEffectors(eval_ctx, scene, ob, NULL, surface->effector_weights, true);
 
                /* allocate memory for force data (dir vector + strength) */
                *force = MEM_mallocN(sData->total_points * 4 * sizeof(float), "PaintEffectForces");
@@ -5758,7 +5760,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, const Sce
 /*
  * Do Dynamic Paint step. Paints scene brush objects of current state/frame to the surface.
  */
-static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, DynamicPaintSurface *surface, float timescale, float subframe)
+static int dynamicPaint_doStep(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DynamicPaintSurface *surface, float timescale, float subframe)
 {
        PaintSurfaceData *sData = surface->data;
        PaintBakeData *bData = sData->bData;
@@ -5782,6 +5784,7 @@ static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, Dynamic
                GroupObject *go = NULL;
                Object *brushObj = NULL;
                ModifierData *md = NULL;
+               SceneLayer *sl = eval_ctx->scene_layer;
 
                /* backup current scene frame */
                int scene_frame = scene->r.cfra;
@@ -5836,7 +5839,7 @@ static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, Dynamic
                                        /* update object data on this subframe */
                                        if (subframe) {
                                                scene_setSubframe(scene, subframe);
-                                               BKE_object_modifier_update_subframe(scene, brushObj, true, SUBFRAME_RECURSION,
+                                               BKE_object_modifier_update_subframe(eval_ctx, scene, brushObj, true, SUBFRAME_RECURSION,
                                                                                    BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
                                        }
                                        /* Prepare materials if required        */
@@ -5855,11 +5858,11 @@ static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, Dynamic
                                                }
                                        /* Object center distance: */
                                        if (brush->collision == MOD_DPAINT_COL_POINT && brushObj != ob) {
-                                               dynamicPaint_paintSinglePoint(surface, brushObj->loc, brush, brushObj, &bMats, scene, timescale);
+                                               dynamicPaint_paintSinglePoint(eval_ctx, surface, brushObj->loc, brush, brushObj, &bMats, scene, timescale);
                                        }
                                        /* Mesh volume/proximity: */
                                        else if (brushObj != ob) {
-                                               dynamicPaint_paintMesh(surface, brush, brushObj, &bMats, scene, timescale);
+                                               dynamicPaint_paintMesh(eval_ctx, surface, brush, brushObj, &bMats, scene, timescale);
                                        }
 
                                        /* free temp material data */
@@ -5869,7 +5872,7 @@ static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, Dynamic
                                        if (subframe) {
                                                scene->r.cfra = scene_frame;
                                                scene->r.subframe = scene_subframe;
-                                               BKE_object_modifier_update_subframe(scene, brushObj, true, SUBFRAME_RECURSION,
+                                               BKE_object_modifier_update_subframe(eval_ctx, scene, brushObj, true, SUBFRAME_RECURSION,
                                                                                    BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
                                        }
 
@@ -5904,7 +5907,7 @@ static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, Dynamic
                                return setError(canvas, N_("Not enough free memory"));
 
                        /* Prepare effects and get number of required steps */
-                       steps = dynamicPaint_prepareEffectStep(surface, scene, ob, &force, timescale);
+                       steps = dynamicPaint_prepareEffectStep(eval_ctx, surface, scene, ob, &force, timescale);
                        for (s = 0; s < steps; s++) {
                                dynamicPaint_doEffectStep(surface, force, prevPoint, timescale, (float)steps);
                        }
@@ -5928,7 +5931,7 @@ static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, Dynamic
 /*
  * Calculate a single frame and included subframes for surface
  */
-int dynamicPaint_calculateFrame(DynamicPaintSurface *surface, Scene *scene, SceneLayer *sl, Object *cObject, int frame)
+int dynamicPaint_calculateFrame(DynamicPaintSurface *surface, struct EvaluationContext *eval_ctx, Scene *scene, Object *cObject, int frame)
 {
        float timescale = 1.0f;
 
@@ -5937,7 +5940,7 @@ int dynamicPaint_calculateFrame(DynamicPaintSurface *surface, Scene *scene, Scen
                dynamicPaint_applySurfaceDisplace(surface, surface->canvas->dm);
 
        /* update bake data */
-       dynamicPaint_generateBakeData(surface, sl, cObject);
+       dynamicPaint_generateBakeData(surface, eval_ctx->scene_layer, cObject);
 
        /* don't do substeps for first frame */
        if (surface->substeps && (frame != surface->start_frame)) {
@@ -5946,10 +5949,10 @@ int dynamicPaint_calculateFrame(DynamicPaintSurface *surface, Scene *scene, Scen
 
                for (st = 1; st <= surface->substeps; st++) {
                        float subframe = ((float) st) / (surface->substeps + 1);
-                       if (!dynamicPaint_doStep(scene, sl, cObject, surface, timescale, subframe))
+                       if (!dynamicPaint_doStep(eval_ctx, scene, cObject, surface, timescale, subframe))
                                return 0;
                }
        }
 
-       return dynamicPaint_doStep(scene, sl, cObject, surface, timescale, 0.0f);
+       return dynamicPaint_doStep(eval_ctx, scene, cObject, surface, timescale, 0.0f);
 }
index baf91b638b9239c7dc38cf00467daa0b33c1e453..df3c652ee19d19887042621607e537985ef980e6 100644 (file)
@@ -2183,14 +2183,14 @@ static void cage_mapped_verts_callback(
        }
 }
 
-float (*BKE_editmesh_vertexCos_get(BMEditMesh *em, Scene *scene, int *r_numVerts))[3]
+float (*BKE_editmesh_vertexCos_get(struct EvaluationContext *eval_ctx, BMEditMesh *em, Scene *scene, int *r_numVerts))[3]
 {
        DerivedMesh *cage, *final;
        BLI_bitmap *visit_bitmap;
        struct CageUserData data;
        float (*cos_cage)[3];
 
-       cage = editbmesh_get_derived_cage_and_final(scene, em->ob, em, CD_MASK_BAREMESH, &final);
+       cage = editbmesh_get_derived_cage_and_final(eval_ctx, scene, em->ob, em, CD_MASK_BAREMESH, &final);
        cos_cage = MEM_callocN(sizeof(*cos_cage) * em->bm->totvert, "bmbvh cos_cage");
 
        /* when initializing cage verts, we only want the first cage coordinate for each vertex,
index 8380588776b6021370ac0c56a824dd8762df10d1..af1d4cc2e7d149f0c169388572335778a8c7da68 100644 (file)
@@ -72,6 +72,7 @@
 #include "BKE_scene.h"
 #include "BKE_smoke.h"
 
+#include "DEG_depsgraph.h"
 
 #include "RE_render_ext.h"
 #include "RE_shader_ext.h"
@@ -146,9 +147,10 @@ void free_partdeflect(PartDeflect *pd)
        MEM_freeN(pd);
 }
 
-static EffectorCache *new_effector_cache(Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd)
+static EffectorCache *new_effector_cache(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd)
 {
        EffectorCache *eff = MEM_callocN(sizeof(EffectorCache), "EffectorCache");
+       eff->eval_ctx = eval_ctx;
        eff->scene = scene;
        eff->ob = ob;
        eff->psys = psys;
@@ -156,7 +158,7 @@ static EffectorCache *new_effector_cache(Scene *scene, Object *ob, ParticleSyste
        eff->frame = -1;
        return eff;
 }
-static void add_object_to_effectors(ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, Object *ob_src, bool for_simulation)
+static void add_object_to_effectors(ListBase **effectors, struct EvaluationContext *eval_ctx, Scene *scene, EffectorWeights *weights, Object *ob, Object *ob_src, bool for_simulation)
 {
        EffectorCache *eff = NULL;
 
@@ -174,14 +176,14 @@ static void add_object_to_effectors(ListBase **effectors, Scene *scene, Effector
        if (*effectors == NULL)
                *effectors = MEM_callocN(sizeof(ListBase), "effectors list");
 
-       eff = new_effector_cache(scene, ob, NULL, ob->pd);
+       eff = new_effector_cache(eval_ctx, scene, ob, NULL, ob->pd);
 
        /* make sure imat is up to date */
        invert_m4_m4(ob->imat, ob->obmat);
 
        BLI_addtail(*effectors, eff);
 }
-static void add_particles_to_effectors(ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src, bool for_simulation)
+static void add_particles_to_effectors(ListBase **effectors, struct EvaluationContext *eval_ctx, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src, bool for_simulation)
 {
        ParticleSettings *part= psys->part;
 
@@ -195,25 +197,33 @@ static void add_particles_to_effectors(ListBase **effectors, Scene *scene, Effec
                if (*effectors == NULL)
                        *effectors = MEM_callocN(sizeof(ListBase), "effectors list");
 
-               BLI_addtail(*effectors, new_effector_cache(scene, ob, psys, part->pd));
+               BLI_addtail(*effectors, new_effector_cache(eval_ctx, scene, ob, psys, part->pd));
        }
 
        if (part->pd2 && part->pd2->forcefield && (!for_simulation || weights->weight[part->pd2->forcefield] != 0.0f)) {
                if (*effectors == NULL)
                        *effectors = MEM_callocN(sizeof(ListBase), "effectors list");
 
-               BLI_addtail(*effectors, new_effector_cache(scene, ob, psys, part->pd2));
+               BLI_addtail(*effectors, new_effector_cache(eval_ctx, scene, ob, psys, part->pd2));
        }
 }
 
 /* returns ListBase handle with objects taking part in the effecting */
-ListBase *pdInitEffectors(Scene *scene, Object *ob_src, ParticleSystem *psys_src,
+ListBase *pdInitEffectors(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob_src, ParticleSystem *psys_src,
                           EffectorWeights *weights, bool for_simulation)
 {
-       SceneLayer *sl = BKE_scene_layer_context_active_PLACEHOLDER(scene); /* Can't get sl from the calling modifiers yet */
+       SceneLayer *sl;
        Base *base;
        unsigned int layer= ob_src->lay;
        ListBase *effectors = NULL;
+
+       /* eval_ctx is NULL during deg build */
+       if (eval_ctx) {
+               sl = eval_ctx->scene_layer;
+       }
+       else {
+               sl = BKE_scene_layer_context_active_PLACEHOLDER(scene);
+       }
        
        if (weights->group) {
                GroupObject *go;
@@ -221,13 +231,13 @@ ListBase *pdInitEffectors(Scene *scene, Object *ob_src, ParticleSystem *psys_src
                for (go= weights->group->gobject.first; go; go= go->next) {
                        if ( (go->ob->lay & layer) ) {
                                if ( go->ob->pd && go->ob->pd->forcefield )
-                                       add_object_to_effectors(&effectors, scene, weights, go->ob, ob_src, for_simulation);
+                                       add_object_to_effectors(&effectors, eval_ctx, scene, weights, go->ob, ob_src, for_simulation);
 
                                if ( go->ob->particlesystem.first ) {
                                        ParticleSystem *psys= go->ob->particlesystem.first;
 
                                        for ( ; psys; psys=psys->next )
-                                               add_particles_to_effectors(&effectors, scene, weights, go->ob, psys, psys_src, for_simulation);
+                                               add_particles_to_effectors(&effectors, eval_ctx, scene, weights, go->ob, psys, psys_src, for_simulation);
                                }
                        }
                }
@@ -235,19 +245,19 @@ ListBase *pdInitEffectors(Scene *scene, Object *ob_src, ParticleSystem *psys_src
        else {
                for (base = FIRSTBASE_NEW; base; base = base->next) {
                        if ( base->object->pd && base->object->pd->forcefield )
-                               add_object_to_effectors(&effectors, scene, weights, base->object, ob_src, for_simulation);
+                               add_object_to_effectors(&effectors, eval_ctx, scene, weights, base->object, ob_src, for_simulation);
 
                        if ( base->object->particlesystem.first ) {
                                ParticleSystem *psys= base->object->particlesystem.first;
 
                                for ( ; psys; psys=psys->next )
-                                       add_particles_to_effectors(&effectors, scene, weights, base->object, psys, psys_src, for_simulation);
+                                       add_particles_to_effectors(&effectors, eval_ctx, scene, weights, base->object, psys, psys_src, for_simulation);
                        }
                }
        }
        
        if (for_simulation)
-               pdPrecalculateEffectors(effectors);
+               pdPrecalculateEffectors(eval_ctx, effectors);
        
        return effectors;
 }
@@ -268,7 +278,7 @@ void pdEndEffectors(ListBase **effectors)
        }
 }
 
-static void precalculate_effector(EffectorCache *eff)
+static void precalculate_effector(struct EvaluationContext *eval_ctx, EffectorCache *eff)
 {
        unsigned int cfra = (unsigned int)(eff->scene->r.cfra >= 0 ? eff->scene->r.cfra : -eff->scene->r.cfra);
        if (!eff->pd->rng)
@@ -280,7 +290,7 @@ static void precalculate_effector(EffectorCache *eff)
                Curve *cu= eff->ob->data;
                if (cu->flag & CU_PATH) {
                        if (eff->ob->curve_cache == NULL || eff->ob->curve_cache->path==NULL || eff->ob->curve_cache->path->data==NULL)
-                               BKE_displist_make_curveTypes(eff->scene, eff->ob, 0);
+                               BKE_displist_make_curveTypes(eval_ctx, eff->scene, eff->ob, 0);
 
                        if (eff->ob->curve_cache->path && eff->ob->curve_cache->path->data) {
                                where_on_path(eff->ob, 0.0, eff->guide_loc, eff->guide_dir, NULL, &eff->guide_radius, NULL);
@@ -301,19 +311,19 @@ static void precalculate_effector(EffectorCache *eff)
        if (eff->ob) {
                float old_vel[3];
 
-               BKE_object_where_is_calc_time(eff->scene, eff->ob, cfra - 1.0f);
+               BKE_object_where_is_calc_time(eval_ctx, eff->scene, eff->ob, cfra - 1.0f);
                copy_v3_v3(old_vel, eff->ob->obmat[3]);
-               BKE_object_where_is_calc_time(eff->scene, eff->ob, cfra);
+               BKE_object_where_is_calc_time(eval_ctx, eff->scene, eff->ob, cfra);
                sub_v3_v3v3(eff->velocity, eff->ob->obmat[3], old_vel);
        }
 }
 
-void pdPrecalculateEffectors(ListBase *effectors)
+void pdPrecalculateEffectors(struct EvaluationContext *eval_ctx, ListBase *effectors)
 {
        if (effectors) {
                EffectorCache *eff = effectors->first;
                for (; eff; eff=eff->next)
-                       precalculate_effector(eff);
+                       precalculate_effector(eval_ctx, eff);
        }
 }
 
@@ -612,6 +622,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
                }
                else {
                        ParticleSimulationData sim= {NULL};
+                       sim.eval_ctx = eff->eval_ctx;
                        sim.scene= eff->scene;
                        sim.ob= eff->ob;
                        sim.psys= eff->psys;
index 8247336d91566330132d4a9044e2c4f69dbec644..5599190010d02072717decd84d2386bd80c0da7c 100644 (file)
@@ -65,7 +65,7 @@
 // file handling
 //-------------------------------------------------------------------------------
 
-void initElbeemMesh(struct Scene *scene, struct Object *ob,
+void initElbeemMesh(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
                     int *numVertices, float **vertices,
                     int *numTriangles, int **triangles,
                     int useGlobalCoords, int modifierIndex)
@@ -78,7 +78,7 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob,
        float *verts;
        int *tris;
 
-       dm = mesh_create_derived_index_render(scene, ob, CD_MASK_BAREMESH, modifierIndex);
+       dm = mesh_create_derived_index_render(eval_ctx, scene, ob, CD_MASK_BAREMESH, modifierIndex);
 
        DM_ensure_looptri(dm);
 
index c6773d98adf265e66898cde9a3f6730a709bca35..fd984c17356d5aa4b6e0ed79ab647a473a20b8fd 100644 (file)
@@ -596,7 +596,7 @@ static bool where_on_path_deform(Object *ob, float ctime, float vec[4], float di
 /* co: local coord, result local too */
 /* returns quaternion for rotation, using cd->no_rot_axis */
 /* axis is using another define!!! */
-static bool calc_curve_deform(Scene *scene, Object *par, float co[3],
+static bool calc_curve_deform(struct EvaluationContext *eval_ctx, Scene *scene, Object *par, float co[3],
                               const short axis, CurveDeform *cd, float r_quat[4])
 {
        Curve *cu = par->data;
@@ -607,7 +607,7 @@ static bool calc_curve_deform(Scene *scene, Object *par, float co[3],
        /* to be sure, mostly after file load, also cyclic dependencies */
 #ifdef CYCLIC_DEPENDENCY_WORKAROUND
        if (par->curve_cache == NULL) {
-               BKE_displist_make_curveTypes(scene, par, false);
+               BKE_displist_make_curveTypes(eval_ctx, scene, par, false);
        }
 #endif
 
@@ -700,7 +700,7 @@ static bool calc_curve_deform(Scene *scene, Object *par, float co[3],
 }
 
 void curve_deform_verts(
-        Scene *scene, Object *cuOb, Object *target, DerivedMesh *dm, float (*vertexCos)[3],
+        struct EvaluationContext *eval_ctx, Scene *scene, Object *cuOb, Object *target, DerivedMesh *dm, float (*vertexCos)[3],
         int numVerts, const char *vgroup, short defaxis)
 {
        Curve *cu;
@@ -759,7 +759,7 @@ void curve_deform_verts(
                                if (weight > 0.0f) {
                                        mul_m4_v3(cd.curvespace, vertexCos[a]);
                                        copy_v3_v3(vec, vertexCos[a]);
-                                       calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL);
+                                       calc_curve_deform(eval_ctx, scene, cuOb, vec, defaxis, &cd, NULL);
                                        interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight);
                                        mul_m4_v3(cd.objectspace, vertexCos[a]);
                                }
@@ -782,7 +782,7 @@ void curve_deform_verts(
                                if (weight > 0.0f) {
                                        /* already in 'cd.curvespace', prev for loop */
                                        copy_v3_v3(vec, vertexCos[a]);
-                                       calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL);
+                                       calc_curve_deform(eval_ctx, scene, cuOb, vec, defaxis, &cd, NULL);
                                        interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight);
                                        mul_m4_v3(cd.objectspace, vertexCos[a]);
                                }
@@ -793,7 +793,7 @@ void curve_deform_verts(
                if (cu->flag & CU_DEFORM_BOUNDS_OFF) {
                        for (a = 0; a < numVerts; a++) {
                                mul_m4_v3(cd.curvespace, vertexCos[a]);
-                               calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
+                               calc_curve_deform(eval_ctx, scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
                                mul_m4_v3(cd.objectspace, vertexCos[a]);
                        }
                }
@@ -808,7 +808,7 @@ void curve_deform_verts(
        
                        for (a = 0; a < numVerts; a++) {
                                /* already in 'cd.curvespace', prev for loop */
-                               calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
+                               calc_curve_deform(eval_ctx, scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
                                mul_m4_v3(cd.objectspace, vertexCos[a]);
                        }
                }
@@ -818,7 +818,7 @@ void curve_deform_verts(
 /* input vec and orco = local coord in armature space */
 /* orco is original not-animated or deformed reference point */
 /* result written in vec and mat */
-void curve_deform_vector(Scene *scene, Object *cuOb, Object *target,
+void curve_deform_vector(struct EvaluationContext *eval_ctx, Scene *scene, Object *cuOb, Object *target,
                          float orco[3], float vec[3], float mat[3][3], int no_rot_axis)
 {
        CurveDeform cd;
@@ -837,7 +837,7 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target,
 
        mul_m4_v3(cd.curvespace, vec);
        
-       if (calc_curve_deform(scene, cuOb, vec, target->trackflag, &cd, quat)) {
+       if (calc_curve_deform(eval_ctx, scene, cuOb, vec, target->trackflag, &cd, quat)) {
                float qmat[3][3];
                
                quat_to_mat3(qmat, quat);
@@ -1027,7 +1027,7 @@ void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3])
        }
 }
 
-void BKE_lattice_modifiers_calc(Scene *scene, Object *ob)
+void BKE_lattice_modifiers_calc(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob)
 {
        Lattice *lt = ob->data;
        VirtualModifierData virtualModifierData;
@@ -1054,7 +1054,7 @@ void BKE_lattice_modifiers_calc(Scene *scene, Object *ob)
                if (mti->type != eModifierTypeType_OnlyDeform) continue;
 
                if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(ob, &numVerts);
-               mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0);
+               mti->deformVerts(md, eval_ctx, ob, NULL, vertexCos, numVerts, 0);
        }
 
        /* always displist to make this work like derivedmesh */
@@ -1248,4 +1248,4 @@ void BKE_lattice_batch_cache_free(Lattice *lt)
        if (lt->batch_cache) {
                BKE_lattice_batch_cache_free_cb(lt);
        }
-}
\ No newline at end of file
+}
index 6ee1eedec944fd8471b644e46c722b6dbaea8900..9be072f1a2183da0ece5366f80b779f6ed65605b 100644 (file)
@@ -1628,10 +1628,10 @@ void BKE_mesh_to_curve_nurblist(DerivedMesh *dm, ListBase *nurblist, const int e
        }
 }
 
-void BKE_mesh_to_curve(Scene *scene, Object *ob)
+void BKE_mesh_to_curve(EvaluationContext *eval_ctx, Scene *scene, Object *ob)
 {
        /* make new mesh data from the original copy */
-       DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_MESH);
+       DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_MESH);
        ListBase nurblist = {NULL, NULL};
        bool needsFree = false;
 
@@ -2466,7 +2466,7 @@ void BKE_mesh_split_faces(Mesh *mesh, bool free_loop_normals)
 
 /* settings: 1 - preview, 2 - render */
 Mesh *BKE_mesh_new_from_object(
-        Main *bmain, Scene *sce, Object *ob,
+        EvaluationContext *eval_ctx, Main *bmain, Scene *sce, Object *ob,
         int apply_modifiers, int settings, int calc_tessface, int calc_undeformed)
 {
        Mesh *tmpmesh;
@@ -2518,7 +2518,7 @@ Mesh *BKE_mesh_new_from_object(
                        copycu->editnurb = tmpcu->editnurb;
 
                        /* get updated display list, and convert to a mesh */
-                       BKE_displist_make_curveTypes_forRender(sce, tmpobj, &dispbase, &derivedFinal, false, render);
+                       BKE_displist_make_curveTypes_forRender(eval_ctx, sce, tmpobj, &dispbase, &derivedFinal, false, render);
 
                        copycu->editfont = NULL;
                        copycu->editnurb = NULL;
@@ -2569,13 +2569,7 @@ Mesh *BKE_mesh_new_from_object(
 
                        if (render) {
                                ListBase disp = {NULL, NULL};
-                               /* TODO(sergey): This is gonna to work for until EvaluationContext
-                                *               only contains for_render flag. As soon as CoW is
-                                *               implemented, this is to be rethinked.
-                                */
-                               EvaluationContext eval_ctx;
-                               DEG_evaluation_context_init(&eval_ctx, DAG_EVAL_RENDER);
-                               BKE_displist_make_mball_forRender(&eval_ctx, sce, ob, &disp);
+                               BKE_displist_make_mball_forRender(eval_ctx, sce, ob, &disp);
                                BKE_mesh_from_metaball(&disp, tmpmesh);
                                BKE_displist_free(&disp);
                        }
@@ -2614,9 +2608,9 @@ Mesh *BKE_mesh_new_from_object(
 
                                /* Write the display mesh into the dummy mesh */
                                if (render)
-                                       dm = mesh_create_derived_render(sce, ob, mask);
+                                       dm = mesh_create_derived_render(eval_ctx, sce, ob, mask);
                                else
-                                       dm = mesh_create_derived_view(sce, ob, mask);
+                                       dm = mesh_create_derived_view(eval_ctx, sce, ob, mask);
 
                                tmpmesh = BKE_mesh_add(bmain, ((ID *)ob->data)->name + 2);
                                DM_to_mesh(dm, tmpmesh, ob, mask, true);
@@ -2733,4 +2727,4 @@ void BKE_mesh_batch_cache_free(Mesh *me)
        if (me->batch_cache) {
                BKE_mesh_batch_cache_free_cb(me);
        }
-}
\ No newline at end of file
+}
index 2276d56b9c6f63c92a892b97a521e4c28c9170bf..b4eb132353cf422b557009a52b667eaccc5a1a93 100644 (file)
@@ -732,8 +732,8 @@ void modifier_path_init(char *path, int path_maxlen, const char *name)
 /* wrapper around ModifierTypeInfo.applyModifier that ensures valid normals */
 
 struct DerivedMesh *modwrap_applyModifier(
-        ModifierData *md, Object *ob,
-        struct DerivedMesh *dm,
+        ModifierData *md, struct EvaluationContext *eval_ctx,
+        Object *ob, struct DerivedMesh *dm,
         ModifierApplyFlag flag)
 {
        const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -742,12 +742,12 @@ struct DerivedMesh *modwrap_applyModifier(
        if (mti->dependsOnNormals && mti->dependsOnNormals(md)) {
                DM_ensure_normals(dm);
        }
-       return mti->applyModifier(md, ob, dm, flag);
+       return mti->applyModifier(md, eval_ctx, ob, dm, flag);
 }
 
 struct DerivedMesh *modwrap_applyModifierEM(
-        ModifierData *md, Object *ob,
-        struct BMEditMesh *em,
+        ModifierData *md, struct EvaluationContext *eval_ctx,
+        Object *ob, struct BMEditMesh *em,
         DerivedMesh *dm,
         ModifierApplyFlag flag)
 {
@@ -757,12 +757,12 @@ struct DerivedMesh *modwrap_applyModifierEM(
        if (mti->dependsOnNormals && mti->dependsOnNormals(md)) {
                DM_ensure_normals(dm);
        }
-       return mti->applyModifierEM(md, ob, em, dm, flag);
+       return mti->applyModifierEM(md, eval_ctx, ob, em, dm, flag);
 }
 
 void modwrap_deformVerts(
-        ModifierData *md, Object *ob,
-        DerivedMesh *dm,
+        ModifierData *md, struct EvaluationContext *eval_ctx,
+        Object *ob, DerivedMesh *dm,
         float (*vertexCos)[3], int numVerts,
         ModifierApplyFlag flag)
 {
@@ -772,11 +772,11 @@ void modwrap_deformVerts(
        if (dm && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
                DM_ensure_normals(dm);
        }
-       mti->deformVerts(md, ob, dm, vertexCos, numVerts, flag);
+       mti->deformVerts(md, eval_ctx, ob, dm, vertexCos, numVerts, flag);
 }
 
 void modwrap_deformVertsEM(
-        ModifierData *md, Object *ob,
+        ModifierData *md, struct EvaluationContext *eval_ctx, Object *ob,
         struct BMEditMesh *em, DerivedMesh *dm,
         float (*vertexCos)[3], int numVerts)
 {
@@ -786,6 +786,6 @@ void modwrap_deformVertsEM(
        if (dm && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
                DM_ensure_normals(dm);
        }
-       mti->deformVertsEM(md, ob, em, dm, vertexCos, numVerts);
+       mti->deformVertsEM(md, eval_ctx, ob, em, dm, vertexCos, numVerts);
 }
 /* end modifier callback wrappers */
index 9679b585e6fa18510fd5aa8eb3ae146b01362183..3e4828afb55c27bf9a9382f6bace73dbcd3d5f90 100644 (file)
@@ -276,14 +276,14 @@ static MDisps *multires_mdisps_initialize_hidden(Mesh *me, int level)
        return mdisps;
 }
 
-DerivedMesh *get_multires_dm(Scene *scene, MultiresModifierData *mmd, Object *ob)
+DerivedMesh *get_multires_dm(struct EvaluationContext *eval_ctx, Scene *scene, MultiresModifierData *mmd, Object *ob)
 {
        ModifierData *md = (ModifierData *)mmd;
        const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
-       DerivedMesh *tdm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
+       DerivedMesh *tdm = mesh_get_derived_deform(eval_ctx, scene, ob, CD_MASK_BAREMESH);
        DerivedMesh *dm;
 
-       dm = mti->applyModifier(md, ob, tdm, MOD_APPLY_USECACHE | MOD_APPLY_IGNORE_SIMPLIFY);
+       dm = mti->applyModifier(md, eval_ctx, ob, tdm, MOD_APPLY_USECACHE | MOD_APPLY_IGNORE_SIMPLIFY);
        if (dm == tdm) {
                dm = CDDM_copy(tdm);
        }
@@ -397,10 +397,10 @@ void multires_force_render_update(Object *ob)
                multires_force_update(ob);
 }
 
-int multiresModifier_reshapeFromDM(Scene *scene, MultiresModifierData *mmd,
+int multiresModifier_reshapeFromDM(struct EvaluationContext *eval_ctx, Scene *scene, MultiresModifierData *mmd,
                                    Object *ob, DerivedMesh *srcdm)
 {
-       DerivedMesh *mrdm = get_multires_dm(scene, mmd, ob);
+       DerivedMesh *mrdm = get_multires_dm(eval_ctx, scene, mmd, ob);
 
        if (mrdm && srcdm && mrdm->getNumVerts(mrdm) == srcdm->getNumVerts(srcdm)) {
                multires_mvert_to_ss(mrdm, srcdm->getVertArray(srcdm));
@@ -419,13 +419,13 @@ int multiresModifier_reshapeFromDM(Scene *scene, MultiresModifierData *mmd,
 }
 
 /* Returns 1 on success, 0 if the src's totvert doesn't match */
-int multiresModifier_reshape(Scene *scene, MultiresModifierData *mmd, Object *dst, Object *src)
+int multiresModifier_reshape(struct EvaluationContext *eval_ctx, Scene *scene, MultiresModifierData *mmd, Object *dst, Object *src)
 {
-       DerivedMesh *srcdm = mesh_get_derived_final(scene, src, CD_MASK_BAREMESH);
-       return multiresModifier_reshapeFromDM(scene, mmd, dst, srcdm);
+       DerivedMesh *srcdm = mesh_get_derived_final(eval_ctx, scene, src, CD_MASK_BAREMESH);
+       return multiresModifier_reshapeFromDM(eval_ctx, scene, mmd, dst, srcdm);
 }
 
-int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mmd,
+int multiresModifier_reshapeFromDeformMod(struct EvaluationContext *eval_ctx, Scene *scene, MultiresModifierData *mmd,
                                           Object *ob, ModifierData *md)
 {
        const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -437,12 +437,12 @@ int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mm
                return 0;
 
        /* Create DerivedMesh for deformation modifier */
-       dm = get_multires_dm(scene, mmd, ob);
+       dm = get_multires_dm(eval_ctx, scene, mmd, ob);
        numVerts = dm->getNumVerts(dm);
        deformedVerts = MEM_mallocN(sizeof(float[3]) * numVerts, "multiresReshape_deformVerts");
 
        dm->getVertCos(dm, deformedVerts);
-       mti->deformVerts(md, ob, dm, deformedVerts, numVerts, 0);
+       mti->deformVerts(md, eval_ctx, ob, dm, deformedVerts, numVerts, 0);
 
        ndm = CDDM_copy(dm);
        CDDM_apply_vert_coords(ndm, deformedVerts);
@@ -451,7 +451,7 @@ int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mm
        dm->release(dm);
 
        /* Reshaping */
-       result = multiresModifier_reshapeFromDM(scene, mmd, ob, ndm);
+       result = multiresModifier_reshapeFromDM(eval_ctx, scene, mmd, ob, ndm);
 
        /* Cleanup */
        ndm->release(ndm);
@@ -2174,7 +2174,7 @@ static void multires_sync_levels(Scene *scene, Object *ob_src, Object *ob_dst)
        }
 }
 
-static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
+static void multires_apply_smat(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float smat[3][3])
 {
        DerivedMesh *dm = NULL, *cddm = NULL, *subdm = NULL;
        CCGElem **gridData, **subGridData;
@@ -2199,10 +2199,10 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
        high_mmd.lvl = high_mmd.totlvl;
 
        /* unscaled multires with applied displacement */
-       subdm = get_multires_dm(scene, &high_mmd, ob);
+       subdm = get_multires_dm(eval_ctx, scene, &high_mmd, ob);
 
        /* prepare scaled CDDM to create ccgDN */
-       cddm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
+       cddm = mesh_get_derived_deform(eval_ctx, scene, ob, CD_MASK_BAREMESH);
 
        totvert = cddm->getNumVerts(cddm);
        vertCos = MEM_mallocN(sizeof(*vertCos) * totvert, "multiresScale vertCos");
@@ -2276,17 +2276,17 @@ int multires_mdisp_corners(MDisps *s)
        return 0;
 }
 
-void multiresModifier_scale_disp(Scene *scene, Object *ob)
+void multiresModifier_scale_disp(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob)
 {
        float smat[3][3];
 
        /* object's scale matrix */
        BKE_object_scale_to_mat3(ob, smat);
 
-       multires_apply_smat(scene, ob, smat);
+       multires_apply_smat(eval_ctx, scene, ob, smat);
 }
 
-void multiresModifier_prepare_join(Scene *scene, Object *ob, Object *to_ob)
+void multiresModifier_prepare_join(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, Object *to_ob)
 {
        float smat[3][3], tmat[3][3], mat[3][3];
        multires_sync_levels(scene, to_ob, ob);
@@ -2297,7 +2297,7 @@ void multiresModifier_prepare_join(Scene *scene, Object *ob, Object *to_ob)
        BKE_object_scale_to_mat3(ob, smat);
        mul_m3_m3m3(mat, smat, tmat);
 
-       multires_apply_smat(scene, ob, mat);
+       multires_apply_smat(eval_ctx, scene, ob, mat);
 }
 
 /* update multires data after topology changing */
index 68e5ddf85834025f00ded2f2966c0e62d6b58217..858c60824fc9bfaae5b43adc62d54649ca26d231 100644 (file)
@@ -1709,13 +1709,16 @@ static bool ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4])
        Curve *cu = par->data;
        float vec[4], dir[3], quat[4], radius, ctime;
 
+       /* TODO: Make sure this doesn't crash. */
+#if 0
        /* only happens on reload file, but violates depsgraph still... fix! */
        if (par->curve_cache == NULL) {
                if (scene == NULL) {
                        return false;
                }
-               BKE_displist_make_curveTypes(scene, par, 0);
+               BKE_displist_make_curveTypes(eval_ctx, scene, par, 0);
        }
+#endif
 
        if (par->curve_cache->path == NULL) {
                return false;
@@ -2096,7 +2099,7 @@ static bool where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat
 }
 
 /* note, scene is the active scene while actual_scene is the scene the object resides in */
-void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
+void BKE_object_where_is_calc_time_ex(EvaluationContext *eval_ctx, Scene *scene, Object *ob, float ctime,
                                       RigidBodyWorld *rbw, float r_originmat[3][3])
 {
        if (ob == NULL) return;
@@ -2132,7 +2135,7 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
        if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) {
                bConstraintOb *cob;
                cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
-               BKE_constraints_solve(&ob->constraints, cob, ctime);
+               BKE_constraints_solve(eval_ctx, &ob->constraints, cob, ctime);
                BKE_constraints_clear_evalob(cob);
        }
        
@@ -2141,9 +2144,9 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
        else ob->transflag &= ~OB_NEG_SCALE;
 }
 
-void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime)
+void BKE_object_where_is_calc_time(EvaluationContext *eval_ctx, Scene *scene, Object *ob, float ctime)
 {
-       BKE_object_where_is_calc_time_ex(scene, ob, ctime, NULL, NULL);
+       BKE_object_where_is_calc_time_ex(eval_ctx, scene, ob, ctime, NULL, NULL);
 }
 
 /* get object transformation matrix without recalculating dependencies and
@@ -2168,17 +2171,17 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
        }
 }
 
-void BKE_object_where_is_calc_ex(Scene *scene, RigidBodyWorld *rbw, Object *ob, float r_originmat[3][3])
+void BKE_object_where_is_calc_ex(EvaluationContext *eval_ctx, Scene *scene, RigidBodyWorld *rbw, Object *ob, float r_originmat[3][3])
 {
-       BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), rbw, r_originmat);
+       BKE_object_where_is_calc_time_ex(eval_ctx, scene, ob, BKE_scene_frame_get(scene), rbw, r_originmat);
 }
-void BKE_object_where_is_calc(Scene *scene, Object *ob)
+void BKE_object_where_is_calc(EvaluationContext *eval_ctx, Scene *scene, Object *ob)
 {
-       BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), NULL, NULL);
+       BKE_object_where_is_calc_time_ex(eval_ctx, scene, ob, BKE_scene_frame_get(scene), NULL, NULL);
 }
 
 /* for calculation of the inverse parent transform, only used for editor */
-void BKE_object_workob_calc_parent(Scene *scene, Object *ob, Object *workob)
+void BKE_object_workob_calc_parent(EvaluationContext *eval_ctx, Scene *scene, Object *ob, Object *workob)
 {
        BKE_object_workob_clear(workob);
        
@@ -2200,7 +2203,7 @@ void BKE_object_workob_calc_parent(Scene *scene, Object *ob, Object *workob)
 
        BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr));
 
-       BKE_object_where_is_calc(scene, workob);
+       BKE_object_where_is_calc(eval_ctx, scene, workob);
 }
 
 /* see BKE_pchan_apply_mat4() for the equivalent 'pchan' function */
@@ -2679,7 +2682,7 @@ void BKE_object_handle_update_ex(EvaluationContext *eval_ctx,
                                        copy_m4_m4(ob->obmat, ob->proxy_from->obmat);
                        }
                        else
-                               BKE_object_where_is_calc_ex(scene, rbw, ob, NULL);
+                               BKE_object_where_is_calc_ex(eval_ctx, scene, rbw, ob, NULL);
                }
                
                if (ob->recalc & OB_RECALC_DATA) {
@@ -3625,7 +3628,7 @@ static void object_cacheIgnoreClear(Object *ob, int state)
 /* Note: this function should eventually be replaced by depsgraph functionality.
  * Avoid calling this in new code unless there is a very good reason for it!
  */
-bool BKE_object_modifier_update_subframe(Scene *scene, Object *ob, bool update_mesh,
+bool BKE_object_modifier_update_subframe(EvaluationContext *eval_ctx, Scene *scene, Object *ob, bool update_mesh,
                                          int parent_recursion, float frame,
                                          int type)
 {
@@ -3650,8 +3653,8 @@ bool BKE_object_modifier_update_subframe(Scene *scene, Object *ob, bool update_m
        if (parent_recursion) {
                int recursion = parent_recursion - 1;
                bool no_update = false;
-               if (ob->parent) no_update |= BKE_object_modifier_update_subframe(scene, ob->parent, 0, recursion, frame, type);
-               if (ob->track) no_update |= BKE_object_modifier_update_subframe(scene, ob->track, 0, recursion, frame, type);
+               if (ob->parent) no_update |= BKE_object_modifier_update_subframe(eval_ctx, scene, ob->parent, 0, recursion, frame, type);
+               if (ob->track) no_update |= BKE_object_modifier_update_subframe(eval_ctx, scene, ob->track, 0, recursion, frame, type);
 
                /* skip subframe if object is parented
                 *  to vertex of a dynamic paint canvas */
@@ -3668,7 +3671,7 @@ bool BKE_object_modifier_update_subframe(Scene *scene, Object *ob, bool update_m
                                cti->get_constraint_targets(con, &targets);
                                for (ct = targets.first; ct; ct = ct->next) {
                                        if (ct->tar)
-                                               BKE_object_modifier_update_subframe(scene, ct->tar, 0, recursion, frame, type);
+                                               BKE_object_modifier_update_subframe(eval_ctx, scene, ct->tar, 0, recursion, frame, type);
                                }
                                /* free temp targets */
                                if (cti->flush_constraint_targets)
@@ -3688,7 +3691,7 @@ bool BKE_object_modifier_update_subframe(Scene *scene, Object *ob, bool update_m
                object_cacheIgnoreClear(ob, 0);
        }
        else
-               BKE_object_where_is_calc_time(scene, ob, frame);
+               BKE_object_where_is_calc_time(eval_ctx, scene, ob, frame);
 
        /* for curve following objects, parented curve has to be updated too */
        if (ob->type == OB_CURVE) {
@@ -3699,7 +3702,7 @@ bool BKE_object_modifier_update_subframe(Scene *scene, Object *ob, bool update_m
        if (ob->type == OB_ARMATURE) {
                bArmature *arm = ob->data;
                BKE_animsys_evaluate_animdata(scene, &arm->id, arm->adt, frame, ADT_RECALC_ANIM);
-               BKE_pose_where_is(scene, ob);
+               BKE_pose_where_is(eval_ctx, scene, ob);
        }
 
        return false;
index 1f10ed252491aa08cf1ca1d01dd20aa317a94f7c..bb57e9b13b61194593e27bde1e703b7f167c4e2f 100644 (file)
@@ -397,7 +397,7 @@ static void make_duplis_frames(const DupliContext *ctx)
                         * However, this has always been the way that this worked (i.e. pre 2.5), so I guess that it'll be fine!
                         */
                        BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */
-                       BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra);
+                       BKE_object_where_is_calc_time(ctx->eval_ctx, scene, ob, (float)scene->r.cfra);
 
                        make_dupli(ctx, ob, ob->obmat, scene->r.cfra, false, false);
                }
@@ -411,7 +411,7 @@ static void make_duplis_frames(const DupliContext *ctx)
        scene->r.cfra = cfrao;
 
        BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */
-       BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra);
+       BKE_object_where_is_calc_time(ctx->eval_ctx, scene, ob, (float)scene->r.cfra);
 
        /* but, to make sure unkeyed object transforms are still sane,
         * let's copy object's original data back over
@@ -546,13 +546,13 @@ static void make_duplis_verts(const DupliContext *ctx)
                CustomDataMask dm_mask = (use_texcoords ? CD_MASK_BAREMESH | CD_MASK_ORCO : CD_MASK_BAREMESH);
 
                if (ctx->eval_ctx->mode == DAG_EVAL_RENDER) {
-                       vdd.dm = mesh_create_derived_render(scene, parent, dm_mask);
+                       vdd.dm = mesh_create_derived_render(ctx->eval_ctx, scene, parent, dm_mask);
                }
                else if (em) {
-                       vdd.dm = editbmesh_get_derived_cage(scene, parent, em, dm_mask);
+                       vdd.dm = editbmesh_get_derived_cage(ctx->eval_ctx, scene, parent, em, dm_mask);
                }
                else {
-                       vdd.dm = mesh_get_derived_final(scene, parent, dm_mask);
+                       vdd.dm = mesh_get_derived_final(ctx->eval_ctx, scene, parent, dm_mask);
                }
                vdd.edit_btmesh = me->edit_btmesh;
 
@@ -814,13 +814,13 @@ static void make_duplis_faces(const DupliContext *ctx)
                CustomDataMask dm_mask = (use_texcoords ? CD_MASK_BAREMESH | CD_MASK_ORCO | CD_MASK_MLOOPUV : CD_MASK_BAREMESH);
 
                if (ctx->eval_ctx->mode == DAG_EVAL_RENDER) {
-                       fdd.dm = mesh_create_derived_render(scene, parent, dm_mask);
+                       fdd.dm = mesh_create_derived_render(ctx->eval_ctx, scene, parent, dm_mask);
                }
                else if (em) {
-                       fdd.dm = editbmesh_get_derived_cage(scene, parent, em, dm_mask);
+                       fdd.dm = editbmesh_get_derived_cage(ctx->eval_ctx, scene, parent, em, dm_mask);
                }
                else {
-                       fdd.dm = mesh_get_derived_final(scene, parent, dm_mask);
+                       fdd.dm = mesh_get_derived_final(ctx->eval_ctx, scene, parent, dm_mask);
                }
 
                if (use_texcoords) {
@@ -898,6 +898,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
 
        if ((psys->renderdata || part->draw_as == PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
                ParticleSimulationData sim = {NULL};
+               sim.eval_ctx = ctx->eval_ctx;
                sim.scene = scene;
                sim.ob = par;
                sim.psys = psys;
@@ -1079,7 +1080,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
                        }
                        else {
                                /* to give ipos in object correct offset */
-                               BKE_object_where_is_calc_time(scene, ob, ctime - pa_time);
+                               BKE_object_where_is_calc_time(ctx->eval_ctx, scene, ob, ctime - pa_time);
 
                                copy_v3_v3(vec, obmat[3]);
                                obmat[3][0] = obmat[3][1] = obmat[3][2] = 0.0f;
@@ -1271,7 +1272,7 @@ int count_duplilist(Object *ob)
        return 1;
 }
 
-DupliApplyData *duplilist_apply(Object *ob, Scene *scene, ListBase *duplilist)
+DupliApplyData *duplilist_apply(EvaluationContext *eval_ctx, Object *ob, Scene *scene, ListBase *duplilist)
 {
        DupliApplyData *apply_data = NULL;
        int num_objects = BLI_listbase_count(duplilist);
@@ -1287,7 +1288,7 @@ DupliApplyData *duplilist_apply(Object *ob, Scene *scene, ListBase *duplilist)
                for (dob = duplilist->first, i = 0; dob; dob = dob->next, ++i) {
                        /* make sure derivedmesh is calculated once, before drawing */
                        if (scene && !(dob->ob->transflag & OB_DUPLICALCDERIVED) && dob->ob->type == OB_MESH) {
-                               mesh_get_derived_final(scene, dob->ob, scene->customdata_mask);
+                               mesh_get_derived_final(eval_ctx, scene, dob->ob, scene->customdata_mask);
                                dob->ob->transflag |= OB_DUPLICALCDERIVED;
                        }
                }
index 4684deb1238821bcaefbb66485345484412ff692..a478671d8a053d02d5bc691b52e45bc52e168d43 100644 (file)
@@ -113,7 +113,7 @@ void BKE_object_eval_parent(EvaluationContext *UNUSED(eval_ctx),
        }
 }
 
-void BKE_object_eval_constraints(EvaluationContext *UNUSED(eval_ctx),
+void BKE_object_eval_constraints(EvaluationContext *eval_ctx,
                                  Scene *scene,
                                  Object *ob)
 {
@@ -132,7 +132,7 @@ void BKE_object_eval_constraints(EvaluationContext *UNUSED(eval_ctx),
         *
         */
        cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
-       BKE_constraints_solve(&ob->constraints, cob, ctime);
+       BKE_constraints_solve(eval_ctx, &ob->constraints, cob, ctime);
        BKE_constraints_clear_evalob(cob);
 }
 
@@ -184,10 +184,10 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx,
                        }
 #endif
                        if (em) {
-                               makeDerivedMesh(scene, ob, em,  data_mask, false); /* was CD_MASK_BAREMESH */
+                               makeDerivedMesh(eval_ctx, scene, ob, em,  data_mask, false); /* was CD_MASK_BAREMESH */
                        }
                        else {
-                               makeDerivedMesh(scene, ob, NULL, data_mask, false);
+                               makeDerivedMesh(eval_ctx, scene, ob, NULL, data_mask, false);
                        }
                        break;
     &n