Browse Source

Added operator overloads for multiplying IntVectors

Modanung 8 years ago
parent
commit
b8ab2cf1d1
2 changed files with 46 additions and 0 deletions
  1. 22 0
      Source/Urho3D/Math/Vector2.h
  2. 24 0
      Source/Urho3D/Math/Vector3.h

+ 22 - 0
Source/Urho3D/Math/Vector2.h

@@ -86,9 +86,15 @@ public:
     /// Multiply with a scalar.
     /// Multiply with a scalar.
     IntVector2 operator *(int rhs) const { return IntVector2(x_ * rhs, y_ * rhs); }
     IntVector2 operator *(int rhs) const { return IntVector2(x_ * rhs, y_ * rhs); }
 
 
+    /// Multiply with a vector.
+    IntVector2 operator *(const IntVector2& rhs) const { return IntVector2(x_ * rhs.x_, y_ * rhs.y_); }
+
     /// Divide by a scalar.
     /// Divide by a scalar.
     IntVector2 operator /(int rhs) const { return IntVector2(x_ / rhs, y_ / rhs); }
     IntVector2 operator /(int rhs) const { return IntVector2(x_ / rhs, y_ / rhs); }
 
 
+    /// Divide by a vector.
+    IntVector2 operator /(const IntVector2& rhs) const { return IntVector2(x_ / rhs.x_, y_ / rhs.y_); }
+
     /// Add-assign a vector.
     /// Add-assign a vector.
     IntVector2& operator +=(const IntVector2& rhs)
     IntVector2& operator +=(const IntVector2& rhs)
     {
     {
@@ -113,6 +119,14 @@ public:
         return *this;
         return *this;
     }
     }
 
 
+    /// Multiply-assign a vector.
+    IntVector2& operator *=(const IntVector2& rhs)
+    {
+        x_ *= rhs.x_;
+        y_ *= rhs.y_;
+        return *this;
+    }
+
     /// Divide-assign a scalar.
     /// Divide-assign a scalar.
     IntVector2& operator /=(int rhs)
     IntVector2& operator /=(int rhs)
     {
     {
@@ -121,6 +135,14 @@ public:
         return *this;
         return *this;
     }
     }
 
 
+    /// Divide-assign a vector.
+    IntVector2& operator /=(const IntVector2& rhs)
+    {
+        x_ /= rhs.x_;
+        y_ /= rhs.y_;
+        return *this;
+    }
+
     /// Return integer data.
     /// Return integer data.
     const int* Data() const { return &x_; }
     const int* Data() const { return &x_; }
 
 

+ 24 - 0
Source/Urho3D/Math/Vector3.h

@@ -91,9 +91,15 @@ public:
     /// Multiply with a scalar.
     /// Multiply with a scalar.
     IntVector3 operator *(int rhs) const { return IntVector3(x_ * rhs, y_ * rhs, z_ * rhs); }
     IntVector3 operator *(int rhs) const { return IntVector3(x_ * rhs, y_ * rhs, z_ * rhs); }
 
 
+    /// Multiply with a vector.
+    IntVector3 operator *(const IntVector3& rhs) const { return IntVector3(x_ * rhs.x_, y_ * rhs.y_, z_ * rhs.z_); }
+
     /// Divide by a scalar.
     /// Divide by a scalar.
     IntVector3 operator /(int rhs) const { return IntVector3(x_ / rhs, y_ / rhs, z_ / rhs); }
     IntVector3 operator /(int rhs) const { return IntVector3(x_ / rhs, y_ / rhs, z_ / rhs); }
 
 
+    /// Divide by a vector.
+    IntVector3 operator /(const IntVector3& rhs) const { return IntVector3(x_ / rhs.x_, y_ / rhs.y_, z_ / rhs.z_); }
+
     /// Add-assign a vector.
     /// Add-assign a vector.
     IntVector3& operator +=(const IntVector3& rhs)
     IntVector3& operator +=(const IntVector3& rhs)
     {
     {
@@ -121,6 +127,15 @@ public:
         return *this;
         return *this;
     }
     }
 
 
+    /// Multiply-assign a vector.
+    IntVector3& operator *=(const IntVector3& rhs)
+    {
+        x_ *= rhs.x_;
+        y_ *= rhs.y_;
+        z_ *= rhs.z_;
+        return *this;
+    }
+
     /// Divide-assign a scalar.
     /// Divide-assign a scalar.
     IntVector3& operator /=(int rhs)
     IntVector3& operator /=(int rhs)
     {
     {
@@ -130,6 +145,15 @@ public:
         return *this;
         return *this;
     }
     }
 
 
+    /// Divide-assign a vector.
+    IntVector3& operator /=(const IntVector3& rhs)
+    {
+        x_ /= rhs.x_;
+        y_ /= rhs.y_;
+        z_ /= rhs.z_;
+        return *this;
+    }
+
     /// Return integer data.
     /// Return integer data.
     const int* Data() const { return &x_; }
     const int* Data() const { return &x_; }