Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Source/OBJ_Loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,35 +222,35 @@ namespace objl
namespace math
{
// Vector3 Cross Product
Vector3 CrossV3(const Vector3 a, const Vector3 b)
inline Vector3 CrossV3(const Vector3 a, const Vector3 b)
{
return Vector3(a.Y * b.Z - a.Z * b.Y,
a.Z * b.X - a.X * b.Z,
a.X * b.Y - a.Y * b.X);
}

// Vector3 Magnitude Calculation
float MagnitudeV3(const Vector3 in)
inline float MagnitudeV3(const Vector3 in)
{
return (sqrtf(powf(in.X, 2) + powf(in.Y, 2) + powf(in.Z, 2)));
}

// Vector3 DotProduct
float DotV3(const Vector3 a, const Vector3 b)
inline float DotV3(const Vector3 a, const Vector3 b)
{
return (a.X * b.X) + (a.Y * b.Y) + (a.Z * b.Z);
}

// Angle between 2 Vector3 Objects
float AngleBetweenV3(const Vector3 a, const Vector3 b)
inline float AngleBetweenV3(const Vector3 a, const Vector3 b)
{
float angle = DotV3(a, b);
angle /= (MagnitudeV3(a) * MagnitudeV3(b));
return angle = acosf(angle);
}

// Projection Calculation of a onto b
Vector3 ProjV3(const Vector3 a, const Vector3 b)
inline Vector3 ProjV3(const Vector3 a, const Vector3 b)
{
Vector3 bn = b / MagnitudeV3(b);
return bn * DotV3(a, bn);
Expand All @@ -264,13 +264,13 @@ namespace objl
namespace algorithm
{
// Vector3 Multiplication Opertor Overload
Vector3 operator*(const float& left, const Vector3& right)
inline Vector3 operator*(const float& left, const Vector3& right)
{
return Vector3(right.X * left, right.Y * left, right.Z * left);
}

// A test to see if P1 is on the same side as P2 of a line segment ab
bool SameSide(Vector3 p1, Vector3 p2, Vector3 a, Vector3 b)
inline bool SameSide(Vector3 p1, Vector3 p2, Vector3 a, Vector3 b)
{
Vector3 cp1 = math::CrossV3(b - a, p1 - a);
Vector3 cp2 = math::CrossV3(b - a, p2 - a);
Expand All @@ -282,7 +282,7 @@ namespace objl
}

// Generate a cross produect normal for a triangle
Vector3 GenTriNormal(Vector3 t1, Vector3 t2, Vector3 t3)
inline Vector3 GenTriNormal(Vector3 t1, Vector3 t2, Vector3 t3)
{
Vector3 u = t2 - t1;
Vector3 v = t3 - t1;
Expand All @@ -293,7 +293,7 @@ namespace objl
}

// Check to see if a Vector3 Point is within a 3 Vector3 Triangle
bool inTriangle(Vector3 point, Vector3 tri1, Vector3 tri2, Vector3 tri3)
inline bool inTriangle(Vector3 point, Vector3 tri1, Vector3 tri2, Vector3 tri3)
{
// Test to see if it is within an infinite prism that the triangle outlines.
bool within_tri_prisim = SameSide(point, tri1, tri2, tri3) && SameSide(point, tri2, tri1, tri3)
Expand Down