| 1 | // Copyright (C) 2017 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #include "quick3dvertexblendanimation_p.h" |
| 5 | |
| 6 | QT_BEGIN_NAMESPACE |
| 7 | |
| 8 | namespace Qt3DAnimation { |
| 9 | namespace Quick { |
| 10 | |
| 11 | QQuick3DVertexBlendAnimation::QQuick3DVertexBlendAnimation(QObject *parent) |
| 12 | : QObject(parent) |
| 13 | { |
| 14 | } |
| 15 | |
| 16 | QQmlListProperty<Qt3DAnimation::QMorphTarget> QQuick3DVertexBlendAnimation::morphTargets() |
| 17 | { |
| 18 | using qt_size_type = qsizetype; |
| 19 | using ListContentType = Qt3DAnimation::QMorphTarget; |
| 20 | auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *morphTarget) { |
| 21 | QQuick3DVertexBlendAnimation *animation |
| 22 | = qobject_cast<QQuick3DVertexBlendAnimation *>(object: list->object); |
| 23 | if (animation) |
| 24 | animation->parentVertexBlendAnimation()->addMorphTarget(target: morphTarget); |
| 25 | }; |
| 26 | auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type { |
| 27 | QQuick3DVertexBlendAnimation *animation |
| 28 | = qobject_cast<QQuick3DVertexBlendAnimation *>(object: list->object); |
| 29 | if (animation) |
| 30 | return animation->parentVertexBlendAnimation()->morphTargetList().size(); |
| 31 | return 0; |
| 32 | }; |
| 33 | auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * { |
| 34 | QQuick3DVertexBlendAnimation *animation |
| 35 | = qobject_cast<QQuick3DVertexBlendAnimation *>(object: list->object); |
| 36 | if (animation) { |
| 37 | return qobject_cast<Qt3DAnimation::QMorphTarget *>( |
| 38 | object: animation->parentVertexBlendAnimation()->morphTargetList().at(i: index)); |
| 39 | } |
| 40 | return nullptr; |
| 41 | }; |
| 42 | auto clearFunction = [](QQmlListProperty<ListContentType> *list) { |
| 43 | QQuick3DVertexBlendAnimation *animation |
| 44 | = qobject_cast<QQuick3DVertexBlendAnimation *>(object: list->object); |
| 45 | if (animation) |
| 46 | animation->parentVertexBlendAnimation()->setMorphTargets({}); |
| 47 | }; |
| 48 | |
| 49 | return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction); |
| 50 | } |
| 51 | |
| 52 | } // namespace Quick |
| 53 | } // namespace Qt3DAnimation |
| 54 | |
| 55 | QT_END_NAMESPACE |
| 56 | |
| 57 | #include "moc_quick3dvertexblendanimation_p.cpp" |
| 58 |
