Permalink
Browse files

llmath merge

  • Loading branch information...
Shyotl committed Apr 6, 2016
1 parent 6ced172 commit 8c946dc706df50f4f6416a1d0e5c33bd3538a9cc
Showing with 54 additions and 4 deletions.
  1. +18 −0 indra/llmath/llquaternion.h
  2. +17 −3 indra/llmath/llvolume.cpp
  3. +1 −1 indra/llmath/llvolumemgr.cpp
  4. +13 −0 indra/llmath/m4math.cpp
  5. +5 −0 indra/llmath/m4math.h
@@ -71,6 +71,9 @@ class LLQuaternion
void quantize8(F32 lower, F32 upper); // changes the vector to reflect quatization
void loadIdentity(); // Loads the quaternion that represents the identity rotation
bool isEqualEps(const LLQuaternion &quat, F32 epsilon) const;
bool isNotEqualEps(const LLQuaternion &quat, F32 epsilon) const;
const LLQuaternion& set(F32 x, F32 y, F32 z, F32 w); // Sets Quaternion to normalize(x, y, z, w)
const LLQuaternion& set(const LLQuaternion &quat); // Copies Quaternion
const LLQuaternion& set(const F32 *q); // Sets Quaternion to normalize(quat[VX], quat[VY], quat[VZ], quat[VW])
@@ -239,6 +242,21 @@ inline void LLQuaternion::loadIdentity()
mQ[VW] = 1.0f;
}
inline bool LLQuaternion::isEqualEps(const LLQuaternion &quat, F32 epsilon) const
{
return ( fabs(mQ[VX] - quat.mQ[VX]) < epsilon
&& fabs(mQ[VY] - quat.mQ[VY]) < epsilon
&& fabs(mQ[VZ] - quat.mQ[VZ]) < epsilon
&& fabs(mQ[VS] - quat.mQ[VS]) < epsilon );
}
inline bool LLQuaternion::isNotEqualEps(const LLQuaternion &quat, F32 epsilon) const
{
return ( fabs(mQ[VX] - quat.mQ[VX]) > epsilon
|| fabs(mQ[VY] - quat.mQ[VY]) > epsilon
|| fabs(mQ[VZ] - quat.mQ[VZ]) > epsilon
|| fabs(mQ[VS] - quat.mQ[VS]) > epsilon );
}
inline const LLQuaternion& LLQuaternion::set(F32 x, F32 y, F32 z, F32 w)
{
View
@@ -2532,14 +2532,18 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
U32 cur_influence = 0;
LLVector4 wght(0,0,0,0);
U32 joints[4] = {0,0,0,0};
LLVector4 joints_with_weights(0,0,0,0);
while (joint != END_INFLUENCES && idx < weights.size())
{
U16 influence = weights[idx++];
influence |= ((U16) weights[idx++] << 8);
F32 w = llclamp((F32) influence / 65535.f, 0.f, 0.99999f);
wght.mV[cur_influence++] = (F32) joint + w;
wght.mV[cur_influence] = w;
joints[cur_influence] = joint;
cur_influence++;
if (cur_influence >= 4)
{
@@ -2550,8 +2554,16 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
joint = weights[idx++];
}
}
face.mWeights[cur_vertex].loadua(wght.mV);
F32 wsum = wght.mV[VX] + wght.mV[VY] + wght.mV[VZ] + wght.mV[VW];
if (wsum <= 0.f)
{
wght = LLVector4(0.99999f,0.f,0.f,0.f);
}
for (U32 k=0; k<4; k++)
{
joints_with_weights[k] = (F32) joints[k] + wght[k];
}
face.mWeights[cur_vertex].loadua(joints_with_weights.mV);
cur_vertex++;
}
@@ -6311,6 +6323,8 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
num_vertices = mNumS*mNumT;
num_indices = (mNumS-1)*(mNumT-1)*6;
partial_build = (num_vertices > mNumVertices || num_indices > mNumIndices) ? FALSE : partial_build;
if (!partial_build)
{
resizeVertices(num_vertices);
@@ -214,7 +214,7 @@ void LLVolumeMgr::useMutex()
{
if (!mDataMutex)
{
mDataMutex = new LLMutex;
mDataMutex = new LLMutex();
}
}
View
@@ -274,6 +274,19 @@ const LLMatrix4& LLMatrix4::invert(void)
return *this;
}
// Convenience func for simplifying comparison-heavy code by
// intentionally stomping values in [-FLT_EPS,FLT_EPS] to 0.0f
//
void LLMatrix4::condition(void)
{
U32 i;
U32 j;
for (i = 0; i < 3;i++)
for (j = 0; j < 3;j++)
mMatrix[i][j] = ((mMatrix[i][j] > -FLT_EPSILON)
&& (mMatrix[i][j] < FLT_EPSILON)) ? 0.0f : mMatrix[i][j];
}
LLVector4 LLMatrix4::getFwdRow4() const
{
return LLVector4(mMatrix[VX][VX], mMatrix[VX][VY], mMatrix[VX][VZ], mMatrix[VX][VW]);
View
@@ -180,6 +180,11 @@ class LLMatrix4
const LLMatrix4& setTranslation(const LLVector4 &translation);
const LLMatrix4& setTranslation(const LLVector3 &translation);
// Convenience func for simplifying comparison-heavy code by
// intentionally stomping values [-FLT_EPS,FLT_EPS] to 0.0
//
void condition(void);
///////////////////////////
//
// Get properties of a matrix

0 comments on commit 8c946dc

Please sign in to comment.