From bdf44be74ccf7613d19ad9f1346ab903a725c3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A5=BF=E9=A3=8E=E9=80=8D=E9=81=A5=E6=B8=B8?= Date: Tue, 15 Sep 2026 15:51:03 +0800 Subject: [PATCH] Fix animation portability checks --- src/modules/animation/AnimParallelInternal.h | 12 ++++++++---- test/animation_two_bone_precision.cpp | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/modules/animation/AnimParallelInternal.h b/src/modules/animation/AnimParallelInternal.h index 714c436b..9fe19cf3 100644 --- a/src/modules/animation/AnimParallelInternal.h +++ b/src/modules/animation/AnimParallelInternal.h @@ -28,12 +28,16 @@ int parallelAnimationItems(std::size_t count, int requested, Body&& body) { } } }; - { - std::vector threads; - threads.reserve(workers - 1); + std::vector threads; + threads.reserve(workers - 1); + try { for (std::size_t i = 1; i < workers; ++i) threads.emplace_back(run); - run(); + } catch (...) { + for (auto& thread : threads) thread.join(); + throw; } + run(); + for (auto& thread : threads) thread.join(); // Report the first failing input, independent of completion order. for (const auto& error : errors) if (error) std::rethrow_exception(error); diff --git a/test/animation_two_bone_precision.cpp b/test/animation_two_bone_precision.cpp index 421679df..bd653eff 100644 --- a/test/animation_two_bone_precision.cpp +++ b/test/animation_two_bone_precision.cpp @@ -38,8 +38,8 @@ TEST_CASE("animation.pose.twoBoneIkReachesTargetsWithoutIteration") { REQUIRE(pose.solveTwoBoneIK(&skeleton, 0, 1, 2, target[0], target[1], target[2], 1)); float error = 0; const auto& p = pose.world(2); - error = - std::sqrt(std::pow(p.px - target[0], 2) + std::pow(p.py - target[1], 2) + std::pow(p.pz - target[2], 2)); + error = std::sqrt(std::pow(p.px - target[0], 2.f) + std::pow(p.py - target[1], 2.f) + + std::pow(p.pz - target[2], 2.f)); CHECK(error < .0003f); const auto before = pose.world(1); REQUIRE(pose.solveTwoBoneIK(&skeleton, 0, 1, 2, target[0], target[1], target[2], 1));