diff options
author | Graham Linden <graham@lindenlab.com> | 2019-08-14 09:15:17 -0700 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2019-08-14 09:15:17 -0700 |
commit | 886fe3eefc8688df206e7b397a6b9438c7492f5f (patch) | |
tree | 1851859f1fb2498bcd89a080d53620e77b9dc68f /indra | |
parent | 7a64e8f8bfeff17d6a5385a6c39f1056214cb59f (diff) | |
parent | 2207dc0e610c1bf18f04620bc216e0da71762237 (diff) |
Merge
Diffstat (limited to 'indra')
40 files changed, 798 insertions, 340 deletions
diff --git a/indra/llappearance/llavatarappearance.cpp b/indra/llappearance/llavatarappearance.cpp index 38cda2e2f1..0c0ad0d265 100644 --- a/indra/llappearance/llavatarappearance.cpp +++ b/indra/llappearance/llavatarappearance.cpp @@ -81,8 +81,8 @@ public: LLAvatarBoneInfo() : mIsJoint(FALSE) {} ~LLAvatarBoneInfo() { - std::for_each(mChildList.begin(), mChildList.end(), DeletePointer()); - mChildList.clear(); + std::for_each(mChildren.begin(), mChildren.end(), DeletePointer()); + mChildren.clear(); } BOOL parseXml(LLXmlTreeNode* node); @@ -96,8 +96,8 @@ private: LLVector3 mRot; LLVector3 mScale; LLVector3 mPivot; - typedef std::vector<LLAvatarBoneInfo*> child_list_t; - child_list_t mChildList; + typedef std::vector<LLAvatarBoneInfo*> bones_t; + bones_t mChildren; }; //------------------------------------------------------------------------ @@ -679,8 +679,8 @@ BOOL LLAvatarAppearance::setupBone(const LLAvatarBoneInfo* info, LLJoint* parent // setup children - LLAvatarBoneInfo::child_list_t::const_iterator iter; - for (iter = info->mChildList.begin(); iter != info->mChildList.end(); ++iter) + LLAvatarBoneInfo::bones_t::const_iterator iter; + for (iter = info->mChildren.begin(); iter != info->mChildren.end(); ++iter) { LLAvatarBoneInfo *child_info = *iter; if (!setupBone(child_info, joint, volume_num, joint_num)) @@ -1669,7 +1669,7 @@ BOOL LLAvatarBoneInfo::parseXml(LLXmlTreeNode* node) delete child_info; return FALSE; } - mChildList.push_back(child_info); + mChildren.push_back(child_info); } return TRUE; } @@ -1728,8 +1728,8 @@ void LLAvatarAppearance::makeJointAliases(LLAvatarBoneInfo *bone_info) mJointAliasMap[*i] = bone_name; } - LLAvatarBoneInfo::child_list_t::const_iterator iter; - for (iter = bone_info->mChildList.begin(); iter != bone_info->mChildList.end(); ++iter) + LLAvatarBoneInfo::bones_t::const_iterator iter; + for (iter = bone_info->mChildren.begin(); iter != bone_info->mChildren.end(); ++iter) { makeJointAliases( *iter ); } diff --git a/indra/llappearance/llavatarjoint.cpp b/indra/llappearance/llavatarjoint.cpp index 29642be099..80b3e42b52 100644 --- a/indra/llappearance/llavatarjoint.cpp +++ b/indra/llappearance/llavatarjoint.cpp @@ -100,7 +100,7 @@ void LLAvatarJoint::setValid( BOOL valid, BOOL recursive ) //---------------------------------------------------------------- if (recursive) { - for (child_list_t::iterator iter = mChildren.begin(); + for (joints_t::iterator iter = mChildren.begin(); iter != mChildren.end(); ++iter) { LLAvatarJoint* joint = (LLAvatarJoint*)(*iter); @@ -118,10 +118,10 @@ void LLAvatarJoint::setSkeletonComponents( U32 comp, BOOL recursive ) mComponents = comp; if (recursive) { - for (child_list_t::iterator iter = mChildren.begin(); + for (joints_t::iterator iter = mChildren.begin(); iter != mChildren.end(); ++iter) { - LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter); + LLAvatarJoint* joint = static_cast<LLAvatarJoint*>(*iter); joint->setSkeletonComponents(comp, recursive); } } @@ -133,7 +133,7 @@ void LLAvatarJoint::setVisible(BOOL visible, BOOL recursive) if (recursive) { - for (child_list_t::iterator iter = mChildren.begin(); + for (joints_t::iterator iter = mChildren.begin(); iter != mChildren.end(); ++iter) { LLAvatarJoint* joint = (LLAvatarJoint*)(*iter); @@ -144,27 +144,27 @@ void LLAvatarJoint::setVisible(BOOL visible, BOOL recursive) void LLAvatarJoint::updateFaceSizes(U32 &num_vertices, U32& num_indices, F32 pixel_area) { - for (child_list_t::iterator iter = mChildren.begin(); + for (joints_t::iterator iter = mChildren.begin(); iter != mChildren.end(); ++iter) { - LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter); + LLAvatarJoint* joint = static_cast<LLAvatarJoint*>(*iter); joint->updateFaceSizes(num_vertices, num_indices, pixel_area); } } void LLAvatarJoint::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind, bool terse_update) { - for (child_list_t::iterator iter = mChildren.begin(); + for (joints_t::iterator iter = mChildren.begin(); iter != mChildren.end(); ++iter) { - LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter); + LLAvatarJoint* joint = static_cast<LLAvatarJoint*>(*iter); joint->updateFaceData(face, pixel_area, damp_wind, terse_update); } } void LLAvatarJoint::updateJointGeometry() { - for (child_list_t::iterator iter = mChildren.begin(); + for (joints_t::iterator iter = mChildren.begin(); iter != mChildren.end(); ++iter) { LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter); @@ -178,10 +178,10 @@ BOOL LLAvatarJoint::updateLOD(F32 pixel_area, BOOL activate) BOOL lod_changed = FALSE; BOOL found_lod = FALSE; - for (child_list_t::iterator iter = mChildren.begin(); + for (joints_t::iterator iter = mChildren.begin(); iter != mChildren.end(); ++iter) { - LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter); + LLAvatarJoint* joint = static_cast<LLAvatarJoint*>(*iter); F32 jointLOD = joint->getLOD(); if (found_lod || jointLOD == DEFAULT_AVATAR_JOINT_LOD) @@ -207,10 +207,10 @@ BOOL LLAvatarJoint::updateLOD(F32 pixel_area, BOOL activate) void LLAvatarJoint::dump() { - for (child_list_t::iterator iter = mChildren.begin(); + for (joints_t::iterator iter = mChildren.begin(); iter != mChildren.end(); ++iter) { - LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter); + LLAvatarJoint* joint = static_cast<LLAvatarJoint*>(*iter); joint->dump(); } } diff --git a/indra/llappearance/llavatarjointmesh.cpp b/indra/llappearance/llavatarjointmesh.cpp index 7ca0928171..0a23b1fda3 100644 --- a/indra/llappearance/llavatarjointmesh.cpp +++ b/indra/llappearance/llavatarjointmesh.cpp @@ -379,7 +379,7 @@ void LLAvatarJointMesh::setupJoint(LLAvatarJoint* current_joint) } // depth-first traversal - for (LLJoint::child_list_t::iterator iter = current_joint->mChildren.begin(); + for (LLJoint::joints_t::iterator iter = current_joint->mChildren.begin(); iter != current_joint->mChildren.end(); ++iter) { LLAvatarJoint* child_joint = (LLAvatarJoint*)(*iter); diff --git a/indra/llappearance/lldriverparam.cpp b/indra/llappearance/lldriverparam.cpp index e5e502b158..05d26fbe7a 100644 --- a/indra/llappearance/lldriverparam.cpp +++ b/indra/llappearance/lldriverparam.cpp @@ -614,7 +614,7 @@ void LLDriverParam::setDrivenWeight(LLDrivenEntry *driven, F32 driven_weight) mAvatarAppearance->isValid() && driven->mParam->getCrossWearable()) { - LLWearable* wearable = dynamic_cast<LLWearable*> (mWearablep); + LLWearable* wearable = mWearablep; if (mAvatarAppearance->getWearableData()->isOnTop(wearable)) { use_self = true; diff --git a/indra/llappearance/llpolyskeletaldistortion.cpp b/indra/llappearance/llpolyskeletaldistortion.cpp index 5b77a7433a..ae38c25dbf 100644 --- a/indra/llappearance/llpolyskeletaldistortion.cpp +++ b/indra/llappearance/llpolyskeletaldistortion.cpp @@ -160,7 +160,7 @@ BOOL LLPolySkeletalDistortion::setInfo(LLPolySkeletalDistortionInfo *info) mJointScales[joint] = bone_info->mScaleDeformation; // apply to children that need to inherit it - for (LLJoint::child_list_t::iterator iter = joint->mChildren.begin(); + for (LLJoint::joints_t::iterator iter = joint->mChildren.begin(); iter != joint->mChildren.end(); ++iter) { LLAvatarJoint* child_joint = (LLAvatarJoint*)(*iter); diff --git a/indra/llcharacter/llcharacter.cpp b/indra/llcharacter/llcharacter.cpp index 4df975ecc5..b764ef0c7e 100644 --- a/indra/llcharacter/llcharacter.cpp +++ b/indra/llcharacter/llcharacter.cpp @@ -252,7 +252,7 @@ void LLCharacter::dumpCharacter( LLJoint* joint ) LL_INFOS() << "DEBUG: " << joint->getName() << " (" << (joint->getParent()?joint->getParent()->getName():std::string("ROOT")) << ")" << LL_ENDL; // recurse - for (LLJoint::child_list_t::iterator iter = joint->mChildren.begin(); + for (LLJoint::joints_t::iterator iter = joint->mChildren.begin(); iter != joint->mChildren.end(); ++iter) { LLJoint* child_joint = *iter; diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index e2f512f86e..a685df5925 100644 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -209,7 +209,7 @@ void LLJoint::touch(U32 flags) child_flags |= POSITION_DIRTY; } - for (child_list_t::iterator iter = mChildren.begin(); + for (joints_t::iterator iter = mChildren.begin(); iter != mChildren.end(); ++iter) { LLJoint* joint = *iter; @@ -251,7 +251,7 @@ LLJoint *LLJoint::findJoint( const std::string &name ) if (name == getName()) return this; - for (child_list_t::iterator iter = mChildren.begin(); + for (joints_t::iterator iter = mChildren.begin(); iter != mChildren.end(); ++iter) { LLJoint* joint = *iter; @@ -286,7 +286,7 @@ void LLJoint::addChild(LLJoint* joint) //-------------------------------------------------------------------- void LLJoint::removeChild(LLJoint* joint) { - child_list_t::iterator iter = std::find(mChildren.begin(), mChildren.end(), joint); + joints_t::iterator iter = std::find(mChildren.begin(), mChildren.end(), joint); if (iter != mChildren.end()) { mChildren.erase(iter); @@ -303,16 +303,17 @@ void LLJoint::removeChild(LLJoint* joint) //-------------------------------------------------------------------- void LLJoint::removeAllChildren() { - for (child_list_t::iterator iter = mChildren.begin(); - iter != mChildren.end();) + for (LLJoint* joint : mChildren) { - child_list_t::iterator curiter = iter++; - LLJoint* joint = *curiter; - mChildren.erase(curiter); - joint->mXform.setParent(NULL); - joint->mParent = NULL; - joint->touch(); + if (joint) + { + joint->mXform.setParent(NULL); + joint->mParent = NULL; + joint->touch(); + //delete joint; + } } + mChildren.clear(); } @@ -985,7 +986,7 @@ void LLJoint::updateWorldMatrixChildren() { updateWorldMatrix(); } - for (child_list_t::iterator iter = mChildren.begin(); + for (joints_t::iterator iter = mChildren.begin(); iter != mChildren.end(); ++iter) { LLJoint* joint = *iter; @@ -1031,7 +1032,7 @@ void LLJoint::clampRotation(LLQuaternion old_rot, LLQuaternion new_rot) { LLVector3 main_axis(1.f, 0.f, 0.f); - for (child_list_t::iterator iter = mChildren.begin(); + for (joints_t::iterator iter = mChildren.begin(); iter != mChildren.end(); ++iter) { LLJoint* joint = *iter; diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h index 8112d246f2..aa997a4cf7 100644 --- a/indra/llcharacter/lljoint.h +++ b/indra/llcharacter/lljoint.h @@ -139,8 +139,8 @@ public: S32 mJointNum; // child joints - typedef std::list<LLJoint*> child_list_t; - child_list_t mChildren; + typedef std::vector<LLJoint*> joints_t; + joints_t mChildren; // debug statics static S32 sNumTouches; diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp index 5d323ed5d6..cde38c8091 100644 --- a/indra/llcharacter/llkeyframemotion.cpp +++ b/indra/llcharacter/llkeyframemotion.cpp @@ -2321,7 +2321,7 @@ void LLKeyframeMotion::onLoadComplete(LLVFS *vfs, LLCharacter* character = *char_iter; // look for an existing instance of this motion - LLKeyframeMotion* motionp = dynamic_cast<LLKeyframeMotion*> (character->findMotion(asset_uuid)); + LLKeyframeMotion* motionp = static_cast<LLKeyframeMotion*> (character->findMotion(asset_uuid)); if (motionp) { if (0 == status) diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 335a0995fe..b46f49ba34 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -181,32 +181,35 @@ namespace { return LLError::getEnabledLogTypesMask() & 0x04; } + LL_FORCE_INLINE std::string createANSI(const std::string& color) + { + std::string ansi_code; + ansi_code += '\033'; + ansi_code += "["; + ansi_code += color; + ansi_code += "m"; + return ansi_code; + } + virtual void recordMessage(LLError::ELevel level, const std::string& message) override - { - if (ANSI_PROBE == mUseANSI) - mUseANSI = (checkANSI() ? ANSI_YES : ANSI_NO); + { + static std::string s_ansi_error = createANSI("31"); // red + static std::string s_ansi_warn = createANSI("34"); // blue + static std::string s_ansi_debug = createANSI("35"); // magenta + + mUseANSI = (ANSI_PROBE == mUseANSI) ? (checkANSI() ? ANSI_YES : ANSI_NO) : mUseANSI; if (ANSI_YES == mUseANSI) { - // Default all message levels to bold so we can distinguish our own messages from those dumped by subprocesses and libraries. - colorANSI("1"); // bold - switch (level) { - case LLError::LEVEL_ERROR: - colorANSI("31"); // red - break; - case LLError::LEVEL_WARN: - colorANSI("34"); // blue - break; - case LLError::LEVEL_DEBUG: - colorANSI("35"); // magenta - break; - default: - break; - } + writeANSI((level == LLError::LEVEL_ERROR) ? s_ansi_error : + (level == LLError::LEVEL_WARN) ? s_ansi_warn : + s_ansi_debug, message); } - fprintf(stderr, "%s\n", message.c_str()); - if (ANSI_YES == mUseANSI) colorANSI("0"); // reset + else + { + fprintf(stderr, "%s\n", message.c_str()); + } } private: @@ -217,11 +220,14 @@ namespace { ANSI_NO } mUseANSI; - void colorANSI(const std::string color) + LL_FORCE_INLINE void writeANSI(const std::string& ansi_code, const std::string& message) { - // ANSI color code escape sequence - fprintf(stderr, "\033[%sm", color.c_str() ); - }; + static std::string s_ansi_bold = createANSI("1"); // bold + static std::string s_ansi_reset = createANSI("0"); // reset + // ANSI color code escape sequence, message, and reset in one fprintf call + // Default all message levels to bold so we can distinguish our own messages from those dumped by subprocesses and libraries. + fprintf(stderr, "%s%s%s\n%s", s_ansi_bold.c_str(), ansi_code.c_str(), message.c_str(), s_ansi_reset.c_str() ); + } bool checkANSI(void) { @@ -232,8 +238,8 @@ namespace { return (0 != isatty(2)) && (NULL == getenv("LL_NO_ANSI_COLOR")); #endif // LL_LINUX - return false; - }; + return FALSE; // works in a cygwin shell... ;) + } }; class RecordToFixedBuffer : public LLError::Recorder diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index e32625796c..df867b332d 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -4656,6 +4656,10 @@ LLVolumeFace::LLVolumeFace() : mTexCoords(NULL), mIndices(NULL), mWeights(NULL), +#if USE_SEPARATE_JOINT_INDICES_AND_WEIGHTS + mJustWeights(NULL), + mJointIndices(NULL), +#endif mWeightsScrubbed(FALSE), mOctree(NULL), mOptimized(FALSE) @@ -4682,6 +4686,10 @@ LLVolumeFace::LLVolumeFace(const LLVolumeFace& src) mTexCoords(NULL), mIndices(NULL), mWeights(NULL), +#if USE_SEPARATE_JOINT_INDICES_AND_WEIGHTS + mJustWeights(NULL), + mJointIndices(NULL), +#endif mWeightsScrubbed(FALSE), mOctree(NULL) { @@ -4746,24 +4754,46 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src) if (src.mWeights) { + llassert(!mWeights); // don't orphan an old alloc here accidentally allocateWeights(src.mNumVertices); - LLVector4a::memcpyNonAliased16((F32*) mWeights, (F32*) src.mWeights, vert_size); + LLVector4a::memcpyNonAliased16((F32*) mWeights, (F32*) src.mWeights, vert_size); + mWeightsScrubbed = src.mWeightsScrubbed; } else { - ll_aligned_free_16(mWeights); - mWeights = NULL; - } - mWeightsScrubbed = src.mWeightsScrubbed; - } + ll_aligned_free_16(mWeights); + mWeights = NULL; + mWeightsScrubbed = FALSE; + } + + #if USE_SEPARATE_JOINT_INDICES_AND_WEIGHTS + if (src.mJointIndices) + { + llassert(!mJointIndices); // don't orphan an old alloc here accidentally + allocateJointIndices(src.mNumVertices); + LLVector4a::memcpyNonAliased16((F32*) mJointIndices, (F32*) src.mJointIndices, src.mNumVertices * sizeof(U8) * 4); + } + else*/ + { + ll_aligned_free_16(mJointIndices); + mJointIndices = NULL; + } + #endif + } + if (mNumIndices) { S32 idx_size = (mNumIndices*sizeof(U16)+0xF) & ~0xF; LLVector4a::memcpyNonAliased16((F32*) mIndices, (F32*) src.mIndices, idx_size); } - + else + { + ll_aligned_free_16(mIndices); + mIndices = NULL; + } + mOptimized = src.mOptimized; //delete @@ -4795,6 +4825,13 @@ void LLVolumeFace::freeData() ll_aligned_free_16(mWeights); mWeights = NULL; +#if USE_SEPARATE_JOINT_INDICES_AND_WEIGHTS + ll_aligned_free_16(mJointIndices); + mJointIndices = NULL; + ll_aligned_free_16(mJustWeights); + mJustWeights = NULL; +#endif + delete mOctree; mOctree = NULL; } @@ -5448,11 +5485,17 @@ bool LLVolumeFace::cacheOptimize() // DO NOT free mNormals and mTexCoords as they are part of mPositions buffer ll_aligned_free_16(mWeights); ll_aligned_free_16(mTangents); +#if USE_SEPARATE_JOINT_INDICES_AND_WEIGHTS + ll_aligned_free_16(mJointIndices); + ll_aligned_free_16(mJustWeights); + mJustWeights = NULL; + mJointIndices = NULL; // filled in later as necessary by skinning code for acceleration +#endif mPositions = pos; mNormals = norm; mTexCoords = tc; - mWeights = wght; + mWeights = wght; mTangents = binorm; //std::string result = llformat("ACMR pre/post: %.3f/%.3f -- %d triangles %d breaks", pre_acmr, post_acmr, mNumIndices/3, breaks); @@ -6362,7 +6405,19 @@ void LLVolumeFace::allocateTangents(S32 num_verts) void LLVolumeFace::allocateWeights(S32 num_verts) { ll_aligned_free_16(mWeights); - mWeights = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts); + mWeights = (LLVector4a*)ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts); + +} + +void LLVolumeFace::allocateJointIndices(S32 num_verts) +{ +#if USE_SEPARATE_JOINT_INDICES_AND_WEIGHTS + ll_aligned_free_16(mJointIndices); + ll_aligned_free_16(mJustWeights); + + mJointIndices = (U8*)ll_aligned_malloc_16(sizeof(U8) * 4 * num_verts); + mJustWeights = (LLVector4a*)ll_aligned_malloc_16(sizeof(LLVector4a) * num_verts); +#endif } void LLVolumeFace::resizeIndices(S32 num_indices) diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h index 1d6d35c432..a77e8c08c6 100644 --- a/indra/llmath/llvolume.h +++ b/indra/llmath/llvolume.h @@ -875,6 +875,7 @@ public: void resizeVertices(S32 num_verts); void allocateTangents(S32 num_verts); void allocateWeights(S32 num_verts); + void allocateJointIndices(S32 num_verts); void resizeIndices(S32 num_indices); void fillFromLegacyData(std::vector<LLVolumeFace::VertexData>& v, std::vector<U16>& idx); @@ -956,6 +957,11 @@ public: // mWeights.size() should be empty or match mVertices.size() LLVector4a* mWeights; +#if USE_SEPARATE_JOINT_INDICES_AND_WEIGHTS + LLVector4a* mJustWeights; + U8* mJointIndices; +#endif + mutable BOOL mWeightsScrubbed; // Which joints are rigged to, and the bounding box of any rigged diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp index 8f75d89e5a..139f48fef8 100644 --- a/indra/llprimitive/lldaeloader.cpp +++ b/indra/llprimitive/lldaeloader.cpp @@ -1784,7 +1784,7 @@ void LLDAELoader::extractTranslationViaElement( daeElement* pTranslateElement, L { if ( pTranslateElement ) { - domTranslate* pTranslateChild = dynamic_cast<domTranslate*>( pTranslateElement ); + domTranslate* pTranslateChild = static_cast<domTranslate*>( pTranslateElement ); domFloat3 translateChild = pTranslateChild->getValue(); LLVector3 singleJointTranslation( translateChild[0], translateChild[1], translateChild[2] ); transform.setTranslation( singleJointTranslation ); diff --git a/indra/llrender/CMakeLists.txt b/indra/llrender/CMakeLists.txt index 589cf86745..47e7ad915b 100644 --- a/indra/llrender/CMakeLists.txt +++ b/indra/llrender/CMakeLists.txt @@ -80,6 +80,7 @@ set(llrender_HEADER_FILES llshadermgr.h lltexture.h lluiimage.h + lluiimage.inl llvertexbuffer.h llglcommonfunc.h ) diff --git a/indra/llrender/lluiimage.cpp b/indra/llrender/lluiimage.cpp index 5d8f92b2e6..db69806097 100644 --- a/indra/llrender/lluiimage.cpp +++ b/indra/llrender/lluiimage.cpp @@ -31,7 +31,6 @@ // Project includes #include "lluiimage.h" -#include "llrender2dutils.h" LLUIImage::LLUIImage(const std::string& name, LLPointer<LLTexture> image) : mName(name), @@ -39,67 +38,29 @@ LLUIImage::LLUIImage(const std::string& name, LLPointer<LLTexture> image) mScaleRegion(0.f, 1.f, 1.f, 0.f), mClipRegion(0.f, 1.f, 1.f, 0.f), mImageLoaded(NULL), - mScaleStyle(SCALE_INNER) -{} + mScaleStyle(SCALE_INNER), + mCachedW(-1), + mCachedH(-1) +{ + getTextureWidth(); + getTextureHeight(); +} LLUIImage::~LLUIImage() { delete mImageLoaded; } -void LLUIImage::setClipRegion(const LLRectf& region) +S32 LLUIImage::getWidth() const { - mClipRegion = region; + // return clipped dimensions of actual image area + return ll_round((F32)mImage->getWidth(0) * mClipRegion.getWidth()); } -void LLUIImage::setScaleRegion(const LLRectf& region) +S32 LLUIImage::getHeight() const { - mScaleRegion = region; -} - -void LLUIImage::setScaleStyle(LLUIImage::EScaleStyle style) -{ - mScaleStyle = style; -} - -//TODO: move drawing implementation inside class -void LLUIImage::draw(S32 x, S32 y, const LLColor4& color) const -{ - draw(x, y, getWidth(), getHeight(), color); -} - -void LLUIImage::draw(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const -{ - gl_draw_scaled_image_with_border( - x, y, - width, height, - mImage, - color, - FALSE, - mClipRegion, - mScaleRegion, - mScaleStyle == SCALE_INNER); -} - -void LLUIImage::drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const -{ - gl_draw_scaled_image_with_border( - x, y, - width, height, - mImage, - color, - TRUE, - mClipRegion, - mScaleRegion, - mScaleStyle == SCALE_INNER); -} - -void LLUIImage::drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& color, S32 border_width) const -{ - LLRect border_rect; - border_rect.setOriginAndSize(x, y, width, height); - border_rect.stretch(border_width, border_width); - drawSolid(border_rect, color); + // return clipped dimensions of actual image area + return ll_round((F32)mImage->getHeight(0) * mClipRegion.getHeight()); } void LLUIImage::draw3D(const LLVector3& origin_agent, const LLVector3& x_axis, const LLVector3& y_axis, @@ -145,28 +106,7 @@ void LLUIImage::draw3D(const LLVector3& origin_agent, const LLVector3& x_axis, c } LLRender2D::popMatrix(); } - -S32 LLUIImage::getWidth() const -{ - // return clipped dimensions of actual image area - return ll_round((F32)mImage->getWidth(0) * mClipRegion.getWidth()); -} - -S32 LLUIImage::getHeight() const -{ - // return clipped dimensions of actual image area - return ll_round((F32)mImage->getHeight(0) * mClipRegion.getHeight()); -} - -S32 LLUIImage::getTextureWidth() const -{ - return mImage->getWidth(0); -} - -S32 LLUIImage::getTextureHeight() const -{ - return mImage->getHeight(0); -} +//#include "lluiimage.inl" boost::signals2::connection LLUIImage::addLoadedCallback( const image_loaded_signal_t::slot_type& cb ) { @@ -186,7 +126,6 @@ void LLUIImage::onImageLoaded() } } - namespace LLInitParam { void ParamValue<LLUIImage*>::updateValueFromBlock() diff --git a/indra/llrender/lluiimage.h b/indra/llrender/lluiimage.h index 6f47385eb0..e462e19004 100644 --- a/indra/llrender/lluiimage.h +++ b/indra/llrender/lluiimage.h @@ -36,6 +36,7 @@ #include <boost/signals2.hpp> #include "llinitparam.h" #include "lltexture.h" +#include "llrender2dutils.h" extern const LLColor4 UI_VERTEX_COLOR; @@ -53,35 +54,46 @@ public: LLUIImage(const std::string& name, LLPointer<LLTexture> image); virtual ~LLUIImage(); - void setClipRegion(const LLRectf& region); - void setScaleRegion(const LLRectf& region); - void setScaleStyle(EScaleStyle style); + LL_FORCE_INLINE void setClipRegion(const LLRectf& region) + { + mClipRegion = region; + } - LLPointer<LLTexture> getImage() { return mImage; } - const LLPointer<LLTexture>& getImage() const { return mImage; } + LL_FORCE_INLINE void setScaleRegion(const LLRectf& region) + { + mScaleRegion = region; + } - void draw(S32 x, S32 y, S32 width, S32 height, const LLColor4& color = UI_VERTEX_COLOR) const; - void draw(S32 x, S32 y, const LLColor4& color = UI_VERTEX_COLOR) const; - void draw(const LLRect& rect, const LLColor4& color = UI_VERTEX_COLOR) const { draw(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color); } + LL_FORCE_INLINE void setScaleStyle(EScaleStyle style) + { + mScaleStyle = style; + } + + LL_FORCE_INLINE LLPointer<LLTexture> getImage() { return mImage; } + LL_FORCE_INLINE const LLPointer<LLTexture>& getImage() const { return mImage; } + + LL_FORCE_INLINE void draw(S32 x, S32 y, S32 width, S32 height, const LLColor4& color = UI_VERTEX_COLOR) const; + LL_FORCE_INLINE void draw(S32 x, S32 y, const LLColor4& color = UI_VERTEX_COLOR) const; + LL_FORCE_INLINE void draw(const LLRect& rect, const LLColor4& color = UI_VERTEX_COLOR) const { draw(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color); } - void drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const; - void drawSolid(const LLRect& rect, const LLColor4& color) const { drawSolid(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color); } - void drawSolid(S32 x, S32 y, const LLColor4& color) const { drawSolid(x, y, getWidth(), getHeight(), color); } + LL_FORCE_INLINE void drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const; + LL_FORCE_INLINE void drawSolid(const LLRect& rect, const LLColor4& color) const { drawSolid(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color); } + LL_FORCE_INLINE void drawSolid(S32 x, S32 y, const LLColor4& color) const { drawSolid(x, y, getWidth(), getHeight(), color); } - void drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& color, S32 border_width) const; - void drawBorder(const LLRect& rect, const LLColor4& color, S32 border_width) const { drawBorder(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color, border_width); } - void drawBorder(S32 x, S32 y, const LLColor4& color, S32 border_width) const { drawBorder(x, y, getWidth(), getHeight(), color, border_width); } + LL_FORCE_INLINE void drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& color, S32 border_width) const; + LL_FORCE_INLINE void drawBorder(const LLRect& rect, const LLColor4& color, S32 border_width) const { drawBorder(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color, border_width); } + LL_FORCE_INLINE void drawBorder(S32 x, S32 y, const LLColor4& color, S32 border_width) const { drawBorder(x, y, getWidth(), getHeight(), color, border_width); } void draw3D(const LLVector3& origin_agent, const LLVector3& x_axis, const LLVector3& y_axis, const LLRect& rect, const LLColor4& color); - const std::string& getName() const { return mName; } + LL_FORCE_INLINE const std::string& getName() const { return mName; } virtual S32 getWidth() const; virtual S32 getHeight() const; // returns dimensions of underlying textures, which might not be equal to ui image portion - S32 getTextureWidth() const; - S32 getTextureHeight() const; + LL_FORCE_INLINE S32 getTextureWidth() const; + LL_FORCE_INLINE S32 getTextureHeight() const; boost::signals2::connection addLoadedCallback( const image_loaded_signal_t::slot_type& cb ); @@ -95,8 +107,12 @@ protected: LLRectf mClipRegion; LLPointer<LLTexture> mImage; EScaleStyle mScaleStyle; + mutable S32 mCachedW; + mutable S32 mCachedH; }; +#include "lluiimage.inl" + namespace LLInitParam { template<> diff --git a/indra/llrender/lluiimage.inl b/indra/llrender/lluiimage.inl new file mode 100644 index 0000000000..f5227556f0 --- /dev/null +++ b/indra/llrender/lluiimage.inl @@ -0,0 +1,77 @@ +/** + * @file lluiimage.inl + * @brief UI inline func implementation + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +void LLUIImage::draw(S32 x, S32 y, const LLColor4& color) const +{ + draw(x, y, getWidth(), getHeight(), color); +} + +void LLUIImage::draw(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const +{ + gl_draw_scaled_image_with_border( + x, y, + width, height, + mImage, + color, + FALSE, + mClipRegion, + mScaleRegion, + mScaleStyle == SCALE_INNER); +} + +void LLUIImage::drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const +{ + gl_draw_scaled_image_with_border( + x, y, + width, height, + mImage, + color, + TRUE, + mClipRegion, + mScaleRegion, + mScaleStyle == SCALE_INNER); +} + +void LLUIImage::drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& color, S32 border_width) const +{ + LLRect border_rect; + border_rect.setOriginAndSize(x, y, width, height); + border_rect.stretch(border_width, border_width); + drawSolid(border_rect, color); +} + +// returns dimensions of underlying textures, which might not be equal to ui image portion +S32 LLUIImage::getTextureWidth() const +{ + mCachedW = (mCachedW == -1) ? getWidth() : mCachedW; + return mCachedW; +} + +S32 LLUIImage::getTextureHeight() const +{ + mCachedH = (mCachedH == -1) ? getHeight() : mCachedH; + return mCachedH; +} diff --git a/indra/llxml/llxmltree.cpp b/indra/llxml/llxmltree.cpp index ca98953f92..ed9c07e1db 100644 --- a/indra/llxml/llxmltree.cpp +++ b/indra/llxml/llxmltree.cpp @@ -111,9 +111,11 @@ LLXmlTreeNode::~LLXmlTreeNode() attribute_map_t::iterator iter; for (iter=mAttributes.begin(); iter != mAttributes.end(); iter++) delete iter->second; - child_list_t::iterator child_iter; - for (child_iter=mChildList.begin(); child_iter != mChildList.end(); child_iter++) - delete *child_iter; + for(LLXmlTreeNode* node : mChildren) + { + delete node; + } + mChildren.clear(); } void LLXmlTreeNode::dump( const std::string& prefix ) @@ -149,15 +151,15 @@ void LLXmlTreeNode::addAttribute(const std::string& name, const std::string& val LLXmlTreeNode* LLXmlTreeNode::getFirstChild() { - mChildListIter = mChildList.begin(); + mChildrenIter = mChildren.begin(); return getNextChild(); } LLXmlTreeNode* LLXmlTreeNode::getNextChild() { - if (mChildListIter == mChildList.end()) + if (mChildrenIter == mChildren.end()) return 0; else - return *mChildListIter++; + return *mChildrenIter++; } LLXmlTreeNode* LLXmlTreeNode::getChildByName(const std::string& name) @@ -184,7 +186,7 @@ void LLXmlTreeNode::appendContents(const std::string& str) void LLXmlTreeNode::addChild(LLXmlTreeNode* child) { llassert( child ); - mChildList.push_back( child ); + mChildren.push_back( child ); // Add a name mapping to this node LLStdStringHandle tableptr = mTree->mNodeNames.insert(child->mName); diff --git a/indra/llxml/llxmltree.h b/indra/llxml/llxmltree.h index a82fee0416..3e425c3870 100644 --- a/indra/llxml/llxmltree.h +++ b/indra/llxml/llxmltree.h @@ -151,7 +151,7 @@ public: LLXmlTreeNode* getParent() { return mParent; } LLXmlTreeNode* getFirstChild(); LLXmlTreeNode* getNextChild(); - S32 getChildCount() { return (S32)mChildList.size(); } + S32 getChildCount() { return (S32)mChildren.size(); } LLXmlTreeNode* getChildByName( const std::string& name ); // returns first child with name, NULL if none LLXmlTreeNode* getNextNamedChild(); // returns next child with name, NULL if none @@ -177,9 +177,9 @@ private: std::string mName; std::string mContents; - typedef std::list<class LLXmlTreeNode *> child_list_t; - child_list_t mChildList; - child_list_t::iterator mChildListIter; + typedef std::vector<class LLXmlTreeNode *> children_t; + children_t mChildren; + children_t::iterator mChildrenIter; typedef std::multimap<LLStdStringHandle, LLXmlTreeNode *> child_map_t; child_map_t mChildMap; // for fast name lookups diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl index 5ce246a114..2cd660ab79 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl @@ -129,8 +129,6 @@ void main() // Add "minimum anti-solar illumination" temp2.x += .25; - //temp2.x *= sun_moon_glow_factor; - vec4 color = ( blue_horizon * blue_weight * (sunlight + ambient_color) + (haze_horizon * haze_weight) * (sunlight * temp2.x + ambient_color) ); diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl index d81a8feb96..0d141342ce 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl @@ -54,17 +54,19 @@ uniform float max_y; uniform vec4 glow; uniform float sun_moon_glow_factor; + uniform vec4 cloud_color; void main() { // World / view / projection - gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); + vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0); + gl_Position = pos; + // Get relative position vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0); - //vec3 P = position.xyz + vec3(0,50,0); // Set altitude if (P.y > 0.) @@ -78,7 +80,8 @@ void main() // Can normalize then vec3 Pn = normalize(P); - float Plen = length(P); + + float Plen = length(P); // Initialize temp variables vec4 temp1 = vec4(0.); @@ -89,29 +92,28 @@ void main() vec4 light_atten; float dens_mul = density_multiplier; - float dist_mul = max(0.05, distance_multiplier); // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes light_atten = (blue_density + vec4(haze_density * 0.25)) * (dens_mul * max_y); // Calculate relative weights - temp1 = blue_density + haze_density; + temp1 = abs(blue_density) + vec4(abs(haze_density)); blue_weight = blue_density / temp1; haze_weight = haze_density / temp1; // Compute sunlight from P & lightnorm (for long rays like sky) - temp2.y = max(0., max(0., Pn.y) * 1.0 + lightnorm.y ); - temp2.y = 1. / temp2.y; - sunlight *= exp( - light_atten * temp2.y); + temp2.y = max(0., max(0., Pn.y) * 1.0 + lightnorm.y ); + temp2.y = 1. / temp2.y; + sunlight *= exp( - light_atten * temp2.y); // Distance temp2.z = Plen * dens_mul; // Transparency (-> temp1) - // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati - // compiler gets confused. - temp1 = exp(-temp1 * temp2.z); + // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati + // compiler gets confused. + temp1 = exp(-temp1 * temp2.z); // Compute haze glow temp2.x = dot(Pn, lightnorm.xyz); @@ -124,40 +126,36 @@ void main() temp2.x = pow(temp2.x, glow.z); // glow.z should be negative, so we're doing a sort of (1 / "angle") function - temp2.x *= sun_moon_glow_factor; - // Add "minimum anti-solar illumination" temp2.x += .25; + vec4 color = ( blue_horizon * blue_weight * (sunlight + ambient_color) + + (haze_horizon * haze_weight) * (sunlight * temp2.x + ambient_color) + ); - // Haze color above cloud - vary_HazeColor = ( blue_horizon * blue_weight * (sunlight + ambient_color) - + (haze_horizon * haze_weight) * (sunlight * temp2.x + ambient_color) - ); + // Final atmosphere additive + color *= (1. - temp1); // Increase ambient when there are more clouds vec4 tmpAmbient = ambient_color; - tmpAmbient += (1. - tmpAmbient) * cloud_shadow * 0.5; + tmpAmbient += max(vec4(0), (1. - ambient_color)) * cloud_shadow * 0.5; // Dim sunlight by cloud shadow percentage - sunlight *= (1. - cloud_shadow); + sunlight *= max(0.0, (1. - cloud_shadow)); // Haze color below cloud vec4 additiveColorBelowCloud = ( blue_horizon * blue_weight * (sunlight + tmpAmbient) + (haze_horizon * haze_weight) * (sunlight * temp2.x + tmpAmbient) ); - // Final atmosphere additive - vary_HazeColor *= (1. - temp1); - // Attenuate cloud color by atmosphere temp1 = sqrt(temp1); //less atmos opacity (more transparency) below clouds // At horizon, blend high altitude sky color towards the darker color below the clouds - vary_HazeColor += (additiveColorBelowCloud - vary_HazeColor) * (1. - sqrt(temp1)); - - // won't compile on mac without this being set - //vary_AtmosAttenuation = vec3(0.0,0.0,0.0); + color += (additiveColorBelowCloud - color) * (1. - sqrt(temp1)); + + // Haze color above cloud + vary_HazeColor = color; } diff --git a/indra/newview/llcontrolavatar.cpp b/indra/newview/llcontrolavatar.cpp index 1e8ec4fe0f..6da7163f9f 100644 --- a/indra/newview/llcontrolavatar.cpp +++ b/indra/newview/llcontrolavatar.cpp @@ -255,7 +255,7 @@ void LLControlAvatar::recursiveScaleJoint(LLJoint* joint, F32 factor) { joint->setScale(factor * joint->getScale()); - for (LLJoint::child_list_t::iterator iter = joint->mChildren.begin(); + for (LLJoint::joints_t::iterator iter = joint->mChildren.begin(); iter != joint->mChildren.end(); ++iter) { LLJoint* child = *iter; diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 15a0595179..789a254389 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -38,6 +38,7 @@ #include "lldrawable.h" #include "lldrawpoolbump.h" #include "llface.h" +#include "llvolume.h" #include "llmeshrepository.h" #include "llsky.h" #include "llviewercamera.h" @@ -1833,15 +1834,13 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer( LLFace* face, const LLMeshSkinInfo* skin, LLVolume* volume, - const LLVolumeFace& vol_face) + LLVolumeFace& vol_face) { LLVector4a* weights = vol_face.mWeights; if (!weights) { return; } - // FIXME ugly const cast - LLSkinningUtil::scrubInvalidJoints(avatar, const_cast<LLMeshSkinInfo*>(skin)); LLPointer<LLVertexBuffer> buffer = face->getVertexBuffer(); LLDrawable* drawable = face->getDrawable(); @@ -1851,6 +1850,48 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer( return; } + const U32 max_joints = LLSkinningUtil::getMaxJointCount(); + +#if USE_SEPARATE_JOINT_INDICES_AND_WEIGHTS + #define CONDITION_WEIGHT(f) ((U8)llclamp((S32)f, (S32)0, (S32)max_joints-1)) + LLVector4a* just_weights = vol_face.mJustWeights; + // we need to calculate the separated indices and store just the matrix weights for this vol... + if (!vol_face.mJointIndices) + { + // not very consty after all... + vol_face.allocateJointIndices(vol_face.mNumVertices); + just_weights = vol_face.mJustWeights; + + U8* joint_indices_cursor = vol_face.mJointIndices; + for (int i = 0; i < vol_face.mNumVertices; i++) + { + F32* w = weights[i].getF32ptr(); + F32* w_ = just_weights[i].getF32ptr(); + + F32 w0 = floorf(w[0]); + F32 w1 = floorf(w[1]); + F32 w2 = floorf(w[2]); + F32 w3 = floorf(w[3]); + + joint_indices_cursor[0] = CONDITION_WEIGHT(w0); + joint_indices_cursor[1] = CONDITION_WEIGHT(w1); + joint_indices_cursor[2] = CONDITION_WEIGHT(w2); + joint_indices_cursor[3] = CONDITION_WEIGHT(w3); + + // remove joint portion of combined weight + w_[0] = w[0] - w0; + w_[1] = w[1] - w1; + w_[2] = w[2] - w2; + w_[3] = w[3] - w3; + + joint_indices_cursor += 4; + } + } +#endif + + // FIXME ugly const cast + LLSkinningUtil::scrubInvalidJoints(avatar, const_cast<LLMeshSkinInfo*>(skin)); + U32 data_mask = face->getRiggedVertexBufferDataMask(); if (!vol_face.mWeightsScrubbed) @@ -1927,29 +1968,67 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer( LLMatrix4a bind_shape_matrix; bind_shape_matrix.loadu(skin->mBindShapeMatrix); - const U32 max_joints = LLSkinningUtil::getMaxJointCount(); - for (U32 j = 0; j < buffer->getNumVerts(); ++j) - { - LLMatrix4a final_mat; - LLSkinningUtil::getPerVertexSkinMatrix(weights[j].getF32ptr(), mat, false, final_mat, max_joints); - - LLVector4a& v = vol_face.mPositions[j]; - - LLVector4a t; - LLVector4a dst; - bind_shape_matrix.affineTransform(v, t); - final_mat.affineTransform(t, dst); - pos[j] = dst; - - if (norm) - { - LLVector4a& n = vol_face.mNormals[j]; - bind_shape_matrix.rotate(n, t); - final_mat.rotate(t, dst); - dst.normalize3fast(); - norm[j] = dst; - } - } +#if USE_SEPARATE_JOINT_INDICES_AND_WEIGHTS + U8* joint_indices_cursor = vol_face.mJointIndices; + // fast path with joint indices separate from weights + if (joint_indices_cursor) + { + LLMatrix4a src[4]; + for (U32 j = 0; j < buffer->getNumVerts(); ++j) + { + LLMatrix4a final_mat; + //LLMatrix4a final_mat_correct; + + F32* jw = just_weights[j].getF32ptr(); + + LLSkinningUtil::getPerVertexSkinMatrixWithIndices(jw, joint_indices_cursor, mat, final_mat, src); + + joint_indices_cursor += 4; + + LLVector4a& v = vol_face.mPositions[j]; + + LLVector4a t; + LLVector4a dst; + bind_shape_matrix.affineTransform(v, t); + final_mat.affineTransform(t, dst); + pos[j] = dst; + + if (norm) + { + LLVector4a& n = vol_face.mNormals[j]; + bind_shape_matrix.rotate(n, t); + final_mat.rotate(t, dst); + dst.normalize3fast(); + norm[j] = dst; + } + } + } + // slow path with joint indices calculated from weights + else +#endif + { + for (U32 j = 0; j < buffer->getNumVerts(); ++j) + { + LLMatrix4a final_mat; + LLSkinningUtil::getPerVertexSkinMatrix(weights[j].getF32ptr(), mat, false, final_mat, max_joints); + + LLVector4a& v = vol_face.mPositions[j]; + LLVector4a t; + LLVector4a dst; + bind_shape_matrix.affineTransform(v, t); + final_mat.affineTransform(t, dst); + pos[j] = dst; + + if (norm) + { + LLVector4a& n = vol_face.mNormals[j]; + bind_shape_matrix.rotate(n, t); + final_mat.rotate(t, dst); + //dst.normalize3fast(); + norm[j] = dst; + } + } + } } } @@ -2301,7 +2380,7 @@ void LLDrawPoolAvatar::updateRiggedVertexBuffers(LLVOAvatar* avatar) stop_glerror(); - const LLVolumeFace& vol_face = volume->getVolumeFace(te); + LLVolumeFace& vol_face = volume->getVolumeFace(te); updateRiggedFaceVertexBuffer(avatar, face, skin, volume, vol_face); } } diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h index e8add0e1d8..cb09eb18e2 100644 --- a/indra/newview/lldrawpoolavatar.h +++ b/indra/newview/lldrawpoolavatar.h @@ -257,7 +257,7 @@ typedef enum LLFace* facep, const LLMeshSkinInfo* skin, LLVolume* volume, - const LLVolumeFace& vol_face); + LLVolumeFace& vol_face); void updateRiggedVertexBuffers(LLVOAvatar* avatar); void renderRigged(LLVOAvatar* avatar, U32 type, bool glow = false); diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index 12614b5e2d..dbe8724088 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -111,37 +111,52 @@ void LLDrawPoolSky::render(S32 pass) LLVertexBuffer::unbind(); gGL.diffuseColor4f(1,1,1,1); - for (S32 i = 0; i < llmin(6, face_count); ++i) + for (S32 i = 0; i < face_count; ++i) { - renderSkyCubeFace(i); + renderSkyFace(i); } gGL.popMatrix(); } -void LLDrawPoolSky::renderSkyCubeFace(U8 side) +void LLDrawPoolSky::renderSkyFace(U8 index) { - LLFace &face = *mDrawFace[LLVOSky::FACE_SIDE0 + side]; - if (!face.getGeomCount()) + LLFace* face = mDrawFace[index]; + + if (!face || !face->getGeomCount()) { return; } - llassert(mSkyTex); - mSkyTex[side].bindTexture(TRUE); - - gGL.getTexUnit(0)->setTextureColorSpace(LLTexUnit::TCS_SRGB); - - face.renderIndexed(); - - if (LLSkyTex::doInterpolate()) - { - - LLGLEnable blend(GL_BLEND); - mSkyTex[side].bindTexture(FALSE); - gGL.diffuseColor4f(1, 1, 1, LLSkyTex::getInterpVal()); // lighting is disabled - face.renderIndexed(); - } + F32 interp_val = gSky.mVOSkyp ? gSky.mVOSkyp->getInterpVal() : 0.0f; + + if (index < 6) // sky tex...interp + { + llassert(mSkyTex); + mSkyTex[index].bindTexture(true); // bind the current tex + + face->renderIndexed(); + + if (interp_val > 0.01f) // iff, we've got enough info to lerp (a to and a from) + { + LLGLEnable blend(GL_BLEND); + llassert(mSkyTex); + mSkyTex[index].bindTexture(false); // bind the "other" texture + gGL.diffuseColor4f(1, 1, 1, interp_val); // lighting is disabled + face->renderIndexed(); + } + } + else // heavenly body faces, no interp... + { + LLGLEnable blend(GL_BLEND); + + LLViewerTexture* tex = face->getTexture(LLRender::DIFFUSE_MAP); + if (tex) + { + gGL.getTexUnit(0)->bind(tex, true); + face->renderIndexed(); + } + } } void LLDrawPoolSky::endRenderPass( S32 pass ) diff --git a/indra/newview/lldrawpoolsky.h b/indra/newview/lldrawpoolsky.h index 098bd2134a..916d8c1cbe 100644 --- a/indra/newview/lldrawpoolsky.h +++ b/indra/newview/lldrawpoolsky.h @@ -61,7 +61,7 @@ public: /*virtual*/ void endRenderPass(S32 pass); void setSkyTex(LLSkyTex* const st) { mSkyTex = st; } - void renderSkyCubeFace(U8 side); + void renderSkyFace(U8 index); void renderHeavenlyBody(U8 hb, LLFace* face); void renderSunHalo(LLFace* face); diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index 1b5c154378..13420fc001 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -500,6 +500,9 @@ void LLDrawPoolWater::shade2(bool edge, LLGLSLShader* shader, const LLColor3& li } } + LLColor4 specular(psky->getIsSunUp() ? psky->getSunlightColor() : psky->getMoonlightColor()); + shader->uniform4fv(LLShaderMgr::SPECULAR_COLOR, 1, specular.mV); + sTime = (F32)LLFrameTimer::getElapsedSeconds() * 0.5f; S32 reftex = shader->enableTexture(LLShaderMgr::WATER_REFTEX); diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 4a93f1b886..4f147fdb07 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -3319,6 +3319,8 @@ void LLPanelLandEnvironment::refresh() if (gDisconnected) return; + commitDayLenOffsetChanges(false); // commit unsaved changes if any + if (!isSameRegion()) { setCrossRegion(true); diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index ab91c34b3d..83215a7fec 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -3731,6 +3731,8 @@ BOOL LLPanelRegionEnvironment::postBuild() void LLPanelRegionEnvironment::refresh() { + commitDayLenOffsetChanges(false); // commit unsaved changes if any + if (!mCurrentEnvironment) { if (mCurEnvVersion <= INVALID_PARCEL_ENVIRONMENT_VERSION) diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 68613be19c..720c7e2388 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -242,7 +242,8 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVecto calcSkyColorWLVert(Pn, vars); - LLColor3 sky_color = isShiny ? vars.hazeColor : psky->gammaCorrect(vars.hazeColor * 2.0f); + LLColor3 sky_color = isShiny ? vars.hazeColor : + !gPipeline.canUseWindLightShaders() ? vars.hazeColor * 2.0f : psky->gammaCorrect(vars.hazeColor * 2.0f); if (isShiny) { @@ -306,6 +307,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) // this is used later for sunlight modulation at various altitudes LLColor3 light_atten = vars.light_atten; LLColor3 light_transmittance = psky->getLightTransmittance(Plen); + (void)light_transmittance; // silence Clang warn-error // Calculate relative weights LLColor3 temp2(0.f, 0.f, 0.f); @@ -321,22 +323,18 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) } // Compute sunlight from P & lightnorm (for long rays like sky) - temp2.mV[1] = llmax(F_APPROXIMATELY_ZERO, llmax(0.f, lighty)); - - if (temp2.mV[1] > 0.0000001f) - { - temp2.mV[1] = 1.f / temp2.mV[1]; - } - temp2.mV[1] = llmax(temp2.mV[1], 0.0000001f); + temp2.mV[1] = llmax(F_APPROXIMATELY_ZERO, llmax(0.f, Pn[1]) * 1.0f + sun_norm.mV[1] ); + temp2.mV[1] = 1.f / temp2.mV[1]; componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); - componentMultBy(sunlight, light_transmittance); + //componentMultBy(sunlight, light_transmittance); // Distance temp2.mV[2] = Plen * density_multiplier; // Transparency (-> temp1) - temp1 = componentExp((temp1 * -1.f) * temp2.mV[2] * distance_multiplier); + temp1 = componentExp((temp1 * -1.f) * temp2.mV[2]);// * distance_multiplier); + (void)distance_multiplier; // Compute haze glow temp2.mV[0] = Pn * LLVector3(sun_norm); @@ -347,7 +345,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) // Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) // Higher glow.x gives dimmer glow (because next step is 1 / "angle") - temp2.mV[0] *= (glow.mV[0] > 0) ? glow.mV[0] : F32_MIN; + temp2.mV[0] *= glow.mV[0]; temp2.mV[0] = pow(temp2.mV[0], glow.mV[2]); // glow.z should be negative, so we're doing a sort of (1 / "angle") function @@ -374,10 +372,13 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) final_atten.mV[2] = llmax(final_atten.mV[2], 0.0f); // Final atmosphere additive - componentMultBy(vars.hazeColor, final_atten); + componentMultBy(vars.hazeColor, LLColor3::white - temp1); + + // Attenuate cloud color by atmosphere + temp1 = componentSqrt(temp1); //less atmos opacity (more transparency) below clouds // At horizon, blend high altitude sky color towards the darker color below the clouds - vars.hazeColor += componentMult(vars.hazeColorBelowCloud - vars.hazeColor, final_atten); + vars.hazeColor += componentMult(vars.hazeColorBelowCloud - vars.hazeColor, LLColor3::white - componentSqrt(temp1)); } void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in) @@ -441,7 +442,7 @@ void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in) vars.density_multiplier = psky->getDensityMultiplier(); vars.distance_multiplier = psky->getDistanceMultiplier(); vars.max_y = psky->getMaxY(); - vars.sun_norm = LLEnvironment::instance().getLightDirectionCFR(); + vars.sun_norm = LLEnvironment::instance().getSunDirectionCFR(); vars.sunlight = psky->getSunlightColor(); vars.ambient = psky->getAmbientColor(); vars.glow = psky->getGlow(); diff --git a/indra/newview/lllegacyatmospherics.h b/indra/newview/lllegacyatmospherics.h index e304ac3043..95700227f9 100644 --- a/indra/newview/lllegacyatmospherics.h +++ b/indra/newview/lllegacyatmospherics.h @@ -206,6 +206,8 @@ public: { } + LL_FORCE_INLINE friend bool operator==(const AtmosphericsVars& a, const AtmosphericsVars& b); + LLColor3 hazeColor; LLColor3 hazeColorBelowCloud; LLColor3 cloudColorSun; @@ -231,6 +233,115 @@ public: LLColor3 total_density; }; +bool operator==(const AtmosphericsVars& a, const AtmosphericsVars& b) +{ + if (a.hazeColor != b.hazeColor) + { + return false; + } + + if (a.hazeColorBelowCloud != b.hazeColorBelowCloud) + { + return false; + } + + if (a.cloudColorSun != b.cloudColorSun) + { + return false; + } + + if (a.cloudColorAmbient != b.cloudColorAmbient) + { + return false; + } + + if (a.cloudDensity != b.cloudDensity) + { + return false; + } + + if (a.density_multiplier != b.density_multiplier) + { + return false; + } + + if (a.haze_horizon != b.haze_horizon) + { + return false; + } + + if (a.haze_density != b.haze_density) + { + return false; + } + + if (a.blue_horizon != b.blue_horizon) + { + return false; + } + + if (a.blue_density != b.blue_density) + { + return false; + } + + if (a.dome_offset != b.dome_offset) + { + return false; + } + + if (a.dome_radius != b.dome_radius) + { + return false; + } + + if (a.cloud_shadow != b.cloud_shadow) + { + return false; + } + + if (a.glow != b.glow) + { + return false; + } + + if (a.ambient != b.ambient) + { + return false; + } + + if (a.sunlight != b.sunlight) + { + return false; + } + + if (a.sun_norm != b.sun_norm) + { + return false; + } + + if (a.gamma != b.gamma) + { + return false; + } + + if (a.max_y != b.max_y) + { + return false; + } + + if (a.distance_multiplier != b.distance_multiplier) + { + return false; + } + + // light_atten, light_transmittance, total_density + // are ignored as they always change when the values above do + // they're just shared calc across the sky map generation to save cycles + + return true; +} + class LLAtmospherics { public: diff --git a/indra/newview/llpanelenvironment.cpp b/indra/newview/llpanelenvironment.cpp index 554fe6e9bc..d63ae4e434 100644 --- a/indra/newview/llpanelenvironment.cpp +++ b/indra/newview/llpanelenvironment.cpp @@ -215,6 +215,8 @@ void LLPanelEnvironmentInfo::onVisibilityChange(BOOL new_visibility) } else { + commitDayLenOffsetChanges(false); // arrow-key changes + LLFloaterSettingsPicker *picker = getSettingsPicker(false); if (picker) { @@ -718,6 +720,11 @@ void LLPanelEnvironmentInfo::onSldDayOffsetChanged(F32 value) void LLPanelEnvironmentInfo::onDayLenOffsetMouseUp() { + commitDayLenOffsetChanges(true); +} + +void LLPanelEnvironmentInfo::commitDayLenOffsetChanges(bool need_callback) +{ if (mCurrentEnvironment && (getDirtyFlag() & (DIRTY_FLAG_DAYLENGTH | DIRTY_FLAG_DAYOFFSET))) { clearDirtyFlag(DIRTY_FLAG_DAYOFFSET); @@ -725,9 +732,23 @@ void LLPanelEnvironmentInfo::onDayLenOffsetMouseUp() LLHandle<LLPanel> that_h = getHandle(); - LLEnvironment::instance().updateParcel(getParcelId(), LLSettingsDay::ptr_t(), - mCurrentEnvironment->mDayLength.value(), mCurrentEnvironment->mDayOffset.value(), LLEnvironment::altitudes_vect_t(), - [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); + if (need_callback) + { + LLEnvironment::instance().updateParcel(getParcelId(), + LLSettingsDay::ptr_t(), + mCurrentEnvironment->mDayLength.value(), + mCurrentEnvironment->mDayOffset.value(), + LLEnvironment::altitudes_vect_t(), + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); + } + else + { + LLEnvironment::instance().updateParcel(getParcelId(), + LLSettingsDay::ptr_t(), + mCurrentEnvironment->mDayLength.value(), + mCurrentEnvironment->mDayOffset.value(), + LLEnvironment::altitudes_vect_t()); + } } } @@ -776,6 +797,8 @@ void LLPanelEnvironmentInfo::onAltSliderMouseUp() if (isRegion() && (getDirtyFlag() & DIRTY_FLAG_ALTITUDES)) { clearDirtyFlag(DIRTY_FLAG_ALTITUDES); + clearDirtyFlag(DIRTY_FLAG_DAYLENGTH); + clearDirtyFlag(DIRTY_FLAG_DAYOFFSET); LLHandle<LLPanel> that_h = getHandle(); LLEnvironment::altitudes_vect_t alts; @@ -785,7 +808,11 @@ void LLPanelEnvironmentInfo::onAltSliderMouseUp() alts.push_back(alt.second.mAltitude); } setControlsEnabled(false); - LLEnvironment::instance().updateParcel(getParcelId(), LLSettingsDay::ptr_t(), -1, -1, alts); + LLEnvironment::instance().updateParcel(getParcelId(), + LLSettingsDay::ptr_t(), + mCurrentEnvironment ? mCurrentEnvironment->mDayLength.value() : -1, + mCurrentEnvironment ? mCurrentEnvironment->mDayOffset.value() : -1, + alts); } } @@ -852,14 +879,21 @@ void LLPanelEnvironmentInfo::onBtnRstAltitudes() LLHandle<LLPanel> that_h = getHandle(); LLEnvironment::altitudes_vect_t alts; + clearDirtyFlag(DIRTY_FLAG_ALTITUDES); + clearDirtyFlag(DIRTY_FLAG_DAYLENGTH); + clearDirtyFlag(DIRTY_FLAG_DAYOFFSET); + for (S32 idx = 1; idx <= ALTITUDE_SLIDER_COUNT; ++idx) { F32 new_height = idx * ALTITUDE_DEFAULT_HEIGHT_STEP; alts.push_back(new_height); } - LLEnvironment::instance().updateParcel(getParcelId(), LLSettingsDay::ptr_t(), - -1, -1, alts, + LLEnvironment::instance().updateParcel(getParcelId(), + LLSettingsDay::ptr_t(), + mCurrentEnvironment ? mCurrentEnvironment->mDayLength.value() : -1, + mCurrentEnvironment ? mCurrentEnvironment->mDayOffset.value() : -1, + alts, [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); } } @@ -930,11 +964,16 @@ void LLPanelEnvironmentInfo::onPickerCommitted(LLUUID item_id, S32 track_num) if (itemp) { LLHandle<LLPanel> that_h = getHandle(); + clearDirtyFlag(DIRTY_FLAG_DAYLENGTH); + clearDirtyFlag(DIRTY_FLAG_DAYOFFSET); - LLEnvironment::instance().updateParcel(getParcelId(), itemp->getAssetUUID(), - itemp->getName(), - track_num, - -1, -1, LLEnvironment::altitudes_vect_t(), + LLEnvironment::instance().updateParcel(getParcelId(), + itemp->getAssetUUID(), + itemp->getName(), + track_num, + mCurrentEnvironment ? mCurrentEnvironment->mDayLength.value() : -1, + mCurrentEnvironment ? mCurrentEnvironment->mDayOffset.value() : -1, + LLEnvironment::altitudes_vect_t(), [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); } } @@ -960,9 +999,14 @@ void LLPanelEnvironmentInfo::onEditCommitted(LLSettingsDay::ptr_t newday) if (newhash != oldhash) { LLHandle<LLPanel> that_h = getHandle(); + clearDirtyFlag(DIRTY_FLAG_DAYLENGTH); + clearDirtyFlag(DIRTY_FLAG_DAYOFFSET); - LLEnvironment::instance().updateParcel(getParcelId(), newday, - -1, -1, LLEnvironment::altitudes_vect_t(), + LLEnvironment::instance().updateParcel(getParcelId(), + newday, + mCurrentEnvironment ? mCurrentEnvironment->mDayLength.value() : -1, + mCurrentEnvironment ? mCurrentEnvironment->mDayOffset.value() : -1, + LLEnvironment::altitudes_vect_t(), [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); } } diff --git a/indra/newview/llpanelenvironment.h b/indra/newview/llpanelenvironment.h index 9eb4040758..50ec1165be 100644 --- a/indra/newview/llpanelenvironment.h +++ b/indra/newview/llpanelenvironment.h @@ -126,6 +126,7 @@ protected: void onPickerCommitted(LLUUID item_id, S32 track_num = LLEnvironment::NO_TRACK); void onEditCommitted(LLSettingsDay::ptr_t newday); void onDayLenOffsetMouseUp(); + void commitDayLenOffsetChanges(bool need_callback); void onPickerAssetDownloaded(LLSettingsBase::ptr_t settings); void onEnvironmentReceived(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo); diff --git a/indra/newview/llskinningutil.cpp b/indra/newview/llskinningutil.cpp index 0fa4c2b114..83b9c8971a 100644 --- a/indra/newview/llskinningutil.cpp +++ b/indra/newview/llskinningutil.cpp @@ -34,8 +34,12 @@ #include "llvolume.h" #include "llrigginginfo.h" +#define DEBUG_SKINNING LL_DEBUG +#define MAT_USE_SSE 1 + void dump_avatar_and_skin_state(const std::string& reason, LLVOAvatar *avatar, const LLMeshSkinInfo *skin) { +#if DEBUG_SKINNING static S32 dump_count = 0; const S32 max_dump = 10; @@ -81,16 +85,16 @@ void dump_avatar_and_skin_state(const std::string& reason, LLVOAvatar *avatar, c dump_count++; } +#endif } void LLSkinningUtil::initClass() { } -U32 LLSkinningUtil::getMaxJointCount() +S32 LLSkinningUtil::getMaxJointCount() { - U32 result = LL_MAX_JOINTS_PER_MESH_OBJECT; - return result; + return (S32)LL_MAX_JOINTS_PER_MESH_OBJECT; } U32 LLSkinningUtil::getMeshJointCount(const LLMeshSkinInfo *skin) @@ -120,6 +124,8 @@ void LLSkinningUtil::scrubInvalidJoints(LLVOAvatar *avatar, LLMeshSkinInfo* skin skin->mInvalidJointsScrubbed = true; } +#define MAT_USE_SSE 1 + void LLSkinningUtil::initSkinningMatrixPalette( LLMatrix4* mat, S32 count, @@ -130,9 +136,9 @@ void LLSkinningUtil::initSkinningMatrixPalette( for (U32 j = 0; j < count; ++j) { LLJoint *joint = avatar->getJoint(skin->mJointNums[j]); + llassert(joint); if (joint) { -#define MAT_USE_SSE #ifdef MAT_USE_SSE LLMatrix4a bind, world, res; bind.loadu(skin->mInvBindMatrix[j]); @@ -147,6 +153,7 @@ void LLSkinningUtil::initSkinningMatrixPalette( else { mat[j] = skin->mInvBindMatrix[j]; +#if DEBUG_SKINNING // This shouldn't happen - in mesh upload, skinned // rendering should be disabled unless all joints are // valid. In other cases of skinned rendering, invalid @@ -157,16 +164,15 @@ void LLSkinningUtil::initSkinningMatrixPalette( LL_WARNS_ONCE("Avatar") << avatar->getFullname() << " avatar build state: isBuilt() " << avatar->isBuilt() << " mInitFlags " << avatar->mInitFlags << LL_ENDL; -#if 0 - dump_avatar_and_skin_state("initSkinningMatrixPalette joint not found", avatar, skin); #endif + dump_avatar_and_skin_state("initSkinningMatrixPalette joint not found", avatar, skin); } } } void LLSkinningUtil::checkSkinWeights(LLVector4a* weights, U32 num_vertices, const LLMeshSkinInfo* skin) { -#ifdef SHOW_ASSERT // same condition that controls llassert() +#if DEBUG_SKINNING const S32 max_joints = skin->mJointNames.size(); for (U32 j=0; j<num_vertices; j++) { @@ -265,6 +271,7 @@ void LLSkinningUtil::initJointNums(LLMeshSkinInfo* skin, LLVOAvatar *avatar) { for (U32 j = 0; j < skin->mJointNames.size(); ++j) { + #if DEBUG_SKINNING LLJoint *joint = NULL; if (skin->mJointNums[j] == -1) { @@ -282,11 +289,16 @@ void LLSkinningUtil::initJointNums(LLMeshSkinInfo* skin, LLVOAvatar *avatar) { LL_WARNS_ONCE("Avatar") << avatar->getFullname() << " unable to find joint " << skin->mJointNames[j] << LL_ENDL; LL_WARNS_ONCE("Avatar") << avatar->getFullname() << " avatar build state: isBuilt() " << avatar->isBuilt() << " mInitFlags " << avatar->mInitFlags << LL_ENDL; -#if 0 dump_avatar_and_skin_state("initJointNums joint not found", avatar, skin); -#endif + skin->mJointNums[j] = 0; } } + #else + LLJoint *joint = (skin->mJointNums[j] == -1) ? avatar->getJoint(skin->mJointNames[j]) : avatar->getJoint(skin->mJointNums[j]); + skin->mJointNums[j] = joint ? joint->getJointNum() : 0; + #endif + // insure we have *a* valid joint to reference + llassert(skin->mJointNums[j] >= 0); } skin->mJointNumsInitialized = true; } @@ -344,14 +356,17 @@ void LLSkinningUtil::updateRiggingInfo(const LLMeshSkinInfo* skin, LLVOAvatar *a // FIXME could precompute these matMuls. LLMatrix4a bind_shape; - bind_shape.loadu(skin->mBindShapeMatrix); LLMatrix4a inv_bind; - inv_bind.loadu(skin->mInvBindMatrix[joint_index]); LLMatrix4a mat; - matMul(bind_shape, inv_bind, mat); LLVector4a pos_joint_space; + + bind_shape.loadu(skin->mBindShapeMatrix); + inv_bind.loadu(skin->mInvBindMatrix[joint_index]); + matMul(bind_shape, inv_bind, mat); + mat.affineTransform(pos, pos_joint_space); pos_joint_space.mul(wght[k]); + LLVector4a *extents = rig_info_tab[joint_num].getRiggedExtents(); update_min_max(extents[0], extents[1], pos_joint_space); } @@ -366,6 +381,8 @@ void LLSkinningUtil::updateRiggingInfo(const LLMeshSkinInfo* skin, LLVOAvatar *a vol_face.mJointRiggingInfoTab.setNeedsUpdate(false); } } + +#if DEBUG_SKINNING if (vol_face.mJointRiggingInfoTab.size()!=0) { LL_DEBUGS("RigSpammish") << "we have rigging info for vf " << &vol_face @@ -376,10 +393,40 @@ void LLSkinningUtil::updateRiggingInfo(const LLMeshSkinInfo* skin, LLVOAvatar *a LL_DEBUGS("RigSpammish") << "no rigging info for vf " << &vol_face << " num_verts " << vol_face.mNumVertices << LL_ENDL; } +#endif } } +void LLSkinningUtil::updateRiggingInfo_(LLMeshSkinInfo* skin, LLVOAvatar *avatar, S32 num_verts, LLVector4a* weights, LLVector4a* positions, U8* joint_indices, LLJointRiggingInfoTab &rig_info_tab) +{ + LL_RECORD_BLOCK_TIME(FTM_FACE_RIGGING_INFO); + for (S32 i=0; i < num_verts; i++) + { + LLVector4a& pos = positions[i]; + LLVector4a& wght = weights[i]; + for (U32 k=0; k<4; ++k) + { + S32 joint_num = skin->mJointNums[joint_indices[k]]; + llassert(joint_num >= 0 && joint_num < LL_CHARACTER_MAX_ANIMATED_JOINTS); + { + rig_info_tab[joint_num].setIsRiggedTo(true); + LLMatrix4a bind_shape; + bind_shape.loadu(skin->mBindShapeMatrix); + LLMatrix4a inv_bind; + inv_bind.loadu(skin->mInvBindMatrix[joint_indices[k]]); + LLMatrix4a mat; + matMul(bind_shape, inv_bind, mat); + LLVector4a pos_joint_space; + mat.affineTransform(pos, pos_joint_space); + pos_joint_space.mul(wght[k]); + LLVector4a *extents = rig_info_tab[joint_num].getRiggedExtents(); + update_min_max(extents[0], extents[1], pos_joint_space); + } + } + } +} + // This is used for extracting rotation from a bind shape matrix that // already has scales baked in LLQuaternion LLSkinningUtil::getUnscaledQuaternion(const LLMatrix4& mat4) diff --git a/indra/newview/llskinningutil.h b/indra/newview/llskinningutil.h index ccc501adc0..d39356451d 100644 --- a/indra/newview/llskinningutil.h +++ b/indra/newview/llskinningutil.h @@ -27,23 +27,48 @@ #ifndef LLSKINNINGUTIL_H #define LLSKINNINGUTIL_H +#include "v2math.h" +#include "v4math.h" +#include "llvector4a.h" +#include "llmatrix4a.h" + class LLVOAvatar; class LLMeshSkinInfo; -class LLMatrix4a; class LLVolumeFace; +class LLJointRiggingInfoTab; namespace LLSkinningUtil { void initClass(); - U32 getMaxJointCount(); + S32 getMaxJointCount(); U32 getMeshJointCount(const LLMeshSkinInfo *skin); void scrubInvalidJoints(LLVOAvatar *avatar, LLMeshSkinInfo* skin); void initSkinningMatrixPalette(LLMatrix4* mat, S32 count, const LLMeshSkinInfo* skin, LLVOAvatar *avatar); void checkSkinWeights(LLVector4a* weights, U32 num_vertices, const LLMeshSkinInfo* skin); void scrubSkinWeights(LLVector4a* weights, U32 num_vertices, const LLMeshSkinInfo* skin); void getPerVertexSkinMatrix(F32* weights, LLMatrix4a* mat, bool handle_bad_scale, LLMatrix4a& final_mat, U32 max_joints); + + LL_FORCE_INLINE void getPerVertexSkinMatrixWithIndices( + F32* weights, + U8* idx, + LLMatrix4a* mat, + LLMatrix4a& final_mat, + LLMatrix4a* src) + { + final_mat.clear(); + src[0].setMul(mat[idx[0]], weights[0]); + src[1].setMul(mat[idx[1]], weights[1]); + final_mat.add(src[0]); + final_mat.add(src[1]); + src[2].setMul(mat[idx[2]], weights[2]); + src[3].setMul(mat[idx[3]], weights[3]); + final_mat.add(src[2]); + final_mat.add(src[3]); + } + void initJointNums(LLMeshSkinInfo* skin, LLVOAvatar *avatar); void updateRiggingInfo(const LLMeshSkinInfo* skin, LLVOAvatar *avatar, LLVolumeFace& vol_face); + void updateRiggingInfo_(LLMeshSkinInfo* skin, LLVOAvatar *avatar, S32 num_verts, LLVector4a* weights, LLVector4a* positions, U8* joint_indices, LLJointRiggingInfoTab &rig_info_tab); LLQuaternion getUnscaledQuaternion(const LLMatrix4& mat4); }; diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index b78937e3b0..ddce419f19 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -196,9 +196,6 @@ void display_update_camera() LLViewerCamera::getInstance()->setFar(final_far); gViewerWindow->setup3DRender(); - // update all the sky/atmospheric/water settings - LLEnvironment::instance().update(LLViewerCamera::getInstance()); - // Update land visibility too LLWorld::getInstance()->setLandFarClip(final_far); } @@ -245,6 +242,7 @@ static LLTrace::BlockTimerStatHandle FTM_HUD_UPDATE("HUD Update"); static LLTrace::BlockTimerStatHandle FTM_DISPLAY_UPDATE_GEOM("Update Geom"); static LLTrace::BlockTimerStatHandle FTM_TEXTURE_UNBIND("Texture Unbind"); static LLTrace::BlockTimerStatHandle FTM_TELEPORT_DISPLAY("Teleport Display"); +static LLTrace::BlockTimerStatHandle FTM_EEP_UPDATE("Env Update"); // Paint the display! void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) @@ -627,7 +625,13 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) stop_glerror(); display_update_camera(); stop_glerror(); - + + { + LL_RECORD_BLOCK_TIME(FTM_EEP_UPDATE); + // update all the sky/atmospheric/water settings + LLEnvironment::instance().update(LLViewerCamera::getInstance()); + } + // *TODO: merge these two methods { LL_RECORD_BLOCK_TIME(FTM_HUD_UPDATE); diff --git a/indra/newview/llviewerjoint.cpp b/indra/newview/llviewerjoint.cpp index b7bd131246..a448a95904 100644 --- a/indra/newview/llviewerjoint.cpp +++ b/indra/newview/llviewerjoint.cpp @@ -141,11 +141,10 @@ U32 LLViewerJoint::render( F32 pixelArea, BOOL first_pass, BOOL is_dummy ) //---------------------------------------------------------------- // render children //---------------------------------------------------------------- - for (child_list_t::iterator iter = mChildren.begin(); - iter != mChildren.end(); ++iter) + for (LLJoint* j : mChildren) { - LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter); - F32 jointLOD = joint->getLOD(); + LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(j); + F32 jointLOD = joint ? joint->getLOD() : 0; if (pixelArea >= jointLOD || sDisableLOD) { triangle_count += joint->render( pixelArea, TRUE, is_dummy ); diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index ad452659c6..78c782eb5f 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -90,7 +90,6 @@ namespace S32 LLSkyTex::sComponents = 4; S32 LLSkyTex::sResolution = 64; -F32 LLSkyTex::sInterpVal = 0.f; S32 LLSkyTex::sCurrent = 0; @@ -479,8 +478,8 @@ void LLVOSky::init() m_atmosphericsVars.haze_horizon = psky->getHazeHorizon(); m_atmosphericsVars.density_multiplier = psky->getDensityMultiplier(); m_atmosphericsVars.max_y = psky->getMaxY(); - m_atmosphericsVars.sun_norm = LLEnvironment::instance().getClampedLightNorm(); - m_atmosphericsVars.sunlight = psky->getSunlightColor(); + m_atmosphericsVars.sun_norm = LLEnvironment::instance().getClampedSunNorm(); + m_atmosphericsVars.sunlight = psky->getIsSunUp() ? psky->getSunlightColor() : psky->getMoonlightColor(); m_atmosphericsVars.ambient = psky->getAmbientColor(); m_atmosphericsVars.glow = psky->getGlow(); m_atmosphericsVars.cloud_shadow = psky->getCloudShadow(); @@ -531,8 +530,8 @@ void LLVOSky::calc() m_atmosphericsVars.density_multiplier = psky->getDensityMultiplier(); m_atmosphericsVars.distance_multiplier = psky->getDistanceMultiplier(); m_atmosphericsVars.max_y = psky->getMaxY(); - m_atmosphericsVars.sun_norm = LLEnvironment::instance().getClampedLightNorm(); - m_atmosphericsVars.sunlight = psky->getSunlightColor(); + m_atmosphericsVars.sun_norm = LLEnvironment::instance().getClampedSunNorm(); + m_atmosphericsVars.sunlight = psky->getIsSunUp() ? psky->getSunlightColor() : psky->getMoonlightColor(); m_atmosphericsVars.ambient = psky->getAmbientColor(); m_atmosphericsVars.glow = psky->getGlow(); m_atmosphericsVars.cloud_shadow = psky->getCloudShadow(); @@ -725,8 +724,6 @@ bool LLVOSky::updateSky() next_frame = next_frame % cycle_frame_no; mInterpVal = (!mInitialized) ? 1 : (F32)next_frame / cycle_frame_no; - // sInterpVal = (F32)next_frame / cycle_frame_no; - LLSkyTex::setInterpVal( mInterpVal ); LLHeavenBody::setInterpVal( mInterpVal ); updateDirections(); @@ -753,7 +750,9 @@ bool LLVOSky::updateSky() calc(); - if (mForceUpdate && mForceUpdateThrottle.hasExpired()) + bool same_atmospherics = m_lastAtmosphericsVars == m_atmosphericsVars; + + if (mForceUpdate && mForceUpdateThrottle.hasExpired() && !same_atmospherics) { LL_RECORD_BLOCK_TIME(FTM_VOSKY_UPDATEFORCED); @@ -761,6 +760,8 @@ bool LLVOSky::updateSky() LLSkyTex::stepCurrent(); + m_lastAtmosphericsVars = m_atmosphericsVars; + if (!direction.isExactlyZero()) { mLastTotalAmbient = total_ambient; @@ -912,6 +913,8 @@ void LLVOSky::setSunTextures(const LLUUID& sun_texture, const LLUUID& sun_textur mSunTexturep[0] = sun_texture.isNull() ? nullptr : LLViewerTextureManager::getFetchedTexture(sun_texture, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); mSunTexturep[1] = sun_texture_next.isNull() ? nullptr : LLViewerTextureManager::getFetchedTexture(sun_texture_next, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); + bool can_use_wl = gPipeline.canUseWindLightShaders(); + if (mFace[FACE_SUN]) { if (mSunTexturep[0]) @@ -934,11 +937,14 @@ void LLVOSky::setSunTextures(const LLUUID& sun_texture, const LLUUID& sun_textur mFace[FACE_SUN]->setTexture(LLRender::DIFFUSE_MAP, mSunTexturep[0]); - if (mSunTexturep[1]) + if (can_use_wl) { - mSunTexturep[1]->setAddressMode(LLTexUnit::TAM_CLAMP); + if (mSunTexturep[1]) + { + mSunTexturep[1]->setAddressMode(LLTexUnit::TAM_CLAMP); + } + mFace[FACE_SUN]->setTexture(LLRender::ALTERNATE_DIFFUSE_MAP, mSunTexturep[1]); } - mFace[FACE_SUN]->setTexture(LLRender::ALTERNATE_DIFFUSE_MAP, mSunTexturep[1]); } } @@ -946,6 +952,8 @@ void LLVOSky::setMoonTextures(const LLUUID& moon_texture, const LLUUID& moon_tex { LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + bool can_use_wl = gPipeline.canUseWindLightShaders(); + mMoonTexturep[0] = moon_texture.isNull() ? nullptr : LLViewerTextureManager::getFetchedTexture(moon_texture, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); mMoonTexturep[1] = moon_texture_next.isNull() ? nullptr : LLViewerTextureManager::getFetchedTexture(moon_texture_next, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); @@ -957,7 +965,7 @@ void LLVOSky::setMoonTextures(const LLUUID& moon_texture, const LLUUID& moon_tex } mFace[FACE_MOON]->setTexture(LLRender::DIFFUSE_MAP, mMoonTexturep[0]); - if (mMoonTexturep[1]) + if (mMoonTexturep[1] && can_use_wl) { mMoonTexturep[1]->setAddressMode(LLTexUnit::TAM_CLAMP); mFace[FACE_MOON]->setTexture(LLRender::ALTERNATE_DIFFUSE_MAP, mMoonTexturep[1]); diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h index 8c2817e1ed..5f27085599 100644 --- a/indra/newview/llvosky.h +++ b/indra/newview/llvosky.h @@ -57,13 +57,8 @@ private: LLColor4 *mSkyData; LLVector3 *mSkyDirs; // Cache of sky direction vectors static S32 sCurrent; - static F32 sInterpVal; public: - static F32 getInterpVal() { return sInterpVal; } - static void setInterpVal(const F32 v) { sInterpVal = v; } - static BOOL doInterpolate() { return sInterpVal > 0.001f; } - void bindTexture(BOOL curr = TRUE); protected: @@ -299,6 +294,8 @@ public: LLFace *mFace[FACE_COUNT]; LLVector3 mBumpSunDir; + F32 getInterpVal() const { return mInterpVal; } + protected: ~LLVOSky(); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 9fa29abc4d..706e2c6895 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4787,18 +4787,44 @@ void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, cons U32 max_joints = LLSkinningUtil::getMaxJointCount(); rigged_vert_count += dst_face.mNumVertices; rigged_face_count++; - for (U32 j = 0; j < dst_face.mNumVertices; ++j) - { - LLMatrix4a final_mat; - LLSkinningUtil::getPerVertexSkinMatrix(weight[j].getF32ptr(), mat, false, final_mat, max_joints); + + #if USE_SEPARATE_JOINT_INDICES_AND_WEIGHTS + if (vol_face.mJointIndices) // fast path with preconditioned joint indices + { + LLMatrix4a src[4]; + U8* joint_indices_cursor = vol_face.mJointIndices; + LLVector4a* just_weights = vol_face.mJustWeights; + for (U32 j = 0; j < dst_face.mNumVertices; ++j) + { + LLMatrix4a final_mat; + F32* w = just_weights[j].getF32ptr(); + LLSkinningUtil::getPerVertexSkinMatrixWithIndices(w, joint_indices_cursor, mat, final_mat, src); + joint_indices_cursor += 4; + + LLVector4a& v = vol_face.mPositions[j]; + LLVector4a t; + LLVector4a dst; + bind_shape_matrix.affineTransform(v, t); + final_mat.affineTransform(t, dst); + pos[j] = dst; + } + } + else + #endif + { + for (U32 j = 0; j < dst_face.mNumVertices; ++j) + { + LLMatrix4a final_mat; + LLSkinningUtil::getPerVertexSkinMatrix(weight[j].getF32ptr(), mat, false, final_mat, max_joints); - LLVector4a& v = vol_face.mPositions[j]; - LLVector4a t; - LLVector4a dst; - bind_shape_matrix.affineTransform(v, t); - final_mat.affineTransform(t, dst); - pos[j] = dst; - } + LLVector4a& v = vol_face.mPositions[j]; + LLVector4a t; + LLVector4a dst; + bind_shape_matrix.affineTransform(v, t); + final_mat.affineTransform(t, dst); + pos[j] = dst; + } + } //update bounding box // VFExtents change @@ -5546,11 +5572,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) U32 mask = mat->getShaderMask(alpha_mode); pool->addRiggedFace(facep, mask); } - - if(vobj->isAnimatedObject() && vobj->isRiggedMesh()) - { - pool->updateRiggedVertexBuffers(vobj->getAvatar()); - } } else if (mat) { |