Dynamic Water Physics 2
Search Results for

    Show / Hide Table of Contents

    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
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    WaterDataProvider
    RaycastWaterDataProvider
    Inherited Members
    WaterDataProvider._singleHeightArray
    WaterDataProvider._singlePointArray
    WaterDataProvider._triggerCollider
    WaterDataProvider.GetWaterFlows(WaterObject, ref Vector3[], ref Vector3[])
    WaterDataProvider.GetWaterHeightsFlowsNormals(WaterObject, ref Vector3[], ref float[], ref Vector3[], ref Vector3[], bool, bool, bool)
    WaterDataProvider.GetWaterHeightSingle(WaterObject, Vector3)
    WaterDataProvider.PointInWater(WaterObject, Vector3)
    WaterDataProvider.GetWaterHeight(WaterObject, Vector3)
    Namespace: NWH.DWP2.WaterData
    Assembly: NWH.DWP2.dll
    Syntax
    public class RaycastWaterDataProvider : WaterDataProvider

    Fields

    | Edit this page View Source

    _flow

    Declaration
    protected Vector3 _flow
    Field Value
    Type Description
    Vector3
    | Edit this page View Source

    _hit

    Declaration
    protected RaycastHit _hit
    Field Value
    Type Description
    RaycastHit
    | Edit this page View Source

    _layerMask

    Declaration
    protected LayerMask _layerMask
    Field Value
    Type Description
    LayerMask
    | Edit this page View Source

    _mesh

    Declaration
    protected Mesh _mesh
    Field Value
    Type Description
    Mesh
    | Edit this page View Source

    _normals

    Declaration
    protected Vector3[] _normals
    Field Value
    Type Description
    Vector3[]
    | Edit this page View Source

    _prevDataSize

    Declaration
    protected int _prevDataSize
    Field Value
    Type Description
    int
    | Edit this page View Source

    _queryParameters

    Declaration
    protected QueryParameters _queryParameters
    Field Value
    Type Description
    QueryParameters
    | Edit this page View Source

    _ray

    Declaration
    protected Ray _ray
    Field Value
    Type Description
    Ray
    | Edit this page View Source

    _rayDirection

    Declaration
    protected Vector3 _rayDirection
    Field Value
    Type Description
    Vector3
    | Edit this page View Source

    _rayStartOffset

    Declaration
    protected Vector3 _rayStartOffset
    Field Value
    Type Description
    Vector3
    | Edit this page View Source

    _raycastCommands

    Declaration
    protected NativeArray<RaycastCommand> _raycastCommands
    Field Value
    Type Description
    NativeArray<RaycastCommand>
    | Edit this page View Source

    _raycastHits

    Declaration
    protected NativeArray<RaycastHit> _raycastHits
    Field Value
    Type Description
    NativeArray<RaycastHit>
    | Edit this page View Source

    _raycastJobHandle

    Declaration
    protected JobHandle _raycastJobHandle
    Field Value
    Type Description
    JobHandle
    | Edit this page View Source

    _tmp

    Declaration
    protected Vector3 _tmp
    Field Value
    Type Description
    Vector3
    | Edit this page View Source

    _tmpCommand

    Declaration
    protected RaycastCommand _tmpCommand
    Field Value
    Type Description
    RaycastCommand
    | Edit this page View Source

    _upVector

    Declaration
    protected Vector3 _upVector
    Field Value
    Type Description
    Vector3
    | Edit this page View Source

    _uv4

    Declaration
    protected Vector2 _uv4
    Field Value
    Type Description
    Vector2
    | Edit this page View Source

    _vertDir

    Declaration
    protected Vector3 _vertDir
    Field Value
    Type Description
    Vector3
    | Edit this page View Source

    _vertIndex

    Declaration
    protected int _vertIndex
    Field Value
    Type Description
    int
    | Edit this page View Source

    _zeroVector

    Declaration
    protected Vector3 _zeroVector
    Field Value
    Type Description
    Vector3
    | 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
    Type Description
    int
    | 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
    Type Description
    int
    | 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
    Type Description
    float
    | 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
    Type Description
    int

    Methods

    | Edit this page View Source

    Awake()

    Declaration
    public override void Awake()
    Overrides
    WaterDataProvider.Awake()
    | 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
    WaterDataProvider.GetWaterHeights(WaterObject, ref Vector3[], ref float[])
    | 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
    WaterDataProvider.GetWaterNormals(WaterObject, ref Vector3[], ref Vector3[])
    | 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
    WaterDataProvider.SupportsWaterFlowQueries()
    | 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
    WaterDataProvider.SupportsWaterHeightQueries()
    | 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
    WaterDataProvider.SupportsWaterNormalQueries()
    • Edit this page
    • View Source
    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics