diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-02-25 17:44:21 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-02-25 19:22:23 +0300 |
commit | 4f4817943704e8bfddf366d01cf958dc0cce0ac6 (patch) | |
tree | 080965a72d942479f304e9b1b506f52a67b93f6f | |
parent | 65aa55babc57232c83cf14b7e74ecefa2c4ac3ba (diff) |
Constraints: fixed Object Solver 'Clear Inverse' operator
The 'Clear Inverse' operator didn't properly update the constraint, so
it didn't do anything until the entire depsgraph was updated. It's now
properly tagged for update.
-rw-r--r-- | source/blender/editors/object/object_constraint.c | 2 | ||||
-rw-r--r-- | tests/python/bl_constraints.py | 27 |
2 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 454d3c07fff..906a9e44870 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -1292,6 +1292,7 @@ void CONSTRAINT_OT_objectsolver_set_inverse(wmOperatorType *ot) static int objectsolver_clear_inverse_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(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; @@ -1304,6 +1305,7 @@ static int objectsolver_clear_inverse_exec(bContext *C, wmOperator *op) /* simply clear the matrix */ unit_m4(data->invmat); + ED_object_constraint_update(bmain, ob); WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); return OPERATOR_FINISHED; diff --git a/tests/python/bl_constraints.py b/tests/python/bl_constraints.py index 21e3fad3be8..42f81bddce6 100644 --- a/tests/python/bl_constraints.py +++ b/tests/python/bl_constraints.py @@ -188,6 +188,33 @@ class ChildOfTest(AbstractConstraintTests): bpy.ops.constraint.childof_clear_inverse(context, constraint='Child Of') self.matrix_test('Child Of.armature.owner', initial_matrix) + +class ObjectSolverTest(AbstractConstraintTests): + layer_collection = 'Object Solver' + + def test_simple_parent(self): + """Object Solver: simple evaluation of parent.""" + initial_matrix = Matrix(( + (-0.970368504524231, 0.03756079450249672, -0.23869234323501587, -0.681557297706604), + (-0.24130365252494812, -0.2019258439540863, 0.9492092132568359, 6.148940086364746), + (-0.012545102275907993, 0.9786801934242249, 0.20500603318214417, 2.2278831005096436), + (0.0, 0.0, 0.0, 1.0), + )) + self.matrix_test('Object Solver.owner', initial_matrix) + + context = self.constraint_context('Object Solver') + bpy.ops.constraint.objectsolver_set_inverse(context, constraint='Object Solver') + self.matrix_test('Object Solver.owner', Matrix(( + (0.9992386102676392, 0.019843988120555878, -0.03359176218509674, 0.10000000149011612), + (-0.017441775649785995, 0.997369647026062, 0.0703534483909607, 0.20000000298023224), + (0.03489949554204941, -0.06971397995948792, 0.9969563484191895, 0.30000001192092896), + (0.0, 0.0, 0.0, 1.0), + ))) + + bpy.ops.constraint.objectsolver_clear_inverse(context, constraint='Object Solver') + self.matrix_test('Object Solver.owner', initial_matrix) + + def main(): global args import argparse |