User Tools


Water Object Manager

WaterObjectManager inspector.

WaterObjectManager is the main script of Dynamic Water Physics 2 and has to be present in the scene for water/object interaction to work. It does not matter to which object it is attached, it just needs to be present. WaterObjectManager fetches the data from all the WaterObjects in the scene, processes it and sends it to a job which then does all the physics calculations and makes use of multiple CPU cores.

Fields

  • Finish Jobs In Single Frame - if set to true jobs will be finished on the same frame they started. Disabling it will improve performance, but will also add a one-frame delay to water/object interaction. This is not significant in most cases. Default is off.
  • Fluid Density - density of the simulated fluid in kg/m3. Default is 1030 (salt water).
  • Velocity Dot Power - when set to one fluid will act as a Newtonian fluid (relationship between velocity and impact force is proportional). Values below 1 will result in pseudo-plastic liquid (relationship is logaritmic) and values above 1 will result in dilatant liquid (relationship is exponential). This is a simplified explanation. Value of 1 should be used for normal water, but slightly higher value can also be used.
  • Simulate Water Normals - if true water normals will be used when calculating forces. Has no effect if the water system does not use normals.
  • Simulate Water Flow - if true water flow will be used when calculating forces. Has no effect if the water system used does not support flow.
  • Calculate Buoyancy Forces - buoyancy will be calculated when this field is true.
  • Calculate Dynamic Forces - hydrodynamics will be approximated when this field is true. Disable to use only buoyancy.
  • Dynamic Force Coefficient - a coefficient by which the resultant force will be multiplied.
  • Dynamic Force Power - an exponent to the power of which the resultant force will raised.
  • Calculate Skin Drag - when true a drag will be calculated as a result of liquid passing over a surface.
  • Skin Friction Drag - can be set to 0 or near 0 for water while goo-like fluids will have a larger value.
  • Generate Gizmos - gizmos will be generated from simulation data when true.

Instantiating WaterObjects at runtime

When Water Object is added to the scene during play mode it will not be automatically registered because this requires re-allocating memory for the jobs which is quite expensive and should ideally be done during the loading screens.

There are two ways to add new objects to the scene during runtime:

  • When there is a low number of triangles instantiating the object and immediately calling WaterObjectManager.Instance.Synchronize() is the best solution.
  • Instantiating all the objects during scene load and deactivating them. WaterObjectManager will allocate memory for inactive objects too, but will not simulate them. When the object is needed it can simply be activated, without calling Synchronize().