Added @setoverlay set of commands for a certain evil kitty

--HG--
branch : RLVa
master
Kitty Barnett 2018-04-30 00:08:11 +02:00
parent a480152609
commit aa90a47a91
12 changed files with 201 additions and 8 deletions

View File

@ -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()) ;

View File

@ -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 ;

View File

@ -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;

View File

@ -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 ;

View File

@ -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();
}

View File

@ -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)

View File

@ -56,7 +56,7 @@ class RlvObject;
struct RlvException;
typedef boost::variant<std::string, LLUUID, S32, ERlvBehaviour> RlvExceptionOption;
typedef boost::variant<int, float, LLVector3, LLUUID> RlvBehaviourModifierValue;
typedef boost::variant<int, float, bool, LLVector3, LLUUID> RlvBehaviourModifierValue;
class RlvGCTimer;

View File

@ -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)

View File

@ -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<RLV_BHVR_EDIT>::onCommandToggle(ERlvBehaviour eBh
RlvUIEnabler::instance().removeGenericFloaterFilter("beacons");
}
// Handles: @setoverlay=n|y toggles
template<> template<>
void RlvBehaviourToggleHandler<RLV_BHVR_SETOVERLAY>::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<const RlvObject*> 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:<uuid>=n|y changes
template<>
void RlvBehaviourModifierHandler<RLV_MODIFIER_OVERLAY_TEXTURE>::onValueChange() const
{
if (RlvBehaviourModifier* pBhvrModifier = RlvBehaviourDictionary::instance().getModifier(RLV_MODIFIER_OVERLAY_TEXTURE))
{
if (pBhvrModifier->hasValue())
gRlvHandler.setOverlayImage(pBhvrModifier->getValue<LLUUID>());
else
gRlvHandler.clearOverlayImage();
}
}
// Handles: @sendchannel[:<channel>]=n|y and @sendchannel_except[:<channel>]=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<bool>()) &&
(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<float>(), 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);
}
// ============================================================================

View File

@ -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<LLViewerFetchedTexture> 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<ERlvBehaviourOptionType optionType> friend struct RlvBehaviourGenericHandler;
template<ERlvBehaviourOptionType> friend struct RlvBehaviourGenericHandler;
template<ERlvParamType> friend struct RlvCommandHandlerBaseImpl;
template<ERlvParamType, ERlvBehaviour> friend struct RlvCommandHandler;
template<ERlvBehaviourModifier> friend class RlvBehaviourModifierHandler;
// --------------------------------

View File

@ -174,6 +174,7 @@ RlvBehaviourDictionary::RlvBehaviourDictionary()
addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_NONE>("viewnote", RLV_BHVR_VIEWNOTE));
addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_NONE>("viewscript", RLV_BHVR_VIEWSCRIPT));
addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_NONE>("viewtexture", RLV_BHVR_VIEWTEXTURE));
// Camera
addEntry(new RlvBehaviourGenericToggleProcessor<RLV_BHVR_SETCAM, RLV_OPTION_NONE>("setcam"));
addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_MODIFIER>("setcam_avdistmin", RLV_BHVR_SETCAM_AVDISTMIN, RlvBehaviourInfo::BHVR_EXPERIMENTAL));
@ -204,6 +205,15 @@ RlvBehaviourDictionary::RlvBehaviourDictionary()
addEntry(new RlvBehaviourProcessor<RLV_BHVR_CAMZOOMMAX, RlvBehaviourCamZoomMinMaxHandler>("camzoommax", RlvBehaviourInfo::BHVR_DEPRECATED));
addEntry(new RlvBehaviourGenericToggleProcessor<RLV_BHVR_SETCAM_UNLOCK, RLV_OPTION_NONE>("camunlock", RlvBehaviourInfo::BHVR_SYNONYM | RlvBehaviourInfo::BHVR_DEPRECATED));
// Overlay
addEntry(new RlvBehaviourGenericToggleProcessor<RLV_BHVR_SETOVERLAY, RLV_OPTION_NONE>("setoverlay", RlvBehaviourInfo::BHVR_EXPERIMENTAL));
addModifier(new RlvBehaviourGenericProcessor<RLV_OPTION_MODIFIER>("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<RLV_OPTION_MODIFIER>("setoverlay_texture", RLV_BHVR_SETOVERLAY_TEXTURE, RlvBehaviourInfo::BHVR_EXPERIMENTAL),
RLV_MODIFIER_OVERLAY_TEXTURE, new RlvBehaviourModifierHandler<RLV_MODIFIER_OVERLAY_TEXTURE>("Overlay - Texture", LLUUID::null, false, new RlvBehaviourModifier_Comp()));
addModifier(new RlvBehaviourGenericProcessor<RLV_OPTION_NONE_OR_MODIFIER>("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");

View File

@ -95,8 +95,9 @@ class RlvBehaviourDictionary : public LLSingleton<RlvBehaviourDictionary>
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