6041 follow path with 0 opacity fixes #6041 do not defer path update if it is used as follow path constraint Diffs= 54d736fec 6041 follow path with 0 opacity (#6060) Co-authored-by: hernan <hernan@rive.app>
diff --git a/.rive_head b/.rive_head index 5f1cbb1..6949616 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -bb7d5ac4ccbe04a80c8469b56da55b9b92a70ef6 +54d736fec499e15bcd2420e61cd370bf11b9b70c
diff --git a/src/shapes/shape.cpp b/src/shapes/shape.cpp index 002061e..0d612bd 100644 --- a/src/shapes/shape.cpp +++ b/src/shapes/shape.cpp
@@ -21,7 +21,9 @@ bool Shape::canDeferPathUpdate() { - return renderOpacity() == 0 && (pathSpace() & PathSpace::Clipping) != PathSpace::Clipping; + return renderOpacity() == 0 + && (pathSpace() & PathSpace::Clipping) != PathSpace::Clipping + && (pathSpace() & PathSpace::FollowPath) != PathSpace::FollowPath; } void Shape::update(ComponentDirt value)
diff --git a/test/assets/follow_path.riv b/test/assets/follow_path.riv new file mode 100644 index 0000000..606950c --- /dev/null +++ b/test/assets/follow_path.riv Binary files differ
diff --git a/test/assets/follow_path_with_0_opacity.riv b/test/assets/follow_path_with_0_opacity.riv new file mode 100644 index 0000000..2948dee --- /dev/null +++ b/test/assets/follow_path_with_0_opacity.riv Binary files differ
diff --git a/test/follow_path_constraint_test.cpp b/test/follow_path_constraint_test.cpp new file mode 100644 index 0000000..7ed2959 --- /dev/null +++ b/test/follow_path_constraint_test.cpp
@@ -0,0 +1,49 @@ +#include <rive/file.hpp> +#include <rive/node.hpp> +#include <rive/shapes/shape.hpp> +#include <rive/math/transform_components.hpp> +#include <utils/no_op_renderer.hpp> +#include "rive_file_reader.hpp" +#include "rive_testing.hpp" +#include <cstdio> + +TEST_CASE("follow path constraint updates world transform", "[file]") +{ + auto file = ReadRiveFile("../../test/assets/follow_path.riv"); + + auto artboard = file->artboard(); + + REQUIRE(artboard->find<rive::TransformComponent>("target") != nullptr); + auto target = artboard->find<rive::TransformComponent>("target"); + + REQUIRE(artboard->find<rive::TransformComponent>("rect") != nullptr); + auto rectangle = artboard->find<rive::TransformComponent>("rect"); + + artboard->advance(0.0f); + + auto targetComponents = target->worldTransform().decompose(); + auto rectComponents = rectangle->worldTransform().decompose(); + REQUIRE(targetComponents.x() == rectComponents.x()); + REQUIRE(targetComponents.y() == rectComponents.y()); +} + + +TEST_CASE("follow path with 0 opacity constraint updates world transform", "[file]") +{ + auto file = ReadRiveFile("../../test/assets/follow_path_with_0_opacity.riv"); + + auto artboard = file->artboard(); + + REQUIRE(artboard->find<rive::TransformComponent>("target") != nullptr); + auto target = artboard->find<rive::TransformComponent>("target"); + + REQUIRE(artboard->find<rive::TransformComponent>("rect") != nullptr); + auto rectangle = artboard->find<rive::TransformComponent>("rect"); + + artboard->advance(0.0f); + + auto targetComponents = target->worldTransform().decompose(); + auto rectComponents = rectangle->worldTransform().decompose(); + REQUIRE(targetComponents.x() == rectComponents.x()); + REQUIRE(targetComponents.y() == rectComponents.y()); +}