diff --git a/.gitignore b/.gitignore index c5f06a6..090149c 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,7 @@ local.properties [Rr]elease/ *_i.c *_p.c +[Bb]uildlog.htm *.ilk *.meta *.o diff --git a/include/Audio/AudioCategory.h b/include/Audio/AudioCategory.h index 9a6393e..0ca467e 100644 --- a/include/Audio/AudioCategory.h +++ b/include/Audio/AudioCategory.h @@ -1,8 +1,16 @@ +/***************************************************************************** + * AudioCategory.h * + * * + * XFX AudioCategory definition file * + * Copyright (c) XFX Team. All Rights Reserved * + *****************************************************************************/ #ifndef XFX_AUDIO_AUDIOCATEGORY_H #define XFX_AUDIO_AUDIOCATEGORY_H #include +using namespace System; + namespace XFX { namespace Audio @@ -11,14 +19,16 @@ namespace XFX { String Name; + int GetType() const; void Pause(); - bool operator!=(const AudioCategory &other) const; - bool operator==(const AudioCategory &other) const; void Resume(); void SetVolume(float volume); void Stop(); + + bool operator!=(const AudioCategory& other) const; + bool operator==(const AudioCategory& other) const; }; } } -#endif //XFX_AUDIO_AUDIOCATEGORY_H +#endif // XFX_AUDIO_AUDIOCATEGORY_H diff --git a/include/Audio/AudioEngine.h b/include/Audio/AudioEngine.h index 3505388..7b7952c 100644 --- a/include/Audio/AudioEngine.h +++ b/include/Audio/AudioEngine.h @@ -1,15 +1,17 @@ -/******************************************************** - * AudioEngine.h * - * * - * XFramework AudioEngine definition file * - * Copyright © XFX Team. All Rights Reserved * - ********************************************************/ -#ifndef XFRAMEWORK_AUDIOENGINE_H -#define XFRAMEWORK_AUDIOENGINE_H +/***************************************************************************** + * AudioEngine.h * + * * + * XFX AudioEngine definition file * + * Copyright (c) XFX Team. All Rights Reserved * + *****************************************************************************/ +#ifndef XFX_AUDIO_AUDIOENGINE_H +#define XFX_AUDIO_AUDIOENGINE_H -#include "System/System.h" +#include -namespace XFramework +using namespace System; + +namespace XFX { namespace Audio { @@ -17,23 +19,23 @@ namespace XFramework class AudioEngine { - protected: - virtual void Dispose(int disposing); + protected: + virtual void Dispose(int disposing); - public: - const int ContentVersion; //XACT version supported + public: + const int ContentVersion; //XACT version supported - AudioEngine(); //Initialize the audio engine for direct wav play. - AudioEngine(char* settingsFile); //Initialize the audio engine for XACT - AudioEngine(char* settingsFile, Timespan &lookAheadTime, char* rendererId); + AudioEngine(); //Initialize the audio engine for direct wav play. + AudioEngine(String& settingsFile); //Initialize the audio engine for XACT + AudioEngine(String& settingsFile, TimeSpan lookAheadTime, char* rendererId); - void Dispose(); - AudioCategory GetCategory(char* name); - float GetGlobalVariable(char* name); - void SetGlobalVariable(char* name, float value); - void Update(); + void Dispose(); + AudioCategory GetCategory(String& name); + float GetGlobalVariable(String& name); + void SetGlobalVariable(String& name, float value); + void Update(); }; } } -#endif //XFRAMEWORK_AUDIOENGINE_H +#endif // XFX_AUDIO_AUDIOENGINE_H diff --git a/include/BoundingBox.h b/include/BoundingBox.h index 97ff58d..097f849 100644 --- a/include/BoundingBox.h +++ b/include/BoundingBox.h @@ -1,9 +1,9 @@ -/******************************************************** - * BoundingBox.h * - * * - * XFX BoundingBox definition file * - * Copyright © XFX Team. All Rights Reserved * - ********************************************************/ +/***************************************************************************** + * BoundingBox.h * + * * + * XFX BoundingBox definition file * + * Copyright (c) XFX Team. All Rights Reserved * + *****************************************************************************/ #ifndef _XFX_BOUNDINGBOX_ #define _XFX_BOUNDINGBOX_ @@ -29,29 +29,29 @@ namespace XFX BoundingBox(const BoundingBox &obj); BoundingBox(); - ContainmentType_t Contains(const BoundingBox box) const; - void Contains(const BoundingBox& box, out ContainmentType_t& result) const; - ContainmentType_t Contains(const BoundingSphere sphere) const; - void Contains(const BoundingSphere& sphere, out ContainmentType_t& result) const; - ContainmentType_t Contains(const Vector3 vector) const; - void Contains(const Vector3& vector, out ContainmentType_t& result) const; - static BoundingBox CreateFromPoints(const Vector3 points[], const int startIndex, const int length); - static BoundingBox CreateFromSphere(const BoundingSphere sphere); - static void CreateFromSphere(const BoundingSphere& sphere, out BoundingBox& result); - static BoundingBox CreateMerged(const BoundingBox box1, const BoundingBox box2); - static void CreateMerged(const BoundingBox& box1, const BoundingBox& box2, out BoundingBox& result); - bool Equals(const Object* obj) const; + ContainmentType_t Contains(BoundingBox box) const; + void Contains(BoundingBox box, out ContainmentType_t& result) const; + ContainmentType_t Contains(BoundingSphere sphere) const; + void Contains(BoundingSphere sphere, out ContainmentType_t& result) const; + ContainmentType_t Contains(Vector3 vector) const; + void Contains(Vector3 vector, out ContainmentType_t& result) const; + static BoundingBox CreateFromPoints(Vector3 points[], int startIndex, int length); + static BoundingBox CreateFromSphere(BoundingSphere sphere); + static void CreateFromSphere(BoundingSphere sphere, out BoundingBox& result); + static BoundingBox CreateMerged(BoundingBox box1, BoundingBox box2); + static void CreateMerged(BoundingBox box1, BoundingBox box2, out BoundingBox& result); + bool Equals(Object const * const obj) const; bool Equals(const BoundingBox obj) const; int GetHashCode() const; int GetType() const; - bool Intersects(const BoundingBox box) const; - void Intersects(const BoundingBox& box, out bool& result) const; - bool Intersects(const BoundingSphere sphere) const; - void Intersects(const BoundingSphere& sphere, out bool& result) const; - PlaneIntersectionType_t Intersects(const Plane plane) const; - void Intersects(const Plane& plane, out PlaneIntersectionType_t& result) const; - float Intersects(const Ray ray) const; - void Intersects(const Ray& ray, out float& distance) const; + bool Intersects(BoundingBox box) const; + void Intersects(BoundingBox box, out bool& result) const; + bool Intersects(BoundingSphere sphere) const; + void Intersects(BoundingSphere sphere, out bool& result) const; + PlaneIntersectionType_t Intersects(Plane plane) const; + void Intersects(Plane plane, out PlaneIntersectionType_t& result) const; + float Intersects(Ray ray) const; + void Intersects(Ray ray, out float& distance) const; const char* ToString() const; bool operator!=(const BoundingBox& other) const; diff --git a/include/Graphics/Color.h b/include/Graphics/Color.h index 546aa07..9ce790b 100644 --- a/include/Graphics/Color.h +++ b/include/Graphics/Color.h @@ -1,9 +1,9 @@ -/******************************************************** - * Color.h * - * * - * XFX Color definition file * - * Copyright © XFX Team. All Rights Reserved * - ********************************************************/ +/***************************************************************************** + * Color.h * + * * + * XFX Color definition file * + * Copyright (c) XFX Team. All Rights Reserved * + *****************************************************************************/ #ifndef _XFX_GRAPHICS_COLOR_ #define _XFX_GRAPHICS_COLOR_ @@ -23,9 +23,9 @@ namespace XFX struct Color : IEquatable, Object { private: - unsigned int _packedValue; + uint _packedValue; - unsigned int RGBAtoARGB(unsigned int value); + unsigned int RGBAtoARGB(uint value); Color(unsigned int packedValue); static unsigned int InitializeFromVector4(const Vector4 vector); static unsigned int InitializeFromVector3(const Vector3 vector); @@ -185,7 +185,7 @@ namespace XFX Color(const byte r, const byte g, const byte b, const byte a); Color(const Color &obj); - bool Equals(const Object* obj) const; + bool Equals(Object const * const obj) const; bool Equals(const Color other) const; int GetHashCode() const; int GetType() const; diff --git a/include/Graphics/DisplayMode.h b/include/Graphics/DisplayMode.h index b039fda..9f02ec6 100644 --- a/include/Graphics/DisplayMode.h +++ b/include/Graphics/DisplayMode.h @@ -1,9 +1,9 @@ -/******************************************************** - * DisplayMode.h * - * * - * XFX DisplayMode structure definition file * - * Copyright © XFX Team. All Rights Reserved * - ********************************************************/ +/***************************************************************************** + * DisplayMode.h * + * * + * XFX DisplayMode structure definition file * + * Copyright (c) XFX Team. All Rights Reserved * + *****************************************************************************/ #ifndef _XFX_GRAPHICS_DISPLAYMODE_ #define _XFX_GRAPHICS_DISPLAYMODE_ @@ -29,7 +29,7 @@ namespace XFX int Width; DisplayMode(); - bool Equals(const Object* obj) const; + bool Equals(Object const * const obj) const; int GetHashCode() const; int GetType() const; diff --git a/include/Graphics/DisplayModeCollection.h b/include/Graphics/DisplayModeCollection.h index 750a206..7a8512b 100644 --- a/include/Graphics/DisplayModeCollection.h +++ b/include/Graphics/DisplayModeCollection.h @@ -1,9 +1,9 @@ -/******************************************************** - * DisplayModeCollection.h * - * * - * XFX DisplayModeCollection definition file * - * Copyright © XFX Team. All Rights Reserved * - ********************************************************/ +/***************************************************************************** + * DisplayModeCollection.h * + * * + * XFX DisplayModeCollection definition file * + * Copyright (c) XFX Team. All Rights Reserved * + *****************************************************************************/ #ifndef _XFX_GRAPHICS_DISPLAYMODECOLLECTION_ #define _XFX_GRAPHICS_DISPLAYMODECOLLECTION_ @@ -19,7 +19,7 @@ namespace XFX namespace Graphics { // Manipulates a collection of DisplayMode structures. - struct DisplayModeCollection + struct DisplayModeCollection : Object { private: int adapterOrdinal; @@ -30,9 +30,10 @@ namespace XFX public: DisplayModeCollection(); - bool Equals(Object* obj) const; + bool Equals(Object const * const obj) const; IEnumerator* GetEnumerator(); int GetHashCode() const; + int GetType() const; bool operator!=(const DisplayModeCollection& other) const; bool operator==(const DisplayModeCollection& other) const; diff --git a/include/Plane.h b/include/Plane.h index 7c237dc..dd0a83c 100644 --- a/include/Plane.h +++ b/include/Plane.h @@ -1,9 +1,9 @@ -/******************************************************** - * Plane.h * - * * - * XFX Plane definition file * - * Copyright © XFX Team. All Rights Reserved * - ********************************************************/ +/***************************************************************************** + * Plane.h * + * * + * XFX Plane definition file * + * Copyright (c) XFX Team. All Rights Reserved * + *****************************************************************************/ #ifndef _XFX_PLANE_ #define _XFX_PLANE_ @@ -35,27 +35,27 @@ namespace XFX Plane(); float Dot(const Vector4 value) const; - void Dot(const Vector4 value, out float result) const; + void Dot(const Vector4 value, out float& result) const; float DotCoordinate(const Vector3 value) const; - void DotCoordinate(const Vector3 value, out float result) const; + void DotCoordinate(const Vector3 value, out float& result) const; float DotNormal(const Vector3 value) const; - void DotNormal(const Vector3 value, out float result) const; - bool Equals(const Object* obj) const; + void DotNormal(const Vector3 value, out float& result) const; + bool Equals(Object const * const obj) const; bool Equals(const Plane obj) const; int GetHashCode() const; int GetType() const; PlaneIntersectionType_t Intersects(const BoundingBox boundingbox) const; - void Intersects(const BoundingBox boundingbox, out PlaneIntersectionType_t result) const; + void Intersects(const BoundingBox boundingbox, out PlaneIntersectionType_t& result) const; PlaneIntersectionType_t Intersects(const BoundingSphere sphere) const; - void Intersects(const BoundingSphere sphere, out PlaneIntersectionType_t result) const; + void Intersects(const BoundingSphere sphere, out PlaneIntersectionType_t& result) const; void Normalize(); static Plane Normalize(const Plane plane); - static void Normalize(const Plane plane, out Plane result); + static void Normalize(const Plane plane, out Plane& result); const char* ToString() const; static Plane Transform(const Plane plane, const Matrix matrix); - static void Transform(const Plane plane, const Matrix matrix, out Plane result); + static void Transform(const Plane plane, const Matrix matrix, out Plane& result); static Plane Transform(const Plane plane, const Quaternion quaternion); - static void Transform(const Plane plane, const Quaternion quaternion, out Plane result); + static void Transform(const Plane plane, const Quaternion quaternion, out Plane& result); bool operator==(const Plane& other) const; bool operator!=(const Plane& other) const; diff --git a/include/Quaternion.h b/include/Quaternion.h index 4a9f662..a51b27d 100644 --- a/include/Quaternion.h +++ b/include/Quaternion.h @@ -1,9 +1,9 @@ -/******************************************************** - * Quaternion.h * - * * - * XFX Quaternion definition file * - * Copyright © XFX Team. All Rights Reserved * - ********************************************************/ +/***************************************************************************** + * Quaternion.h * + * * + * XFX Quaternion definition file * + * Copyright (c) XFX Team. All Rights Reserved * + *****************************************************************************/ #ifndef _XFX_QUATERNION_ #define _XFX_QUATERNION_ @@ -25,53 +25,53 @@ namespace XFX Quaternion(); static Quaternion Add(Quaternion quaternion1, Quaternion quaternion2); - static void Add(Quaternion quaternion1, Quaternion quaternion2, out Quaternion result); + static void Add(Quaternion quaternion1, Quaternion quaternion2, out Quaternion& result); static Quaternion Concatenate(Quaternion quaternion1, Quaternion quaternion2); - static void Concatenate(Quaternion quaternion1, Quaternion quaternion2, out Quaternion result); + static void Concatenate(Quaternion quaternion1, Quaternion quaternion2, out Quaternion& result); void Conjugate(); static Quaternion Conjugate(Quaternion value); - static void Conjugate(Quaternion value, out Quaternion result); + static void Conjugate(Quaternion value, out Quaternion& result); static Quaternion CreateFromAxisAngle(Vector3 axis, float angle); - static void CreateFromAxisAngle(Vector3 axis, float angle, out Quaternion result); + static void CreateFromAxisAngle(Vector3 axis, float angle, out Quaternion& result); static Quaternion CreateFromRotationMatrix(Matrix matrix); - static void CreateFromRotationMatrix(Matrix matrix, out Quaternion result); + static void CreateFromRotationMatrix(Matrix matrix, out Quaternion& result); static Quaternion CreateFromYawPitchRoll(float yaw, float pitch, float roll); - static void CreateFromYawPitchRoll(float yaw, float pitch, float roll, out Quaternion result); + static void CreateFromYawPitchRoll(float yaw, float pitch, float roll, out Quaternion& result); static Quaternion Divide(Quaternion quaternion1, Quaternion quaternion2); - static void Divide(Quaternion quaternion1, Quaternion quaternion2, out Quaternion result); + static void Divide(Quaternion quaternion1, Quaternion quaternion2, out Quaternion& result); static float Dot(Quaternion quaternion1, Quaternion quaternion2); - static void Dot(Quaternion quaternion1, Quaternion quaternion2, out float result); - bool Equals(const Object* obj) const; + static void Dot(Quaternion quaternion1, Quaternion quaternion2, out float& result); + bool Equals(Object const * const obj) const; bool Equals(const Quaternion obj) const; int GetHashCode() const; int GetType() const; static Quaternion Inverse(Quaternion quaternion); - static void Inverse(Quaternion quaternion, out Quaternion result); + static void Inverse(Quaternion quaternion, out Quaternion& result); float Length(); float LengthSquared(); static Quaternion Lerp(Quaternion quaternion1, Quaternion quaternion2, float amount); - static void Lerp(Quaternion quaternion1, Quaternion quaternion2, float amount, out Quaternion result); + static void Lerp(Quaternion quaternion1, Quaternion quaternion2, float amount, out Quaternion& result); static Quaternion Multiply(Quaternion quaternion1, Quaternion quaternion2); - static void Multiply(Quaternion quaternion1, Quaternion quaternion2, out Quaternion result); + static void Multiply(Quaternion quaternion1, Quaternion quaternion2, out Quaternion& result); static Quaternion Multiply(Quaternion quaternion, float scaleFactor); - static void Multiply(Quaternion quaternion, float scaleFactor, out Quaternion result); + static void Multiply(Quaternion quaternion, float scaleFactor, out Quaternion& result); static Quaternion Negate(Quaternion quaternion); - static void Negate(Quaternion quaternion, out Quaternion result); + static void Negate(Quaternion quaternion, out Quaternion& result); void Normalize(); static Quaternion Slerp(Quaternion quaternion1, Quaternion quaternion2, float amount); - static void Slerp(Quaternion quaternion1, Quaternion quaternion2, float amount, out Quaternion result); + static void Slerp(Quaternion quaternion1, Quaternion quaternion2, float amount, out Quaternion& result); static Quaternion Subtract(Quaternion quaternion1, Quaternion quaternion2); - static void Subtract(Quaternion quaternion1, Quaternion quaternion2, out Quaternion result); + static void Subtract(Quaternion quaternion1, Quaternion quaternion2, out Quaternion& result); char* ToString(); - const Quaternion operator+(const Quaternion other); - const Quaternion operator/(const Quaternion other); + Quaternion operator+(const Quaternion& other); + Quaternion operator/(const Quaternion& other); bool operator==(const Quaternion& other) const; bool operator!=(const Quaternion& other) const; - const Quaternion operator*(const Quaternion other); - const Quaternion operator*(const float scaleFactor); - const Quaternion operator-(const Quaternion other); - const Quaternion operator-(); + Quaternion operator*(const Quaternion& other); + Quaternion operator*(const float scaleFactor); + Quaternion operator-(const Quaternion& other); + Quaternion operator-(); } ALIGNED16; } diff --git a/include/Ray.h b/include/Ray.h index 587b580..a5b46ff 100644 --- a/include/Ray.h +++ b/include/Ray.h @@ -1,9 +1,9 @@ -/******************************************************** - * Ray.h * - * * - * XFX Ray definition file * - * Copyright © XFX Team. All Rights Reserved * - ********************************************************/ +/***************************************************************************** + * Ray.h * + * * + * XFX Ray definition file * + * Copyright (c) XFX Team. All Rights Reserved * + *****************************************************************************/ #ifndef _XFX_RAY_ #define _XFX_RAY_ @@ -29,16 +29,16 @@ namespace XFX Ray(const Ray &obj); Ray(); - bool Equals(const Object* obj) const; + bool Equals(Object const * const obj) const; bool Equals(const Ray other) const; int GetHashCode() const; int GetType() const; - float Intersects(const BoundingBox boundingbox) const; - void Intersects(const BoundingBox boundingbox, out float result) const; - float Intersects(const BoundingSphere sphere) const; - void Intersects(const BoundingSphere sphere, out float result) const; - float Intersects(const Plane plane) const; - void Intersects(const Plane plane, out float result) const; + float Intersects(BoundingBox boundingbox) const; + void Intersects(BoundingBox boundingbox, out float& result) const; + float Intersects(BoundingSphere sphere) const; + void Intersects(BoundingSphere sphere, out float& result) const; + float Intersects(Plane plane) const; + void Intersects(Plane plane, out float& result) const; const char* ToString() const; bool operator==(const Ray& right) const; diff --git a/include/Rectangle.h b/include/Rectangle.h index 1f6779c..df79632 100644 --- a/include/Rectangle.h +++ b/include/Rectangle.h @@ -1,9 +1,9 @@ -/******************************************************** - * Rectangle.h * - * * - * XFX Rectangle definition file * - * Copyright © XFX Team. All Rights Reserved * - ********************************************************/ +/***************************************************************************** + * Rectangle.h * + * * + * XFX Rectangle definition file * + * Copyright (c) XFX Team. All Rights Reserved * + *****************************************************************************/ #ifndef _XFX_RECTANGLE_ #define _XFX_RECTANGLE_ @@ -35,19 +35,19 @@ namespace XFX bool Contains(int x, int y); bool Contains(Point pt); - void Contains(Point pt, out int result); + void Contains(Point pt, out bool& result); bool Contains(Rectangle other); - void Contains(Rectangle other, out int result); - bool Equals(const Object* obj) const; + void Contains(Rectangle other, out bool& result); + bool Equals(Object const * const obj) const; bool Equals(const Rectangle obj) const; - int GetHashCode(); + int GetHashCode() const; int GetType() const; void Inflate(int horizontalAmount, int verticalAmount); bool Intersects(Rectangle other); - void Intersects(Rectangle other, out int result); + void Intersects(Rectangle other, out bool& result); void Offset(int x, int y); void Offset(Point pt); - char* ToString(); + const char* ToString(); bool operator==(const Rectangle& other) const; bool operator!=(const Rectangle& other) const; diff --git a/include/System/Array.h b/include/System/Array.h index 38a51d2..4f4587c 100644 --- a/include/System/Array.h +++ b/include/System/Array.h @@ -1,10 +1,10 @@ -/******************************************************** - * Array.h * - * * - * XFX Array class definition file * - * Contains array helper methods * - * Copyright © XFX Team. All Rights Reserved * - ********************************************************/ +/***************************************************************************** + * Array.h * + * * + * XFX Array class definition file * + * Contains array helper methods * + * Copyright (c) XFX Team. All Rights Reserved * + *****************************************************************************/ #ifndef _SYSTEM_ARRAY_ #define _SYSTEM_ARRAY_ @@ -48,12 +48,15 @@ namespace System ~Array() { delete[] _array; } + template + static void Clear(U array[], int startIndex, int count) + { + memset(&array[startIndex], 0, sizeof(U) * count); + } + void Clear() { - for (int i = 0; i < Length; i++) - { - _array[i] = null; - } + Clear(_array, 0, Length); } bool Contains(const T item) const @@ -180,10 +183,7 @@ namespace System void Clear() { - for (int i = 0; i < Length; i++) - { - _array[i] = null; - } + memset(_array, 0, sizeof(T *) * Length); } bool Contains(const T* item) const diff --git a/include/System/BitConverter.h b/include/System/BitConverter.h index c46c2c5..7b05467 100644 --- a/include/System/BitConverter.h +++ b/include/System/BitConverter.h @@ -1,9 +1,9 @@ -/******************************************************** - * BitConverter.h * - * * - * XFX BitConverter definition file * - * Copyright © XFX Team. All Rights Reserved * - ********************************************************/ +/***************************************************************************** + * BitConverter.h * + * * + * XFX BitConverter definition file * + * Copyright (c) XFX Team. All Rights Reserved * + *****************************************************************************/ #ifndef _SYSTEM_BITCONVERTER_ #define _SYSTEM_BITCONVERTER_ @@ -15,7 +15,7 @@ namespace System class BitConverter { private: - static byte* GetBytes(byte *ptr, int count) __attribute__((nonnull(1))); + static byte* GetBytes(byte *ptr, int count) NONNULL(1); static bool AmIBigOrLittleEndian(); static bool SwappedWordsInDouble(); @@ -34,16 +34,16 @@ namespace System static byte* GetBytes(ushort value); static byte* GetBytes(uint value); static byte* GetBytes(ulong value); - static bool ToBoolean(byte value[], int startIndex) __attribute__((nonnull(1))); - static char ToChar(byte value[], int startIndex) __attribute__((nonnull(1))); - static double ToDouble(byte value[], int startIndex) __attribute__((nonnull(1))); - static short ToInt16(byte value[], int startIndex) __attribute__((nonnull(1))); - static int ToInt32(byte value[], int startIndex) __attribute__((nonnull(1))); - static long long ToInt64(byte value[], int startIndex) __attribute__((nonnull(1))); - static float ToSingle(byte value[], int startIndex) __attribute__((nonnull(1))); - static ushort ToUInt16(byte value[], int startIndex) __attribute__((nonnull(1))); - static uint ToUInt32(byte value[], int startIndex) __attribute__((nonnull(1))); - static ulong ToUInt64(byte value[], int startIndex) __attribute__((nonnull(1))); + static bool ToBoolean(byte value[], int startIndex) NONNULL(1); + static char ToChar(byte value[], int startIndex) NONNULL(1); + static double ToDouble(byte value[], int startIndex) NONNULL(1); + static short ToInt16(byte value[], int startIndex) NONNULL(1); + static int ToInt32(byte value[], int startIndex) NONNULL(1); + static long long ToInt64(byte value[], int startIndex) NONNULL(1); + static float ToSingle(byte value[], int startIndex) NONNULL(1); + static ushort ToUInt16(byte value[], int startIndex) NONNULL(1); + static uint ToUInt32(byte value[], int startIndex) NONNULL(1); + static ulong ToUInt64(byte value[], int startIndex) NONNULL(1); }; } diff --git a/include/System/String.h b/include/System/String.h index adb8b2e..792e4d4 100644 --- a/include/System/String.h +++ b/include/System/String.h @@ -1,15 +1,16 @@ -/******************************************************** - * String.h * - * * - * XFX String definition file * - * Copyright © XFX Team. All Rights Reserved * - ********************************************************/ +/***************************************************************************** + * String.h * + * * + * XFX String definition file * + * Copyright (c) XFX Team. All Rights Reserved * + *****************************************************************************/ #ifndef _SYSTEM_STRING_ #define _SYSTEM_STRING_ #include "Enums.h" #include "Interfaces.h" #include "Object.h" +#include "Types.h" namespace System { @@ -42,7 +43,7 @@ namespace System bool Equals(Object const * const obj) const; bool Equals(const String obj) const; bool Equals(const String& str1, const String& str2); - static const char* Format(const char* format, ...); + static const char* Format(const char* format, ...) FORMAT(printf, 1, 2); int GetHashCode() const; int GetType() const; int IndexOf(char value) const; diff --git a/include/System/Types.h b/include/System/Types.h index da49b03..32cd3a0 100644 --- a/include/System/Types.h +++ b/include/System/Types.h @@ -1,9 +1,9 @@ -/******************************************************** - * Types.h * - * * - * Defines types for the entire XFX Framework * - * Copyright © XFX Team. All Rights Reserved * - ********************************************************/ +/***************************************************************************** + * Types.h * + * * + * Defines types for the entire XFX Framework * + * Copyright (c) XFX Team. All Rights Reserved * + *****************************************************************************/ #ifndef _SYSTEM_TYPES_ #define _SYSTEM_TYPES_ @@ -37,10 +37,22 @@ namespace System // #define out +#if _MSC_VER +#define __attribute__(x) +#endif + // Aligning Data types // #define ALIGNED4 __attribute__((aligned (4))) #define ALIGNED8 __attribute__((aligned (8))) #define ALIGNED16 __attribute__((aligned (16))) +#if _MSC_VER +#define FORMAT(...) __attribute__((format(__VA_ARGS__))) +#define NONNULL(...) __attribute__((nonnull(__VA_ARGS__))) +#else +#define FORMAT(x...) __attribute__((format(x))) +#define NONNULL(x...) __attribute__((nonnull(x))) +#endif + #endif //_SYSTEM_TYPES_ diff --git a/include/Vector3.h b/include/Vector3.h index 9407b34..98a0727 100644 --- a/include/Vector3.h +++ b/include/Vector3.h @@ -1,9 +1,9 @@ -/******************************************************** - * Vector3.h * - * * - * XFX Vector3 definition file * - * Copyright © XFX Team. All Rights Reserved * - ********************************************************/ +/***************************************************************************** + * Vector3.h * + * * + * XFX Vector3 definition file * + * Copyright (c) XFX Team. All Rights Reserved * + *****************************************************************************/ #ifndef _XFX_VECTOR3_ #define _XFX_VECTOR3_ @@ -40,76 +40,76 @@ namespace XFX Vector3(); static Vector3 Add(const Vector3 value1, const Vector3 value2); - static void Add(const Vector3 value1, const Vector3 value2, out Vector3 result); + static void Add(const Vector3 value1, const Vector3 value2, out Vector3& result); static Vector3 Baricentric(const Vector3 value1, const Vector3 value2, const Vector3 value3, const float amount1, const float amount2); - static void Baricentric(const Vector3 value1, const Vector3 value2, const Vector3 value3, const float amount1, const float amount2, out Vector3 result); + static void Baricentric(const Vector3 value1, const Vector3 value2, const Vector3 value3, const float amount1, const float amount2, out Vector3& result); static Vector3 CatmullRom(const Vector3 value1, const Vector3 value2, const Vector3 value3, const Vector3 value4, const float amount); - static void CatmullRom(const Vector3 value1, const Vector3 value2, const Vector3 value3, const Vector3 value4, const float amount, out Vector3 result); + static void CatmullRom(const Vector3 value1, const Vector3 value2, const Vector3 value3, const Vector3 value4, const float amount, out Vector3& result); static Vector3 Clamp(const Vector3 value1, const Vector3 min, const Vector3 max); - static void Clamp(const Vector3 value1, const Vector3 min, const Vector3 max, out Vector3 result); + static void Clamp(const Vector3 value1, const Vector3 min, const Vector3 max, out Vector3& result); static Vector3 Cross(const Vector3 vector1, const Vector3 vector2); - static void Cross(const Vector3 vector1, const Vector3 vector2, out Vector3 result); + static void Cross(const Vector3 vector1, const Vector3 vector2, out Vector3& result); static float Distance(const Vector3 value1, const Vector3 value2); - static void Distance(const Vector3 value1, const Vector3 value2, out float result); + static void Distance(const Vector3 value1, const Vector3 value2, out float& result); static float DistanceSquared(const Vector3 value1, const Vector3 value2); - static void DistanceSquared(const Vector3 value1, const Vector3 value2, out float result); + static void DistanceSquared(const Vector3 value1, const Vector3 value2, out float& result); static Vector3 Divide(const Vector3 value1, const float value2); - static void Divide(const Vector3 value1, const float value2, out Vector3 result); + static void Divide(const Vector3 value1, const float value2, out Vector3& result); static Vector3 Divide(const Vector3 value1, const Vector3 value2); - static void Divide(const Vector3 value1, const Vector3 value2, out Vector3 result); + static void Divide(const Vector3 value1, const Vector3 value2, out Vector3& result); static float Dot(const Vector3 value1, const Vector3 value2); - static void Dot(const Vector3 value1, const Vector3 value2, out float result); - bool Equals(const Object* obj) const; + static void Dot(const Vector3 value1, const Vector3 value2, out float& result); + bool Equals(Object const * const obj) const; bool Equals(const Vector3 other) const; int GetHashCode() const; int GetType() const; static Vector3 Hermite(const Vector3 value1, const Vector3 tangent1, const Vector3 value2, const Vector3 tangent2, const float amount); - static void Hermite(const Vector3 value1, const Vector3 tangent1, const Vector3 value2, const Vector3 tangent2, const float amount, out Vector3 result); + static void Hermite(const Vector3 value1, const Vector3 tangent1, const Vector3 value2, const Vector3 tangent2, const float amount, out Vector3& result); float Length() const; float LengthSquared() const; static Vector3 Lerp(const Vector3 value1, const Vector3 value2, float amount); - static void Lerp(const Vector3 value1, const Vector3 value2, const float amount, out Vector3 result); + static void Lerp(const Vector3 value1, const Vector3 value2, const float amount, out Vector3& result); static Vector3 Max(const Vector3 value1, const Vector3 value2); - static void Max(const Vector3 value1, const Vector3 value2, out Vector3 result); + static void Max(const Vector3 value1, const Vector3 value2, out Vector3& result); static Vector3 Min(const Vector3 value1, const Vector3 value2); - static void Min(const Vector3 value1, const Vector3 value2, out Vector3 result); + static void Min(const Vector3 value1, const Vector3 value2, out Vector3& result); static Vector3 Multiply(const Vector3 value1, const float scaleFactor); - static void Multiply(const Vector3 value1, const float scaleFactor, out Vector3 result); + static void Multiply(const Vector3 value1, const float scaleFactor, out Vector3& result); static Vector3 Multiply(const Vector3 value1, const Vector3 value2); - static void Multiply(const Vector3 value1, const Vector3 value2, out Vector3 result); + static void Multiply(const Vector3 value1, const Vector3 value2, out Vector3& result); static Vector3 Negate(const Vector3 value); - static void Negate(const Vector3 value, out Vector3 result); + static void Negate(const Vector3 value, out Vector3& result); void Normalize(); static Vector3 Normalize(const Vector3 value); - static void Normalize(const Vector3 value, out Vector3 result); + static void Normalize(const Vector3 value, out Vector3& result); static Vector3 Reflect(const Vector3 vector, const Vector3 normal); - static void Reflect(const Vector3 vector, const Vector3 normal, out Vector3 result); + static void Reflect(const Vector3 vector, const Vector3 normal, out Vector3& result); static Vector3 SmoothStep(const Vector3 value1, const Vector3 value2, const float amount); - static void SmoothStep(const Vector3 value1, const Vector3 value2, const float amount, out Vector3 result); + static void SmoothStep(const Vector3 value1, const Vector3 value2, const float amount, out Vector3& result); static Vector3 Subtract(const Vector3 value1, const Vector3 value2); - static void Subtract(const Vector3 value1, const Vector3 value2, out Vector3 result); + static void Subtract(const Vector3 value1, const Vector3 value2, out Vector3& result); const char* ToString() const; static Vector3 Transform(const Vector3 position, const Matrix matrix); - static void Transform(const Vector3 position, const Matrix matrix, out Vector3 result); + static void Transform(const Vector3 position, const Matrix matrix, out Vector3& result); static Vector3 Transform(const Vector3 position, const Quaternion rotation); - static void Transform(const Vector3 position, const Quaternion rotation, out Vector3 result); - static void Transform(const Vector3 sourceArray[], const int sourceIndex, const Matrix matrix, Vector3 destinationArray[], const int destinationIndex, const int length); - static void Transform(const Vector3 sourceArray[], const int sourceIndex, const Quaternion rotation, Vector3 destinationArray[], const int destinationIndex, const int length); - static void Transform(const Vector3 sourceArray[], const Matrix matrix, Vector3 destinationArray[]); - static void Transform(const Vector3 sourceArray[], const Quaternion rotation, Vector3 destinationArray[]); + static void Transform(const Vector3 position, const Quaternion rotation, out Vector3& result); + static void Transform(const Vector3 sourceArray[], const int sourceIndex, const Matrix matrix, Vector3 destinationArray[], const int destinationIndex, const int length) NONNULL(1, 4); + static void Transform(const Vector3 sourceArray[], const int sourceIndex, const Quaternion rotation, Vector3 destinationArray[], const int destinationIndex, const int length) NONNULL(1, 4); + static void Transform(const Vector3 sourceArray[], const Matrix matrix, Vector3 destinationArray[]) NONNULL(1, 3); + static void Transform(const Vector3 sourceArray[], const Quaternion rotation, Vector3 destinationArray[]) NONNULL(1, 3); static Vector3 TransformNormal(const Vector3 normal, const Matrix matrix); - static void TransformNormal(const Vector3 normal, const Matrix matrix, out Vector3 result); - static void TransformNormal(const Vector3 sourceArray[], const int sourceIndex, const Matrix matrix, Vector3 destinationArray[], const int destinationIndex, const int length); - static void TransformNormal(const Vector3 sourceArray[], const Matrix matrix, Vector3 destinationArray[]); + static void TransformNormal(const Vector3 normal, const Matrix matrix, out Vector3& result); + static void TransformNormal(const Vector3 sourceArray[], const int sourceIndex, const Matrix matrix, Vector3 destinationArray[], const int destinationIndex, const int length) NONNULL(1, 4); + static void TransformNormal(const Vector3 sourceArray[], const Matrix matrix, Vector3 destinationArray[]) NONNULL(1, 3); - Vector3 operator+(const Vector3 other); + Vector3 operator+(const Vector3& other); Vector3 operator/(const float divider); - Vector3 operator/(const Vector3 other); - bool operator==(const Vector3 other) const; - bool operator!=(const Vector3 other) const; + Vector3 operator/(const Vector3& other); + bool operator==(const Vector3& other) const; + bool operator!=(const Vector3& other) const; Vector3 operator*(const float scaleFactor); - Vector3 operator*(const Vector3 other); - Vector3 operator-(const Vector3 other); + Vector3 operator*(const Vector3& other); + Vector3 operator-(const Vector3& other); Vector3 operator-(); } ALIGNED16; } diff --git a/include/Vector4.h b/include/Vector4.h index cceda41..0e6a4b5 100644 --- a/include/Vector4.h +++ b/include/Vector4.h @@ -1,9 +1,9 @@ -/******************************************************** - * Vector4.h * - * * - * XFX Vector4 definition file * - * Copyright © XFX Team. All Rights Reserved * - ********************************************************/ +/***************************************************************************** + * Vector4.h * + * * + * XFX Vector4 definition file * + * Copyright (c) XFX Team. All Rights Reserved * + *****************************************************************************/ #ifndef _XFX_VECTOR4_ #define _XFX_VECTOR4_ @@ -41,65 +41,65 @@ namespace XFX Vector4(); static Vector4 Add(Vector4 vector1, Vector4 vector2); - static void Add(Vector4 vector1, Vector4 vector2, out Vector4 result); + static void Add(Vector4 vector1, Vector4 vector2, out Vector4& result); static Vector4 Baricentric(Vector4 value1, Vector4 value2, Vector4 value3, float amount1, float amount2); - static void Baricentric(Vector4 value1, Vector4 value2, Vector4 value3, float amount1, float amount2, out Vector4 result); + static void Baricentric(Vector4 value1, Vector4 value2, Vector4 value3, float amount1, float amount2, out Vector4& result); static Vector4 CatmullRom(Vector4 value1, Vector4 value2, Vector4 value3, Vector4 value4, float amount); - static void CatmullRom(Vector4 value1, Vector4 value2, Vector4 value3, Vector4 value4, float amount, out Vector4 result); + static void CatmullRom(Vector4 value1, Vector4 value2, Vector4 value3, Vector4 value4, float amount, out Vector4& result); static Vector4 Clamp(Vector4 value1, Vector4 min, Vector4 max); - static void Clamp(Vector4 value1, Vector4 min, Vector4 max, out Vector4 result); + static void Clamp(Vector4 value1, Vector4 min, Vector4 max, out Vector4& result); static float Distance(Vector4 value1, Vector4 value2); - static void Distance(Vector4 value1, Vector4 value2, out float result); + static void Distance(Vector4 value1, Vector4 value2, out float& result); static float DistanceSquared(Vector4 value1, Vector4 value2); - static void DistanceSquared(Vector4 value1, Vector4 value2, out float result); + static void DistanceSquared(Vector4 value1, Vector4 value2, out float& result); static Vector4 Divide(Vector4 value, float scale); - static void Divide(Vector4 value, float scale, out Vector4 result); + static void Divide(Vector4 value, float scale, out Vector4& result); static Vector4 Divide(Vector4 vector1, Vector4 vector2); - static void Divide(Vector4 vector1, Vector4 vector2, out Vector4 result); - bool Equals(const Object* obj) const; + static void Divide(Vector4 vector1, Vector4 vector2, out Vector4& result); + bool Equals(Object const * const obj) const; bool Equals(const Vector4 other) const; int GetHashCode() const; int GetType() const; static Vector4 Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount); - static void Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount, out Vector4 result); + static void Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount, out Vector4& result); float Length(); float LengthSquared(); static Vector4 Lerp(Vector4 value1, Vector4 value2, float amount); - static void Lerp(Vector4 value1, Vector4 value2, float amount, out Vector4 result); + static void Lerp(Vector4 value1, Vector4 value2, float amount, out Vector4& result); static Vector4 Max(Vector4 value1, Vector4 value2); - static void Max(Vector4 value1, Vector4 value2, out Vector4 result); + static void Max(Vector4 value1, Vector4 value2, out Vector4& result); static Vector4 Min(Vector4 value1, Vector4 value2); - static void Min(Vector4 value1, Vector4 value2, out Vector4 result); + static void Min(Vector4 value1, Vector4 value2, out Vector4& result); static Vector4 Multiply(Vector4 value1, float scaleFactor); - static void Multiply(Vector4 value1, float scaleFactor, out Vector4 result); + static void Multiply(Vector4 value1, float scaleFactor, out Vector4& result); static Vector4 Multiply(Vector4 value1, Vector4 value2); - static void Multiply(Vector4 value1, Vector4 value2, out Vector4 result); + static void Multiply(Vector4 value1, Vector4 value2, out Vector4& result); static Vector4 Negate(Vector4 value); - static void Negate(Vector4 value, out Vector4 result); + static void Negate(Vector4 value, out Vector4& result); void Normalize(); static Vector4 Normalize(Vector4 value); - static void Normalize(Vector4 value, out Vector4 result); + static void Normalize(Vector4 value, out Vector4& result); static Vector4 SmoothStep(Vector4 value1, Vector4 value2, float amount); - static void SmoothStep(Vector4 value1, Vector4 value2, float amount, out Vector4 result); + static void SmoothStep(Vector4 value1, Vector4 value2, float amount, out Vector4& result); static Vector4 Subtract(Vector4 value1, Vector4 value2); - static void Subtract(Vector4 value1, Vector4 value2, out Vector4 result); + static void Subtract(Vector4 value1, Vector4 value2, out Vector4& result); const char* ToString() const; static void Transform(Vector4 sourceArray[], Quaternion rotation, Vector4 destinationArray[]); static void Transform(Vector4 sourceArray[], int sourceIndex, Quaternion rotation, Vector4 destinationArray[], int destinationIndex, int length); static void Transform(Vector4 sourceArray[], Matrix matrix, Vector4 destinationArray[]); static void Transform(Vector4 sourceArray[], int sourceIndex, Matrix matrix, Vector4 destinationArray[], int destinationIndex, int length); static Vector4 Transform(Vector4 vector, Quaternion rotation); - static void Transform(Vector4 vector, Quaternion rotation, out Vector4 result); + static void Transform(Vector4 vector, Quaternion rotation, out Vector4& result); static Vector4 Transform(Vector3 vector, Quaternion rotation); - static void Transform(Vector3 vector, Quaternion rotation, out Vector4 result); + static void Transform(Vector3 vector, Quaternion rotation, out Vector4& result); static Vector4 Transform(Vector2 vector, Quaternion rotation); - static void Transform(Vector2 vector, Quaternion rotation, out Vector4 result); + static void Transform(Vector2 vector, Quaternion rotation, out Vector4& result); static Vector4 Transform(Vector4 vector, Matrix matrix); - static void Transform(Vector4 vector, Matrix matrix, out Vector4 result); + static void Transform(Vector4 vector, Matrix matrix, out Vector4& result); static Vector4 Transform(Vector3 position, Matrix matrix); - static void Transform(Vector3 position, Matrix matrix, out Vector4 result); + static void Transform(Vector3 position, Matrix matrix, out Vector4& result); static Vector4 Transform(Vector2 vector, Matrix matrix); - static void Transform(Vector2 vector, Matrix matrix, out Vector4 result); + static void Transform(Vector2 vector, Matrix matrix, out Vector4& result); Vector4 operator-(const Vector4& other); Vector4 operator-(); diff --git a/src/libXFX/BoundingBox.cpp b/src/libXFX/BoundingBox.cpp index 35185ef..9370deb 100644 --- a/src/libXFX/BoundingBox.cpp +++ b/src/libXFX/BoundingBox.cpp @@ -42,7 +42,7 @@ namespace XFX { const int BoundingBox::CornerCount = 8; - BoundingBox::BoundingBox(Vector3 min, Vector3 max) + BoundingBox::BoundingBox(const Vector3 min, const Vector3 max) : Max(max), Min(min) { } @@ -57,14 +57,14 @@ namespace XFX { } - ContainmentType_t BoundingBox::Contains(const BoundingBox box) const + ContainmentType_t BoundingBox::Contains(BoundingBox box) const { ContainmentType_t result; Contains(box, result); return result; } - void BoundingBox::Contains(const BoundingBox& box, out ContainmentType_t& result) const + void BoundingBox::Contains(BoundingBox box, out ContainmentType_t& result) const { if( Max.X < box.Min.X || Min.X > box.Max.X ) result = ContainmentType::Disjoint; @@ -82,14 +82,14 @@ namespace XFX result = ContainmentType::Intersects; } - ContainmentType_t BoundingBox::Contains(const BoundingSphere sphere) const + ContainmentType_t BoundingBox::Contains(BoundingSphere sphere) const { ContainmentType_t result; Contains(sphere, result); return result; } - void BoundingBox::Contains(const BoundingSphere& sphere, out ContainmentType_t& result) const + void BoundingBox::Contains(BoundingSphere sphere, out ContainmentType_t& result) const { float dist; Vector3 clamped; @@ -125,7 +125,7 @@ namespace XFX return ContainmentType::Disjoint; } - void BoundingBox::Contains(const Vector3& vector, out ContainmentType_t& result) const + void BoundingBox::Contains(Vector3 vector, out ContainmentType_t& result) const { if (Min.X <= vector.X && vector.X <= Max.X && Min.Y <= vector.Y && vector.Y <= Max.Y && Min.Z <= vector.Z && vector.Z <= Max.Z) @@ -134,7 +134,7 @@ namespace XFX result = ContainmentType::Disjoint; } - BoundingBox BoundingBox::CreateFromPoints(const Vector3 points[], const int startIndex, const int length) + BoundingBox BoundingBox::CreateFromPoints(Vector3 points[], int startIndex, int length) { sassert(points != null, String::Format("points; %s", FrameworkResources::ArgumentNull_Generic)); @@ -150,7 +150,7 @@ namespace XFX return BoundingBox(min, max); } - BoundingBox BoundingBox::CreateFromSphere(const BoundingSphere sphere) + BoundingBox BoundingBox::CreateFromSphere(BoundingSphere sphere) { BoundingBox result; result.Min = Vector3(sphere.Center.X - sphere.Radius, sphere.Center.Y - sphere.Radius, sphere.Center.Z - sphere.Radius ); @@ -158,13 +158,13 @@ namespace XFX return result; } - void BoundingBox::CreateFromSphere(const BoundingSphere& sphere, out BoundingBox& result) + void BoundingBox::CreateFromSphere(BoundingSphere sphere, out BoundingBox& result) { result.Min = Vector3(sphere.Center.X - sphere.Radius, sphere.Center.Y - sphere.Radius, sphere.Center.Z - sphere.Radius ); result.Max = Vector3(sphere.Center.X + sphere.Radius, sphere.Center.Y + sphere.Radius, sphere.Center.Z + sphere.Radius ); } - BoundingBox BoundingBox::CreateMerged(const BoundingBox box1, const BoundingBox box2) + BoundingBox BoundingBox::CreateMerged(BoundingBox box1, BoundingBox box2) { BoundingBox result; Vector3::Min(box1.Min, box2.Min, result.Min); @@ -172,15 +172,15 @@ namespace XFX return result; } - void BoundingBox::CreateMerged(const BoundingBox& box1, const BoundingBox& box2, out BoundingBox& result) + void BoundingBox::CreateMerged(BoundingBox box1, BoundingBox box2, out BoundingBox& result) { Vector3::Min(box1.Min, box2.Min, result.Min); Vector3::Max(box1.Max, box2.Max, result.Max); } - bool BoundingBox::Equals(const Object* obj) const + bool BoundingBox::Equals(Object const * const obj) const { - return is(this, obj) ? this->Equals(*(BoundingBox*)obj) : false; + return is(this, obj) ? *this == *(BoundingBox *)obj : false; } bool BoundingBox::Equals(const BoundingBox obj) const @@ -198,14 +198,14 @@ namespace XFX // TODO: implement } - bool BoundingBox::Intersects(const BoundingBox box) const + bool BoundingBox::Intersects(BoundingBox box) const { bool result; Intersects(box, result); return result; } - void BoundingBox::Intersects(const BoundingBox& box, out bool& result) const + void BoundingBox::Intersects(BoundingBox box, out bool& result) const { if (Max.X < box.Min.X || Min.X > box.Max.X) result = false; @@ -216,14 +216,14 @@ namespace XFX result = (Max.Z >= box.Min.Z && Min.Z <= box.Max.Z); } - bool BoundingBox::Intersects(const BoundingSphere sphere) const + bool BoundingBox::Intersects(BoundingSphere sphere) const { bool result; Intersects(sphere, result); return result; } - void BoundingBox::Intersects(const BoundingSphere& sphere, out bool& result) const + void BoundingBox::Intersects(BoundingSphere sphere, out bool& result) const { float dist; Vector3 clamped; @@ -239,24 +239,24 @@ namespace XFX result = (dist <= (sphere.Radius * sphere.Radius)); } - PlaneIntersectionType_t BoundingBox::Intersects(const Plane plane) const + PlaneIntersectionType_t BoundingBox::Intersects(Plane plane) const { return plane.Intersects(*this); } - void BoundingBox::Intersects(const Plane& plane, out PlaneIntersectionType_t& result) const + void BoundingBox::Intersects(Plane plane, out PlaneIntersectionType_t& result) const { result = plane.Intersects(*this); } - float BoundingBox::Intersects(const Ray ray) const + float BoundingBox::Intersects(Ray ray) const { float distance = 0; ray.Intersects(*this, distance); return distance; } - void BoundingBox::Intersects(const Ray& ray, out float& distance) const + void BoundingBox::Intersects(Ray ray, out float& distance) const { ray.Intersects(*this, distance); } diff --git a/src/libXFX/BoundingSphere.cpp b/src/libXFX/BoundingSphere.cpp index 3797e5e..65c0def 100644 --- a/src/libXFX/BoundingSphere.cpp +++ b/src/libXFX/BoundingSphere.cpp @@ -47,7 +47,7 @@ namespace XFX bool BoundingSphere::Equals(const Object* obj) const { - return is(this, obj) ? this->Equals((*(BoundingSphere*)obj)) : false; + return is(this, obj) ? *this == *(BoundingSphere *)obj : false; } bool BoundingSphere::Equals(const BoundingSphere other) const @@ -62,12 +62,12 @@ namespace XFX const char* BoundingSphere::ToString() const { - return String::Format("{{Center:%s Radius:%f}}", Center.ToString(), Radius); + return String::Format("{Center:%s Radius:%f}", Center.ToString(), Radius); } bool BoundingSphere::operator!=(const BoundingSphere& other) const { - return !((Center == other.Center) && (Radius == other.Radius)); + return ((Center != other.Center) || (Radius != other.Radius)); } bool BoundingSphere::operator==(const BoundingSphere& other) const diff --git a/src/libXFX/Matrix.cpp b/src/libXFX/Matrix.cpp index 8e69a18..83cbdef 100644 --- a/src/libXFX/Matrix.cpp +++ b/src/libXFX/Matrix.cpp @@ -952,7 +952,7 @@ namespace XFX bool Matrix::Equals(const Object* obj) const { - return is(this, obj) ? this->Equals((*(Matrix*)obj)) : false; + return is(this, obj) ? *this == *(Matrix*)obj : false; } bool Matrix::Equals(const Matrix other) const @@ -1190,10 +1190,10 @@ namespace XFX const char* Matrix::ToString() const { - return String::Format("{{{M11:%f M12:%f M13:%f M14:%f}}\ - {{M21:%f M22:%f M23:%f M24:%f}}\ - {{M31:%f M32:%f M33:%f M34:%f}}\ - {{M41:%f M42:%f M43:%f M44:%f}}}", + return String::Format("{{M11:%f M12:%f M13:%f M14:%f}\ + {M21:%f M22:%f M23:%f M24:%f}\ + {M31:%f M32:%f M33:%f M34:%f}\ + {M41:%f M42:%f M43:%f M44:%f}}", M11, M12, M13, M14, M21, M22, M23, M24, M31, M32, M33, M34, M41, M42, M43, M44); } @@ -1205,7 +1205,7 @@ namespace XFX return ret; } - void Matrix::Transpose(Matrix matrix, Matrix result) + void Matrix::Transpose(Matrix matrix, out Matrix result) { result.M11 = matrix.M11; result.M12 = matrix.M21; diff --git a/src/libXFX/Plane.cpp b/src/libXFX/Plane.cpp index 724d8fa..39644c4 100644 --- a/src/libXFX/Plane.cpp +++ b/src/libXFX/Plane.cpp @@ -88,7 +88,7 @@ namespace XFX return (Normal.X * value.X) + (Normal.Y * value.Y) + (Normal.Z * value.Z) + (D * value.W); } - void Plane::Dot(const Vector4 value, out float result) const + void Plane::Dot(const Vector4 value, out float& result) const { result = (Normal.X * value.X) + (Normal.Y * value.Y) + (Normal.Z * value.Z) + (D * value.W); } @@ -98,7 +98,7 @@ namespace XFX return (Normal.X * value.X) + (Normal.Y * value.Y) + (Normal.Z * value.Z) + D; } - void Plane::DotCoordinate(const Vector3 value, out float result) const + void Plane::DotCoordinate(const Vector3 value, out float& result) const { result = (Normal.X * value.X) + (Normal.Y * value.Y) + (Normal.Z * value.Z) + D; } @@ -108,14 +108,14 @@ namespace XFX return (Normal.X * value.X) + (Normal.Y * value.Y) + (Normal.Z * value.Z); } - void Plane::DotNormal(const Vector3 value, out float result) const + void Plane::DotNormal(const Vector3 value, out float& result) const { result = (Normal.X * value.X) + (Normal.Y * value.Y) + (Normal.Z * value.Z); } - bool Plane::Equals(const Object* obj) const + bool Plane::Equals(Object const * const obj) const { - return is(this, obj) ? this->Equals((*(Plane*)obj)) : false; + return is(this, obj) ? *this == *(Plane *)obj : false; } bool Plane::Equals(const Plane obj) const @@ -135,29 +135,12 @@ namespace XFX PlaneIntersectionType_t Plane::Intersects(const BoundingBox boundingbox) const { - Vector3 min; - Vector3 max; - max.X = (Normal.X >= 0.0f) ? boundingbox.Min.X : boundingbox.Max.X; - max.Y = (Normal.Y >= 0.0f) ? boundingbox.Min.Y : boundingbox.Max.Y; - max.Z = (Normal.Z >= 0.0f) ? boundingbox.Min.Z : boundingbox.Max.Z; - min.X = (Normal.X >= 0.0f) ? boundingbox.Max.X : boundingbox.Min.X; - min.Y = (Normal.Y >= 0.0f) ? boundingbox.Max.Y : boundingbox.Min.Y; - min.Z = (Normal.Z >= 0.0f) ? boundingbox.Max.Z : boundingbox.Min.Z; - - float dot = (Normal.X * max.X) + (Normal.Y * max.Y) + (Normal.Z * max.Z); - - if(dot + D > 0.0f) - return PlaneIntersectionType::Front; - - dot = (Normal.X * min.X) + (Normal.Y * min.Y) + (Normal.Z * min.Z); - - if(dot + D < 0.0f) - return PlaneIntersectionType::Back; - - return PlaneIntersectionType::Intersecting; + PlaneIntersectionType_t result; + Intersects(boundingbox, result); + return result; } - void Plane::Intersects(const BoundingBox boundingbox, out PlaneIntersectionType_t result) const + void Plane::Intersects(const BoundingBox boundingbox, out PlaneIntersectionType_t& result) const { Vector3 min; Vector3 max; @@ -183,18 +166,12 @@ namespace XFX PlaneIntersectionType_t Plane::Intersects(const BoundingSphere sphere) const { - float dot = (sphere.Center.X * Normal.X) + (sphere.Center.Y * Normal.Y) + (sphere.Center.Z * Normal.Z) + D; - - if(dot > sphere.Radius) - return PlaneIntersectionType::Front; - - if(dot < -sphere.Radius) - return PlaneIntersectionType::Back; - - return PlaneIntersectionType::Intersecting; + PlaneIntersectionType_t result; + Intersects(sphere, result); + return result; } - void Plane::Intersects(const BoundingSphere sphere, out PlaneIntersectionType_t result) const + void Plane::Intersects(const BoundingSphere sphere, out PlaneIntersectionType_t& result) const { float dot = (sphere.Center.X * Normal.X) + (sphere.Center.Y * Normal.Y) + (sphere.Center.Z * Normal.Z) + D; @@ -224,7 +201,7 @@ namespace XFX return Plane(plane.Normal.X * magnitude, plane.Normal.Y * magnitude, plane.Normal.Z * magnitude, plane.D * magnitude); } - void Plane::Normalize(const Plane plane, out Plane result) + void Plane::Normalize(const Plane plane, out Plane& result) { result = Normalize(plane); } @@ -237,21 +214,11 @@ namespace XFX Plane Plane::Transform(Plane plane, Matrix matrix) { Plane result; - float x = plane.Normal.X; - float y = plane.Normal.Y; - float z = plane.Normal.Z; - float d = plane.D; - - matrix = Matrix::Invert(matrix); - result.Normal.X = (((x * matrix.M11) + (y * matrix.M12)) + (z * matrix.M13)) + (d * matrix.M14); - result.Normal.Y = (((x * matrix.M21) + (y * matrix.M22)) + (z * matrix.M23)) + (d * matrix.M24); - result.Normal.Z = (((x * matrix.M31) + (y * matrix.M32)) + (z * matrix.M33)) + (d * matrix.M34); - result.D = (((x * matrix.M41) + (y * matrix.M42)) + (z * matrix.M43)) + (d * matrix.M44); - + Transform(plane, matrix, result); return result; } - void Plane::Transform(Plane plane, Matrix matrix, out Plane result) + void Plane::Transform(Plane plane, Matrix matrix, out Plane& result) { float x = plane.Normal.X; float y = plane.Normal.Y; @@ -267,32 +234,12 @@ namespace XFX Plane Plane::Transform(Plane plane, Quaternion quaternion) { - Plane result; - float x2 = quaternion.X + quaternion.X; - float y2 = quaternion.Y + quaternion.Y; - float z2 = quaternion.Z + quaternion.Z; - float wx = quaternion.W * x2; - float wy = quaternion.W * y2; - float wz = quaternion.W * z2; - float xx = quaternion.X * x2; - float xy = quaternion.X * y2; - float xz = quaternion.X * z2; - float yy = quaternion.Y * y2; - float yz = quaternion.Y * z2; - float zz = quaternion.Z * z2; - - float x = plane.Normal.X; - float y = plane.Normal.Y; - float z = plane.Normal.Z; - - result.Normal.X = ((x * ((1.0f - yy) - zz)) + (y * (xy - wz))) + (z * (xz + wy)); - result.Normal.Y = ((x * (xy + wz)) + (y * ((1.0f - xx) - zz))) + (z * (yz - wx)); - result.Normal.Z = ((x * (xz - wy)) + (y * (yz + wx))) + (z * ((1.0f - xx) - yy)); - result.D = plane.D; + Plane result; + Transform(plane, quaternion, result); return result; } - void Plane::Transform(Plane plane, Quaternion quaternion, out Plane result) + void Plane::Transform(Plane plane, Quaternion quaternion, out Plane& result) { float x2 = quaternion.X + quaternion.X; float y2 = quaternion.Y + quaternion.Y; @@ -324,6 +271,6 @@ namespace XFX bool Plane::operator!=(const Plane& other) const { - return !((D == other.D) && (Normal == other.Normal)); + return ((D != other.D) || (Normal != other.Normal)); } } diff --git a/src/libXFX/Point.cpp b/src/libXFX/Point.cpp index d42df11..8b18be6 100644 --- a/src/libXFX/Point.cpp +++ b/src/libXFX/Point.cpp @@ -49,7 +49,7 @@ namespace XFX bool Point::Equals(Object const * const obj) const { - return is(this, obj) ? *this == *(Point*)obj : false; + return is(this, obj) ? *this == *(Point *)obj : false; } bool Point::Equals(const Point other) const diff --git a/src/libXFX/Quaternion.cpp b/src/libXFX/Quaternion.cpp index f54df7a..0496cc1 100644 --- a/src/libXFX/Quaternion.cpp +++ b/src/libXFX/Quaternion.cpp @@ -65,7 +65,7 @@ namespace XFX quaternion1.W + quaternion2.W); } - void Quaternion::Add(Quaternion quaternion1, Quaternion quaternion2, out Quaternion result) + void Quaternion::Add(Quaternion quaternion1, Quaternion quaternion2, out Quaternion& result) { result.X = quaternion1.X + quaternion2.X; result.Y = quaternion1.Y + quaternion2.Y; @@ -97,7 +97,7 @@ namespace XFX return quaternion; } - void Quaternion::Concatenate(Quaternion quaternion1, Quaternion quaternion2, out Quaternion result) + void Quaternion::Concatenate(Quaternion quaternion1, Quaternion quaternion2, out Quaternion& result) { float rx = quaternion2.X; float ry = quaternion2.Y; @@ -135,7 +135,7 @@ namespace XFX return result; } - void Quaternion::Conjugate(Quaternion value, out Quaternion result) + void Quaternion::Conjugate(Quaternion value, out Quaternion& result) { result.X = -value.X; result.Y = -value.Y; @@ -161,7 +161,7 @@ namespace XFX return result; } - void Quaternion::CreateFromAxisAngle(Vector3 axis, float angle, out Quaternion result) + void Quaternion::CreateFromAxisAngle(Vector3 axis, float angle, out Quaternion& result) { Vector3::Normalize(axis, axis); @@ -231,7 +231,7 @@ namespace XFX return result; } - void Quaternion::CreateFromRotationMatrix(Matrix matrix, out Quaternion result) + void Quaternion::CreateFromRotationMatrix(Matrix matrix, out Quaternion& result) { float scale = matrix.M11 + matrix.M22 + matrix.M33; @@ -303,7 +303,7 @@ namespace XFX return result; } - void Quaternion::CreateFromYawPitchRoll(float yaw, float pitch, float roll, out Quaternion result) + void Quaternion::CreateFromYawPitchRoll(float yaw, float pitch, float roll, out Quaternion& result) { float halfRoll = roll * 0.5f; float sinRoll = Math::Sin(halfRoll); @@ -331,7 +331,7 @@ namespace XFX return result; } - void Quaternion::Divide(Quaternion quaternion1, Quaternion quaternion2, out Quaternion result) + void Quaternion::Divide(Quaternion quaternion1, Quaternion quaternion2, out Quaternion& result) { result.X = quaternion1.X / quaternion2.X; result.Y = quaternion1.Y / quaternion2.Y; @@ -344,14 +344,14 @@ namespace XFX return (quaternion1.X * quaternion2.X) + (quaternion1.Y * quaternion2.Y) + (quaternion1.Z * quaternion2.Z) + (quaternion1.W * quaternion2.W); } - void Quaternion::Dot(Quaternion quaternion1, Quaternion quaternion2, out float result) + void Quaternion::Dot(Quaternion quaternion1, Quaternion quaternion2, out float& result) { result = (quaternion1.X * quaternion2.X) + (quaternion1.Y * quaternion2.Y) + (quaternion1.Z * quaternion2.Z) + (quaternion1.W * quaternion2.W); } - bool Quaternion::Equals(const Object* obj) const + bool Quaternion::Equals(Object const * const obj) const { - return is(this, obj) ? (*this == *(Quaternion*)obj) : false; + return is(this, obj) ? *this == *(Quaternion *)obj : false; } bool Quaternion::Equals(const Quaternion obj) const @@ -380,7 +380,7 @@ namespace XFX return result; } - void Quaternion::Inverse(Quaternion quaternion, out Quaternion result) + void Quaternion::Inverse(Quaternion quaternion, out Quaternion& result) { float lengthSq = 1.0f / ( (quaternion.X * quaternion.X) + (quaternion.Y * quaternion.Y) + (quaternion.Z * quaternion.Z) + (quaternion.W * quaternion.W) ); result.X = -quaternion.X * lengthSq; @@ -409,7 +409,7 @@ namespace XFX return result; } - void Quaternion::Lerp(Quaternion quaternion1, Quaternion quaternion2, float amount, out Quaternion result) + void Quaternion::Lerp(Quaternion quaternion1, Quaternion quaternion2, float amount, out Quaternion& result) { result.X = MathHelper::Lerp(quaternion1.X, quaternion2.X, amount); result.Y = MathHelper::Lerp(quaternion1.Y, quaternion2.Y, amount); @@ -441,7 +441,7 @@ namespace XFX return result; } - void Quaternion::Multiply(Quaternion quaternion1, Quaternion quaternion2, out Quaternion result) + void Quaternion::Multiply(Quaternion quaternion1, Quaternion quaternion2, out Quaternion& result) { float rx = quaternion2.X; float ry = quaternion2.Y; @@ -472,7 +472,7 @@ namespace XFX return result; } - void Quaternion::Multiply(Quaternion quaternion, float scaleFactor, out Quaternion result) + void Quaternion::Multiply(Quaternion quaternion, float scaleFactor, out Quaternion& result) { result.X = quaternion.X * scaleFactor; result.Y = quaternion.Y * scaleFactor; @@ -490,7 +490,7 @@ namespace XFX return result; } - void Quaternion::Negate(Quaternion quaternion, out Quaternion result) + void Quaternion::Negate(Quaternion quaternion, out Quaternion& result) { result.X = -quaternion.X; result.Y = -quaternion.Y; @@ -544,7 +544,7 @@ namespace XFX return result; } - void Quaternion::Slerp(Quaternion quaternion1, Quaternion quaternion2, float amount, out Quaternion result) + void Quaternion::Slerp(Quaternion quaternion1, Quaternion quaternion2, float amount, out Quaternion& result) { float opposite; float inverse; @@ -582,7 +582,7 @@ namespace XFX return Quaternion(quaternion1.X - quaternion2.X, quaternion1.Y - quaternion2.Y, quaternion1.Z - quaternion2.Z, quaternion1.W - quaternion2.W); } - void Quaternion::Subtract(Quaternion quaternion1, Quaternion quaternion2, out Quaternion result) + void Quaternion::Subtract(Quaternion quaternion1, Quaternion quaternion2, out Quaternion& result) { result.X = quaternion1.X - quaternion2.X; result.Y = quaternion1.Y - quaternion2.Y; @@ -590,24 +590,14 @@ namespace XFX result.W = quaternion1.W - quaternion2.W; } - const Quaternion Quaternion::operator+(const Quaternion other) + Quaternion Quaternion::operator +(const Quaternion& other) { - Quaternion result; - result.X = X + other.X; - result.Y = Y + other.Y; - result.Z = Z + other.Z; - result.W = W + other.W; - return result; + return Quaternion(X + other.X, Y + other.Y, Z + other.Z, W + other.W); } - const Quaternion Quaternion::operator/(const Quaternion other) + Quaternion Quaternion::operator /(const Quaternion& other) { - Quaternion result; - result.X = X / other.X; - result.Y = Y / other.Y; - result.Z = Z / other.Z; - result.W = W / other.W; - return result; + return Quaternion(X / other.X, Y / other.Y, Z / other.Z, W / other.W); } bool Quaternion::operator==(const Quaternion& other) const @@ -620,7 +610,7 @@ namespace XFX return ((X != other.X) || (Y != other.Y) || (Z != other.Z) || (W != other.W)); } - const Quaternion Quaternion::operator*(const Quaternion other) + Quaternion Quaternion::operator*(const Quaternion& other) { Quaternion result; float rx = other.X; @@ -644,33 +634,18 @@ namespace XFX return result; } - const Quaternion Quaternion::operator*(const float scaleFactor) + Quaternion Quaternion::operator*(const float scaleFactor) { - Quaternion result; - result.X = X * scaleFactor; - result.Y = Y * scaleFactor; - result.Z = Z * scaleFactor; - result.W = W * scaleFactor; - return result; + return Quaternion(X * scaleFactor, Y * scaleFactor, Z * scaleFactor, W * scaleFactor); } - const Quaternion Quaternion::operator-(const Quaternion other) + Quaternion Quaternion::operator-(const Quaternion& other) { - Quaternion result; - result.X = X - other.X; - result.Y = Y - other.Y; - result.Z = Z - other.Z; - result.W = W - other.W; - return result; + return Quaternion(X - other.X, Y - other.Y, Z - other.Z, W - other.W); } - const Quaternion Quaternion::operator-() + Quaternion Quaternion::operator-() { - Quaternion result; - result.X = -X; - result.Y = -Y; - result.Z = -Z; - result.W = -W; - return result; + return Quaternion(-X, -Y, -Z, -W); } } diff --git a/src/libXFX/Ray.cpp b/src/libXFX/Ray.cpp index 8ab1dec..1fa7464 100644 --- a/src/libXFX/Ray.cpp +++ b/src/libXFX/Ray.cpp @@ -53,9 +53,9 @@ namespace XFX { } - bool Ray::Equals(const Object* obj) const + bool Ray::Equals(Object const * const obj) const { - return is(this, obj) ? (*this == *(Ray*)obj) : false; + return is(this, obj) ? *this == *(Ray *)obj : false; } bool Ray::Equals(const Ray other) const @@ -73,13 +73,13 @@ namespace XFX // TODO: implement } - float Ray::Intersects(const BoundingBox boundingbox) const + float Ray::Intersects(BoundingBox boundingbox) const { float distance; float d = 0.0f; float MAXValue = Single::MaxValue; - if (Math::Abs( Direction.X ) < 0.0000001) + if (Math::Abs(Direction.X) < 0.0000001) { if (Position.X < boundingbox.Min.X || Position.X > boundingbox.Max.X) { @@ -131,19 +131,19 @@ namespace XFX MAX = temp; } - d = Math::Max( MIN, d ); + d = Math::Max(MIN, d); MAXValue = Math::Min(MAX, MAXValue); - if( d > MAXValue ) + if (d > MAXValue) { distance = 0.0f; return distance; } } - if( Math::Abs( Direction.Z ) < 0.0000001 ) + if (Math::Abs(Direction.Z) < 0.0000001) { - if( Position.Z < boundingbox.Min.Z || Position.Z > boundingbox.Max.Z ) + if (Position.Z < boundingbox.Min.Z || Position.Z > boundingbox.Max.Z) { distance = 0.0f; return distance; @@ -155,33 +155,33 @@ namespace XFX float MIN = (boundingbox.Min.Z - Position.Z) * inv; float MAX = (boundingbox.Max.Z - Position.Z) * inv; - if( MIN > MAX ) - { + if (MIN > MAX) + { float temp = MIN; MIN = MAX; MAX = temp; } - d = Math::Max( MIN, d ); - MAXValue = Math::Min( MAX, MAXValue ); + d = Math::Max(MIN, d); + MAXValue = Math::Min(MAX, MAXValue); - if( d > MAXValue ) - { + if (d > MAXValue) + { distance = 0.0f; return distance; } - } + } distance = d; return distance; } - void Ray::Intersects(const BoundingBox boundingbox, out float distance) const + void Ray::Intersects(BoundingBox boundingbox, out float& distance) const { distance = Intersects(boundingbox); } - float Ray::Intersects(const BoundingSphere sphere) const + float Ray::Intersects(BoundingSphere sphere) const { float distance; float x = sphere.Center.X - Position.X; @@ -190,21 +190,21 @@ namespace XFX float pyth = (x * x) + (y * y) + (z * z); float rr = sphere.Radius * sphere.Radius; - if( pyth <= rr ) + if (pyth <= rr) { distance = 0.0f; return distance; } float dot = (x * Direction.X) + (y * Direction.Y) + (z * Direction.Z); - if( dot < 0.0f ) + if (dot < 0.0f) { distance = 0.0f; return distance; } float temp = pyth - (dot * dot); - if( temp > rr ) + if (temp > rr) { distance = 0.0f; return distance; @@ -214,47 +214,47 @@ namespace XFX return distance; } - void Ray::Intersects(const BoundingSphere sphere, out float distance) const + void Ray::Intersects(BoundingSphere sphere, out float& distance) const { distance = Intersects(sphere); } - float Ray::Intersects(const Plane plane) const + float Ray::Intersects(Plane plane) const { float dotDirection = (plane.Normal.X * Direction.X) + (plane.Normal.Y * Direction.Y) + (plane.Normal.Z * Direction.Z); float distance; - if( Math::Abs( dotDirection ) < 0.000001f ) + if (Math::Abs(dotDirection) < 0.000001f) { distance = 0.0f; return distance; } float dotPosition = (plane.Normal.X * Position.X) + (plane.Normal.Y * Position.Y) + (plane.Normal.Z * Position.Z); - float num = ( -plane.D - dotPosition ) / dotDirection; + float num = (-plane.D - dotPosition) / dotDirection; - if( num < 0.0f ) - { - if( num < -0.000001f ) - { + if (num < 0.0f) + { + if (num < -0.000001f) + { distance = 0.0f; return distance; - } + } num = 0.0f; - } + } distance = num; return distance; } - void Ray::Intersects(const Plane plane, out float distance) const + void Ray::Intersects(Plane plane, out float& distance) const { distance = Intersects(plane); } const char* Ray::ToString() const { - return String::Format("{{Position:%s Direction:%s}}", Position.ToString(), Direction.ToString()); + return String::Format("{Position:%s Direction:%s}", Position.ToString(), Direction.ToString()); } bool Ray::operator==(const Ray& right) const @@ -264,6 +264,6 @@ namespace XFX bool Ray::operator!=(const Ray& right) const { - return !((Direction == right.Direction) && (Position == right.Position)); + return ((Direction != right.Direction) || (Position != right.Position)); } } diff --git a/src/libXFX/Rectangle.cpp b/src/libXFX/Rectangle.cpp index 8ce2b76..6f2de20 100644 --- a/src/libXFX/Rectangle.cpp +++ b/src/libXFX/Rectangle.cpp @@ -77,7 +77,7 @@ namespace XFX return ((pt.X >= X) && (pt.Y >=Y) && (pt.X <= Right()) && (pt.Y <= Bottom())); } - void Rectangle::Contains(Point pt, out int result) + void Rectangle::Contains(Point pt, out bool& result) { result = ((pt.X >= X) && (pt.Y >=Y) && (pt.X <= Right()) && (pt.Y <= Bottom())); } @@ -87,14 +87,14 @@ namespace XFX return ((other.X >= X) && (other.Y >= Y) && (other.Bottom() <= Bottom()) && (other.Right() <= Right())); } - void Rectangle::Contains(Rectangle other, out int result) + void Rectangle::Contains(Rectangle other, out bool& result) { result = ((other.X >= X) && (other.Y >= Y) && (other.Bottom() <= Bottom()) && (other.Right() <= Right())); } - bool Rectangle::Equals(const Object *obj) const + bool Rectangle::Equals(Object const * const obj) const { - return is(this, obj) ? (*this == *(Rectangle*)obj) : false; + return is(this, obj) ? *this == *(Rectangle *)obj : false; } bool Rectangle::Equals(const Rectangle obj) const @@ -102,7 +102,7 @@ namespace XFX return (*this == obj); } - int Rectangle::GetHashCode() + int Rectangle::GetHashCode() const { return X ^ Y ^ Width ^ Height; } @@ -123,7 +123,7 @@ namespace XFX return ((Contains(other.Left(), other.Top())) || (Contains(other.Left(), other.Bottom())) || (Contains(other.Right(), other.Top())) || (Contains(other.Right(),other.Bottom()))); } - void Rectangle::Intersects(Rectangle other, out int result) + void Rectangle::Intersects(Rectangle other, out bool& result) { result = Intersects(other); } @@ -147,6 +147,6 @@ namespace XFX bool Rectangle::operator!=(const Rectangle& other) const { - return !((X == other.X) && (Y == other.Y) && (Width == other.Width) && (Height == other.Height)); + return ((X != other.X) || (Y != other.Y) || (Width != other.Width) || (Height != other.Height)); } } diff --git a/src/libXFX/Vector3.cpp b/src/libXFX/Vector3.cpp index a648b2a..0439028 100644 --- a/src/libXFX/Vector3.cpp +++ b/src/libXFX/Vector3.cpp @@ -83,7 +83,7 @@ namespace XFX return Vector3(value1.X + value2.X, value1.Y + value2.Y, value1.Z + value2.Z); } - void Vector3::Add(Vector3 value1, Vector3 value2, out Vector3 result) + void Vector3::Add(Vector3 value1, Vector3 value2, out Vector3& result) { result.X = value1.X + value2.X; result.Y = value1.Y + value2.Y; @@ -99,7 +99,7 @@ namespace XFX return result; } - void Vector3::Baricentric(Vector3 value1, Vector3 value2, Vector3 value3, float amount1, float amount2, out Vector3 result) + void Vector3::Baricentric(Vector3 value1, Vector3 value2, Vector3 value3, float amount1, float amount2, out Vector3& result) { result.X = MathHelper::Baricentric(value1.X, value2.X, value3.X, amount1, amount2); result.Z = MathHelper::Baricentric(value1.X, value2.X, value3.X, amount1, amount2); @@ -115,7 +115,7 @@ namespace XFX return result; } - void Vector3::CatmullRom(Vector3 value1, Vector3 value2, Vector3 value3, Vector3 value4, float amount, out Vector3 result) + void Vector3::CatmullRom(Vector3 value1, Vector3 value2, Vector3 value3, Vector3 value4, float amount, out Vector3& result) { result.X = MathHelper::CatmullRom(value1.X, value2.X, value3.X, value4.X, amount); result.Y = MathHelper::CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount); @@ -131,7 +131,7 @@ namespace XFX return result; } - void Vector3::Clamp(Vector3 value1, Vector3 min, Vector3 max, out Vector3 result) + void Vector3::Clamp(Vector3 value1, Vector3 min, Vector3 max, out Vector3& result) { result.X = MathHelper::Clamp(value1.X, min.X, max.X); result.Y = MathHelper::Clamp(value1.Y, min.Y, max.Y); @@ -147,7 +147,7 @@ namespace XFX return result; } - void Vector3::Cross(Vector3 vector1, Vector3 vector2, out Vector3 result) + void Vector3::Cross(Vector3 vector1, Vector3 vector2, out Vector3& result) { result.X = vector1.Y * vector2.Z - vector1.Z * vector2.Y; result.Y = vector1.Z * vector2.X - vector1.X * vector2.Z; @@ -163,7 +163,7 @@ namespace XFX return Math::Sqrt((x*x) + (y*y) + (z*z)); } - void Vector3::Distance(Vector3 value1, Vector3 value2, out float result) + void Vector3::Distance(Vector3 value1, Vector3 value2, out float& result) { float x = value1.X - value2.X; float y = value1.Y - value2.Y; @@ -181,7 +181,7 @@ namespace XFX return (x*x) + (y*y) + (z*z); } - void Vector3::DistanceSquared(Vector3 value1, Vector3 value2, out float result) + void Vector3::DistanceSquared(Vector3 value1, Vector3 value2, out float& result) { float x = value1.X - value2.X; float y = value1.Y - value2.Y; @@ -195,7 +195,7 @@ namespace XFX return Vector3(value1.X / value2, value1.Y / value2, value1.Z / value2); } - void Vector3::Divide(Vector3 value1, float value2, out Vector3 result) + void Vector3::Divide(Vector3 value1, float value2, out Vector3& result) { result.X = value1.X / value2; result.Y = value1.Y / value2; @@ -211,7 +211,7 @@ namespace XFX return result; } - void Vector3::Divide(Vector3 value1, Vector3 value2, out Vector3 result) + void Vector3::Divide(Vector3 value1, Vector3 value2, out Vector3& result) { result.X = value1.X / value2.X; result.Y = value1.Y / value2.Y; @@ -223,14 +223,14 @@ namespace XFX return (value1.X * value2.X + value1.Y * value2.Y + value1.Z * value2.Z); } - void Vector3::Dot(Vector3 value1, Vector3 value2, out float result) + void Vector3::Dot(Vector3 value1, Vector3 value2, out float& result) { result = (value1.X * value2.X + value1.Y * value2.Y + value1.Z * value2.Z); } - bool Vector3::Equals(const Object* obj) const + bool Vector3::Equals(Object const * const obj) const { - return is(this, obj) ? (*this == *(Vector3*)obj) : false; + return is(this, obj) ? *this == *(Vector3*)obj : false; } bool Vector3::Equals(const Vector3 other) const @@ -251,13 +251,11 @@ namespace XFX Vector3 Vector3::Hermite(Vector3 value1, Vector3 tangent1, Vector3 value2, Vector3 tangent2, float amount) { Vector3 result; - result.X = MathHelper::Hermite(value1.X, tangent1.X, value2.X, tangent2.X, amount); - result.Y = MathHelper::Hermite(value1.Y, tangent1.Y, value2.Y, tangent2.Y, amount); - result.Z = MathHelper::Hermite(value1.Z, tangent1.Z, value2.Z, tangent2.Z, amount); + Hermite(value1, tangent1, value2, tangent2, amount, result); return result; } - void Vector3::Hermite(Vector3 value1, Vector3 tangent1, Vector3 value2, Vector3 tangent2, float amount, out Vector3 result) + void Vector3::Hermite(Vector3 value1, Vector3 tangent1, Vector3 value2, Vector3 tangent2, float amount, out Vector3& result) { result.X = MathHelper::Hermite(value1.X, tangent1.X, value2.X, tangent2.X, amount); result.Y = MathHelper::Hermite(value1.Y, tangent1.Y, value2.Y, tangent2.Y, amount); @@ -277,13 +275,11 @@ namespace XFX Vector3 Vector3::Lerp(Vector3 value1, Vector3 value2, float amount) { Vector3 result; - result.X = MathHelper::Lerp(value1.X, value2.X, amount); - result.Y = MathHelper::Lerp(value1.Y, value2.Y, amount); - result.Z = MathHelper::Lerp(value1.Z, value2.Z, amount); + Lerp(value1, value2, amount, result); return result; } - void Vector3::Lerp(Vector3 value1, Vector3 value2, float amount, out Vector3 result) + void Vector3::Lerp(Vector3 value1, Vector3 value2, float amount, out Vector3& result) { result.X = MathHelper::Lerp(value1.X, value2.X, amount); result.Y = MathHelper::Lerp(value1.Y, value2.Y, amount); @@ -293,13 +289,11 @@ namespace XFX Vector3 Vector3::Max(Vector3 value1, Vector3 value2) { Vector3 result; - result.X = (value1.X > value2.X) ? value1.X : value2.X; - result.Y = (value1.Y > value2.Y) ? value1.Y : value2.Y; - result.Z = (value1.Z > value2.Z) ? value1.Z : value2.Z; + Max(value1, value2, result); return result; } - void Vector3::Max(Vector3 value1, Vector3 value2, out Vector3 result) + void Vector3::Max(Vector3 value1, Vector3 value2, out Vector3& result) { result.X = (value1.X > value2.X) ? value1.X : value2.X; result.Y = (value1.Y > value2.Y) ? value1.Y : value2.Y; @@ -309,13 +303,11 @@ namespace XFX Vector3 Vector3::Min(Vector3 value1, Vector3 value2) { Vector3 result; - result.X = (value1.X < value2.X) ? value1.X : value2.X; - result.Y = (value1.Y < value2.Y) ? value1.Y : value2.Y; - result.Z = (value1.Z < value2.Z) ? value1.Z : value2.Z; + Min(value1, value2, result); return result; } - void Vector3::Min(Vector3 value1, Vector3 value2, out Vector3 result) + void Vector3::Min(Vector3 value1, Vector3 value2, out Vector3& result) { result.X = (value1.X < value2.X) ? value1.X : value2.X; result.Y = (value1.Y < value2.Y) ? value1.Y : value2.Y; @@ -325,13 +317,11 @@ namespace XFX Vector3 Vector3::Multiply(Vector3 value1, float scaleFactor) { Vector3 result; - result.X = value1.X * scaleFactor; - result.Y = value1.Y * scaleFactor; - result.Z = value1.Z * scaleFactor; + Multiply(value1, scaleFactor, result); return result; } - void Vector3::Multiply(Vector3 value1, float scaleFactor, out Vector3 result) + void Vector3::Multiply(Vector3 value1, float scaleFactor, out Vector3& result) { result.X = value1.X * scaleFactor; result.Y = value1.Y * scaleFactor; @@ -341,13 +331,11 @@ namespace XFX Vector3 Vector3::Multiply(Vector3 value1, Vector3 value2) { Vector3 result; - result.X = value1.X * value2.X; - result.Y = value1.Y * value2.Y; - result.Z = value1.Z * value2.Z; + Multiply(value1, value2, result); return result; } - void Vector3::Multiply(Vector3 value1, Vector3 value2, out Vector3 result) + void Vector3::Multiply(Vector3 value1, Vector3 value2, out Vector3& result) { result.X = value1.X * value2.X; result.Y = value1.Y * value2.Y; @@ -357,13 +345,11 @@ namespace XFX Vector3 Vector3::Negate(Vector3 value) { Vector3 result; - result.X = -value.X; - result.Y = -value.Y; - result.Z = -value.Z; + Negate(value, result); return result; } - void Vector3::Negate(Vector3 value, out Vector3 result) + void Vector3::Negate(Vector3 value, out Vector3& result) { result.X = -value.X; result.Y = -value.Y; @@ -394,7 +380,7 @@ namespace XFX return result; } - void Vector3::Normalize(Vector3 value, out Vector3 result) + void Vector3::Normalize(Vector3 value, out Vector3& result) { float length = value.Length(); if(length == 0) @@ -408,16 +394,11 @@ namespace XFX Vector3 Vector3::Reflect(Vector3 vector, Vector3 normal) { Vector3 result; - float dot = ((vector.X * normal.X) + (vector.Y * normal.Y)) + (vector.Z * normal.Z); - - result.X = vector.X - ((2.0f * dot) * normal.X); - result.Y = vector.Y - ((2.0f * dot) * normal.Y); - result.Z = vector.Z - ((2.0f * dot) * normal.Z); - + Reflect(vector, normal, result); return result; } - void Vector3::Reflect(Vector3 vector, Vector3 normal, out Vector3 result) + void Vector3::Reflect(Vector3 vector, Vector3 normal, out Vector3& result) { float dot = ((vector.X * normal.X) + (vector.Y * normal.Y)) + (vector.Z * normal.Z); @@ -429,13 +410,11 @@ namespace XFX Vector3 Vector3::SmoothStep(Vector3 value1, Vector3 value2, float amount) { Vector3 result; - result.X = MathHelper::SmoothStep(value1.X, value2.X, amount); - result.Y = MathHelper::SmoothStep(value1.Y, value2.Y, amount); - result.Z = MathHelper::SmoothStep(value1.Z, value2.Z, amount); + SmoothStep(value1, value2, amount, result); return result; } - void Vector3::SmoothStep(Vector3 value1, Vector3 value2, float amount, out Vector3 result) + void Vector3::SmoothStep(Vector3 value1, Vector3 value2, float amount, out Vector3& result) { result.X = MathHelper::SmoothStep(value1.X, value2.X, amount); result.Y = MathHelper::SmoothStep(value1.Y, value2.Y, amount); @@ -445,13 +424,11 @@ namespace XFX Vector3 Vector3::Subtract(Vector3 value1, Vector3 value2) { Vector3 result; - result.X = value1.X - value2.X; - result.Y = value1.Y - value2.Y; - result.Z = value1.Z - value2.Z; + Subtract(value1, value2, result); return result; } - void Vector3::Subtract(Vector3 value1, Vector3 value2, out Vector3 result) + void Vector3::Subtract(Vector3 value1, Vector3 value2, out Vector3& result) { result.X = value1.X - value2.X; result.Y = value1.Y - value2.Y; @@ -465,17 +442,12 @@ namespace XFX Vector3 Vector3::Transform(Vector3 position, Matrix matrix) { - Vector4 vector; - - vector.X = (((vector.X * matrix.M11) + (vector.Y * matrix.M21)) + (vector.Z * matrix.M31)) + matrix.M41; - vector.Y = (((vector.X * matrix.M12) + (vector.Y * matrix.M22)) + (vector.Z * matrix.M32)) + matrix.M42; - vector.Z = (((vector.X * matrix.M13) + (vector.Y * matrix.M23)) + (vector.Z * matrix.M33)) + matrix.M43; - vector.W = 1 / ((((vector.X * matrix.M14) + (vector.Y * matrix.M24)) + (vector.Z * matrix.M34)) + matrix.M44); - - return Vector3( vector.X * vector.W, vector.Y * vector.W, vector.Z * vector.W ); + Vector3 result; + Transform(position, matrix, result); + return result; } - void Vector3::Transform(Vector3 position, Matrix matrix, out Vector3 result) + void Vector3::Transform(Vector3 position, Matrix matrix, out Vector3& result) { Vector4 vector; @@ -496,7 +468,7 @@ namespace XFX return result; } - void Vector3::Transform(Vector3 position, Quaternion rotation, out Vector3 result) + void Vector3::Transform(Vector3 position, Quaternion rotation, out Vector3& result) { Vector3 xyz = Vector3(rotation.X,rotation.Y, rotation.Z), temp, temp2; Cross(xyz, position, temp); @@ -538,7 +510,7 @@ namespace XFX return result; } - void Vector3::TransformNormal(Vector3 normal, Matrix matrix, out Vector3 result) + void Vector3::TransformNormal(Vector3 normal, Matrix matrix, out Vector3& result) { result.X = ((normal.X * matrix.M11) + (normal.Y * matrix.M21)) + (normal.Z * matrix.M31); result.Y = ((normal.X * matrix.M12) + (normal.Y * matrix.M22)) + (normal.Z * matrix.M32); @@ -557,7 +529,7 @@ namespace XFX } } - Vector3 Vector3::operator+(Vector3 other) + Vector3 Vector3::operator+(const Vector3& other) { Vector3 result; result.X = X + other.X; @@ -566,7 +538,7 @@ namespace XFX return result; } - Vector3 Vector3::operator/(float divider) + Vector3 Vector3::operator/(const float divider) { Vector3 result; result.X = X / divider; @@ -575,7 +547,7 @@ namespace XFX return result; } - Vector3 Vector3::operator/(Vector3 other) + Vector3 Vector3::operator/(const Vector3& other) { Vector3 result; result.X = X / other.X; @@ -584,17 +556,17 @@ namespace XFX return result; } - bool Vector3::operator==(const Vector3 other) const + bool Vector3::operator==(const Vector3& other) const { return Equals(other); } - bool Vector3::operator!=(const Vector3 other) const + bool Vector3::operator!=(const Vector3& other) const { return !Equals(other); } - Vector3 Vector3::operator*(float scaleFactor) + Vector3 Vector3::operator*(const float scaleFactor) { Vector3 result; result.X = X * scaleFactor; @@ -603,7 +575,7 @@ namespace XFX return result; } - Vector3 Vector3::operator*(Vector3 other) + Vector3 Vector3::operator*(const Vector3& other) { Vector3 result; result.X = X * other.X; @@ -612,7 +584,7 @@ namespace XFX return result; } - Vector3 Vector3::operator-(Vector3 other) + Vector3 Vector3::operator-(const Vector3& other) { return Vector3(X -= other.X, Y -= other.Y, Z -= other.Z); } diff --git a/src/libXFX/Vector4.cpp b/src/libXFX/Vector4.cpp index 0e7eb56..4132986 100644 --- a/src/libXFX/Vector4.cpp +++ b/src/libXFX/Vector4.cpp @@ -79,13 +79,12 @@ namespace XFX Vector4 Vector4::Add(Vector4 vector1, Vector4 vector2) { - return Vector4(vector1.X + vector2.X, - vector1.Y + vector2.Y, - vector1.Z + vector2.Z, - vector1.W + vector2.W); + Vector4 result; + Add(vector1, vector2, result); + return result; } - void Vector4::Add(Vector4 vector1, Vector4 vector2, out Vector4 result) + void Vector4::Add(Vector4 vector1, Vector4 vector2, out Vector4& result) { result.W = vector1.W + vector2.W; result.X = vector1.X + vector2.X; @@ -95,15 +94,12 @@ namespace XFX Vector4 Vector4::Baricentric(Vector4 value1, Vector4 value2, Vector4 value3, float amount1, float amount2) { - Vector4 result; - result.X = MathHelper::Baricentric(value1.X, value2.X, value3.X, amount1, amount2); - result.Y = MathHelper::Baricentric(value1.Y, value2.Y, value3.Y, amount1, amount2); - result.Z = MathHelper::Baricentric(value1.Z, value2.Z, value3.Z, amount1, amount2); - result.W = MathHelper::Baricentric(value1.W, value2.W, value3.W, amount1, amount2); - return result; + Vector4 result; + Baricentric(value1, value2, value3, amount1, amount2, result); + return result; } - void Vector4::Baricentric(Vector4 value1, Vector4 value2, Vector4 value3, float amount1, float amount2, out Vector4 result) + void Vector4::Baricentric(Vector4 value1, Vector4 value2, Vector4 value3, float amount1, float amount2, out Vector4& result) { result.X = MathHelper::Baricentric(value1.X, value2.X, value3.X, amount1, amount2); result.Y = MathHelper::Baricentric(value1.Y, value2.Y, value3.Y, amount1, amount2); @@ -121,7 +117,7 @@ namespace XFX return result; } - void Vector4::CatmullRom(Vector4 value1, Vector4 value2, Vector4 value3, Vector4 value4, float amount, out Vector4 result) + void Vector4::CatmullRom(Vector4 value1, Vector4 value2, Vector4 value3, Vector4 value4, float amount, out Vector4& result) { result.X = MathHelper::CatmullRom(value1.X, value2.X, value3.X, value4.X, amount); result.Y = MathHelper::CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount); @@ -136,7 +132,7 @@ namespace XFX return result; } - void Vector4::Clamp(Vector4 value1, Vector4 min, Vector4 max, out Vector4 result) + void Vector4::Clamp(Vector4 value1, Vector4 min, Vector4 max, out Vector4& result) { result = Vector4( MathHelper::Clamp(value1.X, min.X, max.X), @@ -150,7 +146,7 @@ namespace XFX return Math::Sqrt(DistanceSquared(value1, value2)); } - void Vector4::Distance(Vector4 value1, Vector4 value2, out float result) + void Vector4::Distance(Vector4 value1, Vector4 value2, out float& result) { result = Math::Sqrt(DistanceSquared(value1, value2)); } @@ -164,7 +160,7 @@ namespace XFX return result; } - void Vector4::DistanceSquared(Vector4 value1, Vector4 value2, out float result) + void Vector4::DistanceSquared(Vector4 value1, Vector4 value2, out float& result) { result = (value1.W - value2.W) * (value1.W - value2.W) + (value1.X - value2.X) * (value1.X - value2.X) + @@ -177,7 +173,7 @@ namespace XFX return Vector4(value.X / scale, value.Y / scale, value.Z / scale, value.W / scale); } - void Vector4::Divide(Vector4 value, float scale, out Vector4 result) + void Vector4::Divide(Vector4 value, float scale, out Vector4& result) { result.W = value.W / scale; result.X = value.X / scale; @@ -190,7 +186,7 @@ namespace XFX return Vector4(vector1.X / vector2.X, vector1.Y / vector2.Y, vector1.Z / vector2.Z, vector1.W / vector2.W); } - void Vector4::Divide(Vector4 vector1, Vector4 vector2, out Vector4 result) + void Vector4::Divide(Vector4 vector1, Vector4 vector2, out Vector4& result) { result.W = vector1.W / vector2.W; result.X = vector1.X / vector2.X; @@ -198,9 +194,9 @@ namespace XFX result.Z = vector1.Z / vector2.Z; } - bool Vector4::Equals(const Object* obj) const + bool Vector4::Equals(Object const * const obj) const { - return is(this, obj) ? (*this == *(Vector4*)obj) : false; + return is(this, obj) ? *this == *(Vector4*)obj : false; } bool Vector4::Equals(const Vector4 other) const @@ -225,7 +221,7 @@ namespace XFX return result; } - void Vector4::Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount, out Vector4 result) + void Vector4::Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount, out Vector4& result) { result.W = MathHelper::Hermite(value1.W, tangent1.W, value2.W, tangent2.W, amount); result.X = MathHelper::Hermite(value1.X, tangent1.X, value2.X, tangent2.X, amount); @@ -250,13 +246,12 @@ namespace XFX return result; } - void Vector4::Lerp(Vector4 value1, Vector4 value2, float amount, out Vector4 result) + void Vector4::Lerp(Vector4 value1, Vector4 value2, float amount, out Vector4& result) { - result = Vector4( - MathHelper::Lerp(value1.X, value2.X, amount), - MathHelper::Lerp(value1.Y, value2.Y, amount), - MathHelper::Lerp(value1.Z, value2.Z, amount), - MathHelper::Lerp(value1.W, value2.W, amount)); + result.X = MathHelper::Lerp(value1.X, value2.X, amount); + result.Y = MathHelper::Lerp(value1.Y, value2.Y, amount); + result.Z = MathHelper::Lerp(value1.Z, value2.Z, amount); + result.W = MathHelper::Lerp(value1.W, value2.W, amount); } Vector4 Vector4::Max(Vector4 value1, Vector4 value2) @@ -266,13 +261,12 @@ namespace XFX return result; } - void Vector4::Max(Vector4 value1, Vector4 value2, out Vector4 result) + void Vector4::Max(Vector4 value1, Vector4 value2, out Vector4& result) { - result = Vector4( - MathHelper::Max(value1.X, value2.X), - MathHelper::Max(value1.Y, value2.Y), - MathHelper::Max(value1.Z, value2.Z), - MathHelper::Max(value1.W, value2.W)); + result.X = MathHelper::Max(value1.X, value2.X); + result.Y = MathHelper::Max(value1.Y, value2.Y); + result.Z = MathHelper::Max(value1.Z, value2.Z); + result.W = MathHelper::Max(value1.W, value2.W); } Vector4 Vector4::Min(Vector4 value1, Vector4 value2) @@ -282,7 +276,7 @@ namespace XFX return result; } - void Vector4::Min(Vector4 value1, Vector4 value2, out Vector4 result) + void Vector4::Min(Vector4 value1, Vector4 value2, out Vector4& result) { result = Vector4( MathHelper::Min(value1.X, value2.X), @@ -298,7 +292,7 @@ namespace XFX return result; } - void Vector4::Multiply(Vector4 value1, float scaleFactor, out Vector4 result) + void Vector4::Multiply(Vector4 value1, float scaleFactor, out Vector4& result) { result.X = value1.X * scaleFactor; result.Y = value1.Y * scaleFactor; @@ -313,7 +307,7 @@ namespace XFX return result; } - void Vector4::Multiply(Vector4 value1, Vector4 value2, out Vector4 result) + void Vector4::Multiply(Vector4 value1, Vector4 value2, out Vector4& result) { result.W = value1.W * value2.W; result.X = value1.X * value2.X; @@ -328,7 +322,7 @@ namespace XFX return result; } - void Vector4::Negate(Vector4 value, out Vector4 result) + void Vector4::Negate(Vector4 value, out Vector4& result) { result = Vector4(-value.X, -value.Y, -value.Z, -value.W); } @@ -351,7 +345,7 @@ namespace XFX return value; } - void Vector4::Normalize(Vector4 value, out Vector4 result) + void Vector4::Normalize(Vector4 value, out Vector4& result) { float factor; float length = value.Length(); @@ -372,7 +366,7 @@ namespace XFX MathHelper::SmoothStep(value1.W, value2.W, amount)); } - void Vector4::SmoothStep(Vector4 value1, Vector4 value2, float amount, out Vector4 result) + void Vector4::SmoothStep(Vector4 value1, Vector4 value2, float amount, out Vector4& result) { result = Vector4( MathHelper::SmoothStep(value1.X, value2.X, amount), @@ -390,7 +384,7 @@ namespace XFX return vector1; } - void Vector4::Subtract(Vector4 vector1, Vector4 vector2, out Vector4 result) + void Vector4::Subtract(Vector4 vector1, Vector4 vector2, out Vector4& result) { result.X = vector1.X - vector2.X; result.Y = vector1.Y - vector2.Y; @@ -426,7 +420,7 @@ namespace XFX return result; } - void Vector4::Transform(Vector4 vector, Quaternion rotation, out Vector4 result) + void Vector4::Transform(Vector4 vector, Quaternion rotation, out Vector4& result) { float x = rotation.X + rotation.X; float y = rotation.Y + rotation.Y; @@ -453,7 +447,7 @@ namespace XFX return result; } - void Vector4::Transform(Vector3 vector, Quaternion rotation, out Vector4 result) + void Vector4::Transform(Vector3 vector, Quaternion rotation, out Vector4& result) { float x = rotation.X + rotation.X; float y = rotation.Y + rotation.Y; @@ -480,7 +474,7 @@ namespace XFX return result; } - void Vector4::Transform(Vector2 vector, Quaternion rotation, out Vector4 result) + void Vector4::Transform(Vector2 vector, Quaternion rotation, out Vector4& result) { float x = rotation.X + rotation.X; float y = rotation.Y + rotation.Y; @@ -502,16 +496,17 @@ namespace XFX Vector4 Vector4::Transform(Vector4 vector, Matrix matrix) { - Transform(vector, matrix, vector); + Vector4 vector2; + Transform(vector, matrix, vector2); return vector; } - void Vector4::Transform(Vector4 vector, Matrix matrix, Vector4 result) + void Vector4::Transform(Vector4 vector, Matrix matrix, out Vector4& result) { - result = Vector4((vector.X * matrix.M11) + (vector.Y * matrix.M21) + (vector.Z * matrix.M31) + (vector.W * matrix.M41), - (vector.X * matrix.M12) + (vector.Y * matrix.M22) + (vector.Z * matrix.M32) + (vector.W * matrix.M42), - (vector.X * matrix.M13) + (vector.Y * matrix.M23) + (vector.Z * matrix.M33) + (vector.W * matrix.M43), - (vector.X * matrix.M14) + (vector.Y * matrix.M24) + (vector.Z * matrix.M34) + (vector.W * matrix.M44)); + result.X = (vector.X * matrix.M11) + (vector.Y * matrix.M21) + (vector.Z * matrix.M31) + (vector.W * matrix.M41); + result.Y = (vector.X * matrix.M12) + (vector.Y * matrix.M22) + (vector.Z * matrix.M32) + (vector.W * matrix.M42); + result.Z = (vector.X * matrix.M13) + (vector.Y * matrix.M23) + (vector.Z * matrix.M33) + (vector.W * matrix.M43); + result.W = (vector.X * matrix.M14) + (vector.Y * matrix.M24) + (vector.Z * matrix.M34) + (vector.W * matrix.M44); } Vector4 Vector4::Transform(Vector3 vector, Matrix matrix) @@ -521,12 +516,12 @@ namespace XFX return result; } - void Vector4::Transform(Vector3 vector, Matrix matrix, out Vector4 result) + void Vector4::Transform(Vector3 vector, Matrix matrix, out Vector4& result) { - result = Vector4((vector.X * matrix.M11) + (vector.Y * matrix.M21) + (vector.Z * matrix.M31) + matrix.M41, - (vector.X * matrix.M12) + (vector.Y * matrix.M22) + (vector.Z * matrix.M32) + matrix.M42, - (vector.X * matrix.M13) + (vector.Y * matrix.M23) + (vector.Z * matrix.M33) + matrix.M43, - (vector.X * matrix.M14) + (vector.Y * matrix.M24) + (vector.Z * matrix.M34) + matrix.M44); + result.X = (vector.X * matrix.M11) + (vector.Y * matrix.M21) + (vector.Z * matrix.M31) + matrix.M41; + result.Y = (vector.X * matrix.M12) + (vector.Y * matrix.M22) + (vector.Z * matrix.M32) + matrix.M42; + result.Z = (vector.X * matrix.M13) + (vector.Y * matrix.M23) + (vector.Z * matrix.M33) + matrix.M43; + result.W = (vector.X * matrix.M14) + (vector.Y * matrix.M24) + (vector.Z * matrix.M34) + matrix.M44; } Vector4 Vector4::Transform(Vector2 vector, Matrix matrix) @@ -536,17 +531,17 @@ namespace XFX return result; } - void Vector4::Transform(Vector2 vector, Matrix matrix, out Vector4 result) + void Vector4::Transform(Vector2 vector, Matrix matrix, out Vector4& result) { - result = Vector4((vector.X * matrix.M11) + (vector.Y * matrix.M21) + matrix.M41, - (vector.X * matrix.M12) + (vector.Y * matrix.M22) + matrix.M42, - (vector.X * matrix.M13) + (vector.Y * matrix.M23) + matrix.M43, - (vector.X * matrix.M14) + (vector.Y * matrix.M24) + matrix.M44); + result.X = (vector.X * matrix.M11) + (vector.Y * matrix.M21) + matrix.M41; + result.Y = (vector.X * matrix.M12) + (vector.Y * matrix.M22) + matrix.M42; + result.Z = (vector.X * matrix.M13) + (vector.Y * matrix.M23) + matrix.M43; + result.W = (vector.X * matrix.M14) + (vector.Y * matrix.M24) + matrix.M44; } // // Operators // - Vector4 Vector4::operator-(const Vector4& other) + Vector4 Vector4::operator -(const Vector4& other) { X -= other.X; Y -= other.Y; @@ -555,7 +550,7 @@ namespace XFX return *this; } - Vector4 Vector4::operator-() + Vector4 Vector4::operator -() { return Vector4(-X, -Y, -Z, -W); } @@ -565,7 +560,7 @@ namespace XFX return ((X != other.X) || (Y != other.Y) || (Z != other.Z) || (W != other.W)); } - Vector4 Vector4::operator*(const float scaleFactor) + Vector4 Vector4::operator *(const float scaleFactor) { W *= scaleFactor; X *= scaleFactor; @@ -574,7 +569,7 @@ namespace XFX return *this; } - Vector4 Vector4::operator*(const Vector4& other) + Vector4 Vector4::operator *(const Vector4& other) { W *= other.W; X *= other.X; @@ -583,7 +578,7 @@ namespace XFX return *this; } - Vector4 Vector4::operator/(const float scaleFactor) + Vector4 Vector4::operator /(const float scaleFactor) { W /= scaleFactor; X /= scaleFactor; @@ -592,7 +587,7 @@ namespace XFX return *this; } - Vector4 Vector4::operator/(const Vector4& other) + Vector4 Vector4::operator /(const Vector4& other) { W /= other.W; X /= other.X; @@ -601,7 +596,7 @@ namespace XFX return *this; } - Vector4 Vector4::operator+(const Vector4& other) + Vector4 Vector4::operator +(const Vector4& other) { X += other.X; Y += other.Y; diff --git a/src/libXFX/libXFX.vcxproj b/src/libXFX/libXFX.vcxproj index 4832e14..013a80e 100644 --- a/src/libXFX/libXFX.vcxproj +++ b/src/libXFX/libXFX.vcxproj @@ -126,6 +126,7 @@ + diff --git a/src/libXFX/libXFX.vcxproj.filters b/src/libXFX/libXFX.vcxproj.filters index 10c116b..9357a25 100644 --- a/src/libXFX/libXFX.vcxproj.filters +++ b/src/libXFX/libXFX.vcxproj.filters @@ -475,6 +475,9 @@ Header Files\Audio + + Header Files\Audio +