修改了Vector3D的Equals和GetHashCode方法

This commit is contained in:
Tian jianyong 2024-10-21 01:32:08 +08:00
parent 2f692dffbd
commit cabe390112

View File

@ -109,6 +109,20 @@ namespace ActiveProtect.Models
return !(left == right);
}
public override bool Equals(object? obj)
{
if (obj is Vector3D other)
{
return this == other;
}
return false;
}
public override int GetHashCode()
{
return HashCode.Combine(X, Y, Z);
}
/// <summary>
/// 计算向量的模长
/// </summary>
@ -190,6 +204,7 @@ namespace ActiveProtect.Models
Vector3D unitDirection = direction.Normalize();
return a + unitDirection * distance;
}
}
/// <summary>