Commit Graph

86 Commits

Author SHA1 Message Date
Miikka Heikkinen
cb00a8d30f QmlDesigner: Fix orthographic camera hdpi issues in edit 3D view
There is no need to double the viewport anymore when calculating
orthographic camera frustum visualization, Qt6 correctly accounts
for device pixel ratio in ortho projection. Even in Qt5, the old
hack only made frustum visualization correct for hdpi screens while
breaking it for regular screens.

Also fixed zoom factor handling for orthographic edit camera mode.

Task-number: QDS-5469
Change-Id: Ie53b5dfa2fbcc00f098ea64e5a6673e4b7af0963
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-11-22 10:14:42 +00:00
Kaj Grönholm
d8a7c97fcb Use global picking API
When gobal picking is available (Qt 6.2+), use that instead of toggling
models pickable properties.

Task-number: QDS-4978
Change-Id: Id2a501ae97955128874447fa8a3b8afab3d1f2c7
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-10-14 04:08:33 +00:00
Kaj Grönholm
d1d5f47bda Fix building with Quick 3D dev
Adjust to camera changes b74fde27@qtquick3d

Task-number: QTBUG-95932
Change-Id: Id7408541caaebb0ee18240e7bc4208ac416fb0b9
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io>
Reviewed-by: Knud Dollereder <knud.dollereder@qt.io>
2021-08-24 15:35:30 +00:00
Christian Strømme
4788f0671f Update MouseArea3D::getCameraToNodeDir() to not rely on cameraNode()
The cameraNode() function has been removed from QtQuick3D and it only
existed because of the weird way we we're creating the camera node.
Now, instead of the round-trip, just request the spatial node directly.
See: b74fde27@qtquick3d

Change-Id: Icc8584aebee4952356769a134756074cba8d1b0e
Reviewed-by: Kaj Grönholm <kaj.gronholm@qt.io>
2021-08-23 12:22:04 +00:00
Tim Jenssen
27d414458e qmlpuppet: fix qt 5.15 builds
Change-Id: I6d19624537a3980252d43624ecf24e110638225a
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-10 09:07:41 +00:00
Miikka Heikkinen
2c7b2ad685 QmlPuppet: Fix incorrect initial render size/scene for edit 3D
The scene id was stored as array of QChars instead of QString, which
caused issues restoring the correct scene at puppet reset.
The intitial incorrect render size was caused by not changing the
render window size in addition to root QML item size.

Fixes: QDS-4586
Change-Id: Id6b16d778a9d886e8fdc40eab1e549d13091f8f4
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Samuel Ghinet <samuel.ghinet@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2021-08-09 14:00:19 +00:00
Miikka Heikkinen
18f24ffd68 QmlPuppet: Fix multiselection fit object in 3D editor
Multiselection is now properly fit to the view when fit object is used.

Fixes: QDS-4608
Change-Id: Ia80133fc861bd177b9102423ebef37b592c74758
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
2021-07-01 14:29:35 +00:00
Miikka Heikkinen
48348b8dc4 QmlPuppet: Change custom 3D geometries to use public API
Custom geometries often break and code becomes convoluted with
version ifdeffing, so refactor the custom geometries to use public
geometry api, which works both in Qt5 and Qt6.

Fixes: QDS-4611
Change-Id: I2d78776a14d5c8153b52806842254dbedb5de83d
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
2021-06-29 12:03:51 +00:00
Miikka Heikkinen
193f485be2 QmlDesigner: Fix unused variable warnings
Change-Id: I1616452753685bbd57eec8fc6e1c9934c63fef0c
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
2021-06-22 08:54:41 +00:00
Miikka Heikkinen
acb4113f09 QmlPuppet: Enable negative scaling in multiselection
Scenerotation was queried from the node for each drag move, causing
drift in the calculations. Locking the rotation at drag start makes
negative scaling work nicely.

Also enabled negative values on all axis scaling, since it makes no
sense to block it there when single axis/planar scaling already allows
it.

Fixes: QDS-4493
Change-Id: I7a38a08556bd6d729974332d312aa4aa4e84ea30
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2021-06-11 12:28:38 +00:00
Miikka Heikkinen
b73884bee5 QmlPuppet: Fix runtime warnings in 3D editor
Fixes: QDS-4491
Change-Id: I462e165ef59111f70c928b7d652ade99c5b3c0d0
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
2021-06-11 12:28:26 +00:00
Miikka Heikkinen
74f65abed0 QmlPuppet: Fix multiselection 3D transformations when nodes have pivot
We simply need to store the scene position of the pivot point of the
node instead of node itself and work with that.

Fixes: QDS-4515
Change-Id: I99155636c52897794bea21b2db7f7d2d00059d91
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2021-06-11 07:47:19 +00:00
Miikka Heikkinen
4e1ca8d3c5 QmlPuppet: Reset gizmo orientation after multiselection rotation
Gizmo orientation in multiselection case should always be aligned to
the global axes, so we now reset multiselection on release
handlers of rotation gizmo.

Fixes: QDS-4492
Change-Id: Ic10f26f65df42869e4643f48457bcbcbf970fe9a
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2021-06-11 07:47:13 +00:00
Alessandro Portale
dcbf26490d QmlPuppet: Fix build with Qt 6.2
Fixes: QTCREATORBUG-25763
Change-Id: I05f4b44a3793c41fd1c6812f40f6603892cdac50
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
2021-06-04 10:12:30 +00:00
Miikka Heikkinen
f913a65405 QmlPuppet: Support multiselection transformations in 3D edit view
Add support for moving, rotating, and scaling a multiselection of 3D
nodes in 3D edit view.

Fixes: QDS-4313
Change-Id: Icf83911ac6f87fde1cb79d6f5059ae01ed434d7f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2021-06-01 09:38:00 +00:00
Miikka Heikkinen
125cdcc3a0 QmlDesigner: Block changing eulerRotation for 3D Node that has rotation
QtQuick3D doesn't support both rotation and eulerRotation set on same
node, so we delete existing quaternion rotation if user sets an euler
rotation to the node. If node has quaternion rotation animation,
we block any change to eulerRotation in the node.

3D editor also disables the rotation gizmo for blocked nodes.

Task-number: QDS-4335
Change-Id: I4ce7b022c732a9547751f101548ecea948279db8
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2021-05-27 08:43:50 +00:00
Miikka Heikkinen
baf3528af5 QmlPuppet: Fix custom 3D geometries for Qt 6.1
Private API puppet uses for custom 3D geometries has changed.

Change-Id: Ie9f2052b04399db6f9643aba6319f6e95df1c15b
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
2021-02-05 15:03:47 +00:00
Eike Ziller
5ca70bdcb3 Merge remote-tracking branch 'origin/4.14'
Change-Id: Iea84f23cf394de13e99a9ed777c8c113e4eff473
2020-11-19 15:38:13 +01:00
Alessandro Portale
30aec82285 Add missing "final" to unexported/unshared classes
Change-Id: I84d5fc39d7ef5588a20545854d0cfd0b993db090
Reviewed-by: hjk <hjk@qt.io>
2020-11-18 15:40:29 +00:00
Jarek Kobus
df9d1414b8 Don't cast QHoverEvent into QMouseEvent
Such a cast rely on the fact that some internal data
of both classes must match. Qt doesn't guarantee it.

Change-Id: I5c29af98e320b72b599c059a2827eb2e7d3843da
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
2020-11-17 08:42:57 +00:00
Henning Gruendl
f2883c19b1 QmlDesigner: Add lock feature support to 3D editor
Added lock feature support for 3D editor. Also refactored the hide
support, since the two use largely similar logic.

Task-number: QDS-2915
Change-Id: I627848f3a3a73881427a03aeec6793fd26a1885a
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-11-06 09:19:05 +00:00
Miikka Heikkinen
6b8d8e414a QmlDesigner: Port 3D edit view to Qt6
Task-number: QDS-2899
Change-Id: Iedbe5e8561e5ab71ef32922e69da43cd3cc57e90
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-10-20 14:55:43 +00:00
Miikka Heikkinen
762addfbd0 QmlDesigner: Add navigator tooltip for 3D Model nodes
Only the source and geometry properties of the model is taken from the
node, rest of the properties are always same for consistent style.

Change-Id: I2355ce91c3e3d6f23b9f27ecf31430e3e13d0c80
Fixes: QDS-2764
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
2020-09-22 13:35:10 +00:00
Miikka Heikkinen
5cc7dae965 QmlPuppet: Improve gizmo precision
At high zoom levels, picking precision of the gizmos was not good,
because compounding inaccuracies from multiple floating point
operations required. Fixed by reimplementing many operations using
double precision math.

Change-Id: I013876b816379a20b552eb06d2f9cbb3f2aa2d21
Fixes: QDS-2676
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
2020-09-04 11:58:04 +00:00
Miikka Heikkinen
fccc02de96 QmlDesigner: Allow starting free drag on initial selection press
Changed object selection to be done on press instead of click, and
the initial press now also starts free drag of the selected object
after a short distance moved to prevent accidental drags.

Change-Id: I61656661cd734d167ef9f8db42d986f0e97402a3
Fixes: QDS-2376
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
2020-07-03 11:35:49 +00:00
Miikka Heikkinen
29ceaade9c QmlDesigner: Restore the previously active 3D scene on scene creation
Store the last active scene in global 3D tool state and restore it
when a scene is created after puppet relaunch.

Change-Id: Ie2d69f6db6798ab383c66d38b2dea7eba13adc97
Fixes: QDS-2239
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-06-09 12:31:57 +00:00
Miikka Heikkinen
b2b590ae24 QmlDesigner: Restart overlay update timer on each request
If timer is not restarted on each request, the update can end up
happening before the next frame has been rendered. This can happen e.g.
at puppet startup, where the delay between first request and first
frame render can easily be more than 16ms.

Change-Id: Ib9555548e8c60799c585d0ab43d0626cfa31a494
Fixes: QDS-2082
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-06-09 12:14:35 +00:00
Miikka Heikkinen
b441988b58 QmlDesigner: Add fade control handle to point light gizmo
Also changed the point light mesh to just a single camera plane ring
based on discussions with UX.

Change-Id: If9e847440570bbe87483194c0b417cf09c7084a2
Fixes: QDS-2041
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-06-09 12:13:13 +00:00
Miikka Heikkinen
387657b83a QmlDesigner: Add missing camera plane ring to point light model
Task-number: QDS-2037
Change-Id: Ica5a7ec2983da251d2ab75565120423288de27a2
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-06-09 12:10:58 +00:00
Miikka Heikkinen
a3e6e24427 QmlDesigner: Update light gizmos
Directional light model was made constant size, as it doesn't have
actual physical presence.

Spot light cone now shows the cone angle correctly and the length of
the cone is calculated so that 5% of the brightness reaches the
center of the cone bottom.

Area light rectangle matches the area of the light.

Point light mesh changed to three perpendicular circles.
Same formula for size of the circles used as for spotlight length.

All light types share a common brightness indicator arrow.

Task-number: QDS-2037
Change-Id: I534dbcda9cfa2a7768c2537868ba83818979b250
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-06-09 12:09:41 +00:00
Tim Jenssen
53d161c98e Merge remote-tracking branch 'origin/qds-1.59'
Change-Id: I8a5d7d98b4d75379fe3953fe00bdb939d1722676
2020-04-28 16:18:24 +02:00
Miikka Heikkinen
d1a7afa28f QmlDesigner: Add "closeup" option to focusObjectToCamera function
The closeup option is used for itemlibrary thumbnail generation, where
the regular fit produces too small images on most imports.

Change-Id: I2901a2e20d100b155111f002b22489df945e9e01
Fixes: QDS-1899
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
2020-04-24 10:29:43 +00:00
Christian Kandeler
785b184fb6 QmlDesigner: Fix warnings about unused variables and functions
Change-Id: Ib907db11dcdcef9cbbb91c8fd7af22ae420796b1
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-04-23 13:49:04 +00:00
Miikka Heikkinen
e0751d56d0 QmlDesigner: Colorize light gizmos
Light gizmo icons and models are now colored based on the light color.
Image provider is used instead of simpler ColorOverlay component,
as ColorOverlay doesn't properly handle transparency when rendered
offscreen in puppet.

Change-Id: If6af915bca9bea2cb48ac23ac6c5ba46dc150e3b
Fixes: QDS-1733
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-03-31 07:39:16 +00:00
Miikka Heikkinen
6cf8d7d645 QmlDesigner: Create thumbnail for imported 3D assets
Qmlpuppet now allows creating icon from qml source code.

Invoke qmlpuppet with following arguments to create icons:
--rendericon <size> <icon file name> <icon qml source>

E.g. --rendericon 24 ~/my_icon.png ~/my_icon.qml

Two icons are created, one with size x size dimensions and
one with double the dimensions and "@2x" injected into the file name.

3D asset import utilizes this icon rendering to produce item library
icons for imported components.

Change-Id: I92c62c80d961f5f61a0ce1c09b32bbcbf80ea56c
Fixes: QDS-1052
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-03-30 07:59:03 +00:00
Miikka Heikkinen
0496318e9d QmlDesigner: Update selection box when target mesh changes
Change-Id: I45d54baa78e9f8547da65358d93c6d376f24ce3b
Fixes: QDS-1840
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-03-23 08:05:37 +00:00
Miikka Heikkinen
ff6dd4dc2e QmlDesigner: Fix selection issues in navigator and 3d edit view
Fixed multiple issues with showing correct selection in navigator and
3d edit view:
- Dragging items from item library selects only that item,
  regardless if drag was done to 3d edit view or navigator
- Selection is shown correctly after reparenting items, including
  multiselection reparenting
- Adding a new item to the active scene now shows selection box
  correctly for that item

Change-Id: I5156ca4c22e606c41e1e346ea5c32c3d70d89f5e
Fixes: QDS-1577
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-03-19 08:12:55 +00:00
Miikka Heikkinen
2c3f31bc93 QmlDesigner: Add a simple wireframe cone model for edit 3d spotlight
Change-Id: I013e4fc2d77b49694d887e8cadc05584a904ed62
Fixes: QDS-1819
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-03-16 13:37:49 +00:00
Miikka Heikkinen
83d590950b QmlDesigner: Edit 3D view icon update
Added icon for spot light gizmo and updated directional light icon.
Removed icons that are no longer needed on puppet side.

Change-Id: Id1e72c80e122250f7edc8a69a0e5720e755b96fc
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
2020-03-13 10:08:14 +00:00
Miikka Heikkinen
644493fa59 QmlDesigner: Delay camera frustum geometry update in edit 3D view
Calculating camera frustum geometry requires linked camera spatial
node to be up-to-date. However, we can't control the order in which
the spatial nodes of cameras and geometries are updated, so geometry
update will often happen first. Therefore we need to defer geometry
update to the next frame when we detect camera change.

Change-Id: I056eb1bf95db357a73511a6bb7ef0c55c6f4befa
Fixes: QDS-1649
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-03-12 13:37:53 +00:00
Miikka Heikkinen
2c842453b0 QmlDesigner: Add light meshes to edit 3d view
Change-Id: I996498fde14510fc78c729f56cb8d46b28b233bb
Fixes: QDS-1634
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
2020-03-12 09:06:48 +00:00
Miikka Heikkinen
efa11e690b QmlDesigner: Remove remaining separate edit 3D window code
Change-Id: I3d745b54ae3aa5c3c05c859239934125b9ca828d
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
2020-03-09 08:41:55 +00:00
Miikka Heikkinen
a77ef4ca7f QmlDesigner: Port Edit 3D View to 5.15
Qt 5.15.0 is now the minimum version to enable Edit 3D view.

Change-Id: I15cee59e6a7665477825caa0ae412fc6ac7b570a
Fixes: QDS-1694
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
2020-03-04 06:27:45 +00:00
Miikka Heikkinen
4908055937 Integrate Edit3D view into Creator
Edit3D view is now a tab alongside Form Editor.
Buttons were moved to a Creator side task bar on Edit 3D view.

Change-Id: Ia06107e4f855ba512ffea3e628a61558894e800e
Fixes: QDS-1570
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-02-24 12:18:53 +00:00
Miikka Heikkinen
1d71e6ac17 QmlDesigner: Store tool state on per-scene basis
Tool state of the scene is linked to qml id of the scene root, so that
tool states are preserved through delete and undo, which causes
generation of new internal ids for instances.

Tool state storage doesn't currently survive changing of scene root
qml id, as tracking that isn't trivial. It's not enough to simply track
id change commands because model repurposes existing nodes when major
graph changes occur, causing unexpected id changes e.g. when
delete/undo is done.

Change-Id: I74d11ce47e86ce5d29796399c4a91b65980b1597
Fixes: QDS-1536
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-02-11 12:13:24 +00:00
Mahmoud Badri
76bb4e4c08 QmlDesigner: Implement grid zooming
Grid zooms in and out according to camera zoom so that grid spacing is
neither too condense nor too sparse. Also changed the grid color to be
a bit darker and few other small tweaks.
PS: if the view camera is panned, the grid will not work correctly.
This is due to issues with the camera zoom calculations and is not part
of this commit.

Task-number: QDS-1566
Change-Id: Ib08d5387b028b8d870df9ecf88a5766eae5a509e
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-02-07 10:21:06 +00:00
Miikka Heikkinen
ec4e60e691 QmlDesigner: Fix build with Qt 5.14.1
A quick3d private API used was introduced in 5.14.2

Change-Id: I03e48fb79068e16a24b2c2a1e128d59efb6c8fad
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-02-06 12:51:58 +00:00
Miikka Heikkinen
07ada921dc QmlDesigner: Fix camera frustum visualization in 3d edit view
Now camera frustum visualization should always appear correctly in
3D edit view, as the QSSGRenderCamera node is created at frustum
geometry update time if it's missing. Active scene change
also triggers geometry update for camera gizmos.

Change-Id: If24e97490b2ff6607049b5288c6e167aa29a86b2
Fixes: QDS-1472
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-02-06 08:41:11 +00:00
Miikka Heikkinen
13c6e5df28 QmlDesigner: Support adding/removing/reparenting 3D scenes
3D edit view should now update correctly when 3D Nodes and View3D
items are added, removed, or reparented in the scene.

Deleting the active scene will change the active scene to another
existing scene.

Fixes: QDS-1591
Change-Id: Ib885453574e72f486a236264cc10d88cb872e9c7
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-02-04 13:22:53 +00:00
Miikka Heikkinen
3890bf4efb QmlDesigner: Add support for multiple views to 3D edit view
Any subtree of Nodes can be shown in 3D edit view.
Selecting any Node or their children, or View3D changes the
view in 3D edit view to the relevant scene.

Fixes: QDS-1494
Fixes: QDS-1565
Change-Id: I2d5a6f88bab2a20b74c347351235f79fb530519b
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-01-31 14:52:08 +00:00