mirror of
https://github.com/Halofreak1990/XFXFramework
synced 2024-12-26 13:49:34 +01:00
Added missing TypeInfos to XFX namespace
Removed excess whitespace
This commit is contained in:
parent
b0dd58a08b
commit
7c5bc83237
@ -33,6 +33,7 @@
|
||||
#include <System/Math.h>
|
||||
#include <System/Single.h>
|
||||
#include <System/String.h>
|
||||
#include <System/Type.h>
|
||||
|
||||
#include <sassert.h>
|
||||
|
||||
@ -41,6 +42,7 @@ using namespace System;
|
||||
namespace XFX
|
||||
{
|
||||
const int BoundingBox::CornerCount = 8;
|
||||
const Type BoundingBoxTypeInfo("BoundingBox", "XFX::BoundingBox", TypeCode::Object);
|
||||
|
||||
BoundingBox::BoundingBox(const Vector3 min, const Vector3 max)
|
||||
: Max(max), Min(min)
|
||||
@ -67,17 +69,25 @@ namespace XFX
|
||||
void BoundingBox::Contains(BoundingBox box, out ContainmentType_t& result) const
|
||||
{
|
||||
if( Max.X < box.Min.X || Min.X > box.Max.X )
|
||||
{
|
||||
result = ContainmentType::Disjoint;
|
||||
}
|
||||
|
||||
if( Max.Y < box.Min.Y || Min.Y > box.Max.Y )
|
||||
{
|
||||
result = ContainmentType::Disjoint;
|
||||
}
|
||||
|
||||
if( Max.Z < box.Min.Z || Min.Z > box.Max.Z )
|
||||
{
|
||||
result = ContainmentType::Disjoint;
|
||||
}
|
||||
|
||||
if( Min.X <= box.Min.X && box.Max.X <= Max.X && Min.Y <= box.Min.Y &&
|
||||
box.Max.Y <= Max.Y && Min.Z <= box.Min.Z && box.Max.Z <= Max.Z )
|
||||
{
|
||||
result = ContainmentType::Contains;
|
||||
}
|
||||
|
||||
result = ContainmentType::Intersects;
|
||||
}
|
||||
@ -104,14 +114,18 @@ namespace XFX
|
||||
float radius = sphere.Radius;
|
||||
|
||||
if(dist > (radius * radius))
|
||||
{
|
||||
result = ContainmentType::Disjoint;
|
||||
}
|
||||
|
||||
if(Min.X + radius <= sphere.Center.X && sphere.Center.X <= Max.X - radius &&
|
||||
Max.X - Min.X > radius && Min.Y + radius <= sphere.Center.Y &&
|
||||
sphere.Center.Y <= Max.Y - radius && Max.Y - Min.Y > radius &&
|
||||
Min.Z + radius <= sphere.Center.Z && sphere.Center.Z <= Max.Z - radius &&
|
||||
Max.X - Min.X > radius)
|
||||
{
|
||||
result = ContainmentType::Contains;
|
||||
}
|
||||
|
||||
result = ContainmentType::Intersects;
|
||||
}
|
||||
@ -120,7 +134,9 @@ namespace XFX
|
||||
{
|
||||
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)
|
||||
{
|
||||
return ContainmentType::Contains;
|
||||
}
|
||||
|
||||
return ContainmentType::Disjoint;
|
||||
}
|
||||
@ -129,7 +145,9 @@ namespace XFX
|
||||
{
|
||||
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)
|
||||
{
|
||||
result = ContainmentType::Contains;
|
||||
}
|
||||
|
||||
result = ContainmentType::Disjoint;
|
||||
}
|
||||
@ -193,9 +211,9 @@ namespace XFX
|
||||
return Min.GetHashCode() + Max.GetHashCode();
|
||||
}
|
||||
|
||||
int BoundingBox::GetType()
|
||||
const Type& BoundingBox::GetType()
|
||||
{
|
||||
// TODO: implement
|
||||
return BoundingBoxTypeInfo;
|
||||
}
|
||||
|
||||
bool BoundingBox::Intersects(BoundingBox box) const
|
||||
@ -208,10 +226,14 @@ namespace XFX
|
||||
void BoundingBox::Intersects(BoundingBox box, out bool& result) const
|
||||
{
|
||||
if (Max.X < box.Min.X || Min.X > box.Max.X)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (Max.Y < box.Min.Y || Min.Y > box.Max.Y)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
result = (Max.Z >= box.Min.Z && Min.Z <= box.Max.Z);
|
||||
}
|
||||
|
@ -169,16 +169,19 @@ namespace XFX
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return ContainmentType::Contains;
|
||||
}
|
||||
|
||||
return ContainmentType::Intersects;
|
||||
}
|
||||
|
||||
ContainmentType_t BoundingFrustum::Contains(BoundingFrustum frustrum)
|
||||
{
|
||||
ContainmentType_t disjoint = ContainmentType::Disjoint;
|
||||
|
||||
if (Intersects(frustrum))
|
||||
{
|
||||
disjoint = ContainmentType::Contains;
|
||||
@ -190,6 +193,7 @@ namespace XFX
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return disjoint;
|
||||
}
|
||||
|
||||
@ -198,6 +202,7 @@ namespace XFX
|
||||
Vector3 center = sphere.Center;
|
||||
float radius = sphere.Radius;
|
||||
int num2 = 0;
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
float num5 = ((planes[i].Normal.X * center.X) + (planes[i].Normal.Y * center.Y)) + (planes[i].Normal.Z * center.Z);
|
||||
@ -211,10 +216,12 @@ namespace XFX
|
||||
num2++;
|
||||
}
|
||||
}
|
||||
|
||||
if (num2 != 6)
|
||||
{
|
||||
return ContainmentType::Intersects;
|
||||
}
|
||||
|
||||
return ContainmentType::Contains;
|
||||
}
|
||||
|
||||
@ -223,17 +230,20 @@ namespace XFX
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
float num2 = (((planes[i].Normal.X * point.X) + (planes[i].Normal.Y * point.Y)) + (planes[i].Normal.Z * point.Z)) + planes[i].D;
|
||||
|
||||
if (num2 > 1E-05f)
|
||||
{
|
||||
return ContainmentType::Disjoint;
|
||||
}
|
||||
}
|
||||
|
||||
return ContainmentType::Contains;
|
||||
}
|
||||
|
||||
void BoundingFrustum::Contains(BoundingBox box, out ContainmentType_t& result)
|
||||
{
|
||||
bool flag = false;
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
switch (box.Intersects(planes[i]))
|
||||
@ -247,6 +257,7 @@ namespace XFX
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
result = flag ? ContainmentType::Intersects : ContainmentType::Contains;
|
||||
}
|
||||
|
||||
@ -255,20 +266,24 @@ namespace XFX
|
||||
Vector3 center = sphere.Center;
|
||||
float radius = sphere.Radius;
|
||||
int num2 = 0;
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
float num5 = ((planes[i].Normal.X * center.X) + (planes[i].Normal.Y * center.Y)) + (planes[i].Normal.Z * center.Z);
|
||||
float num3 = num5 + planes[i].D;
|
||||
|
||||
if (num3 > radius)
|
||||
{
|
||||
result = ContainmentType::Disjoint;
|
||||
return;
|
||||
}
|
||||
|
||||
if (num3 < -radius)
|
||||
{
|
||||
num2++;
|
||||
}
|
||||
}
|
||||
|
||||
result = (num2 == 6) ? ContainmentType::Contains : ContainmentType::Intersects;
|
||||
}
|
||||
|
||||
@ -277,12 +292,14 @@ namespace XFX
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
float num2 = (((planes[i].Normal.X * point.X) + (planes[i].Normal.Y * point.Y)) + (planes[i].Normal.Z * point.Z)) + planes[i].D;
|
||||
|
||||
if (num2 > 1E-05f)
|
||||
{
|
||||
result = ContainmentType::Disjoint;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
result = ContainmentType::Contains;
|
||||
}
|
||||
|
||||
@ -306,8 +323,10 @@ namespace XFX
|
||||
sassert(corners != null, "corners cannot be null.");
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
corners[i] = cornerArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
int BoundingFrustum::GetHashCode() const
|
||||
{
|
||||
@ -343,10 +362,12 @@ namespace XFX
|
||||
PlaneIntersectionType_t BoundingFrustum::Intersects(Plane plane)
|
||||
{
|
||||
int num = 0;
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
float num3 = 0;
|
||||
Vector3::Dot(cornerArray[i], plane.Normal, num3);
|
||||
|
||||
if ((num3 + plane.D) > 0)
|
||||
{
|
||||
num |= 1;
|
||||
@ -355,15 +376,18 @@ namespace XFX
|
||||
{
|
||||
num |= 2;
|
||||
}
|
||||
|
||||
if (num == 3)
|
||||
{
|
||||
return PlaneIntersectionType::Intersecting;
|
||||
}
|
||||
}
|
||||
|
||||
if (num != 1)
|
||||
{
|
||||
return PlaneIntersectionType::Back;
|
||||
}
|
||||
|
||||
return PlaneIntersectionType::Front;
|
||||
}
|
||||
|
||||
@ -387,10 +411,12 @@ namespace XFX
|
||||
void BoundingFrustum::Intersects(Plane plane, out PlaneIntersectionType_t& result)
|
||||
{
|
||||
int num = 0;
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
float num3 = 0;
|
||||
Vector3::Dot(cornerArray[i], plane.Normal, num3);
|
||||
|
||||
if ((num3 + plane.D) > 0)
|
||||
{
|
||||
num |= 1;
|
||||
@ -399,18 +425,21 @@ namespace XFX
|
||||
{
|
||||
num |= 2;
|
||||
}
|
||||
|
||||
if (num == 3)
|
||||
{
|
||||
result = PlaneIntersectionType::Intersecting;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
result = (num == 1) ? PlaneIntersectionType::Front : PlaneIntersectionType::Back;
|
||||
}
|
||||
|
||||
void BoundingFrustum::Intersects(Ray ray, out float& result)
|
||||
{
|
||||
ContainmentType_t type = Contains(ray.Position);
|
||||
|
||||
if (type == ContainmentType::Contains)
|
||||
{
|
||||
result = 0.0f;
|
||||
@ -420,6 +449,7 @@ namespace XFX
|
||||
float minValue = Single::MinValue;
|
||||
float maxValue = Single::MaxValue;
|
||||
result = 0;
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
float num3 = 0;
|
||||
@ -428,6 +458,7 @@ namespace XFX
|
||||
Vector3::Dot(ray.Direction, normal, num6);
|
||||
Vector3::Dot(ray.Position, normal, num3);
|
||||
num3 += planes[i].D;
|
||||
|
||||
if (Math::Abs(num6) < 1E-05f)
|
||||
{
|
||||
if (num3 > 0.0f)
|
||||
@ -438,12 +469,14 @@ namespace XFX
|
||||
else
|
||||
{
|
||||
float num = -num3 / num6;
|
||||
|
||||
if (num6 < 0.0f)
|
||||
{
|
||||
if (num > maxValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (num > minValue)
|
||||
{
|
||||
minValue = num;
|
||||
@ -455,6 +488,7 @@ namespace XFX
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (num < maxValue)
|
||||
{
|
||||
maxValue = num;
|
||||
@ -462,7 +496,9 @@ namespace XFX
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float num7 = (minValue >= 0) ? minValue : maxValue;
|
||||
|
||||
if (num7 >= 0)
|
||||
{
|
||||
result = float(num7);
|
||||
@ -497,12 +533,14 @@ namespace XFX
|
||||
planes[1].Normal.Y = -value.M24 + value.M23;
|
||||
planes[1].Normal.Z = -value.M34 + value.M33;
|
||||
planes[1].D = -value.M44 + value.M43;
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
float num2 = planes[i].Normal.Length();
|
||||
planes[i].Normal = (planes[i].Normal / num2);
|
||||
planes[i].D /= num2;
|
||||
}
|
||||
|
||||
Ray ray = ComputeIntersectionLine(planes[0], planes[2]);
|
||||
cornerArray[0] = ComputeIntersection(planes[4], ray);
|
||||
cornerArray[3] = ComputeIntersection(planes[5], ray);
|
||||
|
@ -27,9 +27,12 @@
|
||||
|
||||
#include <BoundingSphere.h>
|
||||
#include <System/String.h>
|
||||
#include <System/Type.h>
|
||||
|
||||
namespace XFX
|
||||
{
|
||||
const Type BoundingSphereTypeInfo("BoundingSphere", "XFX::BoundingSphere", TypeCode::Object);
|
||||
|
||||
BoundingSphere::BoundingSphere(const Vector3 center, const float radius)
|
||||
: Center(center), Radius(radius)
|
||||
{
|
||||
@ -55,6 +58,11 @@ namespace XFX
|
||||
return (*this == other);
|
||||
}
|
||||
|
||||
const Type& BoundingSphere::GetType()
|
||||
{
|
||||
return BoundingSphereTypeInfo;
|
||||
}
|
||||
|
||||
int BoundingSphere::GetHashCode() const
|
||||
{
|
||||
return Center.GetHashCode() + (int)Radius;
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <System/Math.h>
|
||||
#include <System/String.h>
|
||||
#include <System/Type.h>
|
||||
#include <MathHelper.h>
|
||||
#include <Matrix.h>
|
||||
#include <Plane.h>
|
||||
@ -40,6 +41,7 @@ using namespace System;
|
||||
namespace XFX
|
||||
{
|
||||
const Matrix Matrix::Identity = Matrix(1.0f, 0, 0, 0, 0, 1.0f, 0, 0, 0, 0, 1.0f, 0, 0, 0, 0, 1.0f);
|
||||
const Type MatrixTypeInfo("Matrix", "XFX::Matrix", TypeCode::Object);
|
||||
|
||||
Matrix::Matrix(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44)
|
||||
: M11(m11), M12(m12), M13(m13), M14(m14),
|
||||
@ -192,6 +194,7 @@ namespace XFX
|
||||
vector.Y = objectPosition.Y - cameraPosition.Y;
|
||||
vector.Z = objectPosition.Z - cameraPosition.Z;
|
||||
float num = vector.LengthSquared();
|
||||
|
||||
if (num < 0.0001f)
|
||||
{
|
||||
vector = (cameraForwardVector != null) ? -Vector3(cameraForwardVector->X, cameraForwardVector->Y, cameraForwardVector->Z) : Vector3::Forward;
|
||||
@ -200,6 +203,7 @@ namespace XFX
|
||||
{
|
||||
Vector3::Multiply(vector, (float) (1.0f / ((float) Math::Sqrt((double) num))), vector);
|
||||
}
|
||||
|
||||
Vector3::Cross(cameraUpVector, vector, vector3);
|
||||
vector3.Normalize();
|
||||
Vector3::Cross(vector, vector3, vector2);
|
||||
@ -238,6 +242,7 @@ namespace XFX
|
||||
vector2.Y = objectPosition.Y - cameraPosition.Y;
|
||||
vector2.Z = objectPosition.Z - cameraPosition.Z;
|
||||
float num2 = vector2.LengthSquared();
|
||||
|
||||
if (num2 < 0.0001f)
|
||||
{
|
||||
vector2 = (cameraForwardVector != null) ? -Vector3(cameraForwardVector->X, cameraForwardVector->Y, cameraForwardVector->Z) : Vector3::Forward;
|
||||
@ -246,14 +251,17 @@ namespace XFX
|
||||
{
|
||||
Vector3::Multiply(vector2, (float) (1.0f / ((float) Math::Sqrt((double) num2))), vector2);
|
||||
}
|
||||
|
||||
Vector3 vector4 = rotateAxis;
|
||||
Vector3::Dot(rotateAxis, vector2, num);
|
||||
|
||||
if (Math::Abs(num) > 0.9982547f)
|
||||
{
|
||||
if (objectForwardVector != null)
|
||||
{
|
||||
vector = Vector3(objectForwardVector->X, objectForwardVector->Y, objectForwardVector->Z);
|
||||
Vector3::Dot(rotateAxis, vector, num);
|
||||
|
||||
if (Math::Abs(num) > 0.9982547f)
|
||||
{
|
||||
num = ((rotateAxis.X * Vector3::Forward.X) + (rotateAxis.Y * Vector3::Forward.Y)) + (rotateAxis.Z * Vector3::Forward.Z);
|
||||
@ -265,6 +273,7 @@ namespace XFX
|
||||
num = ((rotateAxis.X * Vector3::Forward.X) + (rotateAxis.Y * Vector3::Forward.Y)) + (rotateAxis.Z * Vector3::Forward.Z);
|
||||
vector = (Math::Abs(num) > 0.9982547f) ? Vector3::Right : Vector3::Forward;
|
||||
}
|
||||
|
||||
Vector3::Cross(rotateAxis, vector, vector3);
|
||||
vector3.Normalize();
|
||||
Vector3::Cross(vector3, rotateAxis, vector);
|
||||
@ -277,6 +286,7 @@ namespace XFX
|
||||
Vector3::Cross(vector3, vector4, vector);
|
||||
vector.Normalize();
|
||||
}
|
||||
|
||||
result.M11 = vector3.X;
|
||||
result.M12 = vector3.Y;
|
||||
result.M13 = vector3.Z;
|
||||
@ -305,7 +315,9 @@ namespace XFX
|
||||
void Matrix::CreateFromAxisAngle(Vector3 axis, float angle, out Matrix& result)
|
||||
{
|
||||
if(axis.LengthSquared() != 1.0f)
|
||||
{
|
||||
axis.Normalize();
|
||||
}
|
||||
|
||||
float x = axis.X;
|
||||
float y = axis.Y;
|
||||
@ -867,26 +879,44 @@ namespace XFX
|
||||
translation.Y = M42;
|
||||
translation.Z = M43;
|
||||
float xs, ys, zs;
|
||||
|
||||
if (Math::Sign(M11 * M12 * M13 * M14) < 0)
|
||||
{
|
||||
xs = -1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
xs = 1.0f;
|
||||
}
|
||||
|
||||
if (Math::Sign(M21 * M22 * M23 * M24) < 0)
|
||||
{
|
||||
ys = -1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
ys = 1.0f;
|
||||
}
|
||||
|
||||
if (Math::Sign(M31 * M32 * M33 * M34) < 0)
|
||||
{
|
||||
zs = -1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
zs = 1.0f;
|
||||
}
|
||||
|
||||
scale.X = xs * (float)Math::Sqrt(M11 * M11 + M12 * M12 + M13 * M13);
|
||||
scale.Y = ys * (float)Math::Sqrt(M21 * M21 + M22 * M22 + M23 * M23);
|
||||
scale.Z = zs * (float)Math::Sqrt(M31 * M31 + M32 * M32 + M33 * M33);
|
||||
|
||||
if (scale.X == 0.0 || scale.Y == 0.0 || scale.Z == 0.0)
|
||||
{
|
||||
rotation = Quaternion::Identity;
|
||||
return false;
|
||||
}
|
||||
|
||||
Matrix m1 = Matrix(M11/scale.X, M12/scale.X, M13/scale.X, 0,
|
||||
M21/scale.Y, M22/scale.Y, M23/scale.Y, 0,
|
||||
M31/scale.Z, M32/scale.Z, M33/scale.Z, 0,
|
||||
@ -966,9 +996,9 @@ namespace XFX
|
||||
(int)M31 ^ (int)M32 ^ (int)M33 ^ (int)M34 ^ (int)M41 ^ (int)M42 ^ (int)M43 ^ (int)M44);
|
||||
}
|
||||
|
||||
int Matrix::GetType()
|
||||
const Type& Matrix::GetType()
|
||||
{
|
||||
// TODO: implement
|
||||
return MatrixTypeInfo;
|
||||
}
|
||||
|
||||
void Matrix::Invert(Matrix matrix, out Matrix& result)
|
||||
|
@ -157,12 +157,16 @@ namespace XFX
|
||||
float dot = (Normal.X * max.X) + (Normal.Y * max.Y) + (Normal.Z * max.Z);
|
||||
|
||||
if(dot + D > 0.0f)
|
||||
{
|
||||
result = PlaneIntersectionType::Front;
|
||||
}
|
||||
|
||||
dot = (Normal.X * min.X) + (Normal.Y * min.Y) + (Normal.Z * min.Z);
|
||||
|
||||
if(dot + D < 0.0f)
|
||||
{
|
||||
result = PlaneIntersectionType::Back;
|
||||
}
|
||||
|
||||
result = PlaneIntersectionType::Intersecting;
|
||||
}
|
||||
@ -179,10 +183,14 @@ namespace XFX
|
||||
float dot = (sphere.Center.X * Normal.X) + (sphere.Center.Y * Normal.Y) + (sphere.Center.Z * Normal.Z) + D;
|
||||
|
||||
if(dot > sphere.Radius)
|
||||
{
|
||||
result = PlaneIntersectionType::Front;
|
||||
}
|
||||
|
||||
if(dot < -sphere.Radius)
|
||||
{
|
||||
result = PlaneIntersectionType::Back;
|
||||
}
|
||||
|
||||
result = PlaneIntersectionType::Intersecting;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <System/FrameworkResources.h>
|
||||
#include <System/Math.h>
|
||||
#include <System/String.h>
|
||||
#include <System/Type.h>
|
||||
|
||||
#include <sassert.h>
|
||||
|
||||
@ -42,29 +43,26 @@ namespace XFX
|
||||
{
|
||||
const Vector2 Vector2::One = Vector2(1, 1);
|
||||
const Vector2 Vector2::Zero = Vector2(0, 0);
|
||||
const Type Vector2TypeInfo("Vector2", "XFX::Vector2", TypeCode::Object);
|
||||
|
||||
Vector2::Vector2(const float x, const float y)
|
||||
: X(x), Y(y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
Vector2::Vector2(const float value)
|
||||
: X(value), Y(value)
|
||||
{
|
||||
X = value;
|
||||
Y = value;
|
||||
}
|
||||
|
||||
Vector2::Vector2(const Vector2 &obj)
|
||||
: X(obj.X), Y(obj.Y)
|
||||
{
|
||||
X = obj.X;
|
||||
Y = obj.Y;
|
||||
}
|
||||
|
||||
Vector2::Vector2()
|
||||
: X(0), Y(0)
|
||||
{
|
||||
X = 0;
|
||||
Y = 0;
|
||||
}
|
||||
|
||||
Vector2 Vector2::Add(const Vector2 value1, const Vector2 value2)
|
||||
@ -166,9 +164,9 @@ namespace XFX
|
||||
return (int)X ^ (int)Y;
|
||||
}
|
||||
|
||||
int Vector2::GetType()
|
||||
const Type& Vector2::GetType()
|
||||
{
|
||||
// TODO: implement
|
||||
return Vector2TypeInfo;
|
||||
}
|
||||
|
||||
Vector2 Vector2::Hermite(const Vector2 value1, const Vector2 tangent1, const Vector2 value2, const Vector2 tangent2, const float amount)
|
||||
@ -261,8 +259,12 @@ namespace XFX
|
||||
void Vector2::Normalize()
|
||||
{
|
||||
float length = Length();
|
||||
|
||||
if(length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float num = 1 / length;
|
||||
X *= num;
|
||||
Y *= num;
|
||||
@ -278,8 +280,12 @@ namespace XFX
|
||||
void Vector2::Normalize(const Vector2& value, out Vector2& result)
|
||||
{
|
||||
float length = value.Length();
|
||||
|
||||
if (length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float num = 1 / length;
|
||||
result.X = value.X * num;
|
||||
result.Y = value.Y * num;
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <System/Array.h>
|
||||
#include <System/Math.h>
|
||||
#include <System/String.h>
|
||||
#include <System/Type.h>
|
||||
|
||||
#include <sassert.h>
|
||||
|
||||
@ -52,6 +53,7 @@ namespace XFX
|
||||
const Vector3 Vector3::UnitZ = Vector3(0, 0, 1);
|
||||
const Vector3 Vector3::Up = Vector3(0, 1, 0);
|
||||
const Vector3 Vector3::Zero = Vector3(0, 0, 0);
|
||||
const Type Vector3TypeInfo("Vector3", "XFX::Vector3", TypeCode::Object);
|
||||
|
||||
Vector3::Vector3(float value)
|
||||
: X(value), Y(value), Z(value)
|
||||
@ -243,9 +245,9 @@ namespace XFX
|
||||
return ((int)X ^ (int)Y ^ (int)Z);
|
||||
}
|
||||
|
||||
int Vector3::GetType()
|
||||
const Type& Vector3::GetType()
|
||||
{
|
||||
// TODO: implement
|
||||
return Vector3TypeInfo;
|
||||
}
|
||||
|
||||
Vector3 Vector3::Hermite(Vector3 value1, Vector3 tangent1, Vector3 value2, Vector3 tangent2, float amount)
|
||||
@ -359,8 +361,12 @@ namespace XFX
|
||||
void Vector3::Normalize()
|
||||
{
|
||||
float length = Length();
|
||||
|
||||
if(length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float num = 1 / length;
|
||||
X *= num;
|
||||
Y *= num;
|
||||
@ -371,8 +377,12 @@ namespace XFX
|
||||
{
|
||||
Vector3 result;
|
||||
float length = value.Length();
|
||||
|
||||
if(length == 0)
|
||||
{
|
||||
return Vector3::Zero;
|
||||
}
|
||||
|
||||
float num = 1 / length;
|
||||
result.X *= num;
|
||||
result.Y *= num;
|
||||
@ -383,8 +393,12 @@ namespace XFX
|
||||
void Vector3::Normalize(Vector3 value, out Vector3& result)
|
||||
{
|
||||
float length = value.Length();
|
||||
|
||||
if(length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float num = 1 / length;
|
||||
result.X *= num;
|
||||
result.Y *= num;
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <Vector4.h>
|
||||
#include <System/Array.h>
|
||||
#include <System/Math.h>
|
||||
#include <System/Type.h>
|
||||
|
||||
#include <sassert.h>
|
||||
|
||||
@ -46,6 +47,7 @@ namespace XFX
|
||||
const Vector4 Vector4::UnitY = Vector4(0,1,0,0);
|
||||
const Vector4 Vector4::UnitZ = Vector4(0,0,1,0);
|
||||
const Vector4 Vector4::Zero = Vector4(0,0,0,0);
|
||||
const Type Vector4TypeInfo("Vector4", "XFX::Vector4", TypeCode::Object);
|
||||
|
||||
Vector4::Vector4(float value)
|
||||
: X(value), Y(value), Z(value), W(value)
|
||||
@ -209,9 +211,9 @@ namespace XFX
|
||||
return ((int)X ^ (int)Y ^ (int)Z ^ (int)W);
|
||||
}
|
||||
|
||||
int Vector4::GetType()
|
||||
const Type& Vector4::GetType()
|
||||
{
|
||||
// TODO: implement
|
||||
return Vector4TypeInfo;
|
||||
}
|
||||
|
||||
Vector4 Vector4::Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount)
|
||||
@ -330,8 +332,12 @@ namespace XFX
|
||||
void Vector4::Normalize()
|
||||
{
|
||||
float length = Length();
|
||||
|
||||
if(length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float num = 1 / length;
|
||||
X *= num;
|
||||
Y *= num;
|
||||
|
Loading…
x
Reference in New Issue
Block a user