Working on world transform component.
diff --git a/src/transform_component.cpp b/src/transform_component.cpp index df4af10..29942cd 100644 --- a/src/transform_component.cpp +++ b/src/transform_component.cpp
@@ -1,4 +1,5 @@ #include "rive/transform_component.hpp" +#include "rive/world_transform_component.hpp" #include "rive/shapes/clipping_shape.hpp" #include "rive/math/vec2d.hpp" #include "rive/constraints/constraint.hpp" @@ -8,8 +9,8 @@ StatusCode TransformComponent::onAddedClean(CoreContext* context) { m_ParentTransformComponent = - parent() != nullptr && parent()->is<TransformComponent>() - ? parent()->as<TransformComponent>() + parent() != nullptr && parent()->is<WorldTransformComponent>() + ? parent()->as<WorldTransformComponent>() : nullptr; return StatusCode::Ok; } @@ -31,11 +32,6 @@ markWorldTransformDirty(); } -void TransformComponent::markWorldTransformDirty() -{ - addDirt(ComponentDirt::WorldTransform, true); -} - void TransformComponent::updateTransform() { if (rotation() != 0) @@ -91,27 +87,12 @@ } const Mat2D& TransformComponent::transform() const { return m_Transform; } -const Mat2D& TransformComponent::worldTransform() const -{ - return m_WorldTransform; -} -Mat2D& TransformComponent::mutableWorldTransform() { return m_WorldTransform; } Mat2D& TransformComponent::mutableTransform() { return m_Transform; } void TransformComponent::rotationChanged() { markTransformDirty(); } void TransformComponent::scaleXChanged() { markTransformDirty(); } void TransformComponent::scaleYChanged() { markTransformDirty(); } -void TransformComponent::opacityChanged() -{ - addDirt(ComponentDirt::RenderOpacity, true); -} - -void TransformComponent::worldTranslation(Vec2D& result) const -{ - result[0] = m_WorldTransform[4]; - result[1] = m_WorldTransform[5]; -} void TransformComponent::addConstraint(Constraint* constraint) {
diff --git a/src/world_transform_component.cpp b/src/world_transform_component.cpp new file mode 100644 index 0000000..e80f910 --- /dev/null +++ b/src/world_transform_component.cpp
@@ -0,0 +1,34 @@ +#include "rive/transform_component.hpp" +#include "rive/shapes/clipping_shape.hpp" +#include "rive/math/vec2d.hpp" +#include "rive/constraints/constraint.hpp" + +using namespace rive; + +float WorldTransformComponent::childOpacity() { return opacity(); } + +void WorldTransformComponent::markWorldTransformDirty() +{ + addDirt(ComponentDirt::WorldTransform, true); +} + +const Mat2D& WorldTransformComponent::worldTransform() const +{ + return m_WorldTransform; +} + +Mat2D& WorldTransformComponent::mutableWorldTransform() +{ + return m_WorldTransform; +} + +void WorldTransformComponent::opacityChanged() +{ + addDirt(ComponentDirt::RenderOpacity, true); +} + +void WorldTransformComponent::worldTranslation(Vec2D& result) const +{ + result[0] = m_WorldTransform[4]; + result[1] = m_WorldTransform[5]; +}