Skip to content

Commit 84cd3a4

Browse files
cstollmetafacebook-github-bot
authored andcommitted
Fix solver function tests (#244)
Summary: Pull Request resolved: #244 Vertex Error Function tests sometimes broke because the increased number of constraints lead to higher error values than previously supported. Reducing the weight of each constraint fixes this. Also fixed a potential issue where random normals were created using uniform<Vector3<T>>(0, 1).normalized()) This can break in the super rare case where all three random variables are close to 0. Replaced it with a simple uniform<Vector3<T>>(0.1, 1).normalized()) to ensure the norm always has a reasonable value. Reviewed By: jeongseok-meta Differential Revision: D71753984 fbshipit-source-id: 6508e75bf3efda05fbbd33732e94ac48cead64eb
1 parent 3e792d4 commit 84cd3a4

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

momentum/test/character_solver/error_functions_test.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -610,9 +610,9 @@ TYPED_TEST(Momentum_ErrorFunctionsTest, VertexErrorFunction) {
610610
for (size_t iCons = 0; iCons < nConstraints; ++iCons) {
611611
errorFunction.addConstraint(
612612
uniform<int>(0, character_orig.mesh->vertices.size() - 1),
613-
uniform<float>(0, 1),
613+
uniform<float>(0, 1e-4),
614614
uniform<Vector3<T>>(0, 1),
615-
uniform<Vector3<T>>(0, 1).normalized());
615+
uniform<Vector3<T>>(0.1, 1).normalized());
616616
}
617617

618618
TEST_GRADIENT_AND_JACOBIAN(
@@ -634,7 +634,7 @@ TYPED_TEST(Momentum_ErrorFunctionsTest, VertexErrorFunction) {
634634
uniform<int>(0, character_orig.mesh->vertices.size() - 1),
635635
uniform<float>(0, 1),
636636
uniform<Vector3<T>>(0, 1),
637-
uniform<Vector3<T>>(0, 1).normalized());
637+
uniform<Vector3<T>>(0.1, 1).normalized());
638638
}
639639

640640
TEST_GRADIENT_AND_JACOBIAN(
@@ -669,7 +669,7 @@ TYPED_TEST(Momentum_ErrorFunctionsTest, VertexErrorFunction) {
669669
uniform<int>(0, character_blend.mesh->vertices.size() - 1),
670670
uniform<float>(0, 1),
671671
uniform<Vector3<T>>(0, 1),
672-
uniform<Vector3<T>>(0, 1).normalized());
672+
uniform<Vector3<T>>(0.1, 1).normalized());
673673
}
674674

675675
TEST_GRADIENT_AND_JACOBIAN(
@@ -705,7 +705,7 @@ TYPED_TEST(Momentum_ErrorFunctionsTest, VertexPositionErrorFunctionFaceParameter
705705
uniform<int>(0, character_blend.mesh->vertices.size() - 1),
706706
uniform<float>(0, 1),
707707
uniform<Vector3<T>>(0, 1),
708-
uniform<Vector3<T>>(0, 1).normalized());
708+
uniform<Vector3<T>>(0.1, 1).normalized());
709709
}
710710

711711
TEST_GRADIENT_AND_JACOBIAN(
@@ -736,7 +736,7 @@ TYPED_TEST(Momentum_ErrorFunctionsTest, VertexPositionErrorFunctionFaceParameter
736736
uniform<int>(0, character_blend.mesh->vertices.size() - 1),
737737
uniform<float>(0, 1),
738738
uniform<Vector3<T>>(0, 1),
739-
uniform<Vector3<T>>(0, 1).normalized());
739+
uniform<Vector3<T>>(0.1, 1).normalized());
740740
}
741741

742742
TEST_GRADIENT_AND_JACOBIAN(
@@ -996,13 +996,13 @@ TYPED_TEST(Momentum_ErrorFunctionsTest, PlaneErrorL2_GradientsAndJacobians) {
996996
std::vector<PlaneDataT<T>> cl{
997997
PlaneDataT<T>(
998998
uniform<Vector3<T>>(0, 1),
999-
uniform<Vector3<T>>(0, 1).normalized(),
999+
uniform<Vector3<T>>(0.1, 1).normalized(),
10001000
uniform<float>(0, 1),
10011001
2,
10021002
TEST_WEIGHT_VALUE),
10031003
PlaneDataT<T>(
10041004
uniform<Vector3<T>>(0, 1),
1005-
uniform<Vector3<T>>(0, 1).normalized(),
1005+
uniform<Vector3<T>>(0.1, 1).normalized(),
10061006
uniform<float>(0, 1),
10071007
1,
10081008
TEST_WEIGHT_VALUE)};
@@ -1046,13 +1046,13 @@ TYPED_TEST(Momentum_ErrorFunctionsTest, HalfPlaneErrorL2_GradientsAndJacobians)
10461046
std::vector<PlaneDataT<T>> cl{
10471047
PlaneDataT<T>(
10481048
uniform<Vector3<T>>(0, 1),
1049-
uniform<Vector3<T>>(0, 1).normalized(),
1049+
uniform<Vector3<T>>(0.1, 1).normalized(),
10501050
uniform<float>(0, 1),
10511051
2,
10521052
TEST_WEIGHT_VALUE),
10531053
PlaneDataT<T>(
10541054
uniform<Vector3<T>>(0, 1),
1055-
uniform<Vector3<T>>(0, 1).normalized(),
1055+
uniform<Vector3<T>>(0.1, 1).normalized(),
10561056
uniform<float>(0, 1),
10571057
1,
10581058
TEST_WEIGHT_VALUE)};

0 commit comments

Comments
 (0)