diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 5cd34bed11fa7914904f8e32536d1edadf2c816f..eb9205ff04d14e9fc388c22b2c0214c8b8aa77fc 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -77,6 +77,9 @@ #include "llwlparammanager.h" #include "llwaterparammanager.h" #include "llpostprocess.h" +// [RLVa:KB] - Checked: 2010-08-22 (RLVa-1.2.1a) +#include "rlvhandler.h" +// [/RLVa:KB] extern LLPointer<LLViewerTexture> gStartTexture; @@ -914,14 +917,10 @@ void render_hud_attachments() // clamp target zoom level to reasonable values // gAgentCamera.mHUDTargetZoom = llclamp(gAgentCamera.mHUDTargetZoom, 0.1f, 1.f); -// [RLVa:KB] - Checked: 2009-07-06 (RLVa-1.0.0c) - gAgentCamera.mHUDTargetZoom = llclamp(gAgentCamera.mHUDTargetZoom, 0.1f, 1.f); -/* - // TODO-RLVa: while hasLockedHUD() isn't slow this is called per frame so find a better way - gAgent.mHUDTargetZoom = llclamp(gAgent.mHUDTargetZoom, - ( (!rlv_handler_t::isEnabled()) || (!gRlvHandler.hasLockedHUD()) ) ? 0.1f : 0.85f, 1.f); -*/ +// [RLVa:KB] - Checked: 2010-08-22 (RLVa-1.2.1a) | Modified: RLVa-1.0.0c + gAgentCamera.mHUDTargetZoom = llclamp(gAgentCamera.mHUDTargetZoom, (!gRlvAttachmentLocks.hasLockedHUD()) ? 0.1f : 0.85f, 1.f); // [/RLVa:KB] + // smoothly interpolate current zoom level gAgentCamera.mHUDCurZoom = lerp(gAgentCamera.mHUDCurZoom, gAgentCamera.mHUDTargetZoom, LLCriticalDamp::getInterpolant(0.03f)); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 74dc3d4ac3545caf4fbe9aaf2e2f6c0defc84c89..c78e879dd34990ce5177766f7e9c12c5094ddecb 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -1080,7 +1080,10 @@ class LLAdvancedToggleWireframe : public view_listener_t { bool handleEvent(const LLSD& userdata) { - gUseWireframe = !(gUseWireframe); +// gUseWireframe = !(gUseWireframe); +// [RLVa:KB] - Checked: 2010-08-22 (RLVa-1.2.1a) | Added: RLVa-1.2.1a + gUseWireframe = (!gUseWireframe) && (!gRlvAttachmentLocks.hasLockedHUD()); +// [/RLVa:KB] return true; } }; @@ -7777,7 +7780,7 @@ class LLViewShowHUDAttachments : public view_listener_t { bool handleEvent(const LLSD& userdata) { -// [RLVa:KB] - Checked: 2010-04-19 (RLVa-1.2.0f) | Modified: RLVa-1.0.0c +// [RLVa:KB] - Checked: 2010-04-19 (RLVa-1.2.1a) | Modified: RLVa-1.0.0c if ( (rlv_handler_t::isEnabled()) && (gRlvAttachmentLocks.hasLockedHUD()) && (LLPipeline::sShowHUDAttachments) ) return true; // [/RLVa:KB] diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index cdf01ca2d5d9ed6fe10f1a36baa879149b2ac803..43576c0a81392344f2034d421df565cc09cb8160 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -1085,12 +1085,15 @@ const LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *view const LLUUID& attachment_id = viewer_object->getItemID(); LLAppearanceMgr::instance().registerAttachment(attachment_id); -// [RLVa:KB] - Checked: 2010-03-05 (RLVa-1.2.0a) | Added: RLVa-1.2.0a +// [RLVa:KB] - Checked: 2010-08-22 (RLVa-1.2.1a) | Modified: RLVa-1.2.1a // NOTE: RLVa event handlers should be invoked *after* LLVOAvatar::attachObject() calls LLViewerJointAttachment::addObject() if (rlv_handler_t::isEnabled()) { RlvAttachmentLockWatchdog::instance().onAttach(viewer_object, attachment); gRlvHandler.onAttach(viewer_object, attachment); + + if ( (attachment->getIsHUDAttachment()) && (!gRlvAttachmentLocks.hasLockedHUD()) ) + gRlvAttachmentLocks.updateLockedHUD(); } // [/RLVa:KB] } @@ -1151,6 +1154,11 @@ BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object) LLAppearanceMgr::instance().unregisterAttachment(attachment_id); } +// [RLVa:KB] - Checked: 2010-08-22 (RLVa-1.2.1a) | Added: RLVa-1.2.1a + if ( (rlv_handler_t::isEnabled()) && (viewer_object->isHUDAttachment()) && (gRlvAttachmentLocks.hasLockedHUD()) ) + gRlvAttachmentLocks.updateLockedHUD(); +// [/RLVa:KB] + return TRUE; } return FALSE; diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp index e356f78af695cb5faf912f7491763a0a0fe805c8..40fa187c61e5389c35d474163a575e04ba1d3c09 100644 --- a/indra/newview/rlvhandler.cpp +++ b/indra/newview/rlvhandler.cpp @@ -16,13 +16,13 @@ #include "llviewerprecompiledheaders.h" #include "llagentwearables.h" +#include "llappviewer.h" #include "llcallbacklist.h" #include "llviewermessage.h" #include "llviewerobjectlist.h" #include "llviewerparcelmgr.h" #include "llviewerregion.h" #include "llworld.h" -#include "pipeline.h" #include "rlvhandler.h" #include "rlvinventory.h" @@ -412,12 +412,7 @@ void RlvHandler::onAttach(const LLViewerObject* pAttachObj, const LLViewerJointA // We need to check this object for an active "@detach=n" and actually lock it down now that it's been attached somewhere if (itObj->second.hasBehaviour(RLV_BHVR_DETACH, false)) - { - // (Copy/paste from processAddCommand) gRlvAttachmentLocks.addAttachmentLock(pAttachObj->getID(), itObj->second.m_UUID); - if (pAttachObj->isHUDAttachment()) - LLPipeline::sShowHUDAttachments = TRUE; // Prevents hiding of locked HUD attachments - } } } } @@ -525,11 +520,7 @@ bool RlvHandler::onGC() // -> if it does run it likely means that there's a @detach=n in a *child* prim that we couldn't look up in onAttach() // -> since RLV doesn't currently support @detach=n from child prims it's actually not such a big deal right now but still if ( (pObj->isAttachment()) && (itCurObj->second.hasBehaviour(RLV_BHVR_DETACH, false)) ) - { gRlvAttachmentLocks.addAttachmentLock(pObj->getID(), itCurObj->second.m_UUID); - if (pObj->isHUDAttachment()) - LLPipeline::sShowHUDAttachments = TRUE; - } } } } @@ -1290,10 +1281,6 @@ ERlvCmdRet RlvHandler::onAddRemAttach(const LLUUID& idObj, const RlvCommand& rlv } } - // Refresh HUD visibility if needed - if ( (RLV_BHVR_REMATTACH == rlvCmd.getBehaviourType()) && (gRlvAttachmentLocks.hasLockedHUD()) ) - LLPipeline::sShowHUDAttachments = TRUE; - fRefCount = rlvCmd.getOption().empty(); // Only reference count global locks return RLV_RET_SUCCESS; } @@ -1333,10 +1320,6 @@ ERlvCmdRet RlvHandler::onAddRemDetach(const LLUUID& idObj, const RlvCommand& rlv gRlvAttachmentLocks.removeAttachmentPointLock(idxAttachPt, idObj, (ERlvLockMask)(RLV_LOCK_ADD | RLV_LOCK_REMOVE)); } - // Refresh HUD visibility if needed - if ( (RLV_TYPE_ADD == rlvCmd.getParamType()) && (gRlvAttachmentLocks.hasLockedHUD()) ) - LLPipeline::sShowHUDAttachments = TRUE; - fRefCount = false; // Don't reference count @detach[:<option>]=n return RLV_RET_SUCCESS; } diff --git a/indra/newview/rlvlocks.cpp b/indra/newview/rlvlocks.cpp index f8b9a4483f071fede86643e5eb9ebb1ecb0c8be5..61d6e283414de8849e03f8d23f0c1e4666b7658b 100644 --- a/indra/newview/rlvlocks.cpp +++ b/indra/newview/rlvlocks.cpp @@ -17,6 +17,7 @@ #include "llviewerprecompiledheaders.h" #include "llnotifications.h" #include "llviewerobjectlist.h" +#include "pipeline.h" #include "rlvhelper.h" #include "rlvlocks.h" @@ -177,6 +178,7 @@ void RlvAttachmentLocks::addAttachmentLock(const LLUUID& idAttachObj, const LLUU #endif // RLV_RELEASE m_AttachObjRem.insert(std::pair<LLUUID, LLUUID>(idAttachObj, idRlvObj)); + updateLockedHUD(); } // Checked: 2010-02-28 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a @@ -190,7 +192,10 @@ void RlvAttachmentLocks::addAttachmentPointLock(S32 idxAttachPt, const LLUUID& i // NOTE: m_AttachPtXXX can contain duplicate <idxAttachPt, idRlvObj> pairs (ie @detach:spine=n,detach=n from an attachment on spine) if (eLock & RLV_LOCK_REMOVE) + { m_AttachPtRem.insert(std::pair<S32, LLUUID>(idxAttachPt, idRlvObj)); + updateLockedHUD(); + } if (eLock & RLV_LOCK_ADD) m_AttachPtAdd.insert(std::pair<S32, LLUUID>(idxAttachPt, idRlvObj)); } @@ -235,21 +240,6 @@ bool RlvAttachmentLocks::hasLockedAttachment(const LLViewerJointAttachment* pAtt return false; } -bool RlvAttachmentLocks::hasLockedHUD() const -{ - if (!isAgentAvatarValid()) - return false; - - for (LLVOAvatar::attachment_map_t::const_iterator itAttachPt = gAgentAvatarp->mAttachmentPoints.begin(); - itAttachPt != gAgentAvatarp->mAttachmentPoints.end(); ++itAttachPt) - { - const LLViewerJointAttachment* pAttachPt = itAttachPt->second; - if ( (pAttachPt) && (pAttachPt->getIsHUDAttachment()) && (hasLockedAttachment(pAttachPt)) ) - return true; // At least one of our locked attachments is a HUD - } - return false; // None of our locked attachments is a HUD -} - // Checked: 2010-03-19 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a bool RlvAttachmentLocks::isLockedAttachmentExcept(const LLViewerObject* pObj, const LLUUID& idRlvObj) const { @@ -321,6 +311,7 @@ void RlvAttachmentLocks::removeAttachmentLock(const LLUUID& idAttachObj, const L if (idRlvObj == itAttachObj->second) { m_AttachObjRem.erase(itAttachObj); + updateLockedHUD(); break; } } @@ -344,6 +335,7 @@ void RlvAttachmentLocks::removeAttachmentPointLock(S32 idxAttachPt, const LLUUID if (idRlvObj == itAttachPt->second) { m_AttachPtRem.erase(itAttachPt); + updateLockedHUD(); break; } } @@ -363,6 +355,32 @@ void RlvAttachmentLocks::removeAttachmentPointLock(S32 idxAttachPt, const LLUUID } } +// Checked: 2010-08-22 (RLVa-1.2.1a) | Modified: RLVa-1.2.1a +void RlvAttachmentLocks::updateLockedHUD() +{ + if (!isAgentAvatarValid()) + return; + + m_fHasLockedHUD = false; + for (LLVOAvatar::attachment_map_t::const_iterator itAttachPt = gAgentAvatarp->mAttachmentPoints.begin(); + itAttachPt != gAgentAvatarp->mAttachmentPoints.end(); ++itAttachPt) + { + const LLViewerJointAttachment* pAttachPt = itAttachPt->second; + if ( (pAttachPt) && (pAttachPt->getIsHUDAttachment()) && (hasLockedAttachment(pAttachPt)) ) + { + m_fHasLockedHUD = true; + break; + } + } + + // Reset HUD visibility and wireframe options if at least one HUD attachment is locked + if (m_fHasLockedHUD) + { + LLPipeline::sShowHUDAttachments = TRUE; + gUseWireframe = FALSE; + } +} + // Checked: 2010-03-11 (RLVa-1.2.0a) | Added: RLVa-1.2.0a bool RlvAttachmentLocks::verifyAttachmentLocks() { diff --git a/indra/newview/rlvlocks.h b/indra/newview/rlvlocks.h index 365c21d87db649aa7dd38a0107ab4952eab1ec48..22fcee6b454255464f0e123e6e6dbef23b7e6a50 100644 --- a/indra/newview/rlvlocks.h +++ b/indra/newview/rlvlocks.h @@ -63,6 +63,9 @@ class RlvAttachPtLookup // TODO-RLVa: [RLVa-1.2.1] Once everything is working for SL-2.0 thin out the member functions since a few of them are duplicates/unneeded class RlvAttachmentLocks { +public: + RlvAttachmentLocks() : m_fHasLockedHUD(false) {} + public: // Adds an RLV_LOCK_REMOVE lock (held by idRlvObj) for the attachment void addAttachmentLock(const LLUUID& idAttachObj, const LLUUID& idRlvObj); @@ -75,7 +78,7 @@ class RlvAttachmentLocks // - RLV_LOCK_REMOVE: specific attachment locked *or* any attachment point locked (regardless of whether it currently has attachments) bool hasLockedAttachmentPoint(ERlvLockMask eLock) const; // Returns TRUE if there is at least 1 non-detachable HUD attachment - bool hasLockedHUD() const; + bool hasLockedHUD() const { return m_fHasLockedHUD; } // Returns TRUE if the attachment is RLV_LOCK_REMOVE locked bool isLockedAttachment(const LLViewerObject* pObj) const; @@ -91,6 +94,8 @@ class RlvAttachmentLocks // Removes an eLock type lock (held by idRlvObj) for the attachment point void removeAttachmentPointLock(S32 idxAttachPt, const LLUUID& idRlvObj, ERlvLockMask eLock); + // Refreshes locked HUD attachment state + void updateLockedHUD(); // Iterates over all current attachment and attachment point locks and verifies their status (returns TRUE if verification succeeded) bool verifyAttachmentLocks(); @@ -125,6 +130,8 @@ class RlvAttachmentLocks rlv_attachptlock_map_t m_AttachPtAdd; // Map of attachment points that can't be attached to (idxAttachPt -> idObj) rlv_attachptlock_map_t m_AttachPtRem; // Map of attachment points whose attachments can't be detached (idxAttachPt -> idObj) rlv_attachobjlock_map_t m_AttachObjRem; // Map of attachments that can't be detached (idAttachObj -> idObj) + + bool m_fHasLockedHUD; }; extern RlvAttachmentLocks gRlvAttachmentLocks;