Add Raycaster scene query type
PhysicsWorld can cast a ray on request, but a ray that must be checked
on every frame, such as a ground probe, a suspension ray or a line of
sight, needs the same code each time: a frameDone handler that maps the
ray into the scene, runs the query, keeps the result and notices when
the hit body changes. Raycaster is that code as a node. It follows its
own transform, is updated once per physics frame before frameDone, and
holds the closest hit as the locationHit the queries return, so
bindings can use it directly.
This complements TriggerBody rather than duplicating it: a trigger
reports the bodies inside a volume, while the ray reports the nearest
surface along a direction, with its position, normal and distance.
A ray mounted on a body skips that body and every body above it, and
excludedBodies names other bodies to skip. Both are filtered out inside
the query, so each ray costs a single blocking raycast per frame.
Static or dynamic bodies can be left out as a whole. Since a hit is now
kept across frames, the query hit stores its body and shape with
QPointer.
Add an example that shows a ray and its hit, and Design Studio support
for placing one. Rays are not cast in the Design Studio preview, which
has no bodies in its PhysX scene.
[ChangeLog][Raycaster] New type for continuous ray intersection
queries against physics bodies.
Change-Id: I1f4bcdcfd44403d102e06e048b49505729d830e1
Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io>
| commit | 778cba6e95c619f4925b33a63677b86a62239a7f |
| parent | beb9953e8b681bb16923fc14157c62c6b11b688e |
| author | Przemyslaw Nogaj <pno@spyro-soft.com> |
| committer | Przemyslaw Nogaj <pno@spyro-soft.com> |
| commit time | Fri, 2 Oct 2026 05:05:53 +0000 |
- M examples/quick3dphysics/CMakeLists.txt
- A examples/quick3dphysics/raycaster/CMakeLists.txt
- A examples/quick3dphysics/raycaster/Main.qml
- A examples/quick3dphysics/raycaster/doc/images/raycaster-example.webp
- A examples/quick3dphysics/raycaster/doc/src/qtquick3dphysics-examples-raycaster.qdoc
- A examples/quick3dphysics/raycaster/main.cpp
- M src/quick3dphysics/CMakeLists.txt
- M src/quick3dphysics/designer/CMakeLists.txt
- A src/quick3dphysics/designer/RaycasterSection.qml
- A src/quick3dphysics/designer/RaycasterSpecifics.qml
- M src/quick3dphysics/designer/images/CMakeLists.txt
- A src/quick3dphysics/designer/images/raycaster.png
- A src/quick3dphysics/designer/images/raycaster16.png
- A src/quick3dphysics/designer/images/raycaster@2x.png
- M src/quick3dphysics/designer/physics.metainfo
- M src/quick3dphysics/doc/src/qtquick3dphysics-index.qdoc
- M src/quick3dphysics/doc/src/qtquick3dphysics-queries.qdoc
- M src/quick3dphysics/qphysicsworld.cpp
- M src/quick3dphysics/qphysicsworld_p.h
- A src/quick3dphysics/qraycaster.cpp
- A src/quick3dphysics/qraycaster_p.h
- M src/quick3dphysics/queries/qquick3dphysicsqueryhit.cpp
- M src/quick3dphysics/queries/qquick3dphysicsqueryhit_p.h
- M tests/auto/CMakeLists.txt
- A tests/auto/raycaster/CMakeLists.txt
- A tests/auto/raycaster/tst_raycaster.cpp
- A tests/auto/raycaster/tst_raycaster.qml
- A tests/auto/raycaster/tst_raycaster_deleted_body.qml