Commit 33661bed authored by Rye Mutt's avatar Rye Mutt 🍞
Browse files

Various little bits of cleanup

parent 18a8d7f0
......@@ -563,7 +563,7 @@ void LLCamera::calculateFrustumPlanes()
calculateFrustumPlanes(left, right, top, bottom);
}
LLPlane planeFromPoints(LLVector3 p1, LLVector3 p2, LLVector3 p3)
LLPlane planeFromPoints(const LLVector3& p1, const LLVector3& p2, const LLVector3& p3)
{
LLVector3 n = ((p2-p1)%(p3-p1));
n.normVec();
......
......@@ -148,7 +148,9 @@ public:
const LLVector4a& size,
BaseType* parent,
U8 octant = 255)
: mParent((oct_node*)parent),
: mCenter(center),
mSize(size),
mParent((oct_node*)parent),
mOctant(octant)
{
llassert(size[0] >= gOctreeMinSize*0.5f);
......@@ -156,9 +158,6 @@ public:
mData.push_back(NULL);
mDataEnd = &mData[0];
mCenter = center;
mSize = size;
updateMinMax();
if ((mOctant == 255) && mParent)
{
......
......@@ -310,7 +310,7 @@ public:
void negate();
// Set this vector to rhs(2, 3, 2, 3)
inline void setMoveHighLow(const LLVector4a rhs);
inline void setMoveHighLow(const LLVector4a& rhs);
// Move high order bits to low order bits (2, 3, 2, 3)
inline void moveHighLow();
......
......@@ -588,7 +588,7 @@ inline void LLVector4a::negate()
mQ = _mm_xor_ps(*reinterpret_cast<const LLQuad*>(signMask), mQ);
}
inline void LLVector4a::setMoveHighLow(const LLVector4a rhs)
inline void LLVector4a::setMoveHighLow(const LLVector4a& rhs)
{
mQ = _mm_movehl_ps(rhs.mQ, rhs.mQ);
}
......
......@@ -4113,9 +4113,9 @@ public:
};
LLVertexIndexPair::LLVertexIndexPair(const LLVector3 &vertex, const S32 index)
: mVertex(vertex)
, mIndex(index)
{
mVertex = vertex;
mIndex = index;
}
const F32 VERTEX_SLOP = 0.00001f;
......
......@@ -250,8 +250,6 @@ LLQuaternion LLMatrix3::quaternion() const
{
LLQuaternion quat;
F32 tr, s, q[4];
U32 i, j, k;
U32 nxt[3] = {1, 2, 0};
tr = mMatrix[0][0] + mMatrix[1][1] + mMatrix[2][2];
......@@ -267,6 +265,9 @@ LLQuaternion LLMatrix3::quaternion() const
}
else
{
U32 i, j, k;
const U32 nxt[3] = { 1, 2, 0 };
// diagonal is negative
i = 0;
if (mMatrix[1][1] > mMatrix[0][0])
......
......@@ -307,8 +307,6 @@ LLQuaternion LLMatrix4::quaternion() const
{
LLQuaternion quat;
F32 tr, s, q[4];
U32 i, j, k;
U32 nxt[3] = {1, 2, 0};
tr = mMatrix[0][0] + mMatrix[1][1] + mMatrix[2][2];
......@@ -324,6 +322,9 @@ LLQuaternion LLMatrix4::quaternion() const
}
else
{
U32 i, j, k;
const U32 nxt[3] = { 1, 2, 0 };
// diagonal is negative
i = 0;
if (mMatrix[1][1] > mMatrix[0][0])
......@@ -754,64 +755,6 @@ LLVector3 rotate_vector(const LLVector3 &a, const LLMatrix4 &b)
return vec;
}
bool operator==(const LLMatrix4 &a, const LLMatrix4 &b)
{
U32 i, j;
for (i = 0; i < NUM_VALUES_IN_MAT4; i++)
{
for (j = 0; j < NUM_VALUES_IN_MAT4; j++)
{
if (a.mMatrix[j][i] != b.mMatrix[j][i])
return FALSE;
}
}
return TRUE;
}
bool operator!=(const LLMatrix4 &a, const LLMatrix4 &b)
{
U32 i, j;
for (i = 0; i < NUM_VALUES_IN_MAT4; i++)
{
for (j = 0; j < NUM_VALUES_IN_MAT4; j++)
{
if (a.mMatrix[j][i] != b.mMatrix[j][i])
return TRUE;
}
}
return FALSE;
}
bool operator<(const LLMatrix4& a, const LLMatrix4 &b)
{
U32 i, j;
for (i = 0; i < NUM_VALUES_IN_MAT4; i++)
{
for (j = 0; j < NUM_VALUES_IN_MAT4; j++)
{
if (a.mMatrix[i][j] != b.mMatrix[i][j])
{
return a.mMatrix[i][j] < b.mMatrix[i][j];
}
}
}
return false;
}
const LLMatrix4& operator*=(LLMatrix4 &a, F32 k)
{
U32 i, j;
for (i = 0; i < NUM_VALUES_IN_MAT4; i++)
{
for (j = 0; j < NUM_VALUES_IN_MAT4; j++)
{
a.mMatrix[j][i] *= k;
}
}
return a;
}
std::ostream& operator<<(std::ostream& s, const LLMatrix4 &a)
{
s << "{ "
......
......@@ -239,7 +239,7 @@ public:
friend const LLMatrix4& operator+=(LLMatrix4 &a, const LLMatrix4 &b); // Return a + b
friend const LLMatrix4& operator-=(LLMatrix4 &a, const LLMatrix4 &b); // Return a - b
friend const LLMatrix4& operator*=(LLMatrix4 &a, const LLMatrix4 &b); // Return a * b
friend const LLMatrix4& operator*=(LLMatrix4 &a, const F32 &b); // Return a * b
friend const LLMatrix4& operator*=(LLMatrix4 &a, const F32 b); // Return a * b
friend std::ostream& operator<<(std::ostream& s, const LLMatrix4 &a); // Stream a
};
......@@ -294,6 +294,50 @@ inline bool LLMatrix4::isIdentity() const
mMatrix[3][3] == 1.f;
}
inline bool operator==(const LLMatrix4& a, const LLMatrix4& b)
{
U32 i, j;
for (i = 0; i < NUM_VALUES_IN_MAT4; i++)
{
for (j = 0; j < NUM_VALUES_IN_MAT4; j++)
{
if (a.mMatrix[j][i] != b.mMatrix[j][i])
return FALSE;
}
}
return TRUE;
}
inline bool operator!=(const LLMatrix4& a, const LLMatrix4& b)
{
U32 i, j;
for (i = 0; i < NUM_VALUES_IN_MAT4; i++)
{
for (j = 0; j < NUM_VALUES_IN_MAT4; j++)
{
if (a.mMatrix[j][i] != b.mMatrix[j][i])
return TRUE;
}
}
return FALSE;
}
inline bool operator<(const LLMatrix4& a, const LLMatrix4& b)
{
U32 i, j;
for (i = 0; i < NUM_VALUES_IN_MAT4; i++)
{
for (j = 0; j < NUM_VALUES_IN_MAT4; j++)
{
if (a.mMatrix[i][j] != b.mMatrix[i][j])
{
return a.mMatrix[i][j] < b.mMatrix[i][j];
}
}
}
return false;
}
/*
inline LLMatrix4 operator*(const LLMatrix4 &a, const LLMatrix4 &b)
......@@ -333,7 +377,7 @@ inline const LLMatrix4& operator*=(LLMatrix4 &a, const LLMatrix4 &b)
return a;
}
inline const LLMatrix4& operator*=(LLMatrix4 &a, const F32 &b)
inline const LLMatrix4& operator*=(LLMatrix4 &a, const F32 b)
{
U32 i, j;
LLMatrix4 mat;
......
......@@ -35,7 +35,7 @@
BOOL line_plane(const LLVector3 &line_point, const LLVector3 &line_direction,
const LLVector3 &plane_point, const LLVector3 plane_normal,
const LLVector3 &plane_point, const LLVector3& plane_normal,
LLVector3 &intersection)
{
F32 N = line_direction * plane_normal;
......@@ -55,7 +55,7 @@ BOOL line_plane(const LLVector3 &line_point, const LLVector3 &line_direction,
BOOL ray_plane(const LLVector3 &ray_point, const LLVector3 &ray_direction,
const LLVector3 &plane_point, const LLVector3 plane_normal,
const LLVector3 &plane_point, const LLVector3& plane_normal,
LLVector3 &intersection)
{
F32 N = ray_direction * plane_normal;
......@@ -81,7 +81,7 @@ BOOL ray_plane(const LLVector3 &ray_point, const LLVector3 &ray_direction,
BOOL ray_circle(const LLVector3 &ray_point, const LLVector3 &ray_direction,
const LLVector3 &circle_center, const LLVector3 plane_normal, F32 circle_radius,
const LLVector3 &circle_center, const LLVector3& plane_normal, F32 circle_radius,
LLVector3 &intersection)
{
if (ray_plane(ray_point, ray_direction, circle_center, plane_normal, intersection))
......@@ -1105,7 +1105,7 @@ BOOL ray_pyramid(const LLVector3 &ray_point, const LLVector3 &ray_direction,
BOOL linesegment_circle(const LLVector3 &point_a, const LLVector3 &point_b,
const LLVector3 &circle_center, const LLVector3 plane_normal, F32 circle_radius,
const LLVector3 &circle_center, const LLVector3& plane_normal, F32 circle_radius,
LLVector3 &intersection)
{
LLVector3 ray_direction = point_b - point_a;
......
......@@ -63,18 +63,18 @@ class LLQuaternion;
// returns TRUE iff line is not parallel to plane.
BOOL line_plane(const LLVector3 &line_point, const LLVector3 &line_direction,
const LLVector3 &plane_point, const LLVector3 plane_normal,
const LLVector3 &plane_point, const LLVector3& plane_normal,
LLVector3 &intersection);
// returns TRUE iff line is not parallel to plane.
BOOL ray_plane(const LLVector3 &ray_point, const LLVector3 &ray_direction,
const LLVector3 &plane_point, const LLVector3 plane_normal,
const LLVector3 &plane_point, const LLVector3& plane_normal,
LLVector3 &intersection);
BOOL ray_circle(const LLVector3 &ray_point, const LLVector3 &ray_direction,
const LLVector3 &circle_center, const LLVector3 plane_normal, F32 circle_radius,
const LLVector3 &circle_center, const LLVector3& plane_normal, F32 circle_radius,
LLVector3 &intersection);
// point_0 through point_2 define the plane_normal via the right-hand rule:
......@@ -171,7 +171,7 @@ BOOL ray_hemicone(const LLVector3 &ray_point, const LLVector3 &ray_direction,
BOOL linesegment_circle(const LLVector3 &point_a, const LLVector3 &point_b,
const LLVector3 &circle_center, const LLVector3 plane_normal, F32 circle_radius,
const LLVector3 &circle_center, const LLVector3& plane_normal, F32 circle_radius,
LLVector3 &intersection);
// point_0 through point_2 define the plane_normal via the right-hand rule:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment