diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-05-25 12:05:51 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-05-25 13:48:33 +0300 |
commit | fbc65c6b28fb4cec4ad67ba0345cd045914af20e (patch) | |
tree | 5377c9cb59620f7d5adc57bddf3dc3c37272ad10 /source/blender/makesrna/intern/rna_object_api.c | |
parent | 8a78a53e3bbaa119e00a416a289b75889650d3b6 (diff) |
Fix T55165: Driving camera lens with property behaves unexpectedly
Differential Revision: https://developer.blender.org/D3438
Diffstat (limited to 'source/blender/makesrna/intern/rna_object_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_object_api.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 04507d1ed7e..a01192dad68 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -89,6 +89,8 @@ static const EnumPropertyItem space_items[] = { #include "DNA_scene_types.h" #include "DNA_view3d_types.h" +#include "DEG_depsgraph_query.h" + #include "MEM_guardedalloc.h" static void rna_Object_select_set(Object *ob, bContext *C, ReportList *reports, int action) @@ -173,13 +175,14 @@ static void rna_Object_mat_convert_space(Object *ob, ReportList *reports, bPoseC } static void rna_Object_calc_matrix_camera( - Object *ob, float mat_ret[16], int width, int height, float scalex, float scaley) + Object *ob, Depsgraph *depsgraph, float mat_ret[16], int width, int height, float scalex, float scaley) { + const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); CameraParams params; /* setup parameters */ BKE_camera_params_init(¶ms); - BKE_camera_params_from_object(¶ms, ob); + BKE_camera_params_from_object(¶ms, ob_eval); /* compute matrix, viewplane, .. */ BKE_camera_params_compute_viewplane(¶ms, width, height, scalex, scaley); @@ -189,9 +192,9 @@ static void rna_Object_calc_matrix_camera( } static void rna_Object_camera_fit_coords( - Object *ob, Scene *scene, int num_cos, float *cos, float co_ret[3], float *scale_ret) + Object *ob, Depsgraph *depsgraph, int num_cos, float *cos, float co_ret[3], float *scale_ret) { - BKE_camera_view_frame_fit_to_coords(scene, (const float (*)[3])cos, num_cos / 3, ob, co_ret, scale_ret); + BKE_camera_view_frame_fit_to_coords(depsgraph, (const float (*)[3])cos, num_cos / 3, ob, co_ret, scale_ret); } /* copied from Mesh_getFromObject and adapted to RNA interface */ @@ -518,6 +521,9 @@ void RNA_api_object(StructRNA *srna) func = RNA_def_function(srna, "calc_matrix_camera", "rna_Object_calc_matrix_camera"); RNA_def_function_ui_description(func, "Generate the camera projection matrix of this object " "(mostly useful for Camera and Lamp types)"); + parm = RNA_def_pointer(func, "depsgraph", "Depsgraph", "", + "Depsgraph to get evaluated data from"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_property(func, "result", PROP_FLOAT, PROP_MATRIX); RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4); RNA_def_property_ui_text(parm, "", "The camera projection matrix"); @@ -530,7 +536,8 @@ void RNA_api_object(StructRNA *srna) func = RNA_def_function(srna, "camera_fit_coords", "rna_Object_camera_fit_coords"); RNA_def_function_ui_description(func, "Compute the coordinate (and scale for ortho cameras) " "given object should be to 'see' all given coordinates"); - parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene to get render size information from, if available"); + parm = RNA_def_pointer(func, "depsgraph", "Depsgraph", "", + "Depsgraph to get evaluated data from"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_float_array(func, "coordinates", 1, NULL, -FLT_MAX, FLT_MAX, "", "Coordinates to fit in", -FLT_MAX, FLT_MAX); |