Merge branch 'rlva/development'

master
Kitty Barnett 2020-11-21 23:16:39 +01:00
commit dfc6ea61f2
5 changed files with 58 additions and 15 deletions

View File

@ -259,6 +259,9 @@ public:
void initialize();
bool isInitialized();
// [RLVa:KB] - @setenv
virtual bool isTransition() { return false; }
// [/RLVa:KB]
void clear();
@ -318,6 +321,9 @@ public:
virtual bool applyTimeDelta(const LLSettingsBase::Seconds& delta) override;
virtual void animate() override;
// [RLVa:KB] - @setenv
bool isTransition() override { return true; }
// [/RLVa:KB]
protected:
LLSettingsSky::ptr_t mStartSky;
@ -327,6 +333,9 @@ public:
};
DayInstance::ptr_t getSelectedEnvironmentInstance();
// [RLVa:KB] - @setenv
DayInstance::ptr_t getCurrentEnvironmentInstance() { return mCurrentEnvironment; }
// [/RLVa:KB]
DayInstance::ptr_t getSharedEnvironmentInstance();
protected:

View File

@ -368,9 +368,11 @@ bool RlvActions::isLocalTp(const LLVector3d& posGlobal)
// WindLight
//
bool RlvActions::canChangeEnvironment()
bool RlvActions::canChangeEnvironment(const LLUUID& idRlvObject)
{
return !gRlvHandler.hasBehaviour(RLV_BHVR_SETENV);
// User can (partially) change their environment settings if:
// - not specifically restricted from changing their environment (by any object other than the one specified)
return (idRlvObject.isNull()) ? !gRlvHandler.hasBehaviour(RLV_BHVR_SETENV) : !gRlvHandler.hasBehaviourExcept(RLV_BHVR_SETENV, idRlvObject);
}
// ============================================================================

View File

@ -219,9 +219,9 @@ public:
// =========
public:
/*
* Returns true if the user can make changes to their WindLight environment
* Returns true if the user can make changes to their WindLight environment
*/
static bool canChangeEnvironment();
static bool canChangeEnvironment(const LLUUID& idRlvObject = LLUUID::null);
// =================

View File

@ -472,11 +472,42 @@ LLEnvironment::EnvSelection_t RlvEnvironment::getTargetEnvironment()
return RlvActions::canChangeEnvironment() ? LLEnvironment::ENV_LOCAL : LLEnvironment::ENV_EDIT;
}
// static
LLSettingsSky::ptr_t RlvEnvironment::getTargetSky(bool forSetCmd)
{
LLEnvironment* pEnv = LLEnvironment::getInstance();
if (forSetCmd)
{
bool isSharedEnv = !pEnv->getEnvironmentFixedSky(LLEnvironment::ENV_LOCAL),
hasLocalDayCycle = !isSharedEnv && pEnv->getEnvironmentDay(LLEnvironment::ENV_LOCAL),
isLocalTransition = !hasLocalDayCycle && pEnv->getCurrentEnvironmentInstance()->isTransition();
if ( (isSharedEnv) || (hasLocalDayCycle) || (isLocalTransition) )
{
LLSettingsSky::ptr_t pSky = (isSharedEnv) ? pEnv->getEnvironmentFixedSky(LLEnvironment::ENV_PARCEL, true)->buildClone()
: (hasLocalDayCycle) ? pEnv->getEnvironmentFixedSky(LLEnvironment::ENV_LOCAL)->buildClone()
: pEnv->getEnvironmentFixedSky(LLEnvironment::ENV_LOCAL);
pEnv->setEnvironment(LLEnvironment::ENV_LOCAL, pSky);
pEnv->setSelectedEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::TRANSITION_INSTANT);
pEnv->updateEnvironment(LLEnvironment::TRANSITION_INSTANT);
}
}
return pEnv->getCurrentSky();
}
// static
bool RlvEnvironment::onHandleCommand(const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet, const std::string& strCmdPrefix, const handler_map_t& fnLookup, const legacy_handler_map_t& legacyFnLookup)
{
if ( (rlvCmd.getBehaviour().length() > strCmdPrefix.length() + 2) && (boost::starts_with(rlvCmd.getBehaviour(), strCmdPrefix)) )
{
if ( (RLV_TYPE_FORCE == rlvCmd.getParamType()) && (!RlvActions::canChangeEnvironment(rlvCmd.getObjectID())) )
{
cmdRet = RLV_RET_FAILED_LOCK;
return true;
}
std::string strEnvCommand = rlvCmd.getBehaviour().substr(strCmdPrefix.length());
handler_map_t::const_iterator itFnEntry = fnLookup.find(strEnvCommand);
@ -517,21 +548,21 @@ bool RlvEnvironment::onForceCommand(const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet
template<>
std::string RlvEnvironment::handleGetFn<float>(const std::function<float(LLSettingsSky::ptr_t)>& fn)
{
LLSettingsSky::ptr_t pSky = LLEnvironment::instance().getCurrentSky();
LLSettingsSky::ptr_t pSky = getTargetSky();
return std::to_string(fn(pSky));
}
template<>
std::string RlvEnvironment::handleGetFn<LLUUID>(const std::function<LLUUID(LLSettingsSky::ptr_t)>& fn)
{
LLSettingsSky::ptr_t pSky = LLEnvironment::instance().getCurrentSky();
LLSettingsSky::ptr_t pSky = getTargetSky();
return fn(pSky).asString();
}
template<>
std::string RlvEnvironment::handleGetFn<LLVector2>(const std::function<LLVector2(LLSettingsSky::ptr_t)>& fn)
{
LLSettingsSky::ptr_t pSky = LLEnvironment::instance().getCurrentSky();
LLSettingsSky::ptr_t pSky = getTargetSky();
LLVector2 replyVec = fn(pSky);
return llformat("%f/%f", replyVec.mV[VX], replyVec.mV[VY]);
}
@ -539,7 +570,7 @@ std::string RlvEnvironment::handleGetFn<LLVector2>(const std::function<LLVector2
template<>
std::string RlvEnvironment::handleGetFn<LLColor3>(const std::function<LLColor3(LLSettingsSky::ptr_t)>& fn)
{
LLSettingsSky::ptr_t pSky = LLEnvironment::instance().getCurrentSky();
LLSettingsSky::ptr_t pSky = getTargetSky();
LLColor3 replyColor = fn(pSky);
return llformat("%f/%f/%f", replyColor.mV[VX], replyColor.mV[VY], replyColor.mV[VZ]);
}
@ -551,7 +582,7 @@ ERlvCmdRet RlvEnvironment::handleSetFn(const std::string& strRlvOption, const st
if (!RlvCommandOptionHelper::parseOption<T>(strRlvOption, optionValue))
return RLV_RET_FAILED_PARAM;
LLSettingsSky::ptr_t pSky = LLEnvironment::instance().getCurrentSky();
LLSettingsSky::ptr_t pSky = getTargetSky(true);
fn(pSky, optionValue);
pSky->update();
return RLV_RET_SUCCESS;
@ -562,7 +593,7 @@ std::string RlvEnvironment::handleLegacyGetFn<LLVector2>(const std::function<con
{
if (idxComponent >= 2)
return LLStringUtil::null;
return std::to_string(getFn(LLEnvironment::instance().getCurrentSky()).mV[idxComponent]);
return std::to_string(getFn(getTargetSky()).mV[idxComponent]);
}
template<>
@ -570,11 +601,11 @@ std::string RlvEnvironment::handleLegacyGetFn<LLColor3>(const std::function<cons
{
if ( (idxComponent >= VRED) && (idxComponent <= VBLUE) )
{
return std::to_string(getFn(LLEnvironment::instance().getCurrentSky()).mV[idxComponent]);
return std::to_string(getFn(getTargetSky()).mV[idxComponent]);
}
else if (idxComponent == VALPHA)
{
const LLColor3& clr = getFn(LLEnvironment::instance().getCurrentSky());
const LLColor3& clr = getFn(getTargetSky());
return std::to_string(llmax(clr.mV[VRED], clr.mV[VGREEN], clr.mV[VBLUE]));
}
return LLStringUtil::null;
@ -586,7 +617,7 @@ ERlvCmdRet RlvEnvironment::handleLegacySetFn<LLVector2>(float optionValue, LLVec
if (idxComponent >= 2)
return RLV_RET_FAILED_UNKNOWN;
LLSettingsSky::ptr_t pSky = LLEnvironment::instance().getCurrentSky();
LLSettingsSky::ptr_t pSky = getTargetSky(true);
curValue.mV[idxComponent] = optionValue;
setFn(pSky, curValue);
pSky->update();
@ -597,7 +628,7 @@ ERlvCmdRet RlvEnvironment::handleLegacySetFn<LLVector2>(float optionValue, LLVec
template<>
ERlvCmdRet RlvEnvironment::handleLegacySetFn<LLColor3>(float optionValue, LLColor3 curValue, const std::function<void(LLSettingsSkyPtr_t, const LLColor3&)>& setFn, U32 idxComponent)
{
LLSettingsSky::ptr_t pSky = LLEnvironment::instance().getCurrentSky();
LLSettingsSky::ptr_t pSky = getTargetSky(true);
if ( (idxComponent >= VRED) && (idxComponent <= VBLUE) )
{
curValue.mV[idxComponent] = optionValue;
@ -691,7 +722,7 @@ void RlvEnvironment::registerLegacySkyFn(const std::string& strFnName, const std
float optionValue;
if (!RlvCommandOptionHelper::parseOption(strRlvOption, optionValue))
return RLV_RET_FAILED_PARAM;
return handleLegacySetFn<T>(optionValue, getFn(LLEnvironment::instance().getCurrentSky()), setFn, idxComponent);;
return handleLegacySetFn<T>(optionValue, getFn(getTargetSky(true)), setFn, idxComponent);;
}));
}

View File

@ -34,6 +34,7 @@ public:
bool onForceCommand(const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet) override;
protected:
static LLEnvironment::EnvSelection_t getTargetEnvironment();
static LLSettingsSky::ptr_t getTargetSky(bool forSetCmd = false);
typedef std::map<std::string, std::function<ERlvCmdRet(const std::string&)>> handler_map_t;
typedef std::map<std::string, std::function<ERlvCmdRet(const std::string&, U32)>> legacy_handler_map_t;
static bool onHandleCommand(const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet, const std::string& strCmdPrefix, const handler_map_t& fnLookup, const legacy_handler_map_t& legacyFnLookup);