RayCast QML Type
Import Statement: | import Bacon2D 1.0 |
Properties
- maxFraction : float
Signals
- fixtureReported(Fixture fixture, QPointF point1, QPointF point2, qreal fraction)
Detailed Description
You can use ray casts to do line-of-sight checks, fire guns, etc. You perform a ray cast by listening for the fixtureReported signal, then calling rayCast from the Scene providing the start and end points. The signal will be emitted with each fixture hit by the ray. Your callback is provided with the fixture, the point of intersection, the unit normal vector, and the fractional distance along the ray. You cannot make any assumptions about the order of the callbacks.
You control the continuation of the ray cast by returning a fraction. Returning a fraction of zero indicates the ray cast should be terminated. A fraction of one indicates the ray cast should continue as if no hit occurred. If you return the fraction from the argument list, the ray will be clipped to the current intersection point. So you can ray cast any shape, ray cast all shapes, or ray cast the closest shape by returning the appropriate fraction.
You may also return of fraction of -1 to filter the fixture. Then the ray cast will proceed as if the fixture does not exist.
Property Documentation
Signal Documentation
fixtureReported(Fixture fixture, QPointF point1, QPointF point2, qreal fraction) |