diff options
author | Dave Parks <davep@lindenlab.com> | 2021-11-20 18:49:19 +0000 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2021-11-20 18:49:19 +0000 |
commit | 28f9fb06a9f4cb9edccb2ff8132c7f6a9b27c060 (patch) | |
tree | e3096bac94279dded08731dcc4f042d81dc2bfac /indra/newview/llface.cpp | |
parent | 3171aaad9b1f2757f8b0d8cbb784a45a7bbebafa (diff) |
SL-16289 Rigged mesh rendering overhaul
Diffstat (limited to 'indra/newview/llface.cpp')
-rw-r--r-- | indra/newview/llface.cpp | 133 |
1 files changed, 51 insertions, 82 deletions
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 88b958d24a..39ca7961d8 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -56,6 +56,7 @@ #include "llviewertexture.h" #include "llvoavatar.h" #include "llsculptidsize.h" +#include "llmeshrepository.h" #if LL_LINUX // Work-around spurious used before init warning on Vector4a @@ -71,6 +72,7 @@ static LLStaticHashedString sColorIn("color_in"); BOOL LLFace::sSafeRenderSelect = TRUE; // FALSE + #define DOTVEC(a,b) (a.mV[0]*b.mV[0] + a.mV[1]*b.mV[1] + a.mV[2]*b.mV[2]) /* @@ -197,14 +199,7 @@ void LLFace::destroy() if (mDrawPoolp) { - if (this->isState(LLFace::RIGGED) && (mDrawPoolp->getType() == LLDrawPool::POOL_CONTROL_AV || mDrawPoolp->getType() == LLDrawPool::POOL_AVATAR)) - { - ((LLDrawPoolAvatar*) mDrawPoolp)->removeRiggedFace(this); - } - else - { - mDrawPoolp->removeFace(this); - } + mDrawPoolp->removeFace(this); mDrawPoolp = NULL; } @@ -1286,7 +1281,9 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, return FALSE; } - const LLVolumeFace &vf = volume.getVolumeFace(f); + bool rigged = isState(RIGGED); + + const LLVolumeFace &vf = volume.getVolumeFace(f); S32 num_vertices = (S32)vf.mNumVertices; S32 num_indices = (S32) vf.mNumIndices; @@ -1450,9 +1447,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } } - LLMatrix4a mat_normal; - mat_normal.loadu(mat_norm_in); - F32 r = 0, os = 0, ot = 0, ms = 0, mt = 0, cos_ang = 0, sin_ang = 0; bool do_xform = false; if (rebuild_tcoord) @@ -1487,6 +1481,45 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } } + const LLMeshSkinInfo* skin = nullptr; + LLMatrix4a mat_vert; + LLMatrix4a mat_normal; + + // prepare mat_vert + if (rebuild_pos) + { + if (rigged) + { //override with bind shape matrix if rigged + skin = mSkinInfo; + mat_vert = skin->mBindShapeMatrix; + } + else + { + mat_vert.loadu(mat_vert_in); + } + } + + if (rebuild_normal || rebuild_tangent) + { //override mat_normal with inverse of skin->mBindShapeMatrix + LL_PROFILE_ZONE_NAMED("getGeometryVolume - norm mat override"); + if (rigged) + { + if (skin == nullptr) + { + skin = mSkinInfo; + } + + //TODO -- cache this (check profile marker above)? + glh::matrix4f m((F32*) skin->mBindShapeMatrix.getF32ptr()); + m = m.inverse().transpose(); + mat_normal.loadu(m.m); + } + else + { + mat_normal.loadu(mat_norm_in); + } + } + static LLCachedControl<bool> use_transform_feedback(gSavedSettings, "RenderUseTransformFeedback", false); #ifdef GL_TRANSFORM_FEEDBACK_BUFFER @@ -1740,7 +1773,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, do_xform = false; } - if (getVirtualSize() >= MIN_TEX_ANIM_SIZE || isState(LLFace::RIGGED)) + if (getVirtualSize() >= MIN_TEX_ANIM_SIZE) // || isState(LLFace::RIGGED)) { //don't override texture transform during tc bake tex_mode = 0; } @@ -2036,9 +2069,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, mVertexBuffer->getVertexStrider(vert, mGeomIndex, mGeomCount, map_range); - LLMatrix4a mat_vert; - mat_vert.loadu(mat_vert_in); - + F32* dst = (F32*) vert.get(); F32* end_f32 = dst+mGeomCount*4; @@ -2089,10 +2120,10 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } } - if (rebuild_normal) { - //LL_RECORD_TIME_BLOCK(FTM_FACE_GEOM_NORMAL); + LL_PROFILE_ZONE_NAMED("getGeometryVolume - normal"); + mVertexBuffer->getNormalStrider(norm, mGeomIndex, mGeomCount, map_range); F32* normals = (F32*) norm.get(); LLVector4a* src = vf.mNormals; @@ -2714,56 +2745,6 @@ void LLFace::clearVertexBuffer() mVertexBuffer = NULL; } -//static -U32 LLFace::getRiggedDataMask(U32 type) -{ - static const U32 rigged_data_mask[] = { - LLDrawPoolAvatar::RIGGED_MATERIAL_MASK, - LLDrawPoolAvatar::RIGGED_MATERIAL_ALPHA_VMASK, - LLDrawPoolAvatar::RIGGED_MATERIAL_ALPHA_MASK_MASK, - LLDrawPoolAvatar::RIGGED_MATERIAL_ALPHA_EMISSIVE_MASK, - LLDrawPoolAvatar::RIGGED_SPECMAP_VMASK, - LLDrawPoolAvatar::RIGGED_SPECMAP_BLEND_MASK, - LLDrawPoolAvatar::RIGGED_SPECMAP_MASK_MASK, - LLDrawPoolAvatar::RIGGED_SPECMAP_EMISSIVE_MASK, - LLDrawPoolAvatar::RIGGED_NORMMAP_VMASK, - LLDrawPoolAvatar::RIGGED_NORMMAP_BLEND_MASK, - LLDrawPoolAvatar::RIGGED_NORMMAP_MASK_MASK, - LLDrawPoolAvatar::RIGGED_NORMMAP_EMISSIVE_MASK, - LLDrawPoolAvatar::RIGGED_NORMSPEC_VMASK, - LLDrawPoolAvatar::RIGGED_NORMSPEC_BLEND_MASK, - LLDrawPoolAvatar::RIGGED_NORMSPEC_MASK_MASK, - LLDrawPoolAvatar::RIGGED_NORMSPEC_EMISSIVE_MASK, - LLDrawPoolAvatar::RIGGED_SIMPLE_MASK, - LLDrawPoolAvatar::RIGGED_FULLBRIGHT_MASK, - LLDrawPoolAvatar::RIGGED_SHINY_MASK, - LLDrawPoolAvatar::RIGGED_FULLBRIGHT_SHINY_MASK, - LLDrawPoolAvatar::RIGGED_GLOW_MASK, - LLDrawPoolAvatar::RIGGED_ALPHA_MASK, - LLDrawPoolAvatar::RIGGED_FULLBRIGHT_ALPHA_MASK, - LLDrawPoolAvatar::RIGGED_DEFERRED_BUMP_MASK, - LLDrawPoolAvatar::RIGGED_DEFERRED_SIMPLE_MASK, - }; - - llassert(type < sizeof(rigged_data_mask)/sizeof(U32)); - - return rigged_data_mask[type]; -} - -U32 LLFace::getRiggedVertexBufferDataMask() const -{ - U32 data_mask = 0; - for (U32 i = 0; i < mRiggedIndex.size(); ++i) - { - if (mRiggedIndex[i] > -1) - { - data_mask |= LLFace::getRiggedDataMask(i); - } - } - - return data_mask; -} - S32 LLFace::getRiggedIndex(U32 type) const { if (mRiggedIndex.empty()) @@ -2776,19 +2757,7 @@ S32 LLFace::getRiggedIndex(U32 type) const return mRiggedIndex[type]; } -void LLFace::setRiggedIndex(U32 type, S32 index) +U64 LLFace::getSkinHash() { - if (mRiggedIndex.empty()) - { - mRiggedIndex.resize(LLDrawPoolAvatar::NUM_RIGGED_PASSES); - for (U32 i = 0; i < mRiggedIndex.size(); ++i) - { - mRiggedIndex[i] = -1; - } - } - - llassert(type < mRiggedIndex.size()); - - mRiggedIndex[type] = index; + return mSkinInfo ? mSkinInfo->mHash : 0; } - |