forked from qt-creator/qt-creator
Add 3D editor Gizmo for Quick3DParticles
Adds an icon for Particle System Component making the component visible in the editor allowing picking. Task-number: QDS-4784 Change-Id: Ie6cffa9cfe3bb6a693372d7a7b4341e17f89911f Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Miikka Heikkinen
parent
00a2dd0747
commit
b8b6af0dbb
@@ -7,6 +7,8 @@
|
||||
<file>mockfiles/meshes/axishelper.mesh</file>
|
||||
<file>mockfiles/images/editor_camera.png</file>
|
||||
<file>mockfiles/images/editor_camera@2x.png</file>
|
||||
<file>mockfiles/images/editor_particlesystem.png</file>
|
||||
<file>mockfiles/images/editor_particlesystem@2x.png</file>
|
||||
<file>mockfiles/images/area.png</file>
|
||||
<file>mockfiles/images/area@2x.png</file>
|
||||
<file>mockfiles/images/directional.png</file>
|
||||
@@ -33,6 +35,7 @@
|
||||
<file>mockfiles/qt6/LightGizmo.qml</file>
|
||||
<file>mockfiles/qt6/LightIconGizmo.qml</file>
|
||||
<file>mockfiles/qt6/LightModel.qml</file>
|
||||
<file>mockfiles/qt6/ParticleSystemGizmo.qml</file>
|
||||
<file>mockfiles/qt6/Line3D.qml</file>
|
||||
<file>mockfiles/qt6/MaterialNodeView.qml</file>
|
||||
<file>mockfiles/qt6/ModelNode2DImageView.qml</file>
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
@@ -54,6 +54,7 @@ Item {
|
||||
|
||||
property var lightIconGizmos: []
|
||||
property var cameraGizmos: []
|
||||
property var particleSystemIconGizmos: []
|
||||
property var selectionBoxes: []
|
||||
property rect viewPortRect: Qt.rect(0, 0, 1000, 1000)
|
||||
|
||||
@@ -400,6 +401,45 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
function addParticleSystemGizmo(scene, obj)
|
||||
{
|
||||
// Insert into first available gizmo if we don't already have gizmo for this object
|
||||
var slotFound = -1;
|
||||
for (var i = 0; i < particleSystemIconGizmos.length; ++i) {
|
||||
if (!particleSystemIconGizmos[i].targetNode) {
|
||||
slotFound = i;
|
||||
} else if (particleSystemIconGizmos[i].targetNode === obj) {
|
||||
particleSystemIconGizmos[i].scene = scene;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (slotFound !== -1) {
|
||||
particleSystemIconGizmos[slotFound].scene = scene;
|
||||
particleSystemIconGizmos[slotFound].targetNode = obj;
|
||||
particleSystemIconGizmos[slotFound].locked = _generalHelper.isLocked(obj);
|
||||
particleSystemIconGizmos[slotFound].hidden = _generalHelper.isHidden(obj);
|
||||
_generalHelper.registerGizmoTarget(obj);
|
||||
return;
|
||||
}
|
||||
|
||||
// No free gizmos available, create a new one
|
||||
var gizmoComponent = Qt.createComponent("ParticleSystemGizmo.qml");
|
||||
if (gizmoComponent.status === Component.Ready) {
|
||||
_generalHelper.registerGizmoTarget(obj);
|
||||
var gizmo = gizmoComponent.createObject(overlayView,
|
||||
{"view3D": overlayView, "targetNode": obj,
|
||||
"selectedNodes": selectedNodes, "scene": scene,
|
||||
"activeScene": activeScene,
|
||||
"locked": _generalHelper.isLocked(obj),
|
||||
"hidden": _generalHelper.isHidden(obj)});
|
||||
particleSystemIconGizmos[particleSystemIconGizmos.length] = gizmo;
|
||||
gizmo.clicked.connect(handleObjectClicked);
|
||||
gizmo.selectedNodes = Qt.binding(function() {return selectedNodes;});
|
||||
gizmo.activeScene = Qt.binding(function() {return activeScene;});
|
||||
}
|
||||
}
|
||||
|
||||
function releaseLightGizmo(obj)
|
||||
{
|
||||
for (var i = 0; i < lightIconGizmos.length; ++i) {
|
||||
@@ -424,6 +464,18 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
function releaseParticleSystemGizmo(obj)
|
||||
{
|
||||
for (var i = 0; i < particleSystemIconGizmos.length; ++i) {
|
||||
if (particleSystemIconGizmos[i].targetNode === obj) {
|
||||
particleSystemIconGizmos[i].scene = null;
|
||||
particleSystemIconGizmos[i].targetNode = null;
|
||||
_generalHelper.unregisterGizmoTarget(obj);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateLightGizmoScene(scene, obj)
|
||||
{
|
||||
for (var i = 0; i < lightIconGizmos.length; ++i) {
|
||||
@@ -444,6 +496,16 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
function updateParticleSystemGizmoScene(scene, obj)
|
||||
{
|
||||
for (var i = 0; i < particleSystemIconGizmos.length; ++i) {
|
||||
if (particleSystemIconGizmos[i].targetNode === obj) {
|
||||
particleSystemIconGizmos[i].scene = scene;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
createEditView();
|
||||
selectObjects([]);
|
||||
@@ -471,6 +533,13 @@ Item {
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < particleSystemIconGizmos.length; ++i) {
|
||||
if (particleSystemIconGizmos[i].targetNode === node) {
|
||||
particleSystemIconGizmos[i].locked = _generalHelper.isLocked(node);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
function onHiddenStateChanged(node)
|
||||
{
|
||||
@@ -486,6 +555,12 @@ Item {
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < particleSystemIconGizmos.length; ++i) {
|
||||
if (particleSystemIconGizmos[i].targetNode === node) {
|
||||
particleSystemIconGizmos[i].hidden = _generalHelper.isHidden(node);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,32 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 6.0
|
||||
import QtQuick3D 6.0
|
||||
|
||||
IconGizmo {
|
||||
id: particleSystemGizmo
|
||||
iconSource: "qrc:///qtquickplugin/mockfiles/images/editor_particlesystem.png"
|
||||
}
|
@@ -9,6 +9,10 @@ versionAtLeast(QT_VERSION, 5.15.0) {
|
||||
QT *= quick3dassetimport-private
|
||||
DEFINES *= IMPORT_QUICK3D_ASSETS
|
||||
}
|
||||
qtHaveModule(quick3dparticles) {
|
||||
QT *= quick3dparticles-private
|
||||
DEFINES *= QUICK3D_PARTICLES_MODULE
|
||||
}
|
||||
}
|
||||
|
||||
HEADERS += $$PWD/qt5nodeinstanceserver.h \
|
||||
|
@@ -103,6 +103,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef QUICK3D_PARTICLES_MODULE
|
||||
#include <QtQuick3DParticles/private/qquick3dparticlesystem_p.h>
|
||||
#endif
|
||||
|
||||
#ifdef IMPORT_QUICK3D_ASSETS
|
||||
#include <QtQuick3DAssetImport/private/qssgassetimportmanager_p.h>
|
||||
#endif
|
||||
@@ -618,6 +622,11 @@ void Qt5InformationNodeInstanceServer::handleNode3DDestroyed(QObject *obj)
|
||||
} else if (qobject_cast<QQuick3DAbstractLight *>(obj)) {
|
||||
QMetaObject::invokeMethod(m_editView3DData.rootItem, "releaseLightGizmo",
|
||||
Q_ARG(QVariant, objectToVariant(obj)));
|
||||
#ifdef QUICK3D_PARTICLES_MODULE
|
||||
} else if (qobject_cast<QQuick3DParticleSystem *>(obj)) {
|
||||
QMetaObject::invokeMethod(m_editView3DData.rootItem, "releaseParticleSystemGizmo",
|
||||
Q_ARG(QVariant, objectToVariant(obj)));
|
||||
#endif
|
||||
}
|
||||
removeNode3D(obj);
|
||||
#else
|
||||
@@ -720,6 +729,12 @@ void Qt5InformationNodeInstanceServer::resolveSceneRoots()
|
||||
QMetaObject::invokeMethod(m_editView3DData.rootItem, "updateLightGizmoScene",
|
||||
Q_ARG(QVariant, objectToVariant(newRoot)),
|
||||
Q_ARG(QVariant, objectToVariant(node)));
|
||||
#ifdef QUICK3D_PARTICLES_MODULE
|
||||
} else if (qobject_cast<QQuick3DParticleSystem *>(node)) {
|
||||
QMetaObject::invokeMethod(m_editView3DData.rootItem, "updateParticleSystemGizmoScene",
|
||||
Q_ARG(QVariant, objectToVariant(newRoot)),
|
||||
Q_ARG(QVariant, objectToVariant(node)));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
++it;
|
||||
@@ -1231,12 +1246,16 @@ void Qt5InformationNodeInstanceServer::createCameraAndLightGizmos(
|
||||
{
|
||||
QHash<QObject *, QObjectList> cameras;
|
||||
QHash<QObject *, QObjectList> lights;
|
||||
QHash<QObject *, QObjectList> particleSystems;
|
||||
|
||||
for (const ServerNodeInstance &instance : instanceList) {
|
||||
if (instance.isSubclassOf("QQuick3DCamera"))
|
||||
cameras[find3DSceneRoot(instance)] << instance.internalObject();
|
||||
else if (instance.isSubclassOf("QQuick3DAbstractLight"))
|
||||
lights[find3DSceneRoot(instance)] << instance.internalObject();
|
||||
else if (instance.isSubclassOf("QQuick3DParticleSystem"))
|
||||
particleSystems[find3DSceneRoot(instance)] << instance.internalObject();
|
||||
|
||||
}
|
||||
|
||||
auto cameraIt = cameras.constBegin();
|
||||
@@ -1259,6 +1278,16 @@ void Qt5InformationNodeInstanceServer::createCameraAndLightGizmos(
|
||||
}
|
||||
++lightIt;
|
||||
}
|
||||
auto particleIt = particleSystems.constBegin();
|
||||
while (particleIt != particleSystems.constEnd()) {
|
||||
const auto particleObjs = particleIt.value();
|
||||
for (auto &obj : particleObjs) {
|
||||
QMetaObject::invokeMethod(m_editView3DData.rootItem, "addParticleSystemGizmo",
|
||||
Q_ARG(QVariant, objectToVariant(particleIt.key())),
|
||||
Q_ARG(QVariant, objectToVariant(obj)));
|
||||
}
|
||||
++particleIt;
|
||||
}
|
||||
}
|
||||
|
||||
void Qt5InformationNodeInstanceServer::add3DViewPorts(const QList<ServerNodeInstance> &instanceList)
|
||||
@@ -1740,6 +1769,9 @@ void Qt5InformationNodeInstanceServer::changeSelection(const ChangeSelectionComm
|
||||
#ifdef QUICK3D_MODULE
|
||||
if (qobject_cast<QQuick3DModel *>(object)
|
||||
|| qobject_cast<QQuick3DCamera *>(object)
|
||||
#ifdef QUICK3D_PARTICLES_MODULE
|
||||
|| qobject_cast<QQuick3DParticleSystem *>(object)
|
||||
#endif
|
||||
|| qobject_cast<QQuick3DAbstractLight *>(object)) {
|
||||
return true;
|
||||
}
|
||||
|
@@ -160,6 +160,14 @@ extend_qtc_executable(qml2puppet
|
||||
DEFINES IMPORT_QUICK3D_ASSETS
|
||||
)
|
||||
|
||||
find_package(Qt5 5.15.0 COMPONENTS Quick3DParticles QUIET)
|
||||
extend_qtc_executable(qml2puppet
|
||||
CONDITION TARGET Qt5::Quick3DParticles
|
||||
FEATURE_INFO "Qt Quick 3D particles"
|
||||
DEPENDS Qt5::Quick3DParticles Qt5::Quick3DParticlesPrivate
|
||||
DEFINES QUICK3D_PARTICLES_MODULE
|
||||
)
|
||||
|
||||
extend_qtc_executable(qml2puppet
|
||||
CONDITION Qt5_VERSION VERSION_GREATER_EQUAL 6.0.0
|
||||
|
||||
|
@@ -18,11 +18,15 @@ QtcTool {
|
||||
Depends { name: "Qt.quick3d-private"; required: false }
|
||||
property bool useQuick3d: Utilities.versionCompare(Qt.core.version, "5.15") >= 0
|
||||
&& Qt["quick3d-private"].present
|
||||
property bool useParticle3d: Utilities.versionCompare(Qt.core.version, "6.2") >= 0
|
||||
&& Qt["quick3dparticles-private"].present
|
||||
|
||||
cpp.defines: {
|
||||
var defines = base.filter(function(d) { return d != "QT_CREATOR"; });
|
||||
if (useQuick3d)
|
||||
defines.push("QUICK3D_MODULE");
|
||||
if (useParticle3d)
|
||||
defines.push("QUICK3D_PARTICLES_MODULE");
|
||||
return defines;
|
||||
}
|
||||
Properties {
|
||||
|
Reference in New Issue
Block a user