Class TRayCollision
Unit
Declaration
type TRayCollision = class(specialize TStructList<TRayCollisionNode>)
Description
Represents a ray collision with TCastleTransform (TCastleTransform that may have parents).
We advise to access the useful information using only the Transform or Info methods or read Distance field.
Everything else is somewhat internal information and things get complicated if you try to make sense of it. It's a TODO: to maybe deprecate this structure in favor of something simpler.
The full description is that this is a list, from the innermost TCastleTransform that was hit by the ray, to the root of the TCastleTransform tree. The First
item is the collision information with the final TCastleTransform. The rest of items are parent, grandparent etc. of this TCastleTransform object (so it is a path within TCastleViewport.Items hierarchy tree).
But be aware that CGE uses some internal TCastleTransform instances. E.g. TCastleBox, TCastleTiledMap have internal TCastleScene instances. These internal components are marked with csTransient flag in ComponentState.
We, again, advise to not iterate over this list or access e.g. first item directly. Use only Transform or Info methods or read Distance field! Things are simple then.
This is never an empty list when returned by RayCollision.
Hierarchy
- TObject
- TList
- TStructList
- TRayCollision
Overview
Fields
Distance: Single; |
Methods
function IndexOfItem(const Item: TCastleTransform): Integer; overload; |
|
function IndexOfItem(const ItemClass: TCastleTransformClass): Integer; overload; |
|
function Transform: TCastleTransform; |
|
function Info(out HitInfo: TRayCollisionNode): Boolean; |
Description
Fields
Distance: Single; |
|
Distance, in world coordinate system, from the current camera to the picked point. The suggested usage is to decide if player is close enough to reach the 3D object — for example, you may not want to allow player to open a door by clicking on it from a far distance. If the ray hit empty space, the distance is MaxSingle. Such case may occur because, once TCastleTransform handles TCastleTransform.PointingDevicePress, we make sure to inform it about PointingDeviceMove and PointingDeviceRelease, regardless if ray still hits this TCastleTransform instance. |
Methods
function IndexOfItem(const Item: TCastleTransform): Integer; overload; |
|
Index of node with given Item, -1 if none. |
function IndexOfItem(const ItemClass: TCastleTransformClass): Integer; overload; |
|
Index of node with given ItemClass, -1 if none. |
function Transform: TCastleTransform; |
|
TCastleTransform that was hit by given ray. To be precise, this returns the inner-most TCastleTransform in the TCastleTransform tree, except it doesn't return internal TCastleTransform (that has csTransient flag is ComponentState). This way it doesn't return internal components, like internal TCastleScene inside TCastleBox or TCastleTiledMap. Returns |
function Info(out HitInfo: TRayCollisionNode): Boolean; |
|
Returns information about what was hit by given ray. To be precise, this returns the first TRayCollisionNode on the list except it doesn't return TRayCollisionNode that relates to internal TCastleTransform (that has csTransient flag is ComponentState). This way it doesn't return internal components, like internal TCastleScene inside TCastleBox or TCastleTiledMap. Returns |
Generated by PasDoc 0.16.0-snapshot.