Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
        protected override void OnEnable()
        {
            Debug.Assert(Instance == null);
            Instance = this;

            base.OnEnable();
        }
Beispiel #3
0
        /// <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);
        }
Beispiel #4
0
 static void InitStatics()
 {
     // Init here from 2019.3 onwards
     Instance = null;
 }
Beispiel #5
0
        protected override void OnEnable()
        {
            Instance = this;

            base.OnEnable();
        }
Beispiel #6
0
        protected override void OnDisable()
        {
            Instance = null;

            base.OnDisable();
        }