Prechádzať zdrojové kódy

Extra setters for JoltPhysics.js (#730)

Jorrit Rouwe 1 rok pred
rodič
commit
f8da353840
4 zmenil súbory, kde vykonal 22 pridanie a 0 odobranie
  1. 9 0
      Jolt/Math/Quat.h
  2. 3 0
      Jolt/Math/Vec3.h
  3. 3 0
      Jolt/Math/Vec4.h
  4. 7 0
      Jolt/Math/Vector.h

+ 9 - 0
Jolt/Math/Quat.h

@@ -83,6 +83,15 @@ public:
 	/// Get the quaternion as a Vec4
 	/// Get the quaternion as a Vec4
 	JPH_INLINE Vec4 			GetXYZW() const													{ return mValue; }
 	JPH_INLINE Vec4 			GetXYZW() const													{ return mValue; }
 
 
+	/// Set individual components
+	JPH_INLINE void				SetX(float inX)													{ mValue.SetX(inX); }
+	JPH_INLINE void				SetY(float inY)													{ mValue.SetY(inY); }
+	JPH_INLINE void				SetZ(float inZ)													{ mValue.SetZ(inZ); }
+	JPH_INLINE void				SetW(float inW)													{ mValue.SetW(inW); }
+
+	/// Set all components
+	JPH_INLINE void				Set(float inX, float inY, float inZ, float inW)					{ mValue.Set(inX, inY, inZ, inW); }
+
 	///@}
 	///@}
 	///@name Default quaternions
 	///@name Default quaternions
 	///@{
 	///@{

+ 3 - 0
Jolt/Math/Vec3.h

@@ -130,6 +130,9 @@ public:
 	JPH_INLINE void				SetY(float inY)									{ mF32[1] = inY; }
 	JPH_INLINE void				SetY(float inY)									{ mF32[1] = inY; }
 	JPH_INLINE void				SetZ(float inZ)									{ mF32[2] = mF32[3] = inZ; } // Assure Z and W are the same
 	JPH_INLINE void				SetZ(float inZ)									{ mF32[2] = mF32[3] = inZ; } // Assure Z and W are the same
 
 
+	/// Set all components
+	JPH_INLINE void				Set(float inX, float inY, float inZ)			{ *this = Vec3(inX, inY, inZ); }
+
 	/// Get float component by index
 	/// Get float component by index
 	JPH_INLINE float			operator [] (uint inCoordinate) const			{ JPH_ASSERT(inCoordinate < 3); return mF32[inCoordinate]; }
 	JPH_INLINE float			operator [] (uint inCoordinate) const			{ JPH_ASSERT(inCoordinate < 3); return mF32[inCoordinate]; }
 
 

+ 3 - 0
Jolt/Math/Vec4.h

@@ -122,6 +122,9 @@ public:
 	JPH_INLINE void				SetZ(float inZ)									{ mF32[2] = inZ; }
 	JPH_INLINE void				SetZ(float inZ)									{ mF32[2] = inZ; }
 	JPH_INLINE void				SetW(float inW)									{ mF32[3] = inW; }
 	JPH_INLINE void				SetW(float inW)									{ mF32[3] = inW; }
 
 
+	/// Set all components
+	JPH_INLINE void				Set(float inX, float inY, float inZ, float inW)	{ *this = Vec4(inX, inY, inZ, inW); }
+
 	/// Get float component by index
 	/// Get float component by index
 	JPH_INLINE float			operator [] (uint inCoordinate) const			{ JPH_ASSERT(inCoordinate < 4); return mF32[inCoordinate]; }
 	JPH_INLINE float			operator [] (uint inCoordinate) const			{ JPH_ASSERT(inCoordinate < 4); return mF32[inCoordinate]; }
 	JPH_INLINE float &			operator [] (uint inCoordinate)					{ JPH_ASSERT(inCoordinate < 4); return mF32[inCoordinate]; }
 	JPH_INLINE float &			operator [] (uint inCoordinate)					{ JPH_ASSERT(inCoordinate < 4); return mF32[inCoordinate]; }

+ 7 - 0
Jolt/Math/Vector.h

@@ -119,6 +119,13 @@ public:
 		return v;
 		return v;
 	}
 	}
 
 
+	inline Vector &				operator /= (float inV2)
+	{
+		for (uint r = 0; r < Rows; ++r)
+			mF32[r] /= inV2;
+		return *this;
+	}
+
 	/// Add two float vectors (component wise)
 	/// Add two float vectors (component wise)
 	inline Vector				operator + (const Vector &inV2) const
 	inline Vector				operator + (const Vector &inV2) const
 	{
 	{