[Bf-blender-cvs] [e46c49ff3dd] blender2.8: Fix T53788: Camera animation not working

Sergey Sharybin noreply at git.blender.org
Fri Jan 19 11:15:59 CET 2018


Commit: e46c49ff3dd67c7d759b581b677b4ab90cee3c46
Author: Sergey Sharybin
Date:   Thu Jan 18 15:58:02 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBe46c49ff3dd67c7d759b581b677b4ab90cee3c46

Fix T53788: Camera animation not working

Both object level and camera datablock properties animation did not work with
copy on write enabled.

The root of the issue is going to the fact, that all interface elements are
referencing original datablock. For example, View3D has pointer to camera it's
using, and all areas which does access v3d->camera should in fact query for
the evaluated version of that camera, within the current context.

Annoying part of this change is that we now need to pass depsgraph in lots
of places. Which is rather annoying.

Alternative would be to cache evaluated camera in viewport itself, but then
it makes it annoying to keep things in sync.

Not sure if there is nicer solution here.

Reviewers: dfelinto, campbellbarton, mont29

Subscribers: dragoneex

Differential Revision: https://developer.blender.org/D3007

===================================================================

M	source/blender/blenkernel/BKE_camera.h
M	source/blender/blenkernel/intern/camera.c
M	source/blender/draw/engines/eevee/eevee_depth_of_field.c
M	source/blender/draw/engines/eevee/eevee_motion_blur.c
M	source/blender/draw/modes/object_mode.c
M	source/blender/editors/armature/editarmature_sketch.c
M	source/blender/editors/curve/editcurve_paint.c
M	source/blender/editors/gpencil/drawgpencil.c
M	source/blender/editors/gpencil/gpencil_convert.c
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/editors/gpencil/gpencil_utils.c
M	source/blender/editors/include/ED_gpencil.h
M	source/blender/editors/include/ED_mesh.h
M	source/blender/editors/include/ED_view3d.h
M	source/blender/editors/manipulator_library/manipulator_library_utils.c
M	source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
M	source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
M	source/blender/editors/mesh/editmesh_knife.c
M	source/blender/editors/mesh/editmesh_polybuild.c
M	source/blender/editors/mesh/editmesh_utils.c
M	source/blender/editors/physics/particle_edit.c
M	source/blender/editors/render/render_internal.c
M	source/blender/editors/sculpt_paint/paint_image_proj.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/editors/space_view3d/view3d_draw_legacy.c
M	source/blender/editors/space_view3d/view3d_edit.c
M	source/blender/editors/space_view3d/view3d_fly.c
M	source/blender/editors/space_view3d/view3d_intern.h
M	source/blender/editors/space_view3d/view3d_manipulator_camera.c
M	source/blender/editors/space_view3d/view3d_project.c
M	source/blender/editors/space_view3d/view3d_view.c
M	source/blender/editors/space_view3d/view3d_walk.c
M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform.h
M	source/blender/editors/transform/transform_generics.c
M	source/blender/editors/transform/transform_snap_object.c
M	source/blender/windowmanager/intern/wm_draw.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_camera.h b/source/blender/blenkernel/BKE_camera.h
index f69ac7e01cd..d5bf2177f71 100644
--- a/source/blender/blenkernel/BKE_camera.h
+++ b/source/blender/blenkernel/BKE_camera.h
@@ -39,6 +39,7 @@ extern "C" {
 #include "DNA_vec_types.h"
 
 struct Camera;
+struct Depsgraph;
 struct Main;
 struct Object;
 struct RegionView3D;
@@ -113,7 +114,7 @@ typedef struct CameraParams {
 
 void BKE_camera_params_init(CameraParams *params);
 void BKE_camera_params_from_object(CameraParams *params, const struct Object *camera);
-void BKE_camera_params_from_view3d(CameraParams *params, const struct View3D *v3d, const struct RegionView3D *rv3d);
+void BKE_camera_params_from_view3d(CameraParams *params, const struct Depsgraph *depsgraph, const struct View3D *v3d, const struct RegionView3D *rv3d);
 
 void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int winy, float aspx, float aspy);
 void BKE_camera_params_compute_matrix(CameraParams *params);
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index 4993caf14f1..869e312614e 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -57,6 +57,8 @@
 #include "BKE_scene.h"
 #include "BKE_screen.h"
 
+#include "DEG_depsgraph_query.h"
+
 #include "MEM_guardedalloc.h"
 
 #include "GPU_compositing.h"
@@ -262,7 +264,7 @@ void BKE_camera_params_from_object(CameraParams *params, const Object *ob)
 	}
 }
 
-void BKE_camera_params_from_view3d(CameraParams *params, const View3D *v3d, const RegionView3D *rv3d)
+void BKE_camera_params_from_view3d(CameraParams *params, const Depsgraph *depsgraph, const View3D *v3d, const RegionView3D *rv3d)
 {
 	/* common */
 	params->lens = v3d->lens;
@@ -271,7 +273,8 @@ void BKE_camera_params_from_view3d(CameraParams *params, const View3D *v3d, cons
 
 	if (rv3d->persp == RV3D_CAMOB) {
 		/* camera view */
-		BKE_camera_params_from_object(params, v3d->camera);
+		Object *camera_object = DEG_get_evaluated_object(depsgraph, v3d->camera);
+		BKE_camera_params_from_object(params, camera_object);
 
 		params->zoom = BKE_screen_view3d_zoom_to_fac(rv3d->camzoom);
 
diff --git a/source/blender/draw/engines/eevee/eevee_depth_of_field.c b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
index 36f433d5ffb..124873add96 100644
--- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c
+++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
@@ -45,6 +45,7 @@
 #include "BKE_screen.h"
 
 #include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
 
 #include "eevee_private.h"
 #include "GPU_extensions.h"
@@ -96,7 +97,8 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *v
 
 		if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
 			const float *viewport_size = DRW_viewport_size_get();
-			Camera *cam = (Camera *)v3d->camera->data;
+			Object *camera_object = DEG_get_evaluated_object(draw_ctx->depsgraph, v3d->camera);
+			Camera *cam = (Camera *)camera_object->data;
 
 			/* Retreive Near and Far distance */
 			effects->dof_near_far[0] = -cam->clipsta;
@@ -145,7 +147,7 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *v
 			float rotation = cam->gpu_dof.rotation;
 			float ratio = 1.0f / cam->gpu_dof.ratio;
 			float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y);
-			float focus_dist = BKE_camera_object_dof_distance(v3d->camera);
+			float focus_dist = BKE_camera_object_dof_distance(camera_object);
 			float focal_len = cam->lens;
 
 			UNUSED_VARS(rotation, ratio);
diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c
index 10c8ab5744a..b05fbf8c7fb 100644
--- a/source/blender/draw/engines/eevee/eevee_motion_blur.c
+++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c
@@ -40,6 +40,7 @@
 #include "ED_screen.h"
 
 #include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
 
 #include "eevee_private.h"
 #include "GPU_texture.h"
@@ -147,11 +148,12 @@ int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *veda
 			float persmat[4][4];
 			float ctime = BKE_scene_frame_get(scene);
 			float delta = BKE_collection_engine_property_value_get_float(props, "motion_blur_shutter");
+			Object *camera_object = DEG_get_evaluated_object(draw_ctx->depsgraph, v3d->camera);
 
 			/* Current matrix */
 			eevee_motion_blur_camera_get_matrix_at_time(scene,
 			                                            ar, rv3d, v3d,
-			                                            v3d->camera,
+			                                            camera_object,
 			                                            ctime,
 			                                            effects->current_ndc_to_world);
 
@@ -165,7 +167,7 @@ int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *veda
 				/* Past matrix */
 				eevee_motion_blur_camera_get_matrix_at_time(scene,
 				                                            ar, rv3d, v3d,
-				                                            v3d->camera,
+				                                            camera_object,
 				                                            ctime - delta,
 				                                            effects->past_world_to_ndc);
 
@@ -173,7 +175,7 @@ int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *veda
 				/* Future matrix */
 				eevee_motion_blur_camera_get_matrix_at_time(scene,
 				                                            ar, rv3d, v3d,
-				                                            v3d->camera,
+				                                            camera_object,
 				                                            ctime + delta,
 				                                            effects->future_world_to_ndc);
 #endif
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 4e19eff3cfb..1d4d82bf900 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -61,6 +61,8 @@
 #include "draw_manager_text.h"
 #include "draw_common.h"
 
+#include "DEG_depsgraph_query.h"
+
 extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
 extern struct GPUTexture *globals_ramp; /* draw_common.c */
 extern GlobalsUboStorage ts;
@@ -506,8 +508,14 @@ static void OBJECT_engine_init(void *vedata)
 			e_data.zneg_flag = e_data.zpos_flag = CLIP_ZNEG | CLIP_ZPOS;
 		}
 
-		float dist = (rv3d->persp == RV3D_CAMOB && v3d->camera)
-		             ? ((Camera *)v3d->camera)->clipend : v3d->far;
+		float dist;
+		if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
+			Object *camera_object = DEG_get_evaluated_object(draw_ctx->depsgraph, v3d->camera);
+			dist = ((Camera *)camera_object)->clipend;
+		}
+		else {
+			dist = v3d->far;
+		}
 
 		e_data.grid_settings[0] = dist / 2.0f; /* gridDistance */
 		e_data.grid_settings[1] = grid_res; /* gridResolution */
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index 4dd8e4bd6fa..f4bebfd85e0 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -929,7 +929,7 @@ static void sk_interpolateDepth(bContext *C, SK_Stroke *stk, int start, int end,
 		float pval[2] = {0, 0};
 
 		ED_view3d_project_float_global(ar, stk->points[i].p, pval, V3D_PROJ_TEST_NOP);
-		ED_view3d_win_to_ray(ar, v3d, pval, ray_start, ray_normal, false);
+		ED_view3d_win_to_ray(CTX_data_depsgraph(C), ar, v3d, pval, ray_start, ray_normal, false);
 
 		mul_v3_fl(ray_normal, distance * progress / length);
 		add_v3_v3(stk->points[i].p, ray_normal);
@@ -1486,6 +1486,7 @@ static int cmpIntersections(const void *i1, const void *i2)
 /* returns the maximum number of intersections per stroke */
 static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, SK_Stroke *gesture)
 {
+	const Depsgraph *depsgraph = CTX_data_depsgraph(C);
 	ARegion *ar = CTX_wm_region(C);
 	ScrArea *sa = CTX_wm_area(C);
 	View3D *v3d = sa->spacedata.first;
@@ -1526,7 +1527,7 @@ static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, S
 
 					mval[0] = vi[0];
 					mval[1] = vi[1];
-					ED_view3d_win_to_segment(ar, v3d, mval, ray_start, ray_end, true);
+					ED_view3d_win_to_segment(depsgraph, ar, v3d, mval, ray_start, ray_end, true);
 
 					isect_line_line_v3(stk->points[s_i].p,
 					                   stk->points[s_i + 1].p,
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index 5a71cc39f80..062b9c94a1b 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -93,6 +93,8 @@ struct StrokeElem {
 };
 
 struct CurveDrawData {
+	const Depsgraph *depsgraph;
+
 	short init_event_type;
 	short curve_type;
 
@@ -199,7 +201,7 @@ static bool stroke_elem_project(
 	if (cdd->project.use_plane) {
 		/* get the view vector to 'location' */
 		float ray_origin[3], ray_direction[3];
-		ED_view3d_win_to_ray(cdd->vc.ar, v3d, mval_fl, ray_origin, ray_direction, false);
+		ED_view3d_win_to_ray(cdd->depsgraph, cdd->vc.ar, v3d, mval_fl, ray_origin, ray_direction, false);
 
 		float lambda;
 		if (isect_ray_plane_v3(ray_origin, ray_direction, cdd->project.plane, &lambda, true)) {
@@ -603,6 +605,8 @@ static bool curve_draw_init(bContext *C, wmOperator *op, bool is_invoke)
 
 	struct CurveDrawData *cdd = MEM_callocN(sizeof(*cdd), __func__);
 
+	cdd->depsgraph = CTX_data_depsgraph(C);
+
 	if (is_invoke) {
 		view3d_set_viewcontext(C, &cdd->vc);
 		if (ELEM(NULL, cdd->vc.ar, cdd->vc.rv3d, cdd->vc.v3d, cdd->vc.win, cdd->vc.scene)) {
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 1674091f138..4a95027528b 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -1672,6 +1672,7 @@ void ED_gpencil_draw_view2d(const bContext *C, bool onlyv2d)
 void ED_gpencil_draw_view3d(wmWindowManager *wm,
                             Scene *scene,
                             Vi

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list