- Qt 6.11
- Qt 3D
- C++ Classes
- Qt3DRender (Deprecated)
- QRayCasterHit
- Qt 6.11.2 Reference Documentation

# Qt3DRender::QRayCasterHit Class

class Qt3DRender::QRayCasterHit

Details of a hit when casting a ray through a model. More...

Header: | `#include <QRayCasterHit>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS 3drender)` `target_link_libraries(mytarget PRIVATE Qt6::3drender)`
qmake: | `QT += 3drender`
Status: | Deprecated

- List of all members, including inherited members

## Public Types

enum | HitType { TriangleHit, LineHit, PointHit, EntityHit }

## Properties

distance : const float entity : Qt3DCore::QEntity* const entityId : const Qt3DCore::QNodeId localIntersection : const QVector3D primitiveIndex : const uint | type : const QRayCasterHit::HitType vertex1Index : const uint vertex2Index : const uint vertex3Index : const uint worldIntersection : const QVector3D

## Public Functions

float | distance() const
Qt3DCore::QEntity * | entity() const
Qt3DCore::QNodeId | entityId() const
QVector3D | localIntersection() const
uint | primitiveIndex() const
Qt3DRender::QRayCasterHit::HitType | type() const
uint | vertex1Index() const
uint | vertex2Index() const
uint | vertex3Index() const
QVector3D | worldIntersection() const

## Detailed Description

Qt3DRender::QRayCasterHit contains the details of a successful hit when casting a ray through a model using a Qt3DRender::QRayCaster or Qt3DRender::QScreenRayCaster component.

See also Qt3DRender::QRayCaster, Qt3DRender::QScreenRayCaster, and Qt3DRender::QPickingSettings.

## Member Type Documentation

### enum QRayCasterHit::HitType

Specifies type of hit that was returned. This is controlled using QPickingSettings.

Constant | Value | Description
--- | --- | ---
`Qt3DRender::QRayCasterHit::TriangleHit` | `0` | The picked primitive was a triangle and the vertex indices refer to the three points making up the triangle
`Qt3DRender::QRayCasterHit::LineHit` | `1` | The picked primitive was a line segment, and the first two vertices refer to the two points making up the line
`Qt3DRender::QRayCasterHit::PointHit` | `2` | The picked primitive was a single point; all 3 vertex indices will be undefined
`Qt3DRender::QRayCasterHit::EntityHit` | `3` | Only the bounding volume was considered; the primitive and vertex indices will be undefined

## Property Documentation

### `[read-only]` distance : const float

This property holds the distance between the origin of the ray and the intersection point.

Holds the distance from the ray origin to the point where the ray intersected with the entity.

Access functions:

float | distance() const

### `[read-only]` entity : Qt3DCore::QEntity* const

This property holds a pointer to the entity that was hit.

Holds a pointer to the QEntity that was hit by the ray.

Access functions:

Qt3DCore::QEntity * | entity() const

### `[read-only]` entityId : const Qt3DCore::QNodeId

This property holds the id of the entity that was hit.

Holds the node id of the entity that was hit by the ray.

Access functions:

Qt3DCore::QNodeId | entityId() const

### `[read-only]` localIntersection : const QVector3D

This property holds the coordinates of the intersection point in the entity's coordinate system.

Holds the coordinates of the intersection point in the entity's local coordinate system.

Access functions:

QVector3D | localIntersection() const

### `[read-only]` primitiveIndex : const uint

This property holds the index of the picked primitive.

Holds the index of the primitive (triangle, line, or point) that was picked.

Access functions:

uint | primitiveIndex() const

### `[read-only]` type : const QRayCasterHit::HitType

This property holds the type of the hit.

Holds the type of the hit, which can be TriangleHit, LineHit, PointHit, or EntityHit.

Access functions:

Qt3DRender::QRayCasterHit::HitType | type() const

### `[read-only]` vertex1Index : const uint

This property holds the index of the first vertex of the picked primitive.

Holds the index of the first vertex of the picked primitive. For a triangle hit, this is one of the three vertices. For a line hit, this is one of the two vertices.

Access functions:

uint | vertex1Index() const

### `[read-only]` vertex2Index : const uint

This property holds the index of the second vertex of the picked primitive.

Holds the index of the second vertex of the picked primitive. For a triangle hit, this is one of the three vertices. For a line hit, this is one of the two vertices.

Access functions:

uint | vertex2Index() const

### `[read-only]` vertex3Index : const uint

This property holds the index of the third vertex of the picked primitive.

Holds the index of the third vertex of the picked primitive. This is only valid for triangle hits.

Access functions:

uint | vertex3Index() const

### `[read-only]` worldIntersection : const QVector3D

This property holds the coordinates of the intersection point in the model's coordinate system.

Holds the coordinates of the intersection point in the world coordinate system.

Access functions:

QVector3D | worldIntersection() const

## Member Function Documentation

### float QRayCasterHit::distance() const

Returns the distance between the origin of the ray and the intersection point

Note: Getter function for property distance.

### Qt3DCore::QEntity *QRayCasterHit::entity() const

Returns a pointer to the entity that was hit

Note: Getter function for property entity.

### Qt3DCore::QNodeId QRayCasterHit::entityId() const

Returns the id of the entity that was hit

Note: Getter function for property entityId.

### QVector3D QRayCasterHit::localIntersection() const

Returns the coordinates of the intersection point in the entity's coordinate system

Note: Getter function for property localIntersection.

### uint QRayCasterHit::primitiveIndex() const

Returns the index of the picked primitive

Note: Getter function for property primitiveIndex.

### Qt3DRender::QRayCasterHit::HitType QRayCasterHit::type() const

Returns the type of the hit

Note: Getter function for property type.

### uint QRayCasterHit::vertex1Index() const

Returns the index of the first vertex of the picked primitive

Note: Getter function for property vertex1Index.

### uint QRayCasterHit::vertex2Index() const

Returns the index of the second vertex of the picked primitive

Note: Getter function for property vertex2Index.

### uint QRayCasterHit::vertex3Index() const

Returns the index of the third vertex of the picked primitive

Note: Getter function for property vertex3Index.

### QVector3D QRayCasterHit::worldIntersection() const

Returns the coordinates of the intersection point in the model's coordinate system

Note: Getter function for property worldIntersection.