Skip to content

Commit

Permalink
fix: update core/TransformEffects code
Browse files Browse the repository at this point in the history
  • Loading branch information
kaixoo committed Jan 17, 2025
1 parent c1724f3 commit 7d4b5be
Show file tree
Hide file tree
Showing 21 changed files with 173 additions and 139 deletions.
4 changes: 2 additions & 2 deletions src/core/Animators/transformanimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ void AdvancedTransformAnimator::applyTransformEffects(
const qreal relFrame,
qreal& pivotX, qreal& pivotY, qreal& pivotZ,
qreal& posX, qreal& posY, qreal& posZ,
qreal& rot,
qreal& rotX, qreal& rotY, qreal& rotZ,
qreal& scaleX, qreal& scaleY, qreal& scaleZ,
qreal& shearX, qreal& shearY, qreal& shearZ,
QMatrix& postTransform) const {
Expand All @@ -574,7 +574,7 @@ void AdvancedTransformAnimator::applyTransformEffects(
parent->applyTransformEffects(relFrame,
pivotX, pivotY, pivotZ,
posX, posY, posZ,
rot,
rotX, rotY, rotZ,
scaleX, scaleY, scaleZ,
shearX, shearY, shearZ,
postTransform);
Expand Down
10 changes: 1 addition & 9 deletions src/core/Animators/transformanimator.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,10 @@ class CORE_EXPORT AdvancedTransformAnimator : public BasicTransformAnimator {
QMatrix getRelativeTransformAtFrame(
const qreal relFrame, QMatrix* postTransform = nullptr) const;

void applyTransformEffects(const qreal relFrame,
qreal& pivotX, qreal& pivotY,
qreal& posX, qreal& posY,
qreal& rot,
qreal& scaleX, qreal& scaleY,
qreal& shearX, qreal& shearY,
QMatrix& postTransform) const;

void applyTransformEffects(const qreal relFrame,
qreal& pivotX, qreal& pivotY, qreal& pivotZ,
qreal& posX, qreal& posY, qreal& posZ,
qreal& rot,
qreal& rotX, qreal& rotY, qreal& rotZ,
qreal& scaleX, qreal& scaleY, qreal& scaleZ,
qreal& shearX, qreal& shearY, qreal& shearZ,
QMatrix& postTransform) const;
Expand Down
18 changes: 6 additions & 12 deletions src/core/Boxes/boundingbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,22 +340,16 @@ const QStringList BoundingBox::checkRasterEffectsForSVGSupport()

void BoundingBox::applyTransformEffects(
const qreal relFrame,
qreal& pivotX, qreal& pivotY,
qreal& posX, qreal& posY,
qreal& rot,
qreal& scaleX, qreal& scaleY,
qreal& shearX, qreal& shearY,
qreal& pivotX, qreal& pivotY, qreal& pivotZ,
qreal& posX, qreal& posY, qreal& posZ,
qreal& rotX, qreal& rotY, qreal& rotZ,
qreal& scaleX, qreal& scaleY, qreal& scaleZ,
qreal& shearX, qreal& shearY, qreal& shearZ,
QMatrix& postTransform) {
qreal &pivotZ = 0.;
qreal &posZ = 0.;
qreal &rotY = 0.;
qreal &rotZ = 0.;
qreal &scaleZ = 0.;
qreal &shearZ = 0.;
mTransformEffectCollection->applyEffects(relFrame,
pivotX, pivotY, pivotZ,
posX, posY, posZ,
rot, rotY, rotZ,
rotX, rotY, rotZ,
scaleX, scaleY, scaleZ,
shearX, shearY, shearZ,
postTransform, this);
Expand Down
10 changes: 5 additions & 5 deletions src/core/Boxes/boundingbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,11 @@ class CORE_EXPORT BoundingBox : public eBoxOrSound {
const QStringList checkRasterEffectsForSVGSupport();

void applyTransformEffects(const qreal relFrame,
qreal& pivotX, qreal& pivotY,
qreal& posX, qreal& posY,
qreal& rot,
qreal& scaleX, qreal& scaleY,
qreal& shearX, qreal& shearY,
qreal& pivotX, qreal& pivotY, qreal& pivotZ,
qreal& posX, qreal& posY, qreal& posZ,
qreal& rotX, qreal& rotY, qreal& rotZ,
qreal& scaleX, qreal& scaleY, qreal& scaleZ,
qreal& shearX, qreal& shearY, qreal& shearZ,
QMatrix& postTransform);

bool hasTransformEffects() const;
Expand Down
21 changes: 12 additions & 9 deletions src/core/TransformEffects/followobjecteffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,25 @@

#include "Boxes/boundingbox.h"
#include "Animators/transformanimator.h"
#include "Animators/qrealanimator.h"

FollowObjectEffect::FollowObjectEffect() :
FollowObjectEffectBase("follow object",
TransformEffectType::followObject) {}

void FollowObjectEffect::applyEffect(const qreal relFrame,
qreal& pivotX, qreal& pivotY,
qreal& posX, qreal& posY,
qreal& rot,
qreal& scaleX, qreal& scaleY,
qreal& shearX, qreal& shearY,
qreal& pivotX, qreal& pivotY, qreal& pivotZ,
qreal& posX, qreal& posY, qreal& posZ,
qreal& rotX, qreal& rotY, qreal& rotZ,
qreal& scaleX, qreal& scaleY, qreal& scaleZ,
qreal& shearX, qreal& shearY, qreal& shearZ,
QMatrix& postTransform,
BoundingBox* const parent) {
Q_UNUSED(pivotX)
Q_UNUSED(pivotY)
Q_UNUSED(pivotZ)
Q_UNUSED(shearX)
Q_UNUSED(shearY)
Q_UNUSED(shearZ)
Q_UNUSED(postTransform)

if(!isVisible()) return;
Expand All @@ -59,8 +60,10 @@ void FollowObjectEffect::applyEffect(const qreal relFrame,
const auto targetTransform = target->getTotalTransformAtFrame(targetRelFrame);
const auto transform = targetTransform*parentTransform.inverted();

applyEffectWithTransform(relFrame, pivotX, pivotY,
posX, posY, rot,
scaleX, scaleY, shearX, shearY,
applyEffectWithTransform(relFrame, pivotX, pivotY, pivotZ,
posX, posY, posZ,
rotX, rotY, rotZ,
scaleX, scaleY, scaleZ,
shearX, shearY, shearZ,
parent, transform);
}
12 changes: 6 additions & 6 deletions src/core/TransformEffects/followobjecteffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ class FollowObjectEffect : public FollowObjectEffectBase {
FollowObjectEffect();

void applyEffect(const qreal relFrame,
qreal &pivotX, qreal &pivotY,
qreal &posX, qreal &posY,
qreal &rot,
qreal &scaleX, qreal &scaleY,
qreal &shearX, qreal &shearY,
qreal &pivotX, qreal &pivotY, qreal &pivotZ,
qreal &posX, qreal &posY, qreal &posZ,
qreal &rotX, qreal &rotY, qreal &rotZ,
qreal &scaleX, qreal &scaleY, qreal &scaleZ,
qreal &shearX, qreal &shearY, qreal &shearZ,
QMatrix& postTransform,
BoundingBox* const parent) override;
BoundingBox* const parent);
};

#endif // FOLLOWOBJECTEFFECT_H
45 changes: 26 additions & 19 deletions src/core/TransformEffects/followobjecteffectbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,22 @@
// Fork of enve - Copyright (C) 2016-2020 Maurycy Liebner

#include "followobjecteffectbase.h"

#include "Boxes/boundingbox.h"
#include "Animators/transformanimator.h"
#include "Animators/qrealanimator.h"
#include "Animators/qvector3danimator.h"

FollowObjectEffectBase::FollowObjectEffectBase(
const QString& name, const TransformEffectType type) :
TargetTransformEffect(name, type) {
mPosInfluence = enve::make_shared<QPointFAnimator>(
QPointF{1., 1.}, QPointF{-10., -10.},
QPointF{10., 10.}, QPointF{0.01, 0.01},
mPosInfluence = enve::make_shared<QVector3DAnimator>(
QVector3D{1., 1., 1.}, QVector3D{-10., -10., -10.},
QVector3D{10., 10., 10.}, QVector3D{0.01, 0.01, 0.01},
"pos influence");
mScaleInfluence = enve::make_shared<QPointFAnimator>(
QPointF{1., 1.}, QPointF{-10., -10.},
QPointF{10., 10.}, QPointF{0.01, 0.01},
mScaleInfluence = enve::make_shared<QVector3DAnimator>(
QVector3D{1., 1., 1.}, QVector3D{-10., -10., -10.},
QVector3D{10., 10., 10.}, QVector3D{0.01, 0.01, 0.01},
"scale influence");
mRotInfluence = enve::make_shared<QrealAnimator>(
mRotInfluence = enve::make_shared<QVector3DAnimator>(
1, -10, 10, 0.01, "rot influence");

ca_addChild(mPosInfluence);
Expand All @@ -50,16 +49,22 @@ FollowObjectEffectBase::FollowObjectEffectBase(

void FollowObjectEffectBase::applyEffectWithTransform(
const qreal relFrame,
qreal& pivotX, qreal& pivotY,
qreal& posX, qreal& posY, qreal& rot,
qreal& scaleX, qreal& scaleY,
qreal& shearX, qreal& shearY,
qreal& pivotX, qreal& pivotY, qreal& pivotZ,
qreal& posX, qreal& posY, qreal& posZ,
qreal& rotX, qreal& rotY, qreal& rotZ,
qreal& scaleX, qreal& scaleY, qreal& scaleZ,
qreal& shearX, qreal& shearY, qreal& shearZ,
BoundingBox* const parent,
const QMatrix& transform) {
Q_UNUSED(pivotX);
Q_UNUSED(pivotY);
Q_UNUSED(shearX);
Q_UNUSED(shearY);
Q_UNUSED(pivotX)
Q_UNUSED(pivotY)
Q_UNUSED(pivotZ)
Q_UNUSED(posZ)
Q_UNUSED(rotZ)
Q_UNUSED(scaleZ)
Q_UNUSED(shearX)
Q_UNUSED(shearY)
Q_UNUSED(shearZ)

if(!isVisible()) return;

Expand All @@ -85,15 +90,17 @@ void FollowObjectEffectBase::applyEffectWithTransform(
const qreal posYInfl = mPosInfluence->getEffectiveYValue(relFrame);
const qreal scaleXInfl = mScaleInfluence->getEffectiveXValue(relFrame);
const qreal scaleYInfl = mScaleInfluence->getEffectiveYValue(relFrame);
const qreal rotInfl = mRotInfluence->getEffectiveValue(relFrame);
const qreal rotXInfl = mRotInfluence->getEffectiveXValue(relFrame);
const qreal rotYInfl = mRotInfluence->getEffectiveYValue(relFrame);

posX += p1.x()*posXInfl;
posY += p1.y()*posYInfl;

scaleX *= 1 + (xScale - 1)*scaleXInfl;
scaleY *= 1 + (yScale - 1)*scaleYInfl;

rot += targetRot*rotInfl;
rotX += targetRot*rotXInfl;
rotY += targetRot*rotYInfl;
}

void FollowObjectEffectBase::setRotScaleAfterTargetChange(
Expand Down
20 changes: 11 additions & 9 deletions src/core/TransformEffects/followobjecteffectbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@

#include "targettransformeffect.h"

#include "Animators/qpointfanimator.h"
#include "Animators/qvector3danimator.h"

class QVector3D;

class FollowObjectEffectBase : public TargetTransformEffect {
public:
Expand All @@ -38,21 +40,21 @@ class FollowObjectEffectBase : public TargetTransformEffect {
protected:
void applyEffectWithTransform(
const qreal relFrame,
qreal &pivotX, qreal &pivotY,
qreal &posX, qreal &posY,
qreal &rot,
qreal &scaleX, qreal &scaleY,
qreal &shearX, qreal &shearY,
qreal &pivotX, qreal &pivotY, qreal &pivotZ,
qreal &posX, qreal &posY, qreal &posZ,
qreal &rotX, qreal &rotY, qreal &rotZ,
qreal &scaleX, qreal &scaleY, qreal &scaleZ,
qreal &shearX, qreal &shearY, qreal &shearZ,
BoundingBox* const parent,
const QMatrix& transform);
protected:
void setRotScaleAfterTargetChange(
BoundingBox* const oldTarget,
BoundingBox* const newTarget) override;

qsptr<QPointFAnimator> mPosInfluence;
qsptr<QPointFAnimator> mScaleInfluence;
qsptr<QrealAnimator> mRotInfluence;
qsptr<QVector3DAnimator> mPosInfluence;
qsptr<QVector3DAnimator> mScaleInfluence;
qsptr<QVector3DAnimator> mRotInfluence;
};

#endif // FOLLOWOBJECTEFFECTBASE_H
19 changes: 11 additions & 8 deletions src/core/TransformEffects/followobjectrelativeeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ FollowObjectRelativeEffect::FollowObjectRelativeEffect() :

void FollowObjectRelativeEffect::applyEffect(
const qreal relFrame,
qreal& pivotX, qreal& pivotY,
qreal& posX, qreal& posY,
qreal& rot,
qreal& scaleX, qreal& scaleY,
qreal& shearX, qreal& shearY,
qreal& pivotX, qreal& pivotY, qreal& pivotZ,
qreal& posX, qreal& posY, qreal& posZ,
qreal& rotX, qreal& rotY, qreal& rotZ,
qreal& scaleX, qreal& scaleY, qreal& scaleZ,
qreal& shearX, qreal& shearY, qreal& shearZ,
QMatrix& postTransform,
BoundingBox* const parent) {
Q_UNUSED(pivotX)
Expand All @@ -60,8 +60,11 @@ void FollowObjectRelativeEffect::applyEffect(

const auto targetTransform = target->getTotalTransformAtFrame(targetRelFrame);

applyEffectWithTransform(relFrame, pivotX, pivotY,
posX, posY, rot,
scaleX, scaleY, shearX, shearY,
applyEffectWithTransform(relFrame,
pivotX, pivotY, pivotZ,
posX, posY, posZ,
rotX, rotY, rotZ,
scaleX, scaleY, scaleZ,
shearX, shearY, shearZ,
parent, targetTransform);
}
12 changes: 6 additions & 6 deletions src/core/TransformEffects/followobjectrelativeeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ class FollowObjectRelativeEffect :
FollowObjectRelativeEffect();

void applyEffect(const qreal relFrame,
qreal &pivotX, qreal &pivotY,
qreal &posX, qreal &posY,
qreal &rot,
qreal &scaleX, qreal &scaleY,
qreal &shearX, qreal &shearY,
qreal &pivotX, qreal &pivotY, qreal &pivotZ,
qreal &posX, qreal &posY, qreal &posZ,
qreal &rotX, qreal &rotY, qreal &rotZ,
qreal &scaleX, qreal &scaleY, qreal &scaleZ,
qreal &shearX, qreal &shearY, qreal &shearZ,
QMatrix& postTransform,
BoundingBox* const parent) override;
BoundingBox* const parent);
};

#endif // FOLLOWOBJECTRELATIVEEFFECT_H
15 changes: 9 additions & 6 deletions src/core/TransformEffects/followpatheffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,22 @@ void FollowPathEffect::setRotScaleAfterTargetChange(
}

void FollowPathEffect::applyEffect(const qreal relFrame,
qreal& pivotX, qreal& pivotY,
qreal& posX, qreal& posY,
qreal& rot,
qreal& scaleX, qreal& scaleY,
qreal& shearX, qreal& shearY,
qreal& pivotX, qreal& pivotY, qreal& pivotZ,
qreal& posX, qreal& posY, qreal& posZ,
qreal& rotX, qreal& rotY, qreal& rotZ,
qreal& scaleX, qreal& scaleY, qreal& scaleZ,
qreal& shearX, qreal& shearY, qreal& shearZ,
QMatrix& postTransform,
BoundingBox* const parent) {
Q_UNUSED(pivotX)
Q_UNUSED(pivotY)
Q_UNUSED(pivotZ)
Q_UNUSED(scaleX)
Q_UNUSED(scaleY)
Q_UNUSED(scaleZ)
Q_UNUSED(shearX)
Q_UNUSED(shearY)
Q_UNUSED(shearZ)
Q_UNUSED(postTransform)

if(!isVisible()) return;
Expand Down Expand Up @@ -177,7 +180,7 @@ void FollowPathEffect::applyEffect(const qreal relFrame,
lengthBased, rotate, infl, per,
rotChange, posXChange, posYChange);

if(rotate) rot += rotChange;
if(rotate) rotX += rotChange;

posX += posXChange; //p1.x()*infl;
posY += posYChange; //p1.y()*infl;
Expand Down
10 changes: 5 additions & 5 deletions src/core/TransformEffects/followpatheffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class FollowPathEffect : public TargetTransformEffect {
FollowPathEffect();

void applyEffect(const qreal relFrame,
qreal &pivotX, qreal &pivotY,
qreal &posX, qreal &posY,
qreal &rot,
qreal &scaleX, qreal &scaleY,
qreal &shearX, qreal &shearY,
qreal &pivotX, qreal &pivotY, qreal& pivotZ,
qreal &posX, qreal &posY, qreal& posZ,
qreal &rotX, qreal& rotY, qreal& rotZ,
qreal &scaleX, qreal &scaleY, qreal& scaleZ,
qreal &shearX, qreal &shearY, qreal& shearZ,
QMatrix& postTransform,
BoundingBox* const parent) override;

Expand Down
Loading

0 comments on commit 7d4b5be

Please sign in to comment.