瀏覽代碼

correcting reduction source

Marcel Zickler 3 年之前
父節點
當前提交
0ace1f2b03

+ 2 - 2
Assets/Materials/Vignette.mat

@@ -58,10 +58,10 @@ Material:
     - _GlossMapScale: 0
     - _Glossiness: 0
     - _GlossyReflections: 0
-    - _IFOV: 0.9480438
+    - _IFOV: 0.94655627
     - _InnerRadius: 0.15
     - _Metallic: 0
-    - _OFOV: 0.99804384
+    - _OFOV: 0.9965563
     - _OcclusionStrength: 1
     - _QueueOffset: 0
     - _ReceiveShadows: 1

+ 3 - 4
Assets/Scripts/SicknessReduction/DynamicReductionSource.cs

@@ -29,12 +29,9 @@ namespace SicknessReduction
         private ValueBasedRestrictionSuggestor speedSuggestor;
         
         protected float currentValue;
-        protected float change;
 
         public float CurrentValue => currentValue;
 
-        public float Change => change;
-
         protected virtual void Start()
         {
             if (reductionSource == ReductionValueSource.AngularVelocity)
@@ -91,7 +88,9 @@ namespace SicknessReduction
 
             var desiredChange = desiredValue - currentValue;
             var maxChange = Time.deltaTime * maxValueChangePerSecond;
-            change = Mathf.Sign(desiredChange) * Mathf.Min(Mathf.Abs(desiredChange), maxChange);
+            var change = Mathf.Sign(desiredChange) * Mathf.Min(Mathf.Abs(desiredChange), maxChange);
+            
+            currentValue = Mathf.Clamp(currentValue + change, 0, 1);
         }
     }
 }

+ 4 - 4
Assets/Scripts/SicknessReduction/Haptic/VibrationController.cs

@@ -40,18 +40,18 @@ namespace SicknessReduction.Haptic
             base.Update();
 
             // > 0 while cornering
-            var correctedReductionValue = Mathf.Clamp(reductionSource.CurrentValue + reductionSource.Change, 0, 1);
+            var reductionValue = reductionSource.CurrentValue; 
 
             if (!DoUpdate || PreviousUpdateActive) return;
-            if (correctedReductionValue > 0)
+            if (reductionValue > 0)
             {
                 switch (mode)
                 {
                     case VibrationControllerMode.Continuous:
-                        await VibrateContinuous((int) (correctedReductionValue * cycle));
+                        await VibrateContinuous((int) (reductionValue * cycle));
                         break;
                     case VibrationControllerMode.AlternatingFixed:
-                        await VibrateAlternatingFixed((int) (correctedReductionValue * cycle));
+                        await VibrateAlternatingFixed((int) (reductionValue * cycle));
                         break;
                     case VibrationControllerMode.AlternatingCadenceBased:
                         await VibrateAlternatingCadenceBased();

+ 9 - 10
Assets/Scripts/SicknessReduction/Visual/Vignetting/DynamicVignetting.cs

@@ -43,22 +43,21 @@ namespace SicknessReduction.Visual.Vignetting
             if (!blitFeatureAvailable) return;
             base.Update();
 
-            var correctedRestriction = Mathf.Clamp(currentValue + change, 0, 1);
-
-            if (correctedRestriction > 0f)
+            if (currentValue > 0)
             {
                 blitFeature.SetActive(true);
-                UpdateMaterial(correctedRestriction);
-                return;
+                UpdateMaterial();
             }
-
-            blitFeature.SetActive(false);
+            else
+            {
+                blitFeature.SetActive(false);
+            }
+            
         }
 
-        private void UpdateMaterial(float restriction)
+        private void UpdateMaterial()
         {
-            currentValue = restriction;
-            var r = Mathf.Clamp(1 - restriction, 0, 1);
+            var r = Mathf.Clamp(1 - currentValue, 0, 1);
             blitFeatureMaterial.SetFloat("_OFOV", r);
             blitFeatureMaterial.SetFloat("_IFOV", Mathf.Clamp(r - distInnerOuterRadius, 0, 1));
         }