diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-12-30 22:06:02 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-12-30 22:06:02 +0400 |
commit | 3c6e818b22ed9153604cfb87476845416112b7d8 (patch) | |
tree | 903339376cb68d49151d2b2f83543f07610e79d9 /source/blender/editors/object | |
parent | 532afede0236bdf6e29dd4dfc746a1ee0959d8a5 (diff) | |
parent | c2ae77e5bdd60e4cfe9b1f9d3d54e66f8089245c (diff) |
Object tracking integration
This commits merges object tracking implementation from tomato branch.
Summarized changes from branch:
- Added list of objects to be tracked. Default there's only one object called
"Camera" which is used for solving camera motion. Other objects can be added
and each of them will have it;s own list of tracks. Only one object can be used
for camera solving at this moment.
- Added new constraint called "Object Tracking" which makes oriented object be
moving in the save way as solved object motion.
- Scene orientation tools can be used for orienting object to bundles.
- Object has got scale to define "depth" in camera space.
- All tools which works with list of tracks or reconstruction data now
gets that lists from active editing object.
- All objects and their tracking data are available via python api.
- Improvements in witness cameras workflow,
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/object_constraint.c | 149 | ||||
-rw-r--r-- | source/blender/editors/object/object_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 2 |
3 files changed, 136 insertions, 17 deletions
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 796ca01a6a9..8266f3501c5 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -408,8 +408,21 @@ static void test_constraints (Object *owner, bPoseChannel *pchan) if((data->flag&CAMERASOLVER_ACTIVECLIP)==0) { if(data->clip != NULL && data->track[0]) { - if (!BKE_tracking_named_track(&data->clip->tracking, data->track)) + MovieTracking *tracking= &data->clip->tracking; + MovieTrackingObject *tracking_object; + + if(data->object[0]) + tracking_object= BKE_tracking_named_object(tracking, data->object); + else + tracking_object= BKE_tracking_get_camera_object(tracking); + + if(!tracking_object) { curcon->flag |= CONSTRAINT_DISABLE; + } + else { + if (!BKE_tracking_named_track(tracking, tracking_object, data->track)) + curcon->flag |= CONSTRAINT_DISABLE; + } } else curcon->flag |= CONSTRAINT_DISABLE; } @@ -420,6 +433,12 @@ static void test_constraints (Object *owner, bPoseChannel *pchan) if((data->flag&CAMERASOLVER_ACTIVECLIP)==0 && data->clip == NULL) curcon->flag |= CONSTRAINT_DISABLE; } + else if (curcon->type == CONSTRAINT_TYPE_OBJECTSOLVER) { + bObjectSolverConstraint *data = curcon->data; + + if((data->flag&CAMERASOLVER_ACTIVECLIP)==0 && data->clip == NULL) + curcon->flag |= CONSTRAINT_DISABLE; + } /* Check targets for constraints */ if (cti && cti->get_constraint_targets) { @@ -684,25 +703,13 @@ void CONSTRAINT_OT_limitdistance_reset (wmOperatorType *ot) /* ------------- Child-Of Constraint ------------------ */ -/* ChildOf Constraint - set inverse callback */ -static int childof_set_inverse_exec (bContext *C, wmOperator *op) +static void child_get_inverse_matrix (Scene *scene, Object *ob, bConstraint *con, float invmat[4][4]) { - Scene *scene= CTX_data_scene(C); - Object *ob = ED_object_active_context(C); - bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF); - bChildOfConstraint *data= (con) ? (bChildOfConstraint *)con->data : NULL; bConstraint *lastcon = NULL; bPoseChannel *pchan= NULL; - /* despite 3 layers of checks, we may still not be able to find a constraint */ - if (data == NULL) { - printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob)? ob->id.name+2 : "<None>"); - BKE_report(op->reports, RPT_ERROR, "Couldn't find constraint data for Child-Of Set Inverse"); - return OPERATOR_CANCELLED; - } - /* nullify inverse matrix first */ - unit_m4(data->invmat); + unit_m4(invmat); /* try to find a pose channel - assume that this is the constraint owner */ // TODO: get from context instead? @@ -748,7 +755,7 @@ static int childof_set_inverse_exec (bContext *C, wmOperator *op) */ invert_m4_m4(imat, pchan->pose_mat); mult_m4_m4m4(tmat, pmat, imat); - invert_m4_m4(data->invmat, tmat); + invert_m4_m4(invmat, tmat); /* 5. restore constraints */ pchan->constraints.last = lastcon; @@ -770,9 +777,27 @@ static int childof_set_inverse_exec (bContext *C, wmOperator *op) /* use what_does_parent to find inverse - just like for normal parenting */ what_does_parent(scene, ob, &workob); - invert_m4_m4(data->invmat, workob.obmat); + invert_m4_m4(invmat, workob.obmat); + } +} + +/* ChildOf Constraint - set inverse callback */ +static int childof_set_inverse_exec (bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *ob = ED_object_active_context(C); + bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF); + bChildOfConstraint *data= (con) ? (bChildOfConstraint *)con->data : NULL; + + /* despite 3 layers of checks, we may still not be able to find a constraint */ + if (data == NULL) { + printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob)? ob->id.name+2 : "<None>"); + BKE_report(op->reports, RPT_ERROR, "Couldn't find constraint data for Child-Of Set Inverse"); + return OPERATOR_CANCELLED; } + child_get_inverse_matrix(scene, ob, con, data->invmat); + WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); return OPERATOR_FINISHED; @@ -846,6 +871,96 @@ void CONSTRAINT_OT_childof_clear_inverse (wmOperatorType *ot) edit_constraint_properties(ot); } +/* ------------- Object Solver Constraint ------------------ */ + +static int objectsolver_set_inverse_exec (bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *ob = ED_object_active_context(C); + bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_OBJECTSOLVER); + bObjectSolverConstraint *data= (con) ? (bObjectSolverConstraint *)con->data : NULL; + + /* despite 3 layers of checks, we may still not be able to find a constraint */ + if (data == NULL) { + printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob)? ob->id.name+2 : "<None>"); + BKE_report(op->reports, RPT_ERROR, "Couldn't find constraint data for Child-Of Set Inverse"); + return OPERATOR_CANCELLED; + } + + child_get_inverse_matrix(scene, ob, con, data->invmat); + + WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); + + return OPERATOR_FINISHED; +} + +static int objectsolver_set_inverse_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +{ + if (edit_constraint_invoke_properties(C, op)) + return objectsolver_set_inverse_exec(C, op); + else + return OPERATOR_CANCELLED; +} + +void CONSTRAINT_OT_objectsolver_set_inverse (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Set Inverse"; + ot->idname= "CONSTRAINT_OT_objectsolver_set_inverse"; + ot->description= "Set inverse correction for ObjectSolver constraint"; + + ot->exec= objectsolver_set_inverse_exec; + ot->invoke= objectsolver_set_inverse_invoke; + ot->poll= edit_constraint_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + edit_constraint_properties(ot); +} + +static int objectsolver_clear_inverse_exec (bContext *C, wmOperator *op) +{ + Object *ob = ED_object_active_context(C); + bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_OBJECTSOLVER); + bObjectSolverConstraint *data= (con) ? (bObjectSolverConstraint *)con->data : NULL; + + if(data==NULL) { + BKE_report(op->reports, RPT_ERROR, "Childof constraint not found"); + return OPERATOR_CANCELLED; + } + + /* simply clear the matrix */ + unit_m4(data->invmat); + + WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); + + return OPERATOR_FINISHED; +} + +static int objectsolver_clear_inverse_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +{ + if (edit_constraint_invoke_properties(C, op)) + return objectsolver_clear_inverse_exec(C, op); + else + return OPERATOR_CANCELLED; +} + +void CONSTRAINT_OT_objectsolver_clear_inverse (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Clear Inverse"; + ot->idname= "CONSTRAINT_OT_objectsolver_clear_inverse"; + ot->description= "Clear inverse correction for ObjectSolver constraint"; + + ot->exec= objectsolver_clear_inverse_exec; + ot->invoke= objectsolver_clear_inverse_invoke; + ot->poll= edit_constraint_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + edit_constraint_properties(ot); +} + /***************************** BUTTONS ****************************/ void ED_object_constraint_set_active(Object *ob, bConstraint *con) diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 35e802e3e11..8973fb88c85 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -186,6 +186,8 @@ void CONSTRAINT_OT_stretchto_reset(struct wmOperatorType *ot); void CONSTRAINT_OT_limitdistance_reset(struct wmOperatorType *ot); void CONSTRAINT_OT_childof_set_inverse(struct wmOperatorType *ot); void CONSTRAINT_OT_childof_clear_inverse(struct wmOperatorType *ot); +void CONSTRAINT_OT_objectsolver_set_inverse(struct wmOperatorType *ot); +void CONSTRAINT_OT_objectsolver_clear_inverse (struct wmOperatorType *ot); /* object_vgroup.c */ void OBJECT_OT_vertex_group_add(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index a899d60c2ab..acc318723d8 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -161,6 +161,8 @@ void ED_operatortypes_object(void) WM_operatortype_append(CONSTRAINT_OT_limitdistance_reset); WM_operatortype_append(CONSTRAINT_OT_childof_set_inverse); WM_operatortype_append(CONSTRAINT_OT_childof_clear_inverse); + WM_operatortype_append(CONSTRAINT_OT_objectsolver_set_inverse); + WM_operatortype_append(CONSTRAINT_OT_objectsolver_clear_inverse); WM_operatortype_append(OBJECT_OT_vertex_group_add); WM_operatortype_append(OBJECT_OT_vertex_group_remove); |