|
@@ -56,6 +56,7 @@ public class Axis9Handler : AxisBaseHandler
|
|
|
|
|
|
|
|
public override void DoIdentity()
|
|
public override void DoIdentity()
|
|
|
{
|
|
{
|
|
|
|
|
+ if (_9Axis.States.Count == 0) return; //没数据时触发视角归位会产生NAN,从而导致算法崩坏
|
|
|
SetIdentityAndSave();
|
|
SetIdentityAndSave();
|
|
|
m_aimHandler.SetNewRotation(_9Axis.getLastState().Qua);
|
|
m_aimHandler.SetNewRotation(_9Axis.getLastState().Qua);
|
|
|
}
|
|
}
|
|
@@ -188,12 +189,24 @@ public class Axis9Handler : AxisBaseHandler
|
|
|
string accStr = PlayerPrefs.GetString("AccIdentity0", "");
|
|
string accStr = PlayerPrefs.GetString("AccIdentity0", "");
|
|
|
if (accStr.Length > 0) {
|
|
if (accStr.Length > 0) {
|
|
|
double[] arr = JsonConvert.DeserializeObject<double[]>(accStr);
|
|
double[] arr = JsonConvert.DeserializeObject<double[]>(accStr);
|
|
|
- o0.Bow.o09AxisAfterXiaMenFromDll.AccIdentity = new o0.Geometry.Vector<double>(arr);
|
|
|
|
|
|
|
+ var v = new o0.Geometry.Vector<double>(arr);
|
|
|
|
|
+ if (!double.IsNaN(v.x) && !double.IsInfinity(v.x)
|
|
|
|
|
+ && !double.IsNaN(v.y) && !double.IsInfinity(v.y)
|
|
|
|
|
+ && !double.IsNaN(v.z) && !double.IsInfinity(v.z)
|
|
|
|
|
+ ) {
|
|
|
|
|
+ o0.Bow.o09AxisAfterXiaMenFromDll.AccIdentity = v;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
string magStr = PlayerPrefs.GetString("MagIdentity0", "");
|
|
string magStr = PlayerPrefs.GetString("MagIdentity0", "");
|
|
|
if (magStr.Length > 0) {
|
|
if (magStr.Length > 0) {
|
|
|
double[] arr = JsonConvert.DeserializeObject<double[]>(magStr);
|
|
double[] arr = JsonConvert.DeserializeObject<double[]>(magStr);
|
|
|
- o0.Bow.o09AxisAfterXiaMenFromDll.MagIdentity = new o0.Geometry.Vector<double>(arr);
|
|
|
|
|
|
|
+ var v = new o0.Geometry.Vector<double>(arr);
|
|
|
|
|
+ if (!double.IsNaN(v.x) && !double.IsInfinity(v.x)
|
|
|
|
|
+ && !double.IsNaN(v.y) && !double.IsInfinity(v.y)
|
|
|
|
|
+ && !double.IsNaN(v.z) && !double.IsInfinity(v.z)
|
|
|
|
|
+ ) {
|
|
|
|
|
+ o0.Bow.o09AxisAfterXiaMenFromDll.MagIdentity = v;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
} catch (System.Exception e) {
|
|
} catch (System.Exception e) {
|
|
|
Debug.LogError(e.Message);
|
|
Debug.LogError(e.Message);
|