summaryrefslogtreecommitdiff
path: root/indra/llprimitive
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llprimitive')
-rw-r--r--indra/llprimitive/lldaeloader.cpp16
-rw-r--r--indra/llprimitive/llmodel.cpp43
-rw-r--r--indra/llprimitive/llmodel.h20
3 files changed, 64 insertions, 15 deletions
diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp
index 93d492b42d..4b13da5586 100644
--- a/indra/llprimitive/lldaeloader.cpp
+++ b/indra/llprimitive/lldaeloader.cpp
@@ -1224,17 +1224,19 @@ void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, do
LLMeshSkinInfo& skin_info = model->mSkinInfo;
+ LLMatrix4 mat;
for (int i = 0; i < 4; i++)
{
for(int j = 0; j < 4; j++)
{
- skin_info.mBindShapeMatrix.mMatrix[i][j] = dom_value[i + j*4];
+ mat.mMatrix[i][j] = dom_value[i + j*4];
}
}
- LLMatrix4 trans = normalized_transformation;
- trans *= skin_info.mBindShapeMatrix;
- skin_info.mBindShapeMatrix = trans;
+ skin_info.mBindShapeMatrix.loadu(mat);
+
+ LLMatrix4a trans(normalized_transformation);
+ matMul(trans, skin_info.mBindShapeMatrix, skin_info.mBindShapeMatrix);
}
@@ -1452,7 +1454,7 @@ void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, do
mat.mMatrix[i][j] = transform[k*16 + i + j*4];
}
}
- model->mSkinInfo.mInvBindMatrix.push_back(mat);
+ model->mSkinInfo.mInvBindMatrix.push_back(LLMatrix4a(mat));
}
}
}
@@ -1526,9 +1528,9 @@ void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, do
if (mJointMap.find(lookingForJoint) != mJointMap.end()
&& model->mSkinInfo.mInvBindMatrix.size() > i)
{
- LLMatrix4 newInverse = model->mSkinInfo.mInvBindMatrix[i];
+ LLMatrix4 newInverse = LLMatrix4(model->mSkinInfo.mInvBindMatrix[i].getF32ptr());
newInverse.setTranslation( mJointList[lookingForJoint].getTranslation() );
- model->mSkinInfo.mAlternateBindMatrix.push_back( newInverse );
+ model->mSkinInfo.mAlternateBindMatrix.push_back( LLMatrix4a(newInverse) );
}
else
{
diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp
index 702a1b5238..dd37b8ce0b 100644
--- a/indra/llprimitive/llmodel.cpp
+++ b/indra/llprimitive/llmodel.cpp
@@ -31,6 +31,7 @@
#include "llconvexdecomposition.h"
#include "llsdserialize.h"
#include "llvector4a.h"
+#include "llmd5.h"
#ifdef LL_USESYSTEMLIBS
# include <zlib.h>
@@ -1396,7 +1397,7 @@ void LLMeshSkinInfo::fromLLSD(LLSD& skin)
}
}
- mInvBindMatrix.push_back(mat);
+ mInvBindMatrix.push_back(LLMatrix4a(mat));
}
if (mJointNames.size() != mInvBindMatrix.size())
@@ -1410,13 +1411,15 @@ void LLMeshSkinInfo::fromLLSD(LLSD& skin)
if (skin.has("bind_shape_matrix"))
{
+ LLMatrix4 mat;
for (U32 j = 0; j < 4; j++)
{
for (U32 k = 0; k < 4; k++)
{
- mBindShapeMatrix.mMatrix[j][k] = skin["bind_shape_matrix"][j*4+k].asReal();
+ mat.mMatrix[j][k] = skin["bind_shape_matrix"][j*4+k].asReal();
}
}
+ mBindShapeMatrix.loadu(mat);
}
if (skin.has("alt_inverse_bind_matrix"))
@@ -1432,7 +1435,7 @@ void LLMeshSkinInfo::fromLLSD(LLSD& skin)
}
}
- mAlternateBindMatrix.push_back(mat);
+ mAlternateBindMatrix.push_back(LLMatrix4a(mat));
}
}
@@ -1449,6 +1452,8 @@ void LLMeshSkinInfo::fromLLSD(LLSD& skin)
{
mLockScaleIfJointPosition = false;
}
+
+ updateHash();
}
LLSD LLMeshSkinInfo::asLLSD(bool include_joints, bool lock_scale_if_joint_position) const
@@ -1500,6 +1505,38 @@ LLSD LLMeshSkinInfo::asLLSD(bool include_joints, bool lock_scale_if_joint_positi
return ret;
}
+void LLMeshSkinInfo::updateHash()
+{
+ // get hash of data relevant to render batches
+ LLMD5 hash;
+
+ //mJointNames
+ for (auto& name : mJointNames)
+ {
+ hash.update(name);
+ }
+
+ //mJointNums
+ hash.update((U8*)&(mJointNums[0]), sizeof(S32) * mJointNums.size());
+
+ //mInvBindMatrix
+ F32* src = mInvBindMatrix[0].getF32ptr();
+
+ for (int i = 0; i < mInvBindMatrix.size() * 16; ++i)
+ {
+ S32 t = llround(src[i] * 10000.f);
+ hash.update((U8*)&t, sizeof(S32));
+ }
+ //hash.update((U8*)&(mInvBindMatrix[0]), sizeof(LLMatrix4a) * mInvBindMatrix.size());
+
+ hash.finalize();
+
+ U64 digest[2];
+ hash.raw_digest((U8*) digest);
+
+ mHash = digest[0];
+}
+
LLModel::Decomposition::Decomposition(LLSD& data)
{
fromLLSD(data);
diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h
index 96368d64e5..3881b1338c 100644
--- a/indra/llprimitive/llmodel.h
+++ b/indra/llprimitive/llmodel.h
@@ -33,34 +33,44 @@
#include "m4math.h"
#include <queue>
+#include <boost/align/aligned_allocator.hpp>
+
class daeElement;
class domMesh;
#define MAX_MODEL_FACES 8
+LL_ALIGN_PREFIX(16)
class LLMeshSkinInfo
{
+ LL_ALIGN_NEW
public:
LLMeshSkinInfo();
LLMeshSkinInfo(LLSD& data);
void fromLLSD(LLSD& data);
LLSD asLLSD(bool include_joints, bool lock_scale_if_joint_position) const;
+ void updateHash();
LLUUID mMeshID;
std::vector<std::string> mJointNames;
mutable std::vector<S32> mJointNums;
- std::vector<LLMatrix4> mInvBindMatrix;
- std::vector<LLMatrix4> mAlternateBindMatrix;
+ typedef std::vector<LLMatrix4a, boost::alignment::aligned_allocator<LLMatrix4a, 16>> matrix_list_t;
+ matrix_list_t mInvBindMatrix;
+ matrix_list_t mAlternateBindMatrix;
+
+ LL_ALIGN_16(LLMatrix4a mBindShapeMatrix);
- LLMatrix4 mBindShapeMatrix;
float mPelvisOffset;
bool mLockScaleIfJointPosition;
bool mInvalidJointsScrubbed;
bool mJointNumsInitialized;
-};
+ U64 mHash = 0;
+} LL_ALIGN_POSTFIX(16);
+LL_ALIGN_PREFIX(16)
class LLModel : public LLVolume
{
+ LL_ALIGN_NEW
public:
enum
@@ -284,7 +294,7 @@ public:
// A model/object can only have 8 faces, spillover faces will
// be moved to new model/object and assigned a submodel id.
int mSubmodelID;
-};
+} LL_ALIGN_POSTFIX(16);
typedef std::vector<LLPointer<LLModel> > model_list;
typedef std::queue<LLPointer<LLModel> > model_queue;