提交 cb1d1144 编写于 作者: T tanghai

重构了下寻路,客户端使用Unity本身的数学库,服务端使用ET实现的一套Unity兼容的数学库,这样以后更方便移植Unity的插件,性能更好

以后可以不断扩展这套数学库
上级 c69a8a49
using ETModel;
using PF;
using UnityEngine;
namespace ETHotfix
{
......
using System;
using ETModel;
using PF;
using UnityEngine;
namespace ETHotfix
{
......
......@@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Threading;
using ETModel;
using PF;
using UnityEngine;
namespace ETHotfix
{
......
using System;
namespace PF
namespace UnityEngine
{
public static class Mathf
{
......
......@@ -3,7 +3,7 @@
// Licensed under the MIT license
//**************************************************
namespace PF
namespace UnityEngine
{
public struct Matrix3x3
{
......
using System;
using System.Globalization;
namespace PF
namespace UnityEngine
{
[Serializable]
public struct Matrix4x4: IEquatable<Matrix4x4>
......@@ -32,24 +32,6 @@ namespace PF
this.m12 == 0.0f && this.m13 == 0.0f && this.m13 == 0.0f && this.m21 == 0.0f && this.m23 == 0.0f && this.m23 == 0.0f && this.m31 == 0.0f && this.m32 == 0.0f && this.m33 == 0.0f;
}
}
#if !SERVER
public static implicit operator UnityEngine.Matrix4x4(PF.Matrix4x4 m)
{
return new UnityEngine.Matrix4x4(
new UnityEngine.Vector4(m.m00, m.m01, m.m02, m.m03),
new UnityEngine.Vector4(m.m10, m.m11, m.m12, m.m13),
new UnityEngine.Vector4(m.m20, m.m21, m.m22, m.m23),
new UnityEngine.Vector4(m.m30, m.m31, m.m32, m.m33));
}
public static implicit operator Matrix4x4(UnityEngine.Matrix4x4 m)
{
return new Matrix4x4(m.m00, m.m01, m.m02, m.m03,
m.m10, m.m11, m.m12, m.m13,
m.m20, m.m21, m.m22, m.m23,
m.m30, m.m31, m.m32, m.m33);
}
#endif
public Vector3 up
{
......
using System;
using System.Globalization;
namespace PF
namespace UnityEngine
{
[Serializable]
public struct Quaternion: IEquatable<Quaternion>
......
using System;
using System.Globalization;
namespace PF
namespace UnityEngine
{
[Serializable]
public struct Vector2: IEquatable<Vector2>
......@@ -11,17 +11,6 @@ namespace PF
public float x;
public float y;
#if !SERVER
public static implicit operator UnityEngine.Vector2(Vector2 v2)
{
return new UnityEngine.Vector3(v2.x, v2.y);
}
public static implicit operator Vector2(UnityEngine.Vector2 v2)
{
return new Vector2(v2.x, v2.y);
}
#endif
public static implicit operator Vector2(Vector3 v)
{
......@@ -70,11 +59,11 @@ namespace PF
public override string ToString()
{
CultureInfo currentCulture = CultureInfo.CurrentCulture;
return string.Format((IFormatProvider) currentCulture, "{0}, {1}",
return string.Format(currentCulture, "{0}, {1}",
new object[2]
{
(object) this.x.ToString((IFormatProvider) currentCulture),
(object) this.y.ToString((IFormatProvider) currentCulture)
this.x.ToString(currentCulture),
this.y.ToString(currentCulture)
});
}
......@@ -98,12 +87,12 @@ namespace PF
public float Length()
{
return (float) Math.Sqrt((double) this.x * (double) this.x + (double) this.y * (double) this.y);
return (float) Math.Sqrt(this.x * (double) this.x + this.y * (double) this.y);
}
public float LengthSquared()
{
return (float) ((double) this.x * (double) this.x + (double) this.y * (double) this.y);
return (float) (this.x * (double) this.x + this.y * (double) this.y);
}
public float magnitude
......@@ -126,47 +115,47 @@ namespace PF
{
float num1 = value1.x - value2.x;
float num2 = value1.y - value2.y;
return (float) Math.Sqrt((double) num1 * (double) num1 + (double) num2 * (double) num2);
return (float) Math.Sqrt(num1 * (double) num1 + num2 * (double) num2);
}
public static void Distance(ref Vector2 value1, ref Vector2 value2, out float result)
{
float num1 = value1.x - value2.x;
float num2 = value1.y - value2.y;
float num3 = (float) ((double) num1 * (double) num1 + (double) num2 * (double) num2);
result = (float) Math.Sqrt((double) num3);
float num3 = (float) (num1 * (double) num1 + num2 * (double) num2);
result = (float) Math.Sqrt(num3);
}
public static float DistanceSquared(Vector2 value1, Vector2 value2)
{
float num1 = value1.x - value2.x;
float num2 = value1.y - value2.y;
return (float) ((double) num1 * (double) num1 + (double) num2 * (double) num2);
return (float) (num1 * (double) num1 + num2 * (double) num2);
}
public static void DistanceSquared(ref Vector2 value1, ref Vector2 value2, out float result)
{
float num1 = value1.x - value2.x;
float num2 = value1.y - value2.y;
result = (float) ((double) num1 * (double) num1 + (double) num2 * (double) num2);
result = (float) (num1 * (double) num1 + num2 * (double) num2);
}
public void Normalize()
{
float num1 = (float) ((double) this.x * (double) this.x + (double) this.y * (double) this.y);
if ((double) num1 < 9.99999974737875E-06)
float num1 = (float) (this.x * (double) this.x + this.y * (double) this.y);
if (num1 < 9.99999974737875E-06)
return;
float num2 = 1f / (float) Math.Sqrt((double) num1);
float num2 = 1f / (float) Math.Sqrt(num1);
this.x *= num2;
this.y *= num2;
}
public static Vector2 Normalize(Vector2 value)
{
float num1 = (float) ((double) value.x * (double) value.x + (double) value.y * (double) value.y);
if ((double) num1 < 9.99999974737875E-06)
float num1 = (float) (value.x * (double) value.x + value.y * (double) value.y);
if (num1 < 9.99999974737875E-06)
return value;
float num2 = 1f / (float) Math.Sqrt((double) num1);
float num2 = 1f / (float) Math.Sqrt(num1);
Vector2 vector2;
vector2.x = value.x * num2;
vector2.y = value.y * num2;
......@@ -175,14 +164,14 @@ namespace PF
public static void Normalize(ref Vector2 value, out Vector2 result)
{
float num1 = (float) ((double) value.x * (double) value.x + (double) value.y * (double) value.y);
if ((double) num1 < 9.99999974737875E-06)
float num1 = (float) (value.x * (double) value.x + value.y * (double) value.y);
if (num1 < 9.99999974737875E-06)
{
result = value;
}
else
{
float num2 = 1f / (float) Math.Sqrt((double) num1);
float num2 = 1f / (float) Math.Sqrt(num1);
result.x = value.x * num2;
result.y = value.y * num2;
}
......@@ -198,7 +187,7 @@ namespace PF
public static Vector2 Reflect(Vector2 vector, Vector2 normal)
{
float num = (float) ((double) vector.x * (double) normal.x + (double) vector.y * (double) normal.y);
float num = (float) (vector.x * (double) normal.x + vector.y * (double) normal.y);
Vector2 vector2;
vector2.x = vector.x - 2f * num * normal.x;
vector2.y = vector.y - 2f * num * normal.y;
......@@ -207,7 +196,7 @@ namespace PF
public static void Reflect(ref Vector2 vector, ref Vector2 normal, out Vector2 result)
{
float num = (float) ((double) vector.x * (double) normal.x + (double) vector.y * (double) normal.y);
float num = (float) (vector.x * (double) normal.x + vector.y * (double) normal.y);
result.x = vector.x - 2f * num * normal.x;
result.y = vector.y - 2f * num * normal.y;
}
......@@ -283,7 +272,7 @@ namespace PF
public static Vector2 SmoothStep(Vector2 value1, Vector2 value2, float amount)
{
amount = (double) amount > 1.0? 1f : ((double) amount < 0.0? 0.0f : amount);
amount = (float) ((double) amount * (double) amount * (3.0 - 2.0 * (double) amount));
amount = (float) (amount * (double) amount * (3.0 - 2.0 * amount));
Vector2 vector2;
vector2.x = value1.x + (value2.x - value1.x) * amount;
vector2.y = value1.y + (value2.y - value1.y) * amount;
......@@ -293,7 +282,7 @@ namespace PF
public static void SmoothStep(ref Vector2 value1, ref Vector2 value2, float amount, out Vector2 result)
{
amount = (double) amount > 1.0? 1f : ((double) amount < 0.0? 0.0f : amount);
amount = (float) ((double) amount * (double) amount * (3.0 - 2.0 * (double) amount));
amount = (float) (amount * (double) amount * (3.0 - 2.0 * amount));
result.x = value1.x + (value2.x - value1.x) * amount;
result.y = value1.y + (value2.y - value1.y) * amount;
}
......@@ -314,12 +303,12 @@ namespace PF
public static float Dot(Vector2 value1, Vector2 value2)
{
return (float) ((double) value1.x * (double) value2.x + (double) value1.y * (double) value2.y);
return (float) (value1.x * (double) value2.x + value1.y * (double) value2.y);
}
public static void Dot(ref Vector2 value1, ref Vector2 value2, out float result)
{
result = (float) ((double) value1.x * (double) value2.x + (double) value1.y * (double) value2.y);
result = (float) (value1.x * (double) value2.x + value1.y * (double) value2.y);
}
public static float Angle(Vector2 from, Vector2 to)
......@@ -436,7 +425,7 @@ namespace PF
public static bool operator ==(Vector2 lhs, Vector2 rhs)
{
return (double) (lhs - rhs).sqrMagnitude < 9.99999943962493E-11;
return (lhs - rhs).sqrMagnitude < 9.99999943962493E-11;
}
public static bool operator !=(Vector2 lhs, Vector2 rhs)
......
using System;
using System.Globalization;
namespace PF
namespace UnityEngine
{
[Serializable]
public struct Vector3: IEquatable<Vector3>
......@@ -19,17 +19,6 @@ namespace PF
public float x;
public float y;
public float z;
#if !SERVER
public static implicit operator UnityEngine.Vector3(Vector3 v3)
{
return new UnityEngine.Vector3(v3.x, v3.y, v3.z);
}
public static implicit operator Vector3(UnityEngine.Vector3 v3)
{
return new Vector3(v3.x, v3.y, v3.z);
}
#endif
public Vector3(float x, float y, float z)
{
......@@ -53,15 +42,15 @@ namespace PF
public override string ToString()
{
CultureInfo currentCulture = CultureInfo.CurrentCulture;
return string.Format((IFormatProvider) currentCulture, "({0}, {1}, {2})", (object) this.x.ToString((IFormatProvider) currentCulture),
(object) this.y.ToString((IFormatProvider) currentCulture),
(object) this.z.ToString((IFormatProvider) currentCulture));
return string.Format(currentCulture, "({0}, {1}, {2})", this.x.ToString(currentCulture),
this.y.ToString(currentCulture),
this.z.ToString(currentCulture));
}
public bool Equals(Vector3 other)
{
if ((double) this.x == (double) other.x && (double) this.y == (double) other.y)
return (double) this.z == (double) other.z;
if (this.x == (double) other.x && this.y == (double) other.y)
return this.z == (double) other.z;
return false;
}
......@@ -80,12 +69,12 @@ namespace PF
public float Length()
{
return (float) Math.Sqrt((double) this.x * (double) this.x + (double) this.y * (double) this.y + (double) this.z * (double) this.z);
return (float) Math.Sqrt(this.x * (double) this.x + this.y * (double) this.y + this.z * (double) this.z);
}
public float LengthSquared()
{
return (float) ((double) this.x * (double) this.x + (double) this.y * (double) this.y + (double) this.z * (double) this.z);
return (float) (this.x * (double) this.x + this.y * (double) this.y + this.z * (double) this.z);
}
public float magnitude
......@@ -109,7 +98,7 @@ namespace PF
float num1 = value1.x - value2.x;
float num2 = value1.y - value2.y;
float num3 = value1.z - value2.z;
return (float) Math.Sqrt((double) num1 * (double) num1 + (double) num2 * (double) num2 + (double) num3 * (double) num3);
return (float) Math.Sqrt(num1 * (double) num1 + num2 * (double) num2 + num3 * (double) num3);
}
public static void Distance(ref Vector3 value1, ref Vector3 value2, out float result)
......@@ -117,8 +106,8 @@ namespace PF
float num1 = value1.x - value2.x;
float num2 = value1.y - value2.y;
float num3 = value1.z - value2.z;
float num4 = (float) ((double) num1 * (double) num1 + (double) num2 * (double) num2 + (double) num3 * (double) num3);
result = (float) Math.Sqrt((double) num4);
float num4 = (float) (num1 * (double) num1 + num2 * (double) num2 + num3 * (double) num3);
result = (float) Math.Sqrt(num4);
}
public static float DistanceSquared(Vector3 value1, Vector3 value2)
......@@ -126,7 +115,7 @@ namespace PF
float num1 = value1.x - value2.x;
float num2 = value1.y - value2.y;
float num3 = value1.z - value2.z;
return (float) ((double) num1 * (double) num1 + (double) num2 * (double) num2 + (double) num3 * (double) num3);
return (float) (num1 * (double) num1 + num2 * (double) num2 + num3 * (double) num3);
}
public static void DistanceSquared(ref Vector3 value1, ref Vector3 value2, out float result)
......@@ -134,27 +123,27 @@ namespace PF
float num1 = value1.x - value2.x;
float num2 = value1.y - value2.y;
float num3 = value1.z - value2.z;
result = (float) ((double) num1 * (double) num1 + (double) num2 * (double) num2 + (double) num3 * (double) num3);
result = (float) (num1 * (double) num1 + num2 * (double) num2 + num3 * (double) num3);
}
public static float Dot(Vector3 vector1, Vector3 vector2)
{
return (float) ((double) vector1.x * (double) vector2.x + (double) vector1.y * (double) vector2.y +
(double) vector1.z * (double) vector2.z);
return (float) (vector1.x * (double) vector2.x + vector1.y * (double) vector2.y +
vector1.z * (double) vector2.z);
}
public static void Dot(ref Vector3 vector1, ref Vector3 vector2, out float result)
{
result = (float) ((double) vector1.x * (double) vector2.x + (double) vector1.y * (double) vector2.y +
(double) vector1.z * (double) vector2.z);
result = (float) (vector1.x * (double) vector2.x + vector1.y * (double) vector2.y +
vector1.z * (double) vector2.z);
}
public void Normalize()
{
float num1 = (float) ((double) this.x * (double) this.x + (double) this.y * (double) this.y + (double) this.z * (double) this.z);
if ((double) num1 < (double) Mathf.Epsilon)
float num1 = (float) (this.x * (double) this.x + this.y * (double) this.y + this.z * (double) this.z);
if (num1 < (double) Mathf.Epsilon)
return;
float num2 = 1f / (float) Math.Sqrt((double) num1);
float num2 = 1f / (float) Math.Sqrt(num1);
this.x *= num2;
this.y *= num2;
this.z *= num2;
......@@ -170,10 +159,10 @@ namespace PF
public static Vector3 Normalize(Vector3 value)
{
float num1 = (float) ((double) value.x * (double) value.x + (double) value.y * (double) value.y + (double) value.z * (double) value.z);
if ((double) num1 < (double) Mathf.Epsilon)
float num1 = (float) (value.x * (double) value.x + value.y * (double) value.y + value.z * (double) value.z);
if (num1 < (double) Mathf.Epsilon)
return value;
float num2 = 1f / (float) Math.Sqrt((double) num1);
float num2 = 1f / (float) Math.Sqrt(num1);
Vector3 vector3;
vector3.x = value.x * num2;
vector3.y = value.y * num2;
......@@ -183,14 +172,14 @@ namespace PF
public static void Normalize(ref Vector3 value, out Vector3 result)
{
float num1 = (float) ((double) value.x * (double) value.x + (double) value.y * (double) value.y + (double) value.z * (double) value.z);
if ((double) num1 < (double) Mathf.Epsilon)
float num1 = (float) (value.x * (double) value.x + value.y * (double) value.y + value.z * (double) value.z);
if (num1 < (double) Mathf.Epsilon)
{
result = value;
}
else
{
float num2 = 1f / (float) Math.Sqrt((double) num1);
float num2 = 1f / (float) Math.Sqrt(num1);
result.x = value.x * num2;
result.y = value.y * num2;
result.z = value.z * num2;
......@@ -200,17 +189,17 @@ namespace PF
public static Vector3 Cross(Vector3 vector1, Vector3 vector2)
{
Vector3 vector3;
vector3.x = (float) ((double) vector1.y * (double) vector2.z - (double) vector1.z * (double) vector2.y);
vector3.y = (float) ((double) vector1.z * (double) vector2.x - (double) vector1.x * (double) vector2.z);
vector3.z = (float) ((double) vector1.x * (double) vector2.y - (double) vector1.y * (double) vector2.x);
vector3.x = (float) (vector1.y * (double) vector2.z - vector1.z * (double) vector2.y);
vector3.y = (float) (vector1.z * (double) vector2.x - vector1.x * (double) vector2.z);
vector3.z = (float) (vector1.x * (double) vector2.y - vector1.y * (double) vector2.x);
return vector3;
}
public static void Cross(ref Vector3 vector1, ref Vector3 vector2, out Vector3 result)
{
float num1 = (float) ((double) vector1.y * (double) vector2.z - (double) vector1.z * (double) vector2.y);
float num2 = (float) ((double) vector1.z * (double) vector2.x - (double) vector1.x * (double) vector2.z);
float num3 = (float) ((double) vector1.x * (double) vector2.y - (double) vector1.y * (double) vector2.x);
float num1 = (float) (vector1.y * (double) vector2.z - vector1.z * (double) vector2.y);
float num2 = (float) (vector1.z * (double) vector2.x - vector1.x * (double) vector2.z);
float num3 = (float) (vector1.x * (double) vector2.y - vector1.y * (double) vector2.x);
result.x = num1;
result.y = num2;
result.z = num3;
......@@ -219,7 +208,7 @@ namespace PF
public static Vector3 Reflect(Vector3 vector, Vector3 normal)
{
float num =
(float) ((double) vector.x * (double) normal.x + (double) vector.y * (double) normal.y + (double) vector.z * (double) normal.z);
(float) (vector.x * (double) normal.x + vector.y * (double) normal.y + vector.z * (double) normal.z);
Vector3 vector3;
vector3.x = vector.x - 2f * num * normal.x;
vector3.y = vector.y - 2f * num * normal.y;
......@@ -230,7 +219,7 @@ namespace PF
public static void Reflect(ref Vector3 vector, ref Vector3 normal, out Vector3 result)
{
float num =
(float) ((double) vector.x * (double) normal.x + (double) vector.y * (double) normal.y + (double) vector.z * (double) normal.z);
(float) (vector.x * (double) normal.x + vector.y * (double) normal.y + vector.z * (double) normal.z);
result.x = vector.x - 2f * num * normal.x;
result.y = vector.y - 2f * num * normal.y;
result.z = vector.z - 2f * num * normal.z;
......@@ -321,7 +310,7 @@ namespace PF
public static Vector3 SmoothStep(Vector3 value1, Vector3 value2, float amount)
{
amount = (double) amount > 1.0? 1f : ((double) amount < 0.0? 0.0f : amount);
amount = (float) ((double) amount * (double) amount * (3.0 - 2.0 * (double) amount));
amount = (float) (amount * (double) amount * (3.0 - 2.0 * amount));
Vector3 vector3;
vector3.x = value1.x + (value2.x - value1.x) * amount;
vector3.y = value1.y + (value2.y - value1.y) * amount;
......@@ -332,7 +321,7 @@ namespace PF
public static void SmoothStep(ref Vector3 value1, ref Vector3 value2, float amount, out Vector3 result)
{
amount = (double) amount > 1.0? 1f : ((double) amount < 0.0? 0.0f : amount);
amount = (float) ((double) amount * (double) amount * (3.0 - 2.0 * (double) amount));
amount = (float) (amount * (double) amount * (3.0 - 2.0 * amount));
result.x = value1.x + (value2.x - value1.x) * amount;
result.y = value1.y + (value2.y - value1.y) * amount;
result.z = value1.z + (value2.z - value1.z) * amount;
......@@ -342,17 +331,17 @@ namespace PF
{
float num1 = amount * amount;
float num2 = amount * num1;
float num3 = (float) (2.0 * (double) num2 - 3.0 * (double) num1 + 1.0);
float num4 = (float) (-2.0 * (double) num2 + 3.0 * (double) num1);
float num3 = (float) (2.0 * num2 - 3.0 * num1 + 1.0);
float num4 = (float) (-2.0 * num2 + 3.0 * num1);
float num5 = num2 - 2f * num1 + amount;
float num6 = num2 - num1;
Vector3 vector3;
vector3.x = (float) ((double) value1.x * (double) num3 + (double) value2.x * (double) num4 + (double) tangent1.x * (double) num5 +
(double) tangent2.x * (double) num6);
vector3.y = (float) ((double) value1.y * (double) num3 + (double) value2.y * (double) num4 + (double) tangent1.y * (double) num5 +
(double) tangent2.y * (double) num6);
vector3.z = (float) ((double) value1.z * (double) num3 + (double) value2.z * (double) num4 + (double) tangent1.z * (double) num5 +
(double) tangent2.z * (double) num6);
vector3.x = (float) (value1.x * (double) num3 + value2.x * (double) num4 + tangent1.x * (double) num5 +
tangent2.x * (double) num6);
vector3.y = (float) (value1.y * (double) num3 + value2.y * (double) num4 + tangent1.y * (double) num5 +
tangent2.y * (double) num6);
vector3.z = (float) (value1.z * (double) num3 + value2.z * (double) num4 + tangent1.z * (double) num5 +
tangent2.z * (double) num6);
return vector3;
}
......@@ -361,16 +350,16 @@ namespace PF
{
float num1 = amount * amount;
float num2 = amount * num1;
float num3 = (float) (2.0 * (double) num2 - 3.0 * (double) num1 + 1.0);
float num4 = (float) (-2.0 * (double) num2 + 3.0 * (double) num1);
float num3 = (float) (2.0 * num2 - 3.0 * num1 + 1.0);
float num4 = (float) (-2.0 * num2 + 3.0 * num1);
float num5 = num2 - 2f * num1 + amount;
float num6 = num2 - num1;
result.x = (float) ((double) value1.x * (double) num3 + (double) value2.x * (double) num4 + (double) tangent1.x * (double) num5 +
(double) tangent2.x * (double) num6);
result.y = (float) ((double) value1.y * (double) num3 + (double) value2.y * (double) num4 + (double) tangent1.y * (double) num5 +
(double) tangent2.y * (double) num6);
result.z = (float) ((double) value1.z * (double) num3 + (double) value2.z * (double) num4 + (double) tangent1.z * (double) num5 +
(double) tangent2.z * (double) num6);
result.x = (float) (value1.x * (double) num3 + value2.x * (double) num4 + tangent1.x * (double) num5 +
tangent2.x * (double) num6);
result.y = (float) (value1.y * (double) num3 + value2.y * (double) num4 + tangent1.y * (double) num5 +
tangent2.y * (double) num6);
result.z = (float) (value1.z * (double) num3 + value2.z * (double) num4 + tangent1.z * (double) num5 +
tangent2.z * (double) num6);
}
public static Vector3 Negate(Vector3 value)
......@@ -489,22 +478,22 @@ namespace PF
private static float magnitudeStatic(ref Vector3 inV)
{
return (float) Math.Sqrt((double) Vector3.Dot(inV, inV));
return (float) Math.Sqrt(Vector3.Dot(inV, inV));
}
private static Vector3 orthoNormalVectorFast(ref Vector3 n)
{
Vector3 vector3;
if ((double) Math.Abs(n.z) > (double) Vector3.k1OverSqrt2)
if (Math.Abs(n.z) > (double) Vector3.k1OverSqrt2)
{
float num = 1f / (float) Math.Sqrt((double) n.y * (double) n.y + (double) n.z * (double) n.z);
float num = 1f / (float) Math.Sqrt(n.y * (double) n.y + n.z * (double) n.z);
vector3.x = 0.0f;
vector3.y = -n.z * num;
vector3.z = n.y * num;
}
else
{
float num = 1f / (float) Math.Sqrt((double) n.x * (double) n.x + (double) n.y * (double) n.y);
float num = 1f / (float) Math.Sqrt(n.x * (double) n.x + n.y * (double) n.y);
vector3.x = -n.y * num;
vector3.y = n.x * num;
vector3.z = 0.0f;
......@@ -516,14 +505,14 @@ namespace PF
public static void OrthoNormalize(ref Vector3 normal, ref Vector3 tangent)
{
float num1 = Vector3.magnitudeStatic(ref normal);
if ((double) num1 > (double) Mathf.Epsilon)
if (num1 > (double) Mathf.Epsilon)
normal /= num1;
else
normal = new Vector3(1f, 0.0f, 0.0f);
float num2 = Vector3.Dot(normal, tangent);
tangent -= num2 * normal;
float num3 = Vector3.magnitudeStatic(ref tangent);
if ((double) num3 < (double) Mathf.Epsilon)
if (num3 < (double) Mathf.Epsilon)
tangent = Vector3.orthoNormalVectorFast(ref normal);
else
tangent /= num3;
......@@ -532,14 +521,14 @@ namespace PF
public static void OrthoNormalize(ref Vector3 normal, ref Vector3 tangent, ref Vector3 binormal)
{
float num1 = Vector3.magnitudeStatic(ref normal);
if ((double) num1 > (double) Mathf.Epsilon)
if (num1 > (double) Mathf.Epsilon)
normal /= num1;
else
normal = new Vector3(1f, 0.0f, 0.0f);
float num2 = Vector3.Dot(normal, tangent);
tangent -= num2 * normal;
float num3 = Vector3.magnitudeStatic(ref tangent);
if ((double) num3 > (double) Mathf.Epsilon)
if (num3 > (double) Mathf.Epsilon)
tangent /= num3;
else
tangent = Vector3.orthoNormalVectorFast(ref normal);
......@@ -547,7 +536,7 @@ namespace PF
float num5 = Vector3.Dot(normal, binormal);
binormal -= num5 * normal + num4 * tangent;
float num6 = Vector3.magnitudeStatic(ref binormal);
if ((double) num6 > (double) Mathf.Epsilon)
if (num6 > (double) Mathf.Epsilon)
binormal /= num6;
else
binormal = Vector3.Cross(normal, tangent);
......@@ -592,7 +581,7 @@ namespace PF
public static bool operator ==(Vector3 lhs, Vector3 rhs)
{
return (double) (lhs - rhs).sqrMagnitude < 9.99999943962493E-11;
return (lhs - rhs).sqrMagnitude < 9.99999943962493E-11;
}
public static bool operator !=(Vector3 lhs, Vector3 rhs)
......
using System;
using System.Globalization;
namespace PF
namespace UnityEngine
{
[Serializable]
public struct Vector4: IEquatable<Vector4>
......@@ -41,31 +41,20 @@ namespace PF
{
this.x = this.y = this.z = this.w = value;
}
#if !SERVER
public static implicit operator Vector4(UnityEngine.Vector4 v4)
{
return new Vector4(v4.x, v4.y, v4.z, v4.w);
}
public static implicit operator UnityEngine.Vector4(Vector4 v4)
{
return new UnityEngine.Vector4(v4.x, v4.y, v4.z, v4.w);
}
#endif
public override string ToString()
{
CultureInfo currentCulture = CultureInfo.CurrentCulture;
return string.Format((IFormatProvider) currentCulture, "{0}, {1}, {2}, {3}", (object) this.x.ToString((IFormatProvider) currentCulture),
(object) this.y.ToString((IFormatProvider) currentCulture),
(object) this.z.ToString((IFormatProvider) currentCulture),
(object) this.w.ToString((IFormatProvider) currentCulture));
return string.Format(currentCulture, "{0}, {1}, {2}, {3}", (object) this.x.ToString(currentCulture),
(object) this.y.ToString(currentCulture),
(object) this.z.ToString(currentCulture),
(object) this.w.ToString(currentCulture));
}
public bool Equals(Vector4 other)
{
if ((double) this.x == (double) other.x && (double) this.y == (double) other.y && (double) this.z == (double) other.z)
return (double) this.w == (double) other.w;
if (this.x == (double) other.x && this.y == (double) other.y && this.z == (double) other.z)
return this.w == (double) other.w;
return false;
}
......@@ -84,14 +73,14 @@ namespace PF
public float Length()
{
return (float) Math.Sqrt((double) this.x * (double) this.x + (double) this.y * (double) this.y + (double) this.z * (double) this.z +
(double) this.w * (double) this.w);
return (float) Math.Sqrt(this.x * (double) this.x + this.y * (double) this.y + this.z * (double) this.z +
this.w * (double) this.w);
}
public float LengthSquared()
{
return (float) ((double) this.x * (double) this.x + (double) this.y * (double) this.y + (double) this.z * (double) this.z +
(double) this.w * (double) this.w);
return (float) (this.x * (double) this.x + this.y * (double) this.y + this.z * (double) this.z +
this.w * (double) this.w);
}
public static float Distance(Vector4 value1, Vector4 value2)
......@@ -100,8 +89,8 @@ namespace PF
float num2 = value1.y - value2.y;
float num3 = value1.z - value2.z;
float num4 = value1.w - value2.w;
return (float) Math.Sqrt((double) num1 * (double) num1 + (double) num2 * (double) num2 + (double) num3 * (double) num3 +
(double) num4 * (double) num4);
return (float) Math.Sqrt(num1 * (double) num1 + num2 * (double) num2 + num3 * (double) num3 +
num4 * (double) num4);
}
public static void Distance(ref Vector4 value1, ref Vector4 value2, out float result)
......@@ -110,9 +99,9 @@ namespace PF
float num2 = value1.y - value2.y;
float num3 = value1.z - value2.z;
float num4 = value1.w - value2.w;
float num5 = (float) ((double) num1 * (double) num1 + (double) num2 * (double) num2 + (double) num3 * (double) num3 +
(double) num4 * (double) num4);
result = (float) Math.Sqrt((double) num5);
float num5 = (float) (num1 * (double) num1 + num2 * (double) num2 + num3 * (double) num3 +
num4 * (double) num4);
result = (float) Math.Sqrt(num5);
}
public static float DistanceSquared(Vector4 value1, Vector4 value2)
......@@ -121,8 +110,8 @@ namespace PF
float num2 = value1.y - value2.y;
float num3 = value1.z - value2.z;
float num4 = value1.w - value2.w;
return (float) ((double) num1 * (double) num1 + (double) num2 * (double) num2 + (double) num3 * (double) num3 +
(double) num4 * (double) num4);
return (float) (num1 * (double) num1 + num2 * (double) num2 + num3 * (double) num3 +
num4 * (double) num4);
}
public static void DistanceSquared(ref Vector4 value1, ref Vector4 value2, out float result)
......@@ -131,29 +120,29 @@ namespace PF
float num2 = value1.y - value2.y;
float num3 = value1.z - value2.z;
float num4 = value1.w - value2.w;
result = (float) ((double) num1 * (double) num1 + (double) num2 * (double) num2 + (double) num3 * (double) num3 +
(double) num4 * (double) num4);
result = (float) (num1 * (double) num1 + num2 * (double) num2 + num3 * (double) num3 +
num4 * (double) num4);
}
public static float Dot(Vector4 vector1, Vector4 vector2)
{
return (float) ((double) vector1.x * (double) vector2.x + (double) vector1.y * (double) vector2.y +
(double) vector1.z * (double) vector2.z + (double) vector1.w * (double) vector2.w);
return (float) (vector1.x * (double) vector2.x + vector1.y * (double) vector2.y +
vector1.z * (double) vector2.z + vector1.w * (double) vector2.w);
}
public static void Dot(ref Vector4 vector1, ref Vector4 vector2, out float result)
{
result = (float) ((double) vector1.x * (double) vector2.x + (double) vector1.y * (double) vector2.y +
(double) vector1.z * (double) vector2.z + (double) vector1.w * (double) vector2.w);
result = (float) (vector1.x * (double) vector2.x + vector1.y * (double) vector2.y +
vector1.z * (double) vector2.z + vector1.w * (double) vector2.w);
}
public void Normalize()
{
float num1 = (float) ((double) this.x * (double) this.x + (double) this.y * (double) this.y + (double) this.z * (double) this.z +
(double) this.w * (double) this.w);
if ((double) num1 < (double) Mathf.Epsilon)
float num1 = (float) (this.x * (double) this.x + this.y * (double) this.y + this.z * (double) this.z +
this.w * (double) this.w);
if (num1 < (double) Mathf.Epsilon)
return;
float num2 = 1f / (float) Math.Sqrt((double) num1);
float num2 = 1f / (float) Math.Sqrt(num1);
this.x *= num2;
this.y *= num2;
this.z *= num2;
......@@ -162,11 +151,11 @@ namespace PF
public static Vector4 Normalize(Vector4 vector)
{
float num1 = (float) ((double) vector.x * (double) vector.x + (double) vector.y * (double) vector.y +
(double) vector.z * (double) vector.z + (double) vector.w * (double) vector.w);
if ((double) num1 < (double) Mathf.Epsilon)
float num1 = (float) (vector.x * (double) vector.x + vector.y * (double) vector.y +
vector.z * (double) vector.z + vector.w * (double) vector.w);
if (num1 < (double) Mathf.Epsilon)
return vector;
float num2 = 1f / (float) Math.Sqrt((double) num1);
float num2 = 1f / (float) Math.Sqrt(num1);
Vector4 vector4;
vector4.x = vector.x * num2;
vector4.y = vector.y * num2;
......@@ -177,15 +166,15 @@ namespace PF
public static void Normalize(ref Vector4 vector, out Vector4 result)
{
float num1 = (float) ((double) vector.x * (double) vector.x + (double) vector.y * (double) vector.y +
(double) vector.z * (double) vector.z + (double) vector.w * (double) vector.w);
if ((double) num1 < (double) Mathf.Epsilon)
float num1 = (float) (vector.x * (double) vector.x + vector.y * (double) vector.y +
vector.z * (double) vector.z + vector.w * (double) vector.w);
if (num1 < (double) Mathf.Epsilon)
{
result = vector;
}
else
{
float num2 = 1f / (float) Math.Sqrt((double) num1);
float num2 = 1f / (float) Math.Sqrt(num1);
result.x = vector.x * num2;
result.y = vector.y * num2;
result.z = vector.z * num2;
......@@ -292,7 +281,7 @@ namespace PF
public static Vector4 SmoothStep(Vector4 value1, Vector4 value2, float amount)
{
amount = (double) amount > 1.0? 1f : ((double) amount < 0.0? 0.0f : amount);
amount = (float) ((double) amount * (double) amount * (3.0 - 2.0 * (double) amount));
amount = (float) (amount * (double) amount * (3.0 - 2.0 * amount));
Vector4 vector4;
vector4.x = value1.x + (value2.x - value1.x) * amount;
vector4.y = value1.y + (value2.y - value1.y) * amount;
......@@ -304,7 +293,7 @@ namespace PF
public static void SmoothStep(ref Vector4 value1, ref Vector4 value2, float amount, out Vector4 result)
{
amount = (double) amount > 1.0? 1f : ((double) amount < 0.0? 0.0f : amount);
amount = (float) ((double) amount * (double) amount * (3.0 - 2.0 * (double) amount));
amount = (float) (amount * (double) amount * (3.0 - 2.0 * amount));
result.x = value1.x + (value2.x - value1.x) * amount;
result.y = value1.y + (value2.y - value1.y) * amount;
result.z = value1.z + (value2.z - value1.z) * amount;
......@@ -315,19 +304,19 @@ namespace PF
{
float num1 = amount * amount;
float num2 = amount * num1;
float num3 = (float) (2.0 * (double) num2 - 3.0 * (double) num1 + 1.0);
float num4 = (float) (-2.0 * (double) num2 + 3.0 * (double) num1);
float num3 = (float) (2.0 * num2 - 3.0 * num1 + 1.0);
float num4 = (float) (-2.0 * num2 + 3.0 * num1);
float num5 = num2 - 2f * num1 + amount;
float num6 = num2 - num1;
Vector4 vector4;
vector4.x = (float) ((double) value1.x * (double) num3 + (double) value2.x * (double) num4 + (double) tangent1.x * (double) num5 +
(double) tangent2.x * (double) num6);
vector4.y = (float) ((double) value1.y * (double) num3 + (double) value2.y * (double) num4 + (double) tangent1.y * (double) num5 +
(double) tangent2.y * (double) num6);
vector4.z = (float) ((double) value1.z * (double) num3 + (double) value2.z * (double) num4 + (double) tangent1.z * (double) num5 +
(double) tangent2.z * (double) num6);
vector4.w = (float) ((double) value1.w * (double) num3 + (double) value2.w * (double) num4 + (double) tangent1.w * (double) num5 +
(double) tangent2.w * (double) num6);
vector4.x = (float) (value1.x * (double) num3 + value2.x * (double) num4 + tangent1.x * (double) num5 +
tangent2.x * (double) num6);
vector4.y = (float) (value1.y * (double) num3 + value2.y * (double) num4 + tangent1.y * (double) num5 +
tangent2.y * (double) num6);
vector4.z = (float) (value1.z * (double) num3 + value2.z * (double) num4 + tangent1.z * (double) num5 +
tangent2.z * (double) num6);
vector4.w = (float) (value1.w * (double) num3 + value2.w * (double) num4 + tangent1.w * (double) num5 +
tangent2.w * (double) num6);
return vector4;
}
......@@ -336,18 +325,18 @@ namespace PF
{
float num1 = amount * amount;
float num2 = amount * num1;
float num3 = (float) (2.0 * (double) num2 - 3.0 * (double) num1 + 1.0);
float num4 = (float) (-2.0 * (double) num2 + 3.0 * (double) num1);
float num3 = (float) (2.0 * num2 - 3.0 * num1 + 1.0);
float num4 = (float) (-2.0 * num2 + 3.0 * num1);
float num5 = num2 - 2f * num1 + amount;
float num6 = num2 - num1;
result.x = (float) ((double) value1.x * (double) num3 + (double) value2.x * (double) num4 + (double) tangent1.x * (double) num5 +
(double) tangent2.x * (double) num6);
result.y = (float) ((double) value1.y * (double) num3 + (double) value2.y * (double) num4 + (double) tangent1.y * (double) num5 +
(double) tangent2.y * (double) num6);
result.z = (float) ((double) value1.z * (double) num3 + (double) value2.z * (double) num4 + (double) tangent1.z * (double) num5 +
(double) tangent2.z * (double) num6);
result.w = (float) ((double) value1.w * (double) num3 + (double) value2.w * (double) num4 + (double) tangent1.w * (double) num5 +
(double) tangent2.w * (double) num6);
result.x = (float) (value1.x * (double) num3 + value2.x * (double) num4 + tangent1.x * (double) num5 +
tangent2.x * (double) num6);
result.y = (float) (value1.y * (double) num3 + value2.y * (double) num4 + tangent1.y * (double) num5 +
tangent2.y * (double) num6);
result.z = (float) (value1.z * (double) num3 + value2.z * (double) num4 + tangent1.z * (double) num5 +
tangent2.z * (double) num6);
result.w = (float) (value1.w * (double) num3 + value2.w * (double) num4 + tangent1.w * (double) num5 +
tangent2.w * (double) num6);
}
public static Vector4 Project(Vector4 vector, Vector4 onNormal)
......@@ -500,15 +489,15 @@ namespace PF
public static bool operator ==(Vector4 value1, Vector4 value2)
{
if ((double) value1.x == (double) value2.x && (double) value1.y == (double) value2.y && (double) value1.z == (double) value2.z)
return (double) value1.w == (double) value2.w;
if (value1.x == (double) value2.x && value1.y == (double) value2.y && value1.z == (double) value2.z)
return value1.w == (double) value2.w;
return false;
}
public static bool operator !=(Vector4 value1, Vector4 value2)
{
if ((double) value1.x == (double) value2.x && (double) value1.y == (double) value2.y && (double) value1.z == (double) value2.z)
return (double) value1.w != (double) value2.w;
if (value1.x == (double) value2.x && value1.y == (double) value2.y && value1.z == (double) value2.z)
return value1.w != (double) value2.w;
return true;
}
......
using System;
using System.Threading;
using PF;
using UnityEngine;
namespace ETModel
{
......
using PF;
using UnityEngine;
namespace ETModel
{
......
using System.Collections.Generic;
using System.Threading;
using PF;
using UnityEngine;
namespace ETModel
{
......
using System.Collections.Generic;
using PF;
using UnityEngine;
namespace ETModel
{
......
using System.Collections.Generic;
using PF;
using UnityEngine;
namespace ETModel
{
......
......@@ -50,27 +50,6 @@
<Compile Include="..\..\Unity\Assets\Model\Base\Object\IDeserializeSystem.cs">
<Link>Base\Base\IDeserializeSystem.cs</Link>
</Compile>
<Compile Include="..\..\Unity\Assets\Model\Base\UnityMath\Mathf.cs">
<Link>Base\UnityMath\Mathf.cs</Link>
</Compile>
<Compile Include="..\..\Unity\Assets\Model\Base\UnityMath\Matrix3x3.cs">
<Link>Base\UnityMath\Matrix3x3.cs</Link>
</Compile>
<Compile Include="..\..\Unity\Assets\Model\Base\UnityMath\Matrix4x4.cs">
<Link>Base\UnityMath\Matrix4x4.cs</Link>
</Compile>
<Compile Include="..\..\Unity\Assets\Model\Base\UnityMath\Quaternion.cs">
<Link>Base\UnityMath\Quaternion.cs</Link>
</Compile>
<Compile Include="..\..\Unity\Assets\Model\Base\UnityMath\Vector2.cs">
<Link>Base\UnityMath\Vector2.cs</Link>
</Compile>
<Compile Include="..\..\Unity\Assets\Model\Base\UnityMath\Vector3.cs">
<Link>Base\UnityMath\Vector3.cs</Link>
</Compile>
<Compile Include="..\..\Unity\Assets\Model\Base\UnityMath\Vector4.cs">
<Link>Base\UnityMath\Vector4.cs</Link>
</Compile>
<Compile Include="..\..\Unity\Assets\Model\Component\Config\StartConfig.cs">
<Link>Component\Config\StartConfig.cs</Link>
</Compile>
......
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/Highlighting/AnalysisEnabled/@EntryValue">VISIBLE_FILES</s:String></wpf:ResourceDictionary>
\ No newline at end of file
<s:String x:Key="/Default/CodeInspection/Highlighting/AnalysisEnabled/@EntryValue">VISIBLE_FILES</s:String>
<s:String x:Key="/Default/Housekeeping/OptionsDialog/SelectedPageId/@EntryValue">XamlPreviewOptionsPage</s:String></wpf:ResourceDictionary>
\ No newline at end of file
......@@ -33,7 +33,7 @@ namespace Pathfinding {
// Make sure no point arrays are null
for (int i = 0; i < scripts.Length; i++) {
scripts[i].points = scripts[i].points ?? new PF.Vector3[0];
scripts[i].points = scripts[i].points ?? new Vector3[0];
}
if (!points.hasMultipleDifferentValues && points.arraySize == 0) {
......@@ -95,7 +95,7 @@ namespace Pathfinding {
if (GUILayout.Button("Clear all points")) {
for (int i = 0; i < scripts.Length; i++) {
Undo.RecordObject(scripts[i], "Clear points");
scripts[i].points = new PF.Vector3[0];
scripts[i].points = new Vector3[0];
scripts[i].RecalcConvex();
}
}
......@@ -194,11 +194,11 @@ namespace Pathfinding {
// Make sure the points array is not null
if (script.points == null) {
script.points = new PF.Vector3[0];
script.points = new Vector3[0];
EditorUtility.SetDirty(script);
}
List<PF.Vector3> points = ListPool<PF.Vector3>.Claim();
List<Vector3> points = ListPool<Vector3>.Claim();
points.AddRange(script.points);
Matrix4x4 invMatrix = script.transform.worldToLocalMatrix;
......@@ -245,7 +245,7 @@ namespace Pathfinding {
if (((int)Event.current.modifiers & (int)EventModifiers.Alt) != 0) {
if (Event.current.type == EventType.MouseDown && selectedPoint >= 0 && selectedPoint < points.Count) {
Undo.RecordObject(script, "Removed Point");
var arr = new List<PF.Vector3>(script.points);
var arr = new List<Vector3>(script.points);
arr.RemoveAt(selectedPoint);
points.RemoveAt(selectedPoint);
script.points = arr.ToArray();
......@@ -291,7 +291,7 @@ namespace Pathfinding {
points.Insert(insertionIndex, rayhit);
Undo.RecordObject(script, "Added Point");
var arr = new List<PF.Vector3>(script.points);
var arr = new List<Vector3>(script.points);
arr.Insert(insertionIndex, invMatrix.MultiplyPoint3x4(rayhit));
script.points = arr.ToArray();
GUI.changed = true;
......@@ -316,7 +316,7 @@ namespace Pathfinding {
// Make sure the convex hull stays up to date
script.RecalcConvex();
ListPool<PF.Vector3>.Release(ref points);
ListPool<Vector3>.Release(ref points);
if (GUI.changed) HandleUtility.Repaint();
}
......
fileFormatVersion: 2
guid: 8e01398a4ed2b984a9ae0ace15af2c22
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: ecbc20345b2349be966249f2dc088977
timeCreated: 1539057993
\ No newline at end of file
fileFormatVersion: 2
guid: 587b765f9543466b96245687943e5b9b
timeCreated: 1539140684
\ No newline at end of file
fileFormatVersion: 2
guid: 70f2dca9f45f1054086e373dc4e191bd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 638e9a6303bb16b46bbd32d3824a6e8b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 36fb98626b15fe640bc29481adf7f528
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: c959cce495b65214c9a01392cbeff121
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 1f535eb6c5969b84c89d8c82f21584a1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -103,7 +103,6 @@ namespace ILRuntime.Runtime.Generated
ETModel_ETVoid_Binding.Register(app);
ETModel_GizmosDebug_Binding.Register(app);
System_Collections_Generic_List_1_Vector3_Binding.Register(app);
PF_Vector3_Binding.Register(app);
Google_Protobuf_Collections_RepeatedField_1_Single_Binding.Register(app);
UnityEngine_LayerMask_Binding.Register(app);
UnityEngine_Input_Binding.Register(app);
......
......@@ -53,7 +53,7 @@ namespace ILRuntime.Runtime.Generated
}
static void set_Path_0(ref object o, object v)
{
((ETModel.GizmosDebug)o).Path = (System.Collections.Generic.List<PF.Vector3>)v;
((ETModel.GizmosDebug)o).Path = (System.Collections.Generic.List<UnityEngine.Vector3>)v;
}
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using ILRuntime.CLR.TypeSystem;
using ILRuntime.CLR.Method;
using ILRuntime.Runtime.Enviorment;
using ILRuntime.Runtime.Intepreter;
using ILRuntime.Runtime.Stack;
using ILRuntime.Reflection;
using ILRuntime.CLR.Utils;
namespace ILRuntime.Runtime.Generated
{
unsafe class PF_Vector3_Binding
{
public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
{
BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
MethodBase method;
Type[] args;
Type type = typeof(PF.Vector3);
MethodInfo[] methods = type.GetMethods(flag).Where(t => !t.IsGenericMethod).ToArray();
args = new Type[]{typeof(UnityEngine.Vector3)};
method = methods.Where(t => t.Name.Equals("op_Implicit") && t.ReturnType == typeof(PF.Vector3) && t.CheckMethodParams(args)).Single();
app.RegisterCLRMethodRedirection(method, op_Implicit_0);
app.RegisterCLRCreateDefaultInstance(type, () => new PF.Vector3());
}
static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject* ptr_of_this_method, IList<object> __mStack, ref PF.Vector3 instance_of_this_method)
{
ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
switch(ptr_of_this_method->ObjectType)
{
case ObjectTypes.Object:
{
__mStack[ptr_of_this_method->Value] = instance_of_this_method;
}
break;
case ObjectTypes.FieldReference:
{
var ___obj = __mStack[ptr_of_this_method->Value];
if(___obj is ILTypeInstance)
{
((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method;
}
else
{
var t = __domain.GetType(___obj.GetType()) as CLRType;
t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method);
}
}
break;
case ObjectTypes.StaticFieldReference:
{
var t = __domain.GetType(ptr_of_this_method->Value);
if(t is ILType)
{
((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method;
}
else
{
((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method);
}
}
break;
case ObjectTypes.ArrayReference:
{
var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as PF.Vector3[];
instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method;
}
break;
}
}
static StackObject* op_Implicit_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
{
ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
StackObject* ptr_of_this_method;
StackObject* __ret = ILIntepreter.Minus(__esp, 1);
ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
UnityEngine.Vector3 @v3 = (UnityEngine.Vector3)typeof(UnityEngine.Vector3).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
__intp.Free(ptr_of_this_method);
var result_of_this_method = (PF.Vector3)v3;
return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
}
}
}
fileFormatVersion: 2
guid: 37e5c8ba353700d4c874b5ff1515ab1d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -21,11 +21,11 @@ namespace ILRuntime.Runtime.Generated
BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
MethodBase method;
Type[] args;
Type type = typeof(System.Collections.Generic.List<PF.Vector3>);
Type type = typeof(System.Collections.Generic.List<UnityEngine.Vector3>);
args = new Type[]{};
method = type.GetMethod("Clear", flag, null, args, null);
app.RegisterCLRMethodRedirection(method, Clear_0);
args = new Type[]{typeof(PF.Vector3)};
args = new Type[]{typeof(UnityEngine.Vector3)};
method = type.GetMethod("Add", flag, null, args, null);
app.RegisterCLRMethodRedirection(method, Add_1);
......@@ -40,7 +40,7 @@ namespace ILRuntime.Runtime.Generated
StackObject* __ret = ILIntepreter.Minus(__esp, 1);
ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
System.Collections.Generic.List<PF.Vector3> instance_of_this_method = (System.Collections.Generic.List<PF.Vector3>)typeof(System.Collections.Generic.List<PF.Vector3>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
System.Collections.Generic.List<UnityEngine.Vector3> instance_of_this_method = (System.Collections.Generic.List<UnityEngine.Vector3>)typeof(System.Collections.Generic.List<UnityEngine.Vector3>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
__intp.Free(ptr_of_this_method);
instance_of_this_method.Clear();
......@@ -55,11 +55,11 @@ namespace ILRuntime.Runtime.Generated
StackObject* __ret = ILIntepreter.Minus(__esp, 2);
ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
PF.Vector3 @item = (PF.Vector3)typeof(PF.Vector3).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
UnityEngine.Vector3 @item = (UnityEngine.Vector3)typeof(UnityEngine.Vector3).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
__intp.Free(ptr_of_this_method);
ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
System.Collections.Generic.List<PF.Vector3> instance_of_this_method = (System.Collections.Generic.List<PF.Vector3>)typeof(System.Collections.Generic.List<PF.Vector3>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
System.Collections.Generic.List<UnityEngine.Vector3> instance_of_this_method = (System.Collections.Generic.List<UnityEngine.Vector3>)typeof(System.Collections.Generic.List<UnityEngine.Vector3>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
__intp.Free(ptr_of_this_method);
instance_of_this_method.Add(@item);
......
......@@ -102,7 +102,7 @@ namespace Pathfinding {
/** Used for drawing gizmos */
[System.NonSerialized]
List<PF.Vector3> lastCompletedVectorPath;
List<Vector3> lastCompletedVectorPath;
/** Used for drawing gizmos */
[System.NonSerialized]
......
......@@ -39,10 +39,10 @@ namespace Pathfinding {
[HelpURL("http://arongranberg.com/astar/docs/class_pathfinding_1_1_graph_update_scene.php")]
public class GraphUpdateScene : GraphModifier {
/** Points which define the region to update */
public PF.Vector3[] points;
public Vector3[] points;
/** Private cached convex hull of the #points */
private PF.Vector3[] convexPoints;
private Vector3[] convexPoints;
/** Use the convex hull of the points instead of the original polygon.
*
......@@ -252,7 +252,7 @@ namespace Pathfinding {
GraphUpdateShape shape;
if (legacyMode && !legacyUseWorldSpace) {
// Used for compatibility with older versions
var worldPoints = new PF.Vector3[points.Length];
var worldPoints = new Vector3[points.Length];
for (int i = 0; i < points.Length; i++) worldPoints[i] = transform.TransformPoint(points[i]);
shape = new GraphUpdateShape(worldPoints, convex, Matrix4x4.identity, minBoundsHeight);
} else {
......@@ -345,10 +345,10 @@ namespace Pathfinding {
for (int i = 0; i < pts.Length; i++) {
var next = (i+1) % pts.Length;
var p1 = matrix.MultiplyPoint3x4(pts[i] + PF.Vector3.up*(miny - pts[i].y));
var p2 = matrix.MultiplyPoint3x4(pts[i] + PF.Vector3.up*(maxy - pts[i].y));
var p1n = matrix.MultiplyPoint3x4(pts[next] + PF.Vector3.up*(miny - pts[next].y));
var p2n = matrix.MultiplyPoint3x4(pts[next] + PF.Vector3.up*(maxy - pts[next].y));
var p1 = matrix.MultiplyPoint3x4(pts[i] + Vector3.up*(miny - pts[i].y));
var p2 = matrix.MultiplyPoint3x4(pts[i] + Vector3.up*(maxy - pts[i].y));
var p1n = matrix.MultiplyPoint3x4(pts[next] + Vector3.up*(miny - pts[next].y));
var p2n = matrix.MultiplyPoint3x4(pts[next] + Vector3.up*(maxy - pts[next].y));
Gizmos.DrawLine(p1, p2);
Gizmos.DrawLine(p1, p1n);
Gizmos.DrawLine(p2, p2n);
......
......@@ -16,8 +16,8 @@ namespace Pathfinding {
* \see Pathfinding.GraphUpdateObject.shape
*/
public class GraphUpdateShape {
PF.Vector3[] _points;
PF.Vector3[] _convexPoints;
Vector3[] _points;
Vector3[] _convexPoints;
bool _convex;
Vector3 right = Vector3.right;
Vector3 forward = Vector3.forward;
......@@ -28,7 +28,7 @@ namespace Pathfinding {
/** Gets or sets the points of the polygon in the shape.
* These points should be specified in clockwise order.
* Will automatically calculate the convex hull if #convex is set to true */
public PF.Vector3[] points {
public Vector3[] points {
get {
return _points;
}
......@@ -64,7 +64,7 @@ namespace Pathfinding {
* include any points inside it (as testing for inclusion is done in 3D space when updating graphs). This ensures
* that the shape has at least the minimum height (in the up direction that the matrix specifies).
*/
public GraphUpdateShape (PF.Vector3[] points, bool convex, Matrix4x4 matrix, float minimumHeight) {
public GraphUpdateShape (Vector3[] points, bool convex, Matrix4x4 matrix, float minimumHeight) {
this.convex = convex;
this.points = points;
origin = matrix.MultiplyPoint3x4(Vector3.zero);
......@@ -83,7 +83,7 @@ namespace Pathfinding {
return GetBounds(convex ? _convexPoints : points, right, up, forward, origin, minimumHeight);
}
public static Bounds GetBounds (PF.Vector3[] points, Matrix4x4 matrix, float minimumHeight) {
public static Bounds GetBounds (Vector3[] points, Matrix4x4 matrix, float minimumHeight) {
var origin = matrix.MultiplyPoint3x4(Vector3.zero);
var right = matrix.MultiplyPoint3x4(Vector3.right) - origin;
var up = matrix.MultiplyPoint3x4(Vector3.up) - origin;
......@@ -92,7 +92,7 @@ namespace Pathfinding {
return GetBounds(points, right, up, forward, origin, minimumHeight);
}
static Bounds GetBounds (PF.Vector3[] points, Vector3 right, Vector3 up, Vector3 forward, Vector3 origin, float minimumHeight) {
static Bounds GetBounds (Vector3[] points, Vector3 right, Vector3 up, Vector3 forward, Vector3 origin, float minimumHeight) {
if (points == null || points.Length == 0) return new Bounds();
float miny = points[0].y, maxy = points[0].y;
for (int i = 0; i < points.Length; i++) {
......
......@@ -6,7 +6,7 @@ using Vector3 = UnityEngine.Vector3;
namespace Pathfinding.Util {
/** Interpolates along a sequence of points */
public class PathInterpolator {
List<PF.Vector3> path;
List<Vector3> path;
float distanceToSegmentStart;
float currentDistance;
......@@ -68,7 +68,7 @@ namespace Pathfinding.Util {
/** Set the path to interpolate along.
* This will reset all interpolation variables.
*/
public void SetPath (List<PF.Vector3> path) {
public void SetPath (List<Vector3> path) {
this.path = path;
currentDistance = 0;
segmentIndex = 0;
......@@ -125,7 +125,7 @@ namespace Pathfinding.Util {
MoveToSegment(bestIndex, bestFactor);
}
public void MoveToLocallyClosestPoint (PF.Vector3 point, bool allowForwards = true, bool allowBackwards = true) {
public void MoveToLocallyClosestPoint (Vector3 point, bool allowForwards = true, bool allowBackwards = true) {
if (path == null) return;
while (allowForwards && segmentIndex < path.Count - 2 && (path[segmentIndex+1] - point).sqrMagnitude <= (path[segmentIndex] - point).sqrMagnitude) {
......@@ -141,12 +141,12 @@ namespace Pathfinding.Util {
float factor1 = 0, factor2 = 0, d1 = float.PositiveInfinity, d2 = float.PositiveInfinity;
if (segmentIndex > 0) {
factor1 = VectorMath.ClosestPointOnLineFactor(path[segmentIndex-1], path[segmentIndex], point);
d1 = (PF.Vector3.Lerp(path[segmentIndex-1], path[segmentIndex], factor1) - point).sqrMagnitude;
d1 = (Vector3.Lerp(path[segmentIndex-1], path[segmentIndex], factor1) - point).sqrMagnitude;
}
if (segmentIndex < path.Count - 1) {
factor2 = VectorMath.ClosestPointOnLineFactor(path[segmentIndex], path[segmentIndex+1], point);
d2 = (PF.Vector3.Lerp(path[segmentIndex], path[segmentIndex+1], factor2) - point).sqrMagnitude;
d2 = (Vector3.Lerp(path[segmentIndex], path[segmentIndex+1], factor2) - point).sqrMagnitude;
}
if (d1 < d2) MoveToSegment(segmentIndex - 1, factor1);
......
......@@ -578,7 +578,7 @@ namespace Pathfinding.RVO.Sampled {
if (segment) {
// This part will only be reached for line obstacles (i.e not other agents)
if (det3 < radius) {
PF.Vector3 closestPointOnLine = VectorMath.ClosestPointOnSegment(segmentStart.ToPFV2(), segmentEnd.ToPFV2(), p.ToPFV2());
Vector3 closestPointOnLine = VectorMath.ClosestPointOnSegment(segmentStart.ToPFV2(), segmentEnd.ToPFV2(), p.ToPFV2());
var dirFromCenter = p.ToPFV2() - closestPointOnLine.ToV2();
float distToCenter;
gradient = VectorMath.Normalize(dirFromCenter, out distToCenter);
......
......@@ -152,12 +152,12 @@ namespace Pathfinding.Voxels {
// Transform from voxel space to graph space.
// then scale from voxel space (one unit equals one voxel)
// Finally add min
PF.Matrix4x4 voxelMatrix = PF.Matrix4x4.TRS(graphSpaceBounds.min, PF.Quaternion.identity, Vector3.one) * PF.Matrix4x4.Scale(new PF.Vector3(cellSize, cellHeight, cellSize));
Matrix4x4 voxelMatrix = Matrix4x4.TRS(graphSpaceBounds.min, Quaternion.identity, Vector3.one) * Matrix4x4.Scale(new Vector3(cellSize, cellHeight, cellSize));
transformVoxel2Graph = new GraphTransform(voxelMatrix);
// Transform from voxel space to world space
// add half a voxel to fix rounding
transform = graphTransform * voxelMatrix * PF.Matrix4x4.TRS(new Vector3(0.5f, 0, 0.5f), PF.Quaternion.identity, Vector3.one);
transform = graphTransform * voxelMatrix * Matrix4x4.TRS(new Vector3(0.5f, 0, 0.5f), Quaternion.identity, Vector3.one);
int maximumVoxelYCoord = (int)(graphSpaceBounds.size.y / cellHeight);
......
......@@ -4,29 +4,29 @@ namespace Pathfinding
{
public static class MathHelper
{
public static Vector3 ToUnityV3(this PF.Vector3 v3)
public static Vector3 ToUnityV3(this Vector3 v3)
{
return new Vector3(v3.x, v3.y, v3.z);
}
public static PF.Vector3 ToPFV3(this Vector3 v3)
public static Vector3 ToPFV3(this Vector3 v3)
{
return new PF.Vector3(v3.x, v3.y, v3.z);
return new Vector3(v3.x, v3.y, v3.z);
}
public static PF.Vector2 ToV2(this PF.Vector3 v3)
public static Vector2 ToV2(this Vector3 v3)
{
return new PF.Vector2(v3.x, v3.y);
return new Vector2(v3.x, v3.y);
}
public static Vector2 ToUnityV2(this PF.Vector2 v2)
public static Vector2 ToUnityV2(this Vector2 v2)
{
return new Vector3(v2.x, v2.y);
}
public static PF.Vector2 ToPFV2(this Vector2 v2)
public static Vector2 ToPFV2(this Vector2 v2)
{
return new PF.Vector2(v2.x, v2.y);
return new Vector2(v2.x, v2.y);
}
......
......@@ -22,13 +22,13 @@ namespace Pathfinding {
public ConstantTurn turnConstruct2 = new ConstantTurn();
public override void Apply (Path p) {
PF.Vector3[] vectorPath = p.vectorPath.ToArray();
Vector3[] vectorPath = p.vectorPath.ToArray();
if (vectorPath == null || vectorPath.Length <= 2) {
return;
}
List<PF.Vector3> newPath = new List<PF.Vector3>();
List<Vector3> newPath = new List<Vector3>();
newPath.Add(vectorPath[0]);
TurnConstructor.turningRadius = turningRadius;
......@@ -65,7 +65,7 @@ namespace Pathfinding {
p.vectorPath = newPath;
}
void EvaluatePaths (List<Turn> turnList, List<PF.Vector3> output) {
void EvaluatePaths (List<Turn> turnList, List<Vector3> output) {
turnList.Sort();
for (int j = 0; j < turnList.Count; j++) {
......@@ -110,7 +110,7 @@ namespace Pathfinding {
vaLeft = vaRight + Math.PI;
}
public override void Prepare (int i, PF.Vector3[] vectorPath) {
public override void Prepare (int i, Vector3[] vectorPath) {
preRightCircleCenter = rightCircleCenter;
preLeftCircleCenter = leftCircleCenter;
......@@ -273,7 +273,7 @@ namespace Pathfinding {
}
}
public override void GetPath (Turn turn, List<PF.Vector3> output) {
public override void GetPath (Turn turn, List<Vector3> output) {
switch (turn.id) {
case 0:
//Right - Point to tangent
......@@ -325,7 +325,7 @@ namespace Pathfinding {
bool clockwise;
public override void Prepare (int i, PF.Vector3[] vectorPath) {}
public override void Prepare (int i, Vector3[] vectorPath) {}
public override void TangentToTangent (List<Turn> turnList) {
Vector3 preNormal = Vector3.Cross(t1, Vector3.up);
......@@ -354,7 +354,7 @@ namespace Pathfinding {
turnList.Add(new Turn((float)beta, this, 0));
}
public override void GetPath (Turn turn, List<PF.Vector3> output) {
public override void GetPath (Turn turn, List<Vector3> output) {
AddCircleSegment(gamma1, gamma2, clockwise, circleCenter, output, (circleCenter - current).magnitude);
normal = (current - circleCenter).normalized;
......@@ -393,15 +393,15 @@ namespace Pathfinding {
public static bool changedPreviousTangent = false;
public abstract void Prepare (int i, PF.Vector3[] vectorPath);
public abstract void Prepare (int i, Vector3[] vectorPath);
public virtual void OnTangentUpdate () {}
public virtual void PointToTangent (List<Turn> turnList) {}
public virtual void TangentToPoint (List<Turn> turnList) {}
public virtual void TangentToTangent (List<Turn> turnList) {}
public abstract void GetPath (Turn turn, List<PF.Vector3> output);
public abstract void GetPath (Turn turn, List<Vector3> output);
//abstract void Evaluate (Turn turn);
public static void Setup (int i, PF.Vector3[] vectorPath) {
public static void Setup (int i, Vector3[] vectorPath) {
current = vectorPath[i];
prev = vectorPath[i-1];
next = vectorPath[i+1];
......@@ -426,7 +426,7 @@ namespace Pathfinding {
//Utilities
public void AddCircleSegment (double startAngle, double endAngle, bool clockwise, Vector3 center, List<PF.Vector3> output, float radius) {
public void AddCircleSegment (double startAngle, double endAngle, bool clockwise, Vector3 center, List<Vector3> output, float radius) {
double step = ThreeSixtyRadians / 100;
if (clockwise) {
......@@ -543,7 +543,7 @@ namespace Pathfinding {
this.constructor = constructor;
}
public void GetPath (List<PF.Vector3> output) {
public void GetPath (List<Vector3> output) {
constructor.GetPath(this, output);
}
......
......@@ -58,7 +58,7 @@ namespace Pathfinding {
return;
}
List<PF.Vector3> funnelPath = ListPool<PF.Vector3>.Claim();
List<Vector3> funnelPath = ListPool<Vector3>.Claim();
// Split the path into different parts (separated by custom links)
// and run the funnel algorithm on each of them in turn
......@@ -80,9 +80,9 @@ namespace Pathfinding {
var portals = Funnel.ConstructFunnelPortals(p.path, part);
var result = Funnel.Calculate(portals, unwrap, splitAtEveryPortal);
funnelPath.AddRange(result);
ListPool<PF.Vector3>.Release(ref portals.left);
ListPool<PF.Vector3>.Release(ref portals.right);
ListPool<PF.Vector3>.Release(ref result);
ListPool<Vector3>.Release(ref portals.left);
ListPool<Vector3>.Release(ref portals.right);
ListPool<Vector3>.Release(ref result);
} else {
// non-link parts will add the start/end points for the adjacent parts.
// So if there is no non-link part before this one, then we need to add the start point of the link
......@@ -99,7 +99,7 @@ namespace Pathfinding {
UnityEngine.Assertions.Assert.IsTrue(funnelPath.Count >= 1);
ListPool<Funnel.PathPart>.Release(ref parts);
// Pool the previous vectorPath
ListPool<PF.Vector3>.Release(ref p.vectorPath);
ListPool<Vector3>.Release(ref p.vectorPath);
p.vectorPath = funnelPath;
}
}
......
......@@ -133,12 +133,12 @@ namespace Pathfinding {
}
public override void Apply (Path p) {
List<PF.Vector3> vs = p.vectorPath;
List<Vector3> vs = p.vectorPath;
List<PF.Vector3> res = Apply(vs);
List<Vector3> res = Apply(vs);
if (res != vs) {
ListPool<PF.Vector3>.Release(ref p.vectorPath);
ListPool<Vector3>.Release(ref p.vectorPath);
p.vectorPath = res;
}
}
......@@ -149,7 +149,7 @@ namespace Pathfinding {
bool[] dir = new bool[10];
/** Apply this modifier on a raw Vector3 list */
public List<PF.Vector3> Apply (List<PF.Vector3> vs) {
public List<Vector3> Apply (List<Vector3> vs) {
if (vs == null || vs.Count < 3) return vs;
/** \todo Do something about these allocations */
......@@ -253,7 +253,7 @@ namespace Pathfinding {
}
}
List<PF.Vector3> res = ListPool<PF.Vector3>.Claim();
List<Vector3> res = ListPool<Vector3>.Claim();
res.Add(vs[0]);
if (detail < 1) detail = 1;
float step = (float)(2*Math.PI)/detail;
......
......@@ -107,7 +107,7 @@ namespace Pathfinding {
}
static readonly int[] iterationsByQuality = new [] { 1, 2, 1, 3 };
static List<PF.Vector3> buffer = new List<PF.Vector3>();
static List<Vector3> buffer = new List<Vector3>();
static float[] DPCosts = new float[16];
static int[] DPParents = new int[16];
......@@ -141,13 +141,13 @@ namespace Pathfinding {
p.vectorPath = points;
}
List<PF.Vector3> ApplyGreedy (Path p, List<PF.Vector3> points) {
List<Vector3> ApplyGreedy (Path p, List<Vector3> points) {
bool canBeOriginalNodes = points.Count == p.path.Count;
int startIndex = 0;
while (startIndex < points.Count) {
Vector3 start = points[startIndex];
var startNode = canBeOriginalNodes && points[startIndex] == (PF.Vector3)p.path[startIndex].position ? p.path[startIndex] : null;
var startNode = canBeOriginalNodes && points[startIndex] == (Vector3)p.path[startIndex].position ? p.path[startIndex] : null;
buffer.Add(start);
// Do a binary search to find the furthest node we can see from this node
......@@ -185,7 +185,7 @@ namespace Pathfinding {
return points;
}
List<PF.Vector3> ApplyDP (Path p, List<PF.Vector3> points) {
List<Vector3> ApplyDP (Path p, List<Vector3> points) {
if (DPCosts.Length < points.Count) {
DPCosts = new float[points.Count];
DPParents = new int[points.Count];
......@@ -195,15 +195,15 @@ namespace Pathfinding {
for (int i = 0; i < points.Count; i++) {
float d = DPCosts[i];
PF.Vector3 start = points[i];
var startIsOriginalNode = canBeOriginalNodes && start == (PF.Vector3)p.path[i].position;
Vector3 start = points[i];
var startIsOriginalNode = canBeOriginalNodes && start == (Vector3)p.path[i].position;
for (int j = i+1; j < points.Count; j++) {
// Total distance from the start to this point using the best simplified path
// The small additive constant is to make sure that the number of points is kept as small as possible
// even when the total distance is the same (which can happen with e.g multiple colinear points).
float d2 = d + (points[j] - start).magnitude + 0.0001f;
if (DPParents[j] == -1 || d2 < DPCosts[j]) {
var endIsOriginalNode = canBeOriginalNodes && points[j] == (PF.Vector3)p.path[j].position;
var endIsOriginalNode = canBeOriginalNodes && points[j] == (Vector3)p.path[j].position;
if (j == i+1 || ValidateLine(startIsOriginalNode ? p.path[i] : null, endIsOriginalNode ? p.path[j] : null, start, points[j])) {
DPCosts[j] = d2;
DPParents[j] = i;
......
......@@ -97,7 +97,7 @@ namespace Pathfinding {
return;
}
List<PF.Vector3> path = null;
List<Vector3> path = null;
switch (smoothType) {
case SmoothType.Simple:
......@@ -111,12 +111,12 @@ namespace Pathfinding {
}
if (path != p.vectorPath) {
ListPool<PF.Vector3>.Release(ref p.vectorPath);
ListPool<Vector3>.Release(ref p.vectorPath);
p.vectorPath = path;
}
}
public List<PF.Vector3> CurvedNonuniform (List<PF.Vector3> path) {
public List<Vector3> CurvedNonuniform (List<Vector3> path) {
if (maxSegmentLength <= 0) {
Debug.LogWarning("Max Segment Length is <= 0 which would cause DivByZero-exception or other nasty errors (avoid this)");
return path;
......@@ -134,7 +134,7 @@ namespace Pathfinding {
}
}
List<PF.Vector3> subdivided = ListPool<PF.Vector3>.Claim(pointCounter);
List<Vector3> subdivided = ListPool<Vector3>.Claim(pointCounter);
// Set first velocity
Vector3 preEndVel = (path[1]-path[0]).normalized;
......@@ -181,7 +181,7 @@ namespace Pathfinding {
h4*tan2;
}
public List<PF.Vector3> SmoothOffsetSimple (List<PF.Vector3> path) {
public List<Vector3> SmoothOffsetSimple (List<Vector3> path) {
if (path.Count <= 2 || iterations <= 0) {
return path;
}
......@@ -193,8 +193,8 @@ namespace Pathfinding {
int maxLength = (path.Count-2)*(int)Mathf.Pow(2, iterations)+2;
List<PF.Vector3> subdivided = ListPool<PF.Vector3>.Claim(maxLength);
List<PF.Vector3> subdivided2 = ListPool<PF.Vector3>.Claim(maxLength);
List<Vector3> subdivided = ListPool<Vector3>.Claim(maxLength);
List<Vector3> subdivided2 = ListPool<Vector3>.Claim(maxLength);
for (int i = 0; i < maxLength; i++) { subdivided.Add(Vector3.zero); subdivided2.Add(Vector3.zero); }
......@@ -206,7 +206,7 @@ namespace Pathfinding {
int currentPathLength = (path.Count-2)*(int)Mathf.Pow(2, iteration)+2;
//Switch the arrays
List<PF.Vector3> tmp = subdivided;
List<Vector3> tmp = subdivided;
subdivided = subdivided2;
subdivided2 = tmp;
......@@ -248,15 +248,15 @@ namespace Pathfinding {
subdivided[(path.Count-2)*(int)Mathf.Pow(2, iteration+1)+2-1] = subdivided2[currentPathLength-1];
}
ListPool<PF.Vector3>.Release(ref subdivided2);
ListPool<Vector3>.Release(ref subdivided2);
return subdivided;
}
public List<PF.Vector3> SmoothSimple (List<PF.Vector3> path) {
public List<Vector3> SmoothSimple (List<Vector3> path) {
if (path.Count < 2) return path;
List<PF.Vector3> subdivided;
List<Vector3> subdivided;
if (uniformLength) {
// Clamp to a small value to avoid the path being divided into a huge number of segments
......@@ -269,7 +269,7 @@ namespace Pathfinding {
int estimatedNumberOfSegments = Mathf.FloorToInt(pathLength / maxSegmentLength);
// Get a list with an initial capacity high enough so that we can add all points
subdivided = ListPool<PF.Vector3>.Claim(estimatedNumberOfSegments+2);
subdivided = ListPool<Vector3>.Claim(estimatedNumberOfSegments+2);
float distanceAlong = 0;
......@@ -299,7 +299,7 @@ namespace Pathfinding {
}
int steps = 1 << subdivisions;
subdivided = ListPool<PF.Vector3>.Claim((path.Count-1)*steps + 1);
subdivided = ListPool<Vector3>.Claim((path.Count-1)*steps + 1);
Polygon.Subdivide(path, subdivided, steps);
}
......@@ -322,11 +322,11 @@ namespace Pathfinding {
return subdivided;
}
public List<PF.Vector3> SmoothBezier (List<PF.Vector3> path) {
public List<Vector3> SmoothBezier (List<Vector3> path) {
if (subdivisions < 0) subdivisions = 0;
int subMult = 1 << subdivisions;
List<PF.Vector3> subdivided = ListPool<PF.Vector3>.Claim();
List<Vector3> subdivided = ListPool<Vector3>.Claim();
for (int i = 0; i < path.Count-1; i++) {
Vector3 tangent1;
......
......@@ -48,7 +48,7 @@ namespace Pathfinding.Util {
if (InSearchTree(node, debugData, debugPathID)) {
var pnode = debugData.GetPathNode(node);
if (pnode.parent != null) {
builder.DrawLine((PF.Vector3)node.position, (PF.Vector3)this.debugData.GetPathNode(node).parent.node.position, NodeColor(node));
builder.DrawLine((Vector3)node.position, (Vector3)this.debugData.GetPathNode(node).parent.node.position, NodeColor(node));
}
}
} else {
......@@ -57,13 +57,13 @@ namespace Pathfinding.Util {
drawConnectionColor = NodeColor(node);
// Get the node position
// Cast it here to avoid doing it for every neighbour
drawConnectionStart = ((PF.Vector3)node.position).ToUnityV3();
drawConnectionStart = ((Vector3)node.position).ToUnityV3();
node.GetConnections(drawConnection);
}
}
void DrawConnection (GraphNode other) {
builder.DrawLine(drawConnectionStart, Vector3.Lerp((PF.Vector3)other.position, drawConnectionStart, 0.5f), drawConnectionColor);
builder.DrawLine(drawConnectionStart, Vector3.Lerp((Vector3)other.position, drawConnectionStart, 0.5f), drawConnectionColor);
}
/** Color to use for gizmos.
......
......@@ -373,7 +373,7 @@ namespace Pathfinding {
Vector3 pt = center + dir;
if (g.Linecast(center, pt, nn.node, out hit)) {
if (hit.point == PF.Vector3.zero) {
if (hit.point == Vector3.zero) {
// Oops, linecast actually failed completely
// try again unless we have tried lots of times
// then we just continue anyway
......
using System.Collections.Generic;
using System;
using UnityEngine;
namespace PF {
......
//#define ASTARDEBUG //"BBTree Debug" If enables, some queries to the tree will show debug lines. Turn off multithreading when using this since DrawLine calls cannot be called from a different thread
using System;
using UnityEngine;
namespace PF {
......
using System.Collections.Generic;
using UnityEngine;
namespace PF {
......
using System.Collections.Generic;
using UnityEngine;
namespace PF {
......@@ -323,7 +324,7 @@ namespace PF {
*
* \see http://digestingduck.blogspot.se/2010/03/simple-stupid-funnel-algorithm.html
*/
public virtual bool GetPortal (GraphNode other, List<PF.Vector3> left, List<PF.Vector3> right, bool backwards) {
public virtual bool GetPortal (GraphNode other, List<Vector3> left, List<Vector3> right, bool backwards) {
return false;
}
......
using UnityEngine;
namespace PF {
/** Transforms to and from world space to a 2D movement plane.
* The transformation is guaranteed to be purely a rotation
......
using UnityEngine;
namespace PF {
/** Holds a coordinate in integers */
public struct Int3 : System.IEquatable<Int3> {
......@@ -58,20 +60,6 @@ namespace PF {
return new Vector3(ob.x*PrecisionFactor, ob.y*PrecisionFactor, ob.z*PrecisionFactor);
}
#if !SERVER
public static explicit operator Int3 (UnityEngine.Vector3 ob) {
return new Int3(
(int)System.Math.Round(ob.x*FloatPrecision),
(int)System.Math.Round(ob.y*FloatPrecision),
(int)System.Math.Round(ob.z*FloatPrecision)
);
}
public static explicit operator UnityEngine.Vector3 (Int3 ob) {
return new UnityEngine.Vector3(ob.x*PrecisionFactor, ob.y*PrecisionFactor, ob.z*PrecisionFactor);
}
#endif
public static Int3 operator - (Int3 lhs, Int3 rhs) {
lhs.x -= rhs.x;
lhs.y -= rhs.y;
......
using UnityEngine;
namespace PF
{
/** Integer Rectangle.
......
using UnityEngine;
namespace PF {
/** Exposes internal methods for graphs.
* This is used to hide methods that should not be used by any user code
......
using System.Collections.Generic;
using UnityEngine;
namespace PF {
using System.IO;
......
......@@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace PF {
......@@ -207,7 +208,7 @@ namespace PF {
public List<GraphNode> path;
/** Holds the (possibly post processed) path as a Vector3 list */
public List<PF.Vector3> vectorPath;
public List<Vector3> vectorPath;
/** The node currently being processed */
protected PathNode currentR;
......
using UnityEngine;
namespace PF
{
/** What data to draw the graph debugging with */
......
#define DECREASE_KEY
namespace PF {
/** Stores temporary node data for a single pathfinding request.
* Every node has one PathNode per thread used.
......
//#define ASTAR_NO_POOLING // Disable pooling for some reason. Maybe for debugging or just for measuring the difference.
using System;
using System.Collections.Generic;
using UnityEngine;
namespace PF {
/** Pools path objects to reduce load on the garbage collector */
......
using UnityEngine;
namespace PF {
/** Basic path, finds the shortest path from A to B.
* \ingroup paths
......
......@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace PF {
/** Finds all nodes within a specified distance from the start.
......
using UnityEngine;
namespace PF {
/** Returns a path heading away from a specified point to avoid.
* The search will terminate when G \> \a length (passed to the constructor) + FleePath.spread.\n
......
using System;
using System.Collections.Generic;
using UnityEngine;
namespace PF {
/** Floods the area completely for easy computation of any path to a single point.
......
using UnityEngine;
namespace PF {
/** Restrict suitable nodes by if they have been searched by a FloodPath.
*
......
using System.Collections.Generic;
using UnityEngine;
namespace PF {
/** A path which searches from one point to a number of different targets in one search or from a number of different start points to a single target.
......
using UnityEngine;
namespace PF {
/** Finds a path in a random direction from the start node.
* \ingroup paths
......
using UnityEngine;
namespace PF {
/** Extended Path.
* \ingroup paths
......
using System.Collections.Generic;
using UnityEngine;
namespace PF {
......
using System;
using System.IO;
using System.Collections.Generic;
using UnityEngine;
#if ASTAR_NO_ZIP
using Pathfinding.Serialization.Zip;
#elif NETFX_CORE
......
using System.Collections.Generic;
using System;
using UnityEngine;
#if NETFX_CORE
using System.Linq;
......
using UnityEngine;
namespace PF {
/** Interface for something that holds a triangle based navmesh */
public interface INavmeshHolder : ITransformedGraph, INavmesh {
......
......@@ -7,7 +7,7 @@ namespace ETModel
{
public static GizmosDebug Instance { get; private set; }
public List<PF.Vector3> Path;
public List<Vector3> Path;
private void Awake()
{
......
......@@ -120,13 +120,6 @@
<Compile Include="Assets\Model\Base\RecyclableMemoryStream\RecyclableMemoryStream.cs" />
<Compile Include="Assets\Model\Base\RecyclableMemoryStream\RecyclableMemoryStreamManager.cs" />
<Compile Include="Assets\Model\Base\TryLocker.cs" />
<Compile Include="Assets\Model\Base\UnityMath\Mathf.cs" />
<Compile Include="Assets\Model\Base\UnityMath\Matrix3x3.cs" />
<Compile Include="Assets\Model\Base\UnityMath\Matrix4x4.cs" />
<Compile Include="Assets\Model\Base\UnityMath\Quaternion.cs" />
<Compile Include="Assets\Model\Base\UnityMath\Vector2.cs" />
<Compile Include="Assets\Model\Base\UnityMath\Vector3.cs" />
<Compile Include="Assets\Model\Base\UnityMath\Vector4.cs" />
<Compile Include="Assets\Model\Base\UnOrderMultiMap.cs" />
<Compile Include="Assets\Model\Component\Config\ClientConfig.cs" />
<Compile Include="Assets\Model\Component\Config\DBConfig.cs" />
......@@ -225,7 +218,6 @@
<Compile Include="Assets\Model\ILBinding\Google_Protobuf_MessageParser_1_Google_Protobuf_Adapt_IMessage_Binding_Adapto_t.cs" />
<Compile Include="Assets\Model\ILBinding\Google_Protobuf_ProtoPreconditions_Binding.cs" />
<Compile Include="Assets\Model\ILBinding\LitJson_JsonMapper_Binding.cs" />
<Compile Include="Assets\Model\ILBinding\PF_Vector3_Binding.cs" />
<Compile Include="Assets\Model\ILBinding\ReferenceCollector_Binding.cs" />
<Compile Include="Assets\Model\ILBinding\System_Action_1_Google_Protobuf_Adapt_IMessage_Binding_Adaptor_Binding.cs" />
<Compile Include="Assets\Model\ILBinding\System_Activator_Binding.cs" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册