/// <summary> /// Provides ocean shape to CPU. /// </summary> public ICollProvider CreateCollisionProvider() { ICollProvider result = null; switch (_collisionSource) { case CollisionSources.None: result = new CollProviderNull(); break; case CollisionSources.GerstnerWavesCPU: result = FindObjectOfType <ShapeGerstnerBatched>(); break; case CollisionSources.ComputeShaderQueries: result = QueryDisplacements.Instance; break; } if (result == null) { // this should not be hit - return null to create null ref exceptions Debug.Assert(false, "Could not create collision provider. Collision source = " + _collisionSource.ToString()); return(null); } return(result); }
/// <summary> /// Provides ocean shape to CPU. /// </summary> public ICollProvider CreateCollisionProvider() { ICollProvider result = null; switch (_collisionSource) { case CollisionSources.None: result = new CollProviderNull(); break; case CollisionSources.GerstnerWavesCPU: result = FindObjectOfType <ShapeGerstnerBatched>(); break; case CollisionSources.ComputeShaderQueries: result = new QueryDisplacements(); break; } if (result == null) { // this should not be hit, but can be if compute shaders aren't loaded correctly. // they will print out appropriate errors, so we don't want to return just null and have null reference // exceptions spamming the logs. //Debug.LogError($"Could not create collision provider. Collision source = {_collisionSource.ToString()}", this); return(new CollProviderNull()); } return(result); }
/// <summary> /// Provides ocean shape to CPU. /// </summary> public ICollProvider CreateCollisionProvider() { ICollProvider result = null; switch (_collisionSource) { case CollisionSources.None: result = new CollProviderNull(); break; case CollisionSources.OceanDisplacementTexturesGPU: result = GPUReadbackDisps.Instance; break; case CollisionSources.GerstnerWavesCPU: result = FindObjectOfType <ShapeGerstnerBatched>(); break; } if (result == null) { return(null); } if (_cachedHeightQueries) { result = new CollProviderCache(result); } return(result); }
/// <summary> /// Provides ocean shape to CPU. /// </summary> public ICollProvider CreateCollisionProvider() { ICollProvider result = null; switch (_collisionSource) { case CollisionSources.None: result = new CollProviderNull(); break; case CollisionSources.OceanDisplacementTexturesGPU: result = GPUReadbackDisps.Instance; Debug.Assert(result != null, "Sampling collision too early, collision system has not been initialised."); break; case CollisionSources.GerstnerWavesCPU: result = FindObjectOfType <ShapeGerstnerBatched>(); break; case CollisionSources.ComputeShaderQueries: result = QueryDisplacements.Instance; break; } if (result == null && _collisionSource == CollisionSources.OceanDisplacementTexturesGPU) { // can happen if async readback not supported on device result = new CollProviderNull(); } if (result == null) { // this should not be hit - return null to create null ref exceptions Debug.Assert(false, "Could not create collision provider. Collision source = " + _collisionSource.ToString()); return(null); } if (_cachedHeightQueries) { result = new CollProviderCache(result); } return(result); }
/// <summary> /// Provides ocean shape to CPU. /// </summary> public ICollProvider CreateCollisionProvider() { ICollProvider result = null; switch (_collisionSource) { case CollisionSources.None: result = new CollProviderNull(); break; case CollisionSources.GerstnerWavesCPU: result = FindObjectOfType <ShapeGerstnerBatched>(); break; case CollisionSources.ComputeShaderQueries: if (!OceanRenderer.RunningWithoutGPU) { result = new QueryDisplacements(); } else { Debug.LogError("Crest: Compute shader queries not supported in headless/batch mode. To resolve, assign an Animated Wave Settings asset to the OceanRenderer component and set the Collision Source to be a CPU option."); } break; } if (result == null) { // this should not be hit, but can be if compute shaders aren't loaded correctly. // they will print out appropriate errors, so we don't want to return just null and have null reference // exceptions spamming the logs. //Debug.LogError($"Could not create collision provider. Collision source = {_collisionSource.ToString()}", this); return(new CollProviderNull()); } return(result); }