[cpp] 4.3 porting WIP

This commit is contained in:
Mario Zechner 2025-07-04 21:48:13 +02:00
parent e3433c5903
commit fe20361d13
2 changed files with 13 additions and 7 deletions

View File

@ -135,6 +135,7 @@ namespace spine {
}
};
/// Changes a physics constraint's PhysicsConstraintPose::getMassInverse(). The timeline values are not inverted.
class SP_API PhysicsConstraintMassTimeline : public PhysicsConstraintTimeline {
friend class SkeletonBinary;
@ -208,6 +209,7 @@ namespace spine {
}
};
/// Changes a physics constraint's PhysicsConstraintPose::getMix().
class SP_API PhysicsConstraintMixTimeline : public PhysicsConstraintTimeline {
friend class SkeletonBinary;
@ -232,6 +234,7 @@ namespace spine {
}
};
/// Resets a physics constraint when specific animation times are reached.
class SP_API PhysicsConstraintResetTimeline : public Timeline, public ConstraintTimeline {
friend class SkeletonBinary;
@ -240,7 +243,8 @@ namespace spine {
RTTI_DECL
public:
explicit PhysicsConstraintResetTimeline(size_t frameCount, int physicsConstraintIndex): Timeline(frameCount, 1), ConstraintTimeline(physicsConstraintIndex) {
/// @param constraintIndex -1 for all physics constraints in the skeleton.
explicit PhysicsConstraintResetTimeline(size_t frameCount, int constraintIndex): Timeline(frameCount, 1), ConstraintTimeline(constraintIndex) {
PropertyId ids[] = {((PropertyId)Property_PhysicsConstraintReset) << 32};
setPropertyIds(ids, 1);
}
@ -251,6 +255,10 @@ namespace spine {
int getFrameCount() { return (int)_frames.size(); }
/// The index of the physics constraint in Skeleton::getConstraints() that will be reset when this timeline is
/// applied, or -1 if all physics constraints in the skeleton will be reset.
virtual int getConstraintIndex() override { return _constraintIndex; }
/// Sets the time for the specified frame.
void setFrame(int frame, float time) {
_frames[frame] = time;

View File

@ -68,16 +68,14 @@ void PhysicsConstraintTimeline::apply(Skeleton &skeleton, float, float time, Vec
PhysicsConstraint *constraint = physicsConstraints[i];
if (constraint->isActive() && global(constraint->_data)) {
PhysicsConstraintPose &pose = appliedPose ? *constraint->_applied : constraint->_pose;
PhysicsConstraintPose &setupPose = constraint->_data._setup;
set(pose, getAbsoluteValue(time, alpha, blend, get(pose), get(setupPose), value));
set(pose, getAbsoluteValue(time, alpha, blend, get(pose), get(constraint->_data._setup), value));
}
}
} else {
PhysicsConstraint *constraint = skeleton.getPhysicsConstraints()[_constraintIndex];
PhysicsConstraint *constraint = static_cast<PhysicsConstraint *>(skeleton.getConstraints()[_constraintIndex]);
if (constraint->isActive()) {
PhysicsConstraintPose &pose = appliedPose ? *constraint->_applied : constraint->_pose;
PhysicsConstraintPose &setupPose = constraint->_data._setup;
set(pose, getAbsoluteValue(time, alpha, blend, get(pose), get(setupPose)));
set(pose, getAbsoluteValue(time, alpha, blend, get(pose), get(constraint->_data._setup)));
}
}
}
@ -85,7 +83,7 @@ void PhysicsConstraintTimeline::apply(Skeleton &skeleton, float, float time, Vec
void PhysicsConstraintResetTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *, float alpha, MixBlend blend, MixDirection direction, bool appliedPose) {
PhysicsConstraint *constraint = nullptr;
if (_constraintIndex != -1) {
constraint = skeleton.getPhysicsConstraints()[_constraintIndex];
constraint = static_cast<PhysicsConstraint *>(skeleton.getConstraints()[_constraintIndex]);
if (!constraint->isActive()) return;
}