From aa90a47a9174d19cbdfe44d86299ff5b3f2f25f3 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 30 Apr 2018 00:08:11 +0200 Subject: [PATCH] Added @setoverlay set of commands for a certain evil kitty --HG-- branch : RLVa --- indra/llrender/llgltexture.cpp | 5 +- indra/llrender/llgltexture.h | 5 +- indra/llrender/llimagegl.cpp | 5 +- indra/llrender/llimagegl.h | 5 +- indra/newview/llviewerdisplay.cpp | 7 ++ indra/newview/llviewerwindow.cpp | 10 +++ indra/newview/rlvcommon.h | 2 +- indra/newview/rlvdefines.h | 9 +++ indra/newview/rlvhandler.cpp | 121 ++++++++++++++++++++++++++++++ indra/newview/rlvhandler.h | 20 ++++- indra/newview/rlvhelper.cpp | 17 +++++ indra/newview/rlvhelper.h | 3 +- 12 files changed, 201 insertions(+), 8 deletions(-) diff --git a/indra/llrender/llgltexture.cpp b/indra/llrender/llgltexture.cpp index 3a6eebebba..7bb67594af 100644 --- a/indra/llrender/llgltexture.cpp +++ b/indra/llrender/llgltexture.cpp @@ -316,7 +316,10 @@ BOOL LLGLTexture::getIsAlphaMask() const return mGLTexturep->getIsAlphaMask() ; } -BOOL LLGLTexture::getMask(const LLVector2 &tc) +//BOOL LLGLTexture::getMask(const LLVector2 &tc) +// [RLVa:KB] - Checked: RLVa-2.3 (@setoverlay) +bool LLGLTexture::getMask(const LLVector2 &tc) const +// [/RLVa:KB] { llassert(mGLTexturep.notNull()) ; diff --git a/indra/llrender/llgltexture.h b/indra/llrender/llgltexture.h index 45592ee077..5b8ad47765 100644 --- a/indra/llrender/llgltexture.h +++ b/indra/llrender/llgltexture.h @@ -142,7 +142,10 @@ public: LLGLenum getPrimaryFormat() const; BOOL getIsAlphaMask() const ; LLTexUnit::eTextureType getTarget(void) const ; - BOOL getMask(const LLVector2 &tc); +// [RLVa:KB] - Checked: RLVa-2.3 (@setoverlay) + bool getMask(const LLVector2 &tc) const; +// [/RLVa:KB] +// BOOL getMask(const LLVector2 &tc); F32 getTimePassedSinceLastBound(); BOOL getMissed() const ; BOOL isJustBound()const ; diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 89500dcc04..cd2b7f952f 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1993,7 +1993,10 @@ void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in) } } -BOOL LLImageGL::getMask(const LLVector2 &tc) +//BOOL LLImageGL::getMask(const LLVector2 &tc) +// [RLVa:KB] - Checked: RLVa-2.3 (@setoverlay) +BOOL LLImageGL::getMask(const LLVector2 &tc) const +// [/RLVa:KB] { BOOL res = TRUE; diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index 2be54be062..fc86a68132 100644 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -150,7 +150,10 @@ public: void setUseMipMaps(BOOL usemips) { mUseMipMaps = usemips; } void updatePickMask(S32 width, S32 height, const U8* data_in); - BOOL getMask(const LLVector2 &tc); +// [RLVa:KB] - Checked: RLVa-2.3 (@setoverlay) + BOOL getMask(const LLVector2 &tc) const; +// [/RLVa:KB] +// BOOL getMask(const LLVector2 &tc); void checkTexSize(bool forced = false) const ; diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 7f0b8726c4..da5f89743d 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -79,6 +79,7 @@ #include "llpostprocess.h" #include "llscenemonitor.h" // [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) +#include "rlvhandler.h" #include "rlvlocks.h" // [/RLVa:KB] @@ -1305,6 +1306,12 @@ void render_ui(F32 zoom_factor, int subfield) } render_hud_elements(); +// [RLVa:KB] - Checked: RLVa-2.3 (@setoverlay) + if (gRlvHandler.isEnabled()) + { + gRlvHandler.renderOverlay(); + } +// [/RLVa:KB] render_hud_attachments(); } diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index d56692a227..5919322918 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -5543,6 +5543,16 @@ void LLPickInfo::fetchResults() mPickPt = mMousePt; +// [RLVa:KB] - Checked: RLVa-2.3 (@setoverlay) + if ( (gRlvHandler.isEnabled()) && (hit_object) && (!hit_object->isHUDAttachment()) ) + { + if (gRlvHandler.hitTestOverlay(mMousePt)) + { + hit_object = nullptr; + } + } +// [/RLVa:KB] + U32 te_offset = face_hit > -1 ? face_hit : 0; if (mPickParticle) diff --git a/indra/newview/rlvcommon.h b/indra/newview/rlvcommon.h index eb7c5e6e47..68fc57d2a4 100644 --- a/indra/newview/rlvcommon.h +++ b/indra/newview/rlvcommon.h @@ -56,7 +56,7 @@ class RlvObject; struct RlvException; typedef boost::variant RlvExceptionOption; -typedef boost::variant RlvBehaviourModifierValue; +typedef boost::variant RlvBehaviourModifierValue; class RlvGCTimer; diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h index d999249f8f..bce3ce0cc9 100644 --- a/indra/newview/rlvdefines.h +++ b/indra/newview/rlvdefines.h @@ -231,6 +231,12 @@ enum ERlvBehaviour { // Camera (force) RLV_BHVR_SETCAM_MODE, // Switch the user's camera into the specified mode (e.g. mouselook or thirdview) + // Overlay + RLV_BHVR_SETOVERLAY, // Gives an object exclusive control of the overlay + RLV_BHVR_SETOVERLAY_ALPHA, // Changes the overlay texture's transparency level + RLV_BHVR_SETOVERLAY_TEXTURE, // Changes the overlay texture + RLV_BHVR_SETOVERLAY_TOUCH, // Block world interaction (=touching) based on the alpha channel of the overlay texture + RLV_BHVR_COUNT, RLV_BHVR_UNKNOWN }; @@ -238,6 +244,9 @@ enum ERlvBehaviour { enum ERlvBehaviourModifier { RLV_MODIFIER_FARTOUCHDIST, // Radius of a sphere around the user in which they can interact with the world + RLV_MODIFIER_OVERLAY_ALPHA, // Transparency level of the overlay texture (in addition to the texture's own alpha channel) + RLV_MODIFIER_OVERLAY_TEXTURE, // Specifies the UUID of the overlay texture + RLV_MODIFIER_OVERLAY_TOUCH, // Determines whether the overlay texture's alpha channel will be used to allow/block world interaction RLV_MODIFIER_RECVIMDISTMIN, // Minimum distance to receive an IM from an otherwise restricted sender (squared value) RLV_MODIFIER_RECVIMDISTMAX, // Maximum distance to receive an IM from an otherwise restricted sender (squared value) RLV_MODIFIER_SENDIMDISTMIN, // Minimum distance to send an IM to an otherwise restricted recipient (squared value) diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp index a2a9c4d642..216e444ca4 100644 --- a/indra/newview/rlvhandler.cpp +++ b/indra/newview/rlvhandler.cpp @@ -49,6 +49,7 @@ #include "llviewercamera.h" // @setcam and related #include "llworldmapmessage.h" // @tpto #include "llviewertexturelist.h" // @setcam_texture +#include "llviewerwindow.h" // @setoverlay // RLVa includes #include "rlvactions.h" @@ -1625,6 +1626,40 @@ void RlvBehaviourToggleHandler::onCommandToggle(ERlvBehaviour eBh RlvUIEnabler::instance().removeGenericFloaterFilter("beacons"); } +// Handles: @setoverlay=n|y toggles +template<> template<> +void RlvBehaviourToggleHandler::onCommandToggle(ERlvBehaviour eBhvr, bool fHasBhvr) +{ + // Once an object has exclusive control over the overlay only its behaviours should be active. This affects: + // - behaviour modifiers => handled for us once we set the primary object + + LLUUID idRlvObject; + if (fHasBhvr) + { + // Get the UUID of the primary object (there should only be one) + std::list lObjects; + gRlvHandler.findBehaviour(RLV_BHVR_SETOVERLAY, lObjects); + RLV_ASSERT(lObjects.size() == 1); + idRlvObject = lObjects.front()->getObjectID(); + } + + RlvBehaviourDictionary::instance().getModifier(RLV_MODIFIER_OVERLAY_ALPHA)->setPrimaryObject(idRlvObject); + RlvBehaviourDictionary::instance().getModifier(RLV_MODIFIER_OVERLAY_TEXTURE)->setPrimaryObject(idRlvObject); +} + +// Handles: @setoverlay_texture:=n|y changes +template<> +void RlvBehaviourModifierHandler::onValueChange() const +{ + if (RlvBehaviourModifier* pBhvrModifier = RlvBehaviourDictionary::instance().getModifier(RLV_MODIFIER_OVERLAY_TEXTURE)) + { + if (pBhvrModifier->hasValue()) + gRlvHandler.setOverlayImage(pBhvrModifier->getValue()); + else + gRlvHandler.clearOverlayImage(); + } +} + // Handles: @sendchannel[:]=n|y and @sendchannel_except[:]=n|y template<> template<> ERlvCmdRet RlvBehaviourSendChannelHandler::onCommand(const RlvCommand& rlvCmd, bool& fRefCount) @@ -3178,3 +3213,89 @@ ERlvCmdRet RlvHandler::onGetPath(const RlvCommand& rlvCmd, std::string& strReply } // ============================================================================ +// Command specific helper functions - @setoverlay +// + +void RlvHandler::clearOverlayImage() +{ + if (m_pOverlayImage) + { + m_pOverlayImage->setBoostLevel(m_nOverlayOrigBoost); + m_pOverlayImage = nullptr; + } +} + +bool RlvHandler::hitTestOverlay(const LLCoordGL& ptMouse) const +{ + if (!m_pOverlayImage) + return false; + + RlvBehaviourModifier* pTouchModifier = RlvBehaviourDictionary::instance().getModifier(RLV_MODIFIER_OVERLAY_TOUCH); + return (pTouchModifier) && (pTouchModifier->hasValue()) && (pTouchModifier->getValue()) && + (m_pOverlayImage->getMask(LLVector2((float)ptMouse.mX / gViewerWindow->getWorldViewWidthScaled(), (float)ptMouse.mY / gViewerWindow->getWorldViewHeightScaled()))); +} + +void RlvHandler::renderOverlay() +{ + if (m_pOverlayImage) + { + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.bind(); + } + + int nWidth = gViewerWindow->getWorldViewWidthScaled(); + int nHeight = gViewerWindow->getWorldViewHeightScaled(); + + m_pOverlayImage->addTextureStats(nWidth * nHeight); + m_pOverlayImage->setKnownDrawSize(nWidth, nHeight); + + LLGLSUIDefault glsUI; + gViewerWindow->setup2DRender(); + gGL.pushMatrix(); + + const LLVector2& displayScale = gViewerWindow->getDisplayScale(); + gGL.scalef(displayScale.mV[VX], displayScale.mV[VY], 1.f); + + gGL.getTexUnit(0)->bind(m_pOverlayImage); + gGL.color4f(1.f, 1.f, 1.f, llclamp(RlvBehaviourDictionary::instance().getModifier(RLV_MODIFIER_OVERLAY_ALPHA)->getValue(), 0.0f, 1.0f)); + + gGL.begin(LLRender::QUADS); + gGL.texCoord2f(1.f, 1.f); + gGL.vertex2i(nWidth, nHeight); + + gGL.texCoord2f(0.f, 1.f); + gGL.vertex2i(0, nHeight); + + gGL.texCoord2f(0.f, 0.f); + gGL.vertex2i(0, 0); + + gGL.texCoord2f(1.f, 0.f); + gGL.vertex2i(nWidth, 0); + gGL.end(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + gGL.popMatrix(); + gGL.flush(); + + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.unbind(); + } + } +} + +void RlvHandler::setOverlayImage(const LLUUID& idTexture) +{ + if ( (m_pOverlayImage) && (m_pOverlayImage->getID() == idTexture) ) + return; + + clearOverlayImage(); + m_pOverlayImage = LLViewerTextureManager::getFetchedTexture(idTexture, FTT_DEFAULT, MIPMAP_YES, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + m_nOverlayOrigBoost = m_pOverlayImage->getBoostLevel(); + m_pOverlayImage->setBoostLevel(LLGLTexture::BOOST_PREVIEW); + m_pOverlayImage->forceToSaveRawImage(0); +} + +// ============================================================================ diff --git a/indra/newview/rlvhandler.h b/indra/newview/rlvhandler.h index ef2ca55786..0ad5a0fc15 100644 --- a/indra/newview/rlvhandler.h +++ b/indra/newview/rlvhandler.h @@ -22,6 +22,12 @@ #include "rlvcommon.h" #include "rlvhelper.h" + // ============================================================================ + // Forward declarations + // + +class LLViewerFetchedTexture; + // ============================================================================ class RlvHandler : public LLOldEvents::LLSimpleListener @@ -93,7 +99,7 @@ public: * Helper functions */ public: - // Accessors + // Accessors/Mutators const LLUUID& getAgentGroup() const { return m_idAgentGroup; } // @setgroup bool getCanCancelTp() const { return m_fCanCancelTp; } // @accepttp and @tpto void setCanCancelTp(bool fAllow) { m_fCanCancelTp = fAllow; } // @accepttp and @tpto @@ -102,7 +108,9 @@ public: // Command specific helper functions bool filterChat(std::string& strUTF8Text, bool fFilterEmote) const; // @sendchat, @recvchat and @redirchat + bool hitTestOverlay(const LLCoordGL& ptMouse) const; // @setoverlay bool redirectChatOrEmote(const std::string& strUTF8Test) const; // @redirchat and @rediremote + void renderOverlay(); // @setoverlay // Command processing helper functions ERlvCmdRet processCommand(const LLUUID& idObj, const std::string& strCommand, bool fFromObj); @@ -119,6 +127,10 @@ public: static bool isEnabled() { return m_fEnabled; } static bool setEnabled(bool fEnable); protected: + // Command specific helper functions + void clearOverlayImage(); // @setoverlay + void setOverlayImage(const LLUUID& idTexture); // @setoverlay + void onIMQueryListResponse(const LLSD& sdNotification, const LLSD sdResponse); // -------------------------------- @@ -209,11 +221,15 @@ protected: mutable LLVector3d m_posSitSource; // @standtp=n (mutable because onForceXXX handles are all declared as const) mutable LLUUID m_idAgentGroup; // @setgroup=n + LLPointer m_pOverlayImage = nullptr; // @setoverlay + int m_nOverlayOrigBoost = 0 /*LLGLTexture::BOOST_NONE*/; // @setoverlay + friend class RlvSharedRootFetcher; // Fetcher needs access to m_fFetchComplete friend class RlvGCTimer; // Timer clear its own point at destruction - template friend struct RlvBehaviourGenericHandler; + template friend struct RlvBehaviourGenericHandler; template friend struct RlvCommandHandlerBaseImpl; template friend struct RlvCommandHandler; + template friend class RlvBehaviourModifierHandler; // -------------------------------- diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp index ba6d297fc2..68cb4238f8 100644 --- a/indra/newview/rlvhelper.cpp +++ b/indra/newview/rlvhelper.cpp @@ -174,6 +174,7 @@ RlvBehaviourDictionary::RlvBehaviourDictionary() addEntry(new RlvBehaviourGenericProcessor("viewnote", RLV_BHVR_VIEWNOTE)); addEntry(new RlvBehaviourGenericProcessor("viewscript", RLV_BHVR_VIEWSCRIPT)); addEntry(new RlvBehaviourGenericProcessor("viewtexture", RLV_BHVR_VIEWTEXTURE)); + // Camera addEntry(new RlvBehaviourGenericToggleProcessor("setcam")); addEntry(new RlvBehaviourGenericProcessor("setcam_avdistmin", RLV_BHVR_SETCAM_AVDISTMIN, RlvBehaviourInfo::BHVR_EXPERIMENTAL)); @@ -204,6 +205,15 @@ RlvBehaviourDictionary::RlvBehaviourDictionary() addEntry(new RlvBehaviourProcessor("camzoommax", RlvBehaviourInfo::BHVR_DEPRECATED)); addEntry(new RlvBehaviourGenericToggleProcessor("camunlock", RlvBehaviourInfo::BHVR_SYNONYM | RlvBehaviourInfo::BHVR_DEPRECATED)); + // Overlay + addEntry(new RlvBehaviourGenericToggleProcessor("setoverlay", RlvBehaviourInfo::BHVR_EXPERIMENTAL)); + addModifier(new RlvBehaviourGenericProcessor("setoverlay_alpha", RLV_BHVR_SETOVERLAY_ALPHA, RlvBehaviourInfo::BHVR_EXPERIMENTAL), + RLV_MODIFIER_OVERLAY_ALPHA, new RlvBehaviourModifier("Overlay - Alpha", 1.0f, false, new RlvBehaviourModifier_Comp())); + addModifier(new RlvBehaviourGenericProcessor("setoverlay_texture", RLV_BHVR_SETOVERLAY_TEXTURE, RlvBehaviourInfo::BHVR_EXPERIMENTAL), + RLV_MODIFIER_OVERLAY_TEXTURE, new RlvBehaviourModifierHandler("Overlay - Texture", LLUUID::null, false, new RlvBehaviourModifier_Comp())); + addModifier(new RlvBehaviourGenericProcessor("setoverlay_touch", RLV_BHVR_SETOVERLAY_TOUCH, RlvBehaviourInfo::BHVR_EXPERIMENTAL), + RLV_MODIFIER_OVERLAY_TOUCH, new RlvBehaviourModifier("Overlay - Touch", true, true, new RlvBehaviourModifier_Comp())); + // // Force-wear // @@ -352,6 +362,13 @@ void RlvBehaviourDictionary::addModifier(ERlvBehaviour eBhvr, ERlvBehaviourModif } } +// Convenience function to add both the behaviour entry as well as the corresponding modifier entry +void RlvBehaviourDictionary::addModifier(const RlvBehaviourInfo* pBhvrEntry, ERlvBehaviourModifier eModifier, RlvBehaviourModifier* pModifierEntry) +{ + addEntry(pBhvrEntry); + addModifier(pBhvrEntry->getBehaviourType(), eModifier, pModifierEntry); +} + const RlvBehaviourInfo* RlvBehaviourDictionary::getBehaviourInfo(const std::string& strBhvr, ERlvParamType eParamType, bool* pfStrict) const { bool fStrict = boost::algorithm::ends_with(strBhvr, "_sec"); diff --git a/indra/newview/rlvhelper.h b/indra/newview/rlvhelper.h index fdb1497336..8dba8e639e 100644 --- a/indra/newview/rlvhelper.h +++ b/indra/newview/rlvhelper.h @@ -95,8 +95,9 @@ class RlvBehaviourDictionary : public LLSingleton protected: ~RlvBehaviourDictionary(); public: - void addEntry(const RlvBehaviourInfo* pEntry); + void addEntry(const RlvBehaviourInfo* pBhvrEntry); void addModifier(ERlvBehaviour eBhvr, ERlvBehaviourModifier eModifier, RlvBehaviourModifier* pModifierEntry); + void addModifier(const RlvBehaviourInfo* pBhvrEntry, ERlvBehaviourModifier eModifier, RlvBehaviourModifier* pModifierEntry); /* * General helper functions