Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2020-02-27 12:24:11 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-02-27 12:37:59 +0300
commit10162d68e38514aa8741cf9efd9e0f5deac32085 (patch)
treed78cfe4761c1fef9ef7af434eed0551158c6ff55 /tests
parent4952fb1669fb7d254fc26a527b6dc2a44ac2c496 (diff)
Constraints: replace 'Set Inverse' operator with an eval-time update
This fixes {T70269}. Before this commit there was complicated code to try and compute the correct parent inverse matrix for the 'Child Of' and 'Object Solver' constraints outside the constraint evaluation. This was done mostly correctly, but did have some issues. The Set Inverse operator now defers this computation to be performed during constraint evaluation by just setting a flag. If the constraint is disabled, and thus tagging it for update in the depsgraph is not enough to trigger immediate evaluation, evaluation is forced by temporarily enabling it. This fix changes the way how the inverse matrix works when some of the channels of the constraint are disabled. Before this commit, the channel flags were used to filter both the parent and the inverse matrix. This meant that it was impossible to make an inverse matrix that would actually fully neutralize the effect of the constraint. Now only the parent matrix is filtered, while inverse is applied fully. As a result, pressing the 'Set Inverse' matrix produces the same transformation as disabling the constraint. This is also reflected in the changed values in the 'Child Of' unit test. This change is not backward compatible, but it should be OK because the old way was effectively unusable, so it is unlikely anybody relied on it. The change in matrix for the Object Solver constraint is due to a different method of computing it, which caused a slightly different floating point error that was slightly bigger than allowed by the test, so I updated the matrix values there as well. This patch was original written by @angavrilov and subsequently updated by me. Differential Revision: https://developer.blender.org/D6091
Diffstat (limited to 'tests')
-rw-r--r--tests/python/bl_constraints.py35
1 files changed, 29 insertions, 6 deletions
diff --git a/tests/python/bl_constraints.py b/tests/python/bl_constraints.py
index 42f81bddce6..13a431541bc 100644
--- a/tests/python/bl_constraints.py
+++ b/tests/python/bl_constraints.py
@@ -156,9 +156,9 @@ class ChildOfTest(AbstractConstraintTests):
context = self.constraint_context('Child Of', owner_name='Child Of.object.owner')
bpy.ops.constraint.childof_set_inverse(context, constraint='Child Of')
self.matrix_test('Child Of.object.owner', Matrix((
- (0.9228900671005249, 0.23250490427017212, -0.035540513694286346, 0.10000000149011612),
- (-0.011224273592233658, 0.9838480949401855, 0.24731633067131042, 0.21246682107448578),
- (0.0383986234664917, -0.3163823187351227, 0.9553266167640686, 0.27248233556747437),
+ (0.9992386102676392, 0.019843991845846176, -0.03359176218509674, 0.10000000149011612),
+ (-0.017441775649785995, 0.997369647026062, 0.0703534483909607, 0.2000001221895218),
+ (0.034899499267339706, -0.06971398741006851, 0.996956467628479, 0.3000001311302185),
(0.0, 0.0, 0.0, 1.0),
)))
@@ -188,6 +188,29 @@ class ChildOfTest(AbstractConstraintTests):
bpy.ops.constraint.childof_clear_inverse(context, constraint='Child Of')
self.matrix_test('Child Of.armature.owner', initial_matrix)
+ def test_vertexgroup_simple_parent(self):
+ """Child Of: simple evaluation of vertex group parent."""
+ initial_matrix = Matrix((
+ (-0.8076590895652771, 0.397272527217865, 0.4357309341430664, 1.188504934310913),
+ (-0.4534659683704376, -0.8908230066299438, -0.028334975242614746, 1.7851561307907104),
+ (0.3769024908542633, -0.22047416865825653, 0.8996308445930481, 3.4457669258117676),
+ (0.0, 0.0, 0.0, 1.0),
+ ))
+ self.matrix_test('Child Of.vertexgroup.owner', initial_matrix)
+
+ context = self.constraint_context('Child Of', owner_name='Child Of.vertexgroup.owner')
+ bpy.ops.constraint.childof_set_inverse(context, constraint='Child Of')
+
+ self.matrix_test('Child Of.vertexgroup.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.childof_clear_inverse(context, constraint='Child Of')
+ self.matrix_test('Child Of.vertexgroup.owner', initial_matrix)
+
class ObjectSolverTest(AbstractConstraintTests):
layer_collection = 'Object Solver'
@@ -205,9 +228,9 @@ class ObjectSolverTest(AbstractConstraintTests):
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.9992387294769287, 0.019843989983201027, -0.03359176591038704, 0.10000025480985641),
+ (-0.017441747710108757, 0.9973697662353516, 0.07035345584154129, 0.1999993920326233),
+ (0.034899502992630005, -0.06971398741006851, 0.996956467628479, 0.29999980330467224),
(0.0, 0.0, 0.0, 1.0),
)))