Adding optional flags to settings objects.
parent
cb7592e490
commit
3b10414c63
|
|
@ -54,6 +54,10 @@ const std::string LLSettingsBase::SETTING_NAME("name");
|
|||
const std::string LLSettingsBase::SETTING_HASH("hash");
|
||||
const std::string LLSettingsBase::SETTING_TYPE("type");
|
||||
const std::string LLSettingsBase::SETTING_ASSETID("asset_id");
|
||||
const std::string LLSettingsBase::SETTING_FLAGS("flags");
|
||||
|
||||
const U32 LLSettingsBase::FLAG_NOCOPY(0x01 << 0);
|
||||
const U32 LLSettingsBase::FLAG_NOMOD(0x01 << 1);
|
||||
|
||||
//=========================================================================
|
||||
LLSettingsBase::LLSettingsBase():
|
||||
|
|
@ -239,13 +243,23 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F
|
|||
// case LLSD::TypeBinary:
|
||||
// case LLSD::TypeDate:
|
||||
default:
|
||||
/* TODO: If the UUID points to an image ID, blend the images. */
|
||||
// atomic or unknown data types. Lerping between them does not make sense so switch at the break.
|
||||
newSettings[key_name] = (mix > BREAK_POINT) ? other_value : value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Special handling cases
|
||||
// Flags
|
||||
if (settings.has(SETTING_FLAGS))
|
||||
{
|
||||
U32 flags = (U32)settings[SETTING_FLAGS].asInteger();
|
||||
if (other.has(SETTING_FLAGS))
|
||||
flags |= (U32)other[SETTING_FLAGS].asInteger();
|
||||
|
||||
newSettings[SETTING_FLAGS] = LLSD::Integer(flags);
|
||||
}
|
||||
|
||||
// Now add anything that is in other but not in the settings
|
||||
for (LLSD::map_const_iterator it = other.beginMap(); it != other.endMap(); ++it)
|
||||
{
|
||||
|
|
@ -262,6 +276,19 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F
|
|||
return newSettings;
|
||||
}
|
||||
|
||||
LLSettingsBase::stringset_t LLSettingsBase::getSkipInterpolateKeys() const
|
||||
{
|
||||
static stringset_t skipSet;
|
||||
|
||||
if (skipSet.empty())
|
||||
{
|
||||
skipSet.insert(SETTING_FLAGS);
|
||||
skipSet.insert(SETTING_HASH);
|
||||
}
|
||||
|
||||
return skipSet;
|
||||
}
|
||||
|
||||
LLSD LLSettingsBase::getSettings() const
|
||||
{
|
||||
return mSettings;
|
||||
|
|
@ -311,6 +338,7 @@ LLSD LLSettingsBase::settingValidation(LLSD &settings, validation_list_t &valida
|
|||
static Validator validateHash(SETTING_HASH, false, LLSD::TypeInteger);
|
||||
static Validator validateType(SETTING_TYPE, false, LLSD::TypeString);
|
||||
static Validator validateAssetId(SETTING_ASSETID, false, LLSD::TypeUUID);
|
||||
static Validator validateFlags(SETTING_FLAGS, false, LLSD::TypeInteger);
|
||||
stringset_t validated;
|
||||
stringset_t strip;
|
||||
bool isValid(true);
|
||||
|
|
@ -353,6 +381,13 @@ LLSD LLSettingsBase::settingValidation(LLSD &settings, validation_list_t &valida
|
|||
}
|
||||
validated.insert(validateType.getName());
|
||||
|
||||
if (!validateFlags.verify(settings))
|
||||
{
|
||||
errors.append(LLSD::String("Unable to validate 'flags'."));
|
||||
isValid = false;
|
||||
}
|
||||
validated.insert(validateFlags.getName());
|
||||
|
||||
// Fields for specific settings.
|
||||
for (validation_list_t::iterator itv = validations.begin(); itv != validations.end(); ++itv)
|
||||
{
|
||||
|
|
@ -415,7 +450,6 @@ bool LLSettingsBase::Validator::verify(LLSD &data)
|
|||
{
|
||||
if (!mDefault.isUndefined())
|
||||
{
|
||||
LL_INFOS("SETTINGS") << "Inserting missing default for '" << mName << "'." << LL_ENDL;
|
||||
data[mName] = mDefault;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,10 @@ public:
|
|||
static const std::string SETTING_HASH;
|
||||
static const std::string SETTING_TYPE;
|
||||
static const std::string SETTING_ASSETID;
|
||||
static const std::string SETTING_FLAGS;
|
||||
|
||||
static const U32 FLAG_NOCOPY;
|
||||
static const U32 FLAG_NOMOD;
|
||||
|
||||
typedef std::map<std::string, S32> parammapping_t;
|
||||
|
||||
|
|
@ -113,6 +117,48 @@ public:
|
|||
return LLUUID();
|
||||
}
|
||||
|
||||
inline U32 getFlags() const
|
||||
{
|
||||
if (mSettings.has(SETTING_FLAGS))
|
||||
return static_cast<U32>(mSettings[SETTING_FLAGS].asInteger());
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline void setFlags(U32 value)
|
||||
{
|
||||
setLLSD(SETTING_FLAGS, LLSD::Integer(value));
|
||||
}
|
||||
|
||||
inline bool getFlag(U32 flag) const
|
||||
{
|
||||
if (mSettings.has(SETTING_FLAGS))
|
||||
return ((U32)mSettings[SETTING_FLAGS].asInteger() & flag) == flag;
|
||||
return false;
|
||||
}
|
||||
|
||||
inline void setFlag(U32 flag)
|
||||
{
|
||||
U32 flags((mSettings.has(SETTING_FLAGS)) ? (U32)mSettings[SETTING_FLAGS].asInteger() : 0);
|
||||
|
||||
flags |= flag;
|
||||
|
||||
if (flags)
|
||||
mSettings[SETTING_FLAGS] = LLSD::Integer(flags);
|
||||
else
|
||||
mSettings.erase(SETTING_FLAGS);
|
||||
}
|
||||
|
||||
inline void clearFlag(U32 flag)
|
||||
{
|
||||
U32 flags((mSettings.has(SETTING_FLAGS)) ? (U32)mSettings[SETTING_FLAGS].asInteger() : 0);
|
||||
|
||||
flags &= ~flag;
|
||||
|
||||
if (flags)
|
||||
mSettings[SETTING_FLAGS] = LLSD::Integer(flags);
|
||||
else
|
||||
mSettings.erase(SETTING_FLAGS);
|
||||
}
|
||||
|
||||
virtual void replaceSettings(LLSD settings)
|
||||
{
|
||||
|
|
@ -270,7 +316,7 @@ protected:
|
|||
/// when lerping between settings, some may require special handling.
|
||||
/// Get a list of these key to be skipped by the default settings lerp.
|
||||
/// (handling should be performed in the override of lerpSettings.
|
||||
virtual stringset_t getSkipInterpolateKeys() const { return stringset_t(); }
|
||||
virtual stringset_t getSkipInterpolateKeys() const;
|
||||
|
||||
// A list of settings that represent quaternions and should be slerped
|
||||
// rather than lerped.
|
||||
|
|
|
|||
|
|
@ -435,6 +435,7 @@ LLSettingsSky::stringset_t LLSettingsSky::getSkipInterpolateKeys() const
|
|||
|
||||
if (skipSet.empty())
|
||||
{
|
||||
skipSet = LLSettingsBase::getSkipInterpolateKeys();
|
||||
skipSet.insert(SETTING_RAYLEIGH_CONFIG);
|
||||
skipSet.insert(SETTING_MIE_CONFIG);
|
||||
skipSet.insert(SETTING_ABSORPTION_CONFIG);
|
||||
|
|
|
|||
|
|
@ -444,11 +444,15 @@ F32 LLEnvironment::getWaterHeight() const
|
|||
|
||||
bool LLEnvironment::getIsSunUp() const
|
||||
{
|
||||
if (!mCurrentEnvironment || !mCurrentEnvironment->getSky())
|
||||
return false;
|
||||
return mCurrentEnvironment->getSky()->getIsSunUp();
|
||||
}
|
||||
|
||||
bool LLEnvironment::getIsMoonUp() const
|
||||
{
|
||||
if (!mCurrentEnvironment || !mCurrentEnvironment->getSky())
|
||||
return false;
|
||||
return mCurrentEnvironment->getSky()->getIsMoonUp();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue