Class RaycastWaterDataProvider
Water data provider that uses raycasting to detect water surface.
Works with any water system that has a collider.
Supports water height and normal queries through raycasting.
Uses Unity's job system for parallel raycasts.
Inheritance
RaycastWaterDataProvider
Assembly: NWH.DWP2.dll
Syntax
public class RaycastWaterDataProvider : WaterDataProvider
Fields
|
Edit this page
View Source
_flow
Declaration
Field Value
|
Edit this page
View Source
_hit
Declaration
protected RaycastHit _hit
Field Value
|
Edit this page
View Source
_layerMask
Declaration
protected LayerMask _layerMask
Field Value
|
Edit this page
View Source
_mesh
Declaration
Field Value
|
Edit this page
View Source
_normals
Declaration
protected Vector3[] _normals
Field Value
|
Edit this page
View Source
_prevDataSize
Declaration
protected int _prevDataSize
Field Value
|
Edit this page
View Source
_queryParameters
Declaration
protected QueryParameters _queryParameters
Field Value
|
Edit this page
View Source
_ray
Declaration
Field Value
|
Edit this page
View Source
_rayDirection
Declaration
protected Vector3 _rayDirection
Field Value
|
Edit this page
View Source
_rayStartOffset
Declaration
protected Vector3 _rayStartOffset
Field Value
|
Edit this page
View Source
_raycastCommands
Declaration
protected NativeArray<RaycastCommand> _raycastCommands
Field Value
|
Edit this page
View Source
_raycastHits
Declaration
protected NativeArray<RaycastHit> _raycastHits
Field Value
|
Edit this page
View Source
_raycastJobHandle
Declaration
protected JobHandle _raycastJobHandle
Field Value
|
Edit this page
View Source
_tmp
Declaration
Field Value
|
Edit this page
View Source
_tmpCommand
Declaration
protected RaycastCommand _tmpCommand
Field Value
|
Edit this page
View Source
_upVector
Declaration
protected Vector3 _upVector
Field Value
|
Edit this page
View Source
_uv4
Declaration
Field Value
|
Edit this page
View Source
_vertDir
Declaration
protected Vector3 _vertDir
Field Value
|
Edit this page
View Source
_vertIndex
Declaration
Field Value
|
Edit this page
View Source
_zeroVector
Declaration
protected Vector3 _zeroVector
Field Value
|
Edit this page
View Source
commandsPerJob
Number of raycast commands to process per job batch.
Higher values may improve performance on systems with more CPU cores.
Declaration
[Tooltip("Minimum number of RaycastCommands per job.")]
public int commandsPerJob
Field Value
|
Edit this page
View Source
objectLayer
Layer that floating objects are on.
Used to prevent physics collisions between water and objects.
Declaration
[Tooltip(" Layer the water object(s) are on. Required to be able to disable physics collisions between water and object.")]
public int objectLayer
Field Value
|
Edit this page
View Source
raycastDistance
Maximum distance raycasts can travel in each direction.
Raycasts extend this distance above and below each point.
Lower values improve performance but may miss water surfaces that are far from the object.
Declaration
[Tooltip(" Raycasts will start at this distance above the point and extend this distance below the point. This means\r\n that if the water surface is raycastDistance below or above the point, it will not be detected.\r\n Using lower value will slightly improve performance of Raycasts.")]
public float raycastDistance
Field Value
|
Edit this page
View Source
waterLayer
Layer that water surface colliders are on.
Used to filter raycasts and prevent physics collisions.
Declaration
[Tooltip(" Layer the water is on. Required to be able to disable physics collisions between water and object.")]
public int waterLayer
Field Value
Methods
|
Edit this page
View Source
Awake()
Declaration
public override void Awake()
Overrides
|
Edit this page
View Source
Deallocate()
Deallocates native arrays used for raycasting.
Called automatically on disable or destroy.
Declaration
public virtual void Deallocate()
|
Edit this page
View Source
GetWaterHeights(WaterObject, ref Vector3[], ref float[])
Returns water height at each given point.
Override this method to provide water height data from your water system.
Declaration
public override void GetWaterHeights(WaterObject waterObject, ref Vector3[] points, ref float[] waterHeights)
Parameters
| Type |
Name |
Description |
| WaterObject |
waterObject |
WaterObject requesting the data.
|
| Vector3[] |
points |
Position array in world coordinates.
|
| float[] |
waterHeights |
Water height array in world coordinates. Corresponds to positions.
|
Overrides
|
Edit this page
View Source
GetWaterNormals(WaterObject, ref Vector3[], ref Vector3[])
Returns water surface normals at each given point.
Override this method to provide water normal data from your water system.
Declaration
public override void GetWaterNormals(WaterObject waterObject, ref Vector3[] points, ref Vector3[] waterNormals)
Parameters
| Type |
Name |
Description |
| WaterObject |
waterObject |
WaterObject requesting the data.
|
| Vector3[] |
points |
Position array in world coordinates.
|
| Vector3[] |
waterNormals |
Water surface normal array in world coordinates. Corresponds to positions.
|
Overrides
|
Edit this page
View Source
OnDestroy()
Declaration
public virtual void OnDestroy()
|
Edit this page
View Source
OnDisable()
Declaration
public virtual void OnDisable()
|
Edit this page
View Source
SupportsWaterFlowQueries()
Does this water system support water velocity queries?
Declaration
public override bool SupportsWaterFlowQueries()
Returns
| Type |
Description |
| bool |
True if it does, false if it does not.
|
Overrides
|
Edit this page
View Source
SupportsWaterHeightQueries()
Does this water system support water height queries?
Declaration
public override bool SupportsWaterHeightQueries()
Returns
| Type |
Description |
| bool |
True if it does, false if it does not.
|
Overrides
|
Edit this page
View Source
SupportsWaterNormalQueries()
Does this water system support water normal queries?
Declaration
public override bool SupportsWaterNormalQueries()
Returns
| Type |
Description |
| bool |
True if it does, false if it does not.
|
Overrides