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.
This commit is contained in:
Sybren A. Stüvel 2020-02-25 15:44:21 +01:00
parent 65aa55babc
commit 4f48179437
2 changed files with 29 additions and 0 deletions

View File

@ -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;

View File

@ -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