diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 2cb523442dc..fd46fe3099e 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -920,8 +920,7 @@ class CLIP_PT_tracking_lens(Panel): col.prop(camera, "units", text="Units") col = layout.column() - col.prop(clip.tracking.camera, "principal", text="Optical Center") - col.operator("clip.set_center_principal", text="Set Center") + col.prop(clip.tracking.camera, "principal_point", text="Optical Center") col = layout.column() col.prop(camera, "distortion_model", text="Lens Distortion") @@ -1353,7 +1352,6 @@ class CLIP_MT_clip(Menu): if clip: layout.operator("clip.set_scene_frames") - layout.operator("clip.set_center_principal") layout.operator("clip.prefetch") layout.operator("clip.reload") layout.menu("CLIP_MT_proxy") diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 9c5ed01bed1..5709891893b 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -25,7 +25,7 @@ extern "C" { /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 1 +#define BLENDER_FILE_SUBVERSION 2 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and show a warning if the file diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h index 38cb2b17f72..63aad6b4dff 100644 --- a/source/blender/blenkernel/BKE_tracking.h +++ b/source/blender/blenkernel/BKE_tracking.h @@ -457,6 +457,12 @@ void BKE_tracking_camera_get_reconstructed_interpolate(struct MovieTracking *tra float framenr, float mat[4][4]); +/* Access the principal point in pixels space. */ +void BKE_tracking_camera_principal_point_pixel_get(struct MovieClip *clip, + float r_principal_point_pixel[2]); +void BKE_tracking_camera_principal_point_pixel_set(struct MovieClip *clip, + const float principal_point_pixel[2]); + /* -------------------------------------------------------------------- * (Un)distortion. */ diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index f77a03c4eac..6ea537f9038 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -69,6 +69,8 @@ #include "BLO_read_write.h" +#include "tracking_private.h" + /* Convert camera object to legacy format where the camera tracks are stored in the MovieTracking * structure when saving .blend file. */ #define USE_LEGACY_CAMERA_OBJECT_FORMAT_ON_SAVE 1 @@ -221,6 +223,16 @@ static void movieclip_blend_write(BlendWriter *writer, ID *id, const void *id_ad } #endif + /* Assign the pixel-space principal point for forward compatibility. */ + /* TODO(sergey): Remove with the next major version update when forward compatibility is allowed + * to be broken. */ + if (!is_undo && clip->lastsize[0] != 0 && clip->lastsize[1] != 0) { + tracking_principal_point_normalized_to_pixel(tracking->camera.principal_point, + clip->lastsize[0], + clip->lastsize[1], + tracking->camera.principal_legacy); + } + BLO_write_id_struct(writer, MovieClip, id_address, &clip->id); BKE_id_blend_write(writer, &clip->id); @@ -725,7 +737,7 @@ typedef struct MovieClipCache { /* cache for undistorted shot */ float focal_length; - float principal[2]; + float principal_point[2]; float polynomial_k[3]; float division_k[2]; float nuke_k[2]; @@ -981,17 +993,6 @@ static void movieclip_load_get_size(MovieClip *clip) } } -static void movieclip_principal_to_center(MovieClip *clip) -{ - MovieClipUser user = *DNA_struct_default_get(MovieClipUser); - - int width, height; - BKE_movieclip_get_size(clip, &user, &width, &height); - - clip->tracking.camera.principal[0] = ((float)width) / 2.0f; - clip->tracking.camera.principal[1] = ((float)height) / 2.0f; -} - static void detect_clip_source(Main *bmain, MovieClip *clip) { ImBuf *ibuf; @@ -1041,7 +1042,6 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *name) clip->tracking.camera.focal = 24.0f * width / clip->tracking.camera.sensor_width; } - movieclip_principal_to_center(clip); movieclip_calc_length(clip); return clip; @@ -1154,7 +1154,7 @@ static bool check_undistortion_cache_flags(const MovieClip *clip) } /* check for distortion model changes */ - if (!equals_v2v2(camera->principal, cache->postprocessed.principal)) { + if (!equals_v2v2(camera->principal_point, cache->postprocessed.principal_point)) { return false; } @@ -1279,7 +1279,7 @@ static void put_postprocessed_frame_to_cache( if (need_undistortion_postprocess(user, flag)) { cache->postprocessed.distortion_model = camera->distortion_model; cache->postprocessed.focal_length = camera->focal; - copy_v2_v2(cache->postprocessed.principal, camera->principal); + copy_v2_v2(cache->postprocessed.principal_point, camera->principal_point); copy_v3_v3(cache->postprocessed.polynomial_k, &camera->k1); copy_v2_v2(cache->postprocessed.division_k, &camera->division_k1); copy_v2_v2(cache->postprocessed.nuke_k, &camera->nuke_k1); @@ -1719,26 +1719,12 @@ void BKE_movieclip_reload(Main *bmain, MovieClip *clip) /* update clip source */ detect_clip_source(bmain, clip); - const int old_width = clip->lastsize[0]; - const int old_height = clip->lastsize[1]; - /* Tag for re-calculation of the actual size. */ clip->lastsize[0] = clip->lastsize[1] = 0; movieclip_load_get_size(clip); movieclip_calc_length(clip); - int width, height; - MovieClipUser user = *DNA_struct_default_get(MovieClipUser); - BKE_movieclip_get_size(clip, &user, &width, &height); - - /* If the resolution changes then re-initialize the principal point. - * Ideally the principal point will be in some sort of relative space, but this is not how it is - * designed currently. The code should cover the most of the common cases. */ - if (width != old_width || height != old_height) { - movieclip_principal_to_center(clip); - } - BKE_ntree_update_tag_id_changed(bmain, &clip->id); } diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index a49464a11eb..dfb39c7bc37 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -14,6 +14,7 @@ #include "DNA_anim_types.h" #include "DNA_camera_types.h" +#include "DNA_defaults.h" #include "DNA_gpencil_types.h" #include "DNA_movieclip_types.h" #include "DNA_object_types.h" /* SELECT */ @@ -51,7 +52,7 @@ typedef struct MovieDistortion { struct libmv_CameraIntrinsics *intrinsics; /* Parameters needed for coordinates normalization. */ - float principal[2]; + float principal_px[2]; float pixel_aspect; float focal; } MovieDistortion; @@ -2103,10 +2104,14 @@ static void reconstructed_camera_scale_set(const MovieTrackingObject *tracking_o void BKE_tracking_camera_shift_get( MovieTracking *tracking, int winx, int winy, float *shiftx, float *shifty) { + float principal_px[2]; + tracking_principal_point_normalized_to_pixel( + tracking->camera.principal_point, winx, winy, principal_px); + /* Indeed in both of cases it should be winx - * it's just how camera shift works for blender's camera. */ - *shiftx = (0.5f * winx - tracking->camera.principal[0]) / winx; - *shifty = (0.5f * winy - tracking->camera.principal[1]) / winx; + *shiftx = (0.5f * winx - principal_px[0]) / winx; + *shifty = (0.5f * winy - principal_px[1]) / winx; } void BKE_tracking_camera_to_blender( @@ -2167,6 +2172,32 @@ void BKE_tracking_camera_get_reconstructed_interpolate(MovieTracking *UNUSED(tra reconstructed_camera_scale_set(tracking_object, mat); } +void BKE_tracking_camera_principal_point_pixel_get(struct MovieClip *clip, + float r_principal_point_pixel[2]) +{ + const MovieTrackingCamera *camera = &clip->tracking.camera; + + int frame_width, frame_height; + MovieClipUser user = *DNA_struct_default_get(MovieClipUser); + BKE_movieclip_get_size(clip, &user, &frame_width, &frame_height); + + tracking_principal_point_normalized_to_pixel( + camera->principal_point, frame_width, frame_height, r_principal_point_pixel); +} + +void BKE_tracking_camera_principal_point_pixel_set(struct MovieClip *clip, + const float principal_point_pixel[2]) +{ + MovieTrackingCamera *camera = &clip->tracking.camera; + + int frame_width, frame_height; + MovieClipUser user = *DNA_struct_default_get(MovieClipUser); + BKE_movieclip_get_size(clip, &user, &frame_width, &frame_height); + + tracking_principal_point_pixel_to_normalized( + principal_point_pixel, frame_width, frame_height, camera->principal_point); +} + /* -------------------------------------------------------------------- * (Un)distortion. */ @@ -2185,7 +2216,10 @@ MovieDistortion *BKE_tracking_distortion_new(MovieTracking *tracking, distortion->intrinsics = libmv_cameraIntrinsicsNew(&camera_intrinsics_options); const MovieTrackingCamera *camera = &tracking->camera; - copy_v2_v2(distortion->principal, camera->principal); + tracking_principal_point_normalized_to_pixel(tracking->camera.principal_point, + calibration_width, + calibration_height, + distortion->principal_px); distortion->pixel_aspect = camera->pixel_aspect; distortion->focal = camera->focal; @@ -2203,7 +2237,10 @@ void BKE_tracking_distortion_update(MovieDistortion *distortion, tracking, calibration_width, calibration_height, &camera_intrinsics_options); const MovieTrackingCamera *camera = &tracking->camera; - copy_v2_v2(distortion->principal, camera->principal); + tracking_principal_point_normalized_to_pixel(tracking->camera.principal_point, + calibration_width, + calibration_height, + distortion->principal_px); distortion->pixel_aspect = camera->pixel_aspect; distortion->focal = camera->focal; @@ -2296,8 +2333,8 @@ void BKE_tracking_distortion_distort_v2(MovieDistortion *distortion, /* Normalize coords. */ float inv_focal = 1.0f / distortion->focal; - double x = (co[0] - distortion->principal[0]) * inv_focal, - y = (co[1] - distortion->principal[1] * aspy) * inv_focal; + double x = (co[0] - distortion->principal_px[0]) * inv_focal, + y = (co[1] - distortion->principal_px[1] * aspy) * inv_focal; libmv_cameraIntrinsicsApply(distortion->intrinsics, x, y, &x, &y); @@ -2314,8 +2351,8 @@ void BKE_tracking_distortion_undistort_v2(MovieDistortion *distortion, libmv_cameraIntrinsicsInvert(distortion->intrinsics, x, y, &x, &y); const float aspy = 1.0f / distortion->pixel_aspect; - r_co[0] = (float)x * distortion->focal + distortion->principal[0]; - r_co[1] = (float)y * distortion->focal + distortion->principal[1] * aspy; + r_co[0] = (float)x * distortion->focal + distortion->principal_px[0]; + r_co[1] = (float)y * distortion->focal + distortion->principal_px[1] * aspy; } void BKE_tracking_distortion_free(MovieDistortion *distortion) @@ -2336,9 +2373,13 @@ void BKE_tracking_distort_v2( tracking, image_width, image_height, &camera_intrinsics_options); libmv_CameraIntrinsics *intrinsics = libmv_cameraIntrinsicsNew(&camera_intrinsics_options); + float principal_px[2]; + tracking_principal_point_normalized_to_pixel( + tracking->camera.principal_point, image_width, image_height, principal_px); + /* Normalize coordinates. */ - double x = (co[0] - camera->principal[0]) / camera->focal, - y = (co[1] - camera->principal[1] * aspy) / camera->focal; + double x = (co[0] - principal_px[0]) / camera->focal, + y = (co[1] - principal_px[1] * aspy) / camera->focal; libmv_cameraIntrinsicsApply(intrinsics, x, y, &x, &y); libmv_cameraIntrinsicsDestroy(intrinsics); @@ -2363,8 +2404,12 @@ void BKE_tracking_undistort_v2( libmv_cameraIntrinsicsInvert(intrinsics, x, y, &x, &y); libmv_cameraIntrinsicsDestroy(intrinsics); - r_co[0] = (float)x * camera->focal + camera->principal[0]; - r_co[1] = (float)y * camera->focal + camera->principal[1] * aspy; + float principal_px[2]; + tracking_principal_point_normalized_to_pixel( + tracking->camera.principal_point, image_width, image_height, principal_px); + + r_co[0] = (float)x * camera->focal + principal_px[0]; + r_co[1] = (float)y * camera->focal + principal_px[1] * aspy; } ImBuf *BKE_tracking_undistort_frame(MovieTracking *tracking, diff --git a/source/blender/blenkernel/intern/tracking_util.c b/source/blender/blenkernel/intern/tracking_util.c index fa36d8d2c02..dd4bc3fd021 100644 --- a/source/blender/blenkernel/intern/tracking_util.c +++ b/source/blender/blenkernel/intern/tracking_util.c @@ -373,6 +373,30 @@ void tracking_set_marker_coords_from_tracking(int frame_width, marker->pos[1] += marker_unified[1]; } +void tracking_principal_point_normalized_to_pixel(const float principal_point_normalized[2], + const int frame_width, + const int frame_height, + float r_principal_point_pixel[2]) +{ + const float frame_center_x = ((float)frame_width) / 2; + const float frame_center_y = ((float)frame_height) / 2; + + r_principal_point_pixel[0] = frame_center_x + principal_point_normalized[0] * frame_center_x; + r_principal_point_pixel[1] = frame_center_y + principal_point_normalized[1] * frame_center_y; +} + +void tracking_principal_point_pixel_to_normalized(const float principal_point_pixel[2], + const int frame_width, + const int frame_height, + float r_principal_point_normalized[2]) +{ + const float frame_center_x = ((float)frame_width) / 2; + const float frame_center_y = ((float)frame_height) / 2; + + r_principal_point_normalized[0] = (principal_point_pixel[0] - frame_center_x) / frame_center_x; + r_principal_point_normalized[1] = (principal_point_pixel[1] - frame_center_y) / frame_center_y; +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -487,19 +511,23 @@ static void distortion_model_parameters_from_options( void tracking_cameraIntrinscisOptionsFromTracking( MovieTracking *tracking, - int calibration_width, - int calibration_height, + const int calibration_width, + const int calibration_height, libmv_CameraIntrinsicsOptions *camera_intrinsics_options) { MovieTrackingCamera *camera = &tracking->camera; - float aspy = 1.0f / tracking->camera.pixel_aspect; + const float aspy = 1.0f / tracking->camera.pixel_aspect; + + float principal_px[2]; + tracking_principal_point_normalized_to_pixel( + camera->principal_point, calibration_width, calibration_height, principal_px); camera_intrinsics_options->num_threads = BLI_system_thread_count(); camera_intrinsics_options->focal_length = camera->focal; - camera_intrinsics_options->principal_point_x = camera->principal[0]; - camera_intrinsics_options->principal_point_y = camera->principal[1] * aspy; + camera_intrinsics_options->principal_point_x = principal_px[0]; + camera_intrinsics_options->principal_point_y = principal_px[1] * aspy; distortion_model_parameters_from_tracking(camera, camera_intrinsics_options); @@ -515,8 +543,13 @@ void tracking_trackingCameraFromIntrinscisOptions( camera->focal = camera_intrinsics_options->focal_length; - camera->principal[0] = camera_intrinsics_options->principal_point_x; - camera->principal[1] = camera_intrinsics_options->principal_point_y / (double)aspy; + const float principal_px[2] = {camera_intrinsics_options->principal_point_x, + camera_intrinsics_options->principal_point_y / (double)aspy}; + + tracking_principal_point_pixel_to_normalized(principal_px, + camera_intrinsics_options->image_width, + camera_intrinsics_options->image_height, + camera->principal_point); distortion_model_parameters_from_options(camera_intrinsics_options, camera); } diff --git a/source/blender/blenkernel/tracking_private.h b/source/blender/blenkernel/tracking_private.h index 9400f16a458..f92f2ec9e2d 100644 --- a/source/blender/blenkernel/tracking_private.h +++ b/source/blender/blenkernel/tracking_private.h @@ -79,6 +79,26 @@ void tracking_set_marker_coords_from_tracking(int frame_width, const double search_pixel_x[5], const double search_pixel_y[5]); +/** + * Convert the lens principal point (optical center) between normalized and pixel spaces. + * + * The normalized space stores principal point relative to the frame center which has normalized + * princibal coordinate of (0, 0). The right top corder of the frame corresponds to a notmalized + * principal coordinate of (1, 1), and the left bottom cornder corresponds to coordinate of + * (-1, -1). + * + * The pixel space is measured in pixels, with the reference being the left bottom cornder of + * the frame. + */ +void tracking_principal_point_normalized_to_pixel(const float principal_point_normalized[2], + int frame_width, + int frame_height, + float r_principal_point_pixel[2]); +void tracking_principal_point_pixel_to_normalized(const float principal_point_pixel[2], + int frame_width, + int frame_height, + float r_principal_point_normalized[2]); + /*********************** General purpose utility functions *************************/ /** diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index 07220239b55..5a54a517620 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -34,9 +34,11 @@ #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_modifier_types.h" +#include "DNA_movieclip_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" #include "DNA_text_types.h" +#include "DNA_tracking_types.h" #include "DNA_workspace_types.h" #include "BKE_action.h" @@ -3700,6 +3702,22 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) } } + if (!MAIN_VERSION_ATLEAST(bmain, 305, 2)) { + LISTBASE_FOREACH (MovieClip *, clip, &bmain->movieclips) { + MovieTracking *tracking = &clip->tracking; + + const float frame_center_x = ((float)clip->lastsize[0]) / 2; + const float frame_center_y = ((float)clip->lastsize[1]) / 2; + + tracking->camera.principal_point[0] = (tracking->camera.principal_legacy[0] - + frame_center_x) / + frame_center_x; + tracking->camera.principal_point[1] = (tracking->camera.principal_legacy[1] - + frame_center_y) / + frame_center_y; + } + } + /** * Versioning code until next subversion bump goes here. * diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index 0ccecc2b400..ebdb56f2a12 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -229,8 +229,6 @@ void CLIP_OT_set_scale(struct wmOperatorType *ot); void CLIP_OT_set_solution_scale(struct wmOperatorType *ot); void CLIP_OT_apply_solution_scale(struct wmOperatorType *ot); -void CLIP_OT_set_center_principal(struct wmOperatorType *ot); - void CLIP_OT_slide_marker(struct wmOperatorType *ot); void CLIP_OT_frame_jump(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 3631a1740f7..d94228a2dad 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -442,9 +442,6 @@ static void clip_operatortypes(void) /* navigation */ WM_operatortype_append(CLIP_OT_frame_jump); - /* set optical center to frame center */ - WM_operatortype_append(CLIP_OT_set_center_principal); - /* selection */ WM_operatortype_append(CLIP_OT_select); WM_operatortype_append(CLIP_OT_select_all); diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index a47cd301cc0..3d096837420 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -964,47 +964,6 @@ void CLIP_OT_disable_markers(wmOperatorType *ot) /** \} */ -/* -------------------------------------------------------------------- */ -/** \name Set Principal Center Operator - * \{ */ - -static int set_center_principal_exec(bContext *C, wmOperator *UNUSED(op)) -{ - SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip_get_clip(sc); - int width, height; - - BKE_movieclip_get_size(clip, &sc->user, &width, &height); - - if (width == 0 || height == 0) { - return OPERATOR_CANCELLED; - } - - clip->tracking.camera.principal[0] = ((float)width) / 2.0f; - clip->tracking.camera.principal[1] = ((float)height) / 2.0f; - - WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); - - return OPERATOR_FINISHED; -} - -void CLIP_OT_set_center_principal(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Set Principal to Center"; - ot->description = "Set optical center to center of footage"; - ot->idname = "CLIP_OT_set_center_principal"; - - /* api callbacks */ - ot->exec = set_center_principal_exec; - ot->poll = ED_space_clip_tracking_poll; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} - -/** \} */ - /* -------------------------------------------------------------------- */ /** \name Hide Tracks Operator * \{ */ diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h index ab792a9befe..a275371f511 100644 --- a/source/blender/makesdna/DNA_tracking_types.h +++ b/source/blender/makesdna/DNA_tracking_types.h @@ -48,8 +48,17 @@ typedef struct MovieTrackingCamera { /** Units of focal length user is working with. */ short units; char _pad1[2]; - /** Principal point. */ - float principal[2]; + + /* Principal point (optical center) stored in normalized coordinates. + * + * The normalized space stores principal point relative to the frame center which has normalized + * princibal coordinate of (0, 0). The right top corder of the frame corresponds to a notmalized + * principal coordinate of (1, 1), and the left bottom cornder corresponds to coordinate of + * (-1, -1). */ + float principal_point[2]; + + /** Legacy principal point in pixel space. */ + float principal_legacy[2]; /* Polynomial distortion */ /** Polynomial radial distortion. */ diff --git a/source/blender/makesdna/intern/dna_rename_defs.h b/source/blender/makesdna/intern/dna_rename_defs.h index 615e9740c9f..b2bf0aead90 100644 --- a/source/blender/makesdna/intern/dna_rename_defs.h +++ b/source/blender/makesdna/intern/dna_rename_defs.h @@ -95,6 +95,7 @@ DNA_STRUCT_RENAME_ELEM(MovieTracking, plane_tracks, plane_tracks_legacy) DNA_STRUCT_RENAME_ELEM(MovieTracking, reconstruction, reconstruction_legacy) DNA_STRUCT_RENAME_ELEM(MovieTracking, act_track, act_track_legacy) DNA_STRUCT_RENAME_ELEM(MovieTracking, act_plane_track, act_plane_track_legacy) +DNA_STRUCT_RENAME_ELEM(MovieTrackingCamera, principal, principal_legacy) DNA_STRUCT_RENAME_ELEM(NodeCryptomatte, num_inputs, inputs_num) DNA_STRUCT_RENAME_ELEM(Object, col, color) DNA_STRUCT_RENAME_ELEM(Object, dup_group, instance_collection) diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 365c13ecec1..3f037563ea2 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -387,6 +387,20 @@ static void rna_trackingCamera_focal_mm_set(PointerRNA *ptr, float value) } } +static void rna_trackingCamera_principal_point_pixels_get(PointerRNA *ptr, + float *r_principal_point_pixels) +{ + MovieClip *clip = (MovieClip *)ptr->owner_id; + BKE_tracking_camera_principal_point_pixel_get(clip, r_principal_point_pixels); +} + +static void rna_trackingCamera_principal_point_pixels_set(PointerRNA *ptr, + const float *principal_point_pixels) +{ + MovieClip *clip = (MovieClip *)ptr->owner_id; + BKE_tracking_camera_principal_point_pixel_set(clip, principal_point_pixels); +} + static char *rna_trackingStabilization_path(const PointerRNA *UNUSED(ptr)) { return BLI_strdup("tracking.stabilization"); @@ -1198,13 +1212,26 @@ static void rna_def_trackingCamera(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Units", "Units used for camera focal length"); /* Principal Point */ - prop = RNA_def_property(srna, "principal", PROP_FLOAT, PROP_PIXEL); + prop = RNA_def_property(srna, "principal_point", PROP_FLOAT, PROP_NONE); RNA_def_property_array(prop, 2); - RNA_def_property_float_sdna(prop, NULL, "principal"); + RNA_def_property_float_sdna(prop, NULL, "principal_point"); + RNA_def_property_range(prop, -1, 1); + RNA_def_property_ui_range(prop, -1, 1, 0.1, 3); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Principal Point", "Optical center of lens"); RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, NULL); + /* Principal Point, in pixels */ + prop = RNA_def_property(srna, "principal_point_pixels", PROP_FLOAT, PROP_PIXEL); + RNA_def_property_array(prop, 2); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_float_funcs(prop, + "rna_trackingCamera_principal_point_pixels_get", + "rna_trackingCamera_principal_point_pixels_set", + NULL); + RNA_def_property_ui_text(prop, "Principal Point", "Optical center of lens in pixels"); + RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, NULL); + /* Radial distortion parameters */ prop = RNA_def_property(srna, "k1", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "k1");