diff --git a/Assets/NanoBrain/LinearAlgebra/src/Vector2Float.cs b/Assets/NanoBrain/LinearAlgebra/src/Vector2Float.cs
index e0418a8..ac1867c 100644
--- a/Assets/NanoBrain/LinearAlgebra/src/Vector2Float.cs
+++ b/Assets/NanoBrain/LinearAlgebra/src/Vector2Float.cs
@@ -324,27 +324,13 @@ namespace LinearAlgebra {
public static Vector2Float Scale(Vector2Float v1, Vector2Float v2) {
return new Vector2Float(v1.horizontal * v2.horizontal, v1.vertical * v2.vertical);
}
-
- /*
+
///
/// Tests if the vector has equal values as the given vector
///
/// The vector to compare to
/// true if the vector values are equal
- public bool Equals(Vector2Float v1) => horizontal == v1.horizontal && vertical == v1.vertical;
-
- ///
- /// Tests if the vector is equal to the given object
- ///
- /// The object to compare to
- /// false when the object is not a Vector2 or does not have equal values
- public override bool Equals(object obj) {
- if (!(obj is Vector2Float v))
- return false;
-
- return (horizontal == v.horizontal && vertical == v.vertical);
- }
- */
+ //public readonly bool Equals(Vector2Float v1) => horizontal == v1.horizontal && vertical == v1.vertical;
///
/// Tests if the two vectors have equal values
@@ -372,15 +358,25 @@ namespace LinearAlgebra {
return (v1.horizontal != v2.horizontal || v1.vertical != v2.vertical);
}
- /*
+ ///
+ /// Tests if the vector is equal to the given object
+ ///
+ /// The object to compare to
+ /// false when the object is not a Vector2 or does not have equal values
+ public override readonly bool Equals(object obj) {
+ if (obj is not Vector2Float v)
+ return false;
+
+ return (horizontal == v.horizontal && vertical == v.vertical);
+ }
+
///
/// Get an hash code for the vector
///
/// The hash code
- public override int GetHashCode() {
- return (horizontal, vertical).GetHashCode();
+ public override readonly int GetHashCode() {
+ return HashCode.Combine(horizontal, vertical);
}
- */
///
/// Get the distance between two vectors
diff --git a/Assets/NanoBrain/LinearAlgebra/src/Vector2Int.cs b/Assets/NanoBrain/LinearAlgebra/src/Vector2Int.cs
index 0eca7dc..ed68e8b 100644
--- a/Assets/NanoBrain/LinearAlgebra/src/Vector2Int.cs
+++ b/Assets/NanoBrain/LinearAlgebra/src/Vector2Int.cs
@@ -60,17 +60,6 @@ namespace LinearAlgebra {
/// true if the vector values are equal
public readonly bool Equals(Vector2Int v) => this.horizontal == v.horizontal && vertical == v.vertical;
- ///
- /// Tests if the vector is equal to the given object
- ///
- /// The object to compare to
- /// false when the object is not a Vector2 or does not have equal values
- public override readonly bool Equals(object obj) {
- if (obj is not Vector2Int v)
- return false;
-
- return (this.horizontal == v.horizontal && this.vertical == v.vertical);
- }
*/
///
@@ -98,6 +87,26 @@ namespace LinearAlgebra {
return (v1.horizontal != v2.horizontal || v1.vertical != v2.vertical);
}
+ ///
+ /// Tests if the vector is equal to the given object
+ ///
+ /// The object to compare to
+ /// false when the object is not a Vector2 or does not have equal values
+ public override readonly bool Equals(object obj) {
+ if (obj is not Vector2Int v)
+ return false;
+
+ return (this.horizontal == v.horizontal && this.vertical == v.vertical);
+ }
+
+ ///
+ /// Get an hash code for the vector
+ ///
+ /// The hash code
+ public override readonly int GetHashCode() {
+ return HashCode.Combine(horizontal, vertical);
+ }
+
public readonly float sqrMagnitude => this.horizontal * this.horizontal + this.vertical * this.vertical;
public static float SqrMagnitudeOf(Vector2Int v) {
diff --git a/Assets/NanoBrain/LinearAlgebra/src/Vector3Float.cs b/Assets/NanoBrain/LinearAlgebra/src/Vector3Float.cs
index bff0936..d8208d3 100644
--- a/Assets/NanoBrain/LinearAlgebra/src/Vector3Float.cs
+++ b/Assets/NanoBrain/LinearAlgebra/src/Vector3Float.cs
@@ -250,30 +250,22 @@ namespace LinearAlgebra {
public static Vector3Float operator *(Vector3Float v1, float d) {
- Vector3Float v = new Vector3Float(v1.horizontal * d, v1.vertical * d, v1.depth * d);
+ Vector3Float v = new(v1.horizontal * d, v1.vertical * d, v1.depth * d);
return v;
}
public static Vector3Float operator *(float d, Vector3Float v1) {
- Vector3Float v = new Vector3Float(d * v1.horizontal, d * v1.vertical, d * v1.depth);
+ Vector3Float v = new(d * v1.horizontal, d * v1.vertical, d * v1.depth);
return v;
}
public static Vector3Float operator /(Vector3Float v1, float d) {
- Vector3Float v = new Vector3Float(v1.horizontal / d, v1.vertical / d, v1.depth / d);
+ Vector3Float v = new(v1.horizontal / d, v1.vertical / d, v1.depth / d);
return v;
}
- /*
- public bool Equals(Vector3Float v) => (horizontal == v.horizontal && vertical == v.vertical && depth == v.depth);
-
- public override bool Equals(object obj) {
- if (!(obj is Vector3Float v))
- return false;
-
- return (horizontal == v.horizontal && vertical == v.vertical && depth == v.depth);
- }
- */
+
+ //public bool Equals(Vector3Float v) => (horizontal == v.horizontal && vertical == v.vertical && depth == v.depth);
public static bool operator ==(Vector3Float v1, Vector3Float v2) {
return (v1.horizontal == v2.horizontal && v1.vertical == v2.vertical && v1.depth == v2.depth);
@@ -283,9 +275,16 @@ namespace LinearAlgebra {
return (v1.horizontal != v2.horizontal || v1.vertical != v2.vertical || v1.depth != v2.depth);
}
- // public override int GetHashCode() {
- // return (horizontal, vertical, depth).GetHashCode();
- // }
+ public override readonly bool Equals(object obj) {
+ if (obj is not Vector3Float v)
+ return false;
+
+ return (horizontal == v.horizontal && vertical == v.vertical && depth == v.depth);
+ }
+
+ public override readonly int GetHashCode() {
+ return HashCode.Combine(horizontal, vertical, depth);
+ }
/// @brief The distance between two vectors
/// @param v1 The first vector
diff --git a/Assets/NanoBrain/VisualEditor/Editor/NanoBrainEditor.cs b/Assets/NanoBrain/VisualEditor/Editor/NanoBrainEditor.cs
index f1946f3..31938b1 100644
--- a/Assets/NanoBrain/VisualEditor/Editor/NanoBrainEditor.cs
+++ b/Assets/NanoBrain/VisualEditor/Editor/NanoBrainEditor.cs
@@ -501,7 +501,7 @@ public static class OpenAssetHandler {
// Called when an asset is double-clicked or opened.
[OnOpenAsset]
public static bool OpenMyScriptableObject(int instanceID, int line) {
- NanoBrainObj obj = EditorUtility.InstanceIDToObject(instanceID) as NanoBrainObj;
+ NanoBrainObj obj = EditorUtility.EntityIdToObject(instanceID) as NanoBrainObj;
if (obj != null) {
NanoBrainEditor.Open(obj);
return true; // handled