コード例 #1
0
        private void Update()
        {
            switch (_buoyancyType)
            {
            case BuoyancyType.NonPhysical:
            {
                var t   = transform;
                var vec = t.position;
                vec.y      = Heights[0].y + waterLevelOffset;
                t.position = vec;
                t.up       = Vector3.Slerp(t.up, _normals[0], Time.deltaTime);
                break;
            }

            case BuoyancyType.NonPhysicalVoxel:
                // do the voxel non-physical
                break;

            case BuoyancyType.Physical:
                LocalToWorldJob.CompleteJob(_guid);
                GetVelocityPoints();
                break;

            case BuoyancyType.PhysicalVoxel:
                LocalToWorldJob.CompleteJob(_guid);
                GetVelocityPoints();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            GerstnerWavesJobs.UpdateSamplePoints(ref _samplePoints, _guid);
            GerstnerWavesJobs.GetData(_guid, ref Heights, ref _normals);
        }
コード例 #2
0
        private void FixedUpdate()
        {
            var submergedAmount = 0f;

            switch (_buoyancyType)
            {
            case BuoyancyType.PhysicalVoxel:
            {
                LocalToWorldJob.CompleteJob(_guid);
                //Debug.Log("new pass: " + gameObject.name);
                Physics.autoSyncTransforms = false;

                for (var i = 0; i < _voxels.Length; i++)
                {
                    BuoyancyForce(_samplePoints[i], _velocity[i], Heights[i].y + waterLevelOffset, ref submergedAmount, ref _debugInfo[i]);
                }
                Physics.SyncTransforms();
                Physics.autoSyncTransforms = true;
                UpdateDrag(submergedAmount);
                break;
            }

            case BuoyancyType.Physical:
                //LocalToWorldJob.CompleteJob(_guid);
                BuoyancyForce(Vector3.zero, _velocity[0], Heights[0].y + waterLevelOffset, ref submergedAmount, ref _debugInfo[0]);
                //UpdateDrag(submergedAmount);
                break;

            case BuoyancyType.NonPhysical:
                break;

            case BuoyancyType.NonPhysicalVoxel:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }