diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2015-11-11 11:09:48 +0000 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2015-11-11 22:12:38 +0000 |
commit | df4a57731ba9cc5aa56d29de0cd7701b07672c31 (patch) | |
tree | b8a30814cb5fc3d4647e0e3bdc456a7db30c17d9 /src/qml/qml/v8 | |
parent | ded64d03686268b9ead0f0b5c9299683859a1160 (diff) |
Introduce a more sane "default constructor" for Qt.matrix4x4()
If no arguments are specified, create an identity matrix. This is by
far the most common use case. This change avoids having to type in the
16 arguments of the identity matrix.
Change-Id: I9e0d71897c5368d19ae87cff936df4b9e5e9b84a
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/qml/qml/v8')
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 72a3fe1537..ca488021c8 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -434,11 +434,16 @@ Returns a Matrix4x4 with the specified values. Alternatively, the function may be called with a single argument where that argument is a JavaScript array which contains the sixteen matrix values. +Finally, the function may be called with no arguments and the resulting +matrix will be the identity matrix. */ ReturnedValue QtObject::method_matrix4x4(QV4::CallContext *ctx) { QV4::ExecutionEngine *v4 = ctx->d()->engine; + if (ctx->argc() == 0) + return ctx->engine()->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QMatrix4x4, 0, Q_NULLPTR)); + if (ctx->argc() == 1 && ctx->args()[0].isObject()) { bool ok = false; QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QMatrix4x4, QQmlV4Handle(ctx->args()[0]), v4, &ok); |