Kaynağa Gözat

Added '/' operator for vector3 and float.

It divides the components of the vector by the float, and returns a new vector.
Rachel Brindle 13 yıl önce
ebeveyn
işleme
a4a12dba2e
2 değiştirilmiş dosya ile 15 ekleme ve 0 silme
  1. 10 0
      gameplay/src/Vector3.h
  2. 5 0
      gameplay/src/Vector3.inl

+ 10 - 0
gameplay/src/Vector3.h

@@ -424,6 +424,16 @@ public:
      * @return The scaled vector.
      */
     inline const Vector3 operator*(float x) const;
+    
+    /**
+     * Returns the components of this vector divided by the given constant
+     *
+     * Note: this does not modify this vector.
+     *
+     * @param x the constant to divide this vector with
+     * @return a smaller vector
+     */
+    inline const Vector3 operator/(float x) const;
 
     /**
      * Scales this vector by the given value.

+ 5 - 0
gameplay/src/Vector3.inl

@@ -57,6 +57,11 @@ inline Vector3& Vector3::operator*=(float x)
     return *this;
 }
 
+inline const Vector3 Vector3::operator/(const float x) const
+{
+    return Vector3(this->x / x, this->y / x, this->z / x);
+}
+
 inline bool Vector3::operator<(const Vector3& v) const
 {
     if (x == v.x)