lvjincheng 3 ani în urmă
părinte
comite
f7b7104fa4

+ 13 - 3
Assets/BowArrow/Scripts/Bluetooth/AimHandler.cs

@@ -29,8 +29,6 @@ public class AimHandler : MonoBehaviour
     //陀螺仪校准进度记录
     [NonSerialized] public int gyrCalibrateCompleteCount = 0;
     [NonSerialized] public int gyrCalibrateTotalCount = 2000;
-    //时差记录(新版算法不需要)
-    [NonSerialized] public long msOld = 0;
 
     public static AimHandler ins; 
 
@@ -41,8 +39,14 @@ public class AimHandler : MonoBehaviour
 
         m_axisHandler = new Axis9NopackHandler(this);
         m_axisHandler.Init();
+        //  StartCoroutine(TestRecord());
     }
 
+    // System.Collections.IEnumerator TestRecord() {
+    //     while (LoginMgr.myUserInfo.id == 0) yield return null;
+    //     UserComp.Instance.saveMac();
+    // }
+
     [NonSerialized] public Quaternion newRotation = Quaternion.identity;
     [NonSerialized] public bool lerpForRotation = true;
     [NonSerialized] public float lerpTimeRate = 7;
@@ -115,11 +119,17 @@ public class AimHandler : MonoBehaviour
         m_ban9AxisCalculate = ban;
         if (!ban) 
         {
-            msOld = default;
+            SetMsOldDefault();
             if (m_controlObj) m_controlObj.localRotation = newRotation;
         }
     }
 
+    public void SetMsOldDefault()
+    {
+        if (m_axisHandler.GetType() == typeof(Axis9NopackHandler))
+            (m_axisHandler as Axis9NopackHandler).msOld = default;
+    }
+
     public void DoIdentity()
     {
         m_axisHandler.DoIdentity();

+ 1 - 1
Assets/BowArrow/Scripts/Bluetooth/BluetoothAim.cs

@@ -108,7 +108,7 @@ public class BluetoothAim : MonoBehaviour
         SetStatus(BluetoothStatusEnum.ConnectFail);
         BowCamera.isTouchMode = true;
         DestroyWhenDisconenct();
-        if (AimHandler.ins) AimHandler.ins.msOld = default;
+        if (AimHandler.ins) AimHandler.ins.SetMsOldDefault();
     }
 
     void Update()

+ 5 - 4
Assets/BowArrow/Scripts/Bluetooth/New/Axis9NopackHandler.cs

@@ -19,6 +19,7 @@ public class Axis9NopackHandler : AxisBaseHandler
         InitMag(null);
     }
 
+    public long msOld = 0;
     long TimeGap = default;
     Vector3 Acc = default;
     Vector3 Gyr = default;
@@ -86,13 +87,13 @@ public class Axis9NopackHandler : AxisBaseHandler
         Mag = o0VectorToUnity(mag0o);
 
         var ms = (((long)bytes[1]) *60 + bytes[2])*1000 + (long)TwoByteToFloat(bytes[3], bytes[4]);
-        if(m_aimHandler.msOld == default)
+        if(msOld == default)
         {
-            m_aimHandler.msOld = ms;
+            msOld = ms;
             return;
         }
-        TimeGap = ms - m_aimHandler.msOld;
-        m_aimHandler.msOld = ms;
+        TimeGap = ms - msOld;
+        msOld = ms;
 
         GapMs = TimeGap;
         gyr0o = UnityVectorTo0o(Gyr);