diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-12-16 00:38:23 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-12-16 00:38:23 +0400 |
commit | 8a9d901c81b0357bca833f3ccb2d4f674873e58d (patch) | |
tree | 16d3d3746a87970ae931c2bf4438b3d92b1ea06f /source/blender/makesrna/intern/rna_constraint.c | |
parent | e534af906a938b6e3cf0727d577c89a51052f6ff (diff) |
Camera tracking: add camera to follow track and object solver constraint
Object used to be parented to active camera which isn't very convenient when
working with witness cameras.
Now parent camera can be specified in constraint (if it's not specified, active camera is used)
Diffstat (limited to 'source/blender/makesrna/intern/rna_constraint.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_constraint.c | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 4d064c01fae..6439d22e808 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -330,6 +330,49 @@ static void rna_SplineIKConstraint_joint_bindings_set(PointerRNA *ptr, const flo memcpy(ikData->points, values, ikData->numpoints * sizeof(float)); } +static int rna_Constraint_cameraObject_poll(PointerRNA *ptr, PointerRNA value) +{ + Object *ob= (Object*)value.data; + + if (ob) { + if (ob->type == OB_CAMERA && ob != (Object*)ptr->id.data) { + return 1; + } + } + + return 0; +} + +static void rna_Constraint_followTrack_camera_set(PointerRNA *ptr, PointerRNA value) +{ + bConstraint *con= (bConstraint*)ptr->data; + bFollowTrackConstraint *data= (bFollowTrackConstraint*)con->data; + Object *ob= (Object*)value.data; + + if (ob) { + if (ob->type == OB_CAMERA && ob != (Object*)ptr->id.data) { + data->camera= ob; + } + } else { + data->camera= NULL; + } +} + +static void rna_Constraint_objectSolver_camera_set(PointerRNA *ptr, PointerRNA value) +{ + bConstraint *con= (bConstraint*)ptr->data; + bObjectSolverConstraint *data= (bObjectSolverConstraint*)con->data; + Object *ob= (Object*)value.data; + + if (ob) { + if (ob->type == OB_CAMERA && ob != (Object*)ptr->id.data) { + data->camera= ob; + } + } else { + data->camera= NULL; + } +} + #else EnumPropertyItem constraint_distance_items[] = { @@ -2073,8 +2116,16 @@ static void rna_def_constraint_follow_track(BlenderRNA *brna) /* object */ prop= RNA_def_property(srna, "object", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "object"); - RNA_def_property_ui_text(prop, "Object", "Movie tracking object to follow"); + RNA_def_property_ui_text(prop, "Object", "Movie tracking object to follow (if empty, camera object is used)"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); + + /* camera */ + prop= RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "camera"); + RNA_def_property_ui_text(prop, "Camera", "Camera to which motion is parented (if empty active scene camera is used)"); + RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_Constraint_followTrack_camera_set", NULL, "rna_Constraint_cameraObject_poll"); } static void rna_def_constraint_camera_solver(BlenderRNA *brna) @@ -2127,6 +2178,14 @@ static void rna_def_constraint_object_solver(BlenderRNA *brna) RNA_def_property_string_sdna(prop, NULL, "object"); RNA_def_property_ui_text(prop, "Object", "Movie tracking object to follow"); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); + + /* camera */ + prop= RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "camera"); + RNA_def_property_ui_text(prop, "Camera", "Camera to which motion is parented (if empty active scene camera is used)"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_Constraint_objectSolver_camera_set", NULL, "rna_Constraint_cameraObject_poll"); } /* base struct for constraints */ |