Update a couple constructs

meow-7.2.2
Rider Linden 2018-02-09 10:10:13 -08:00
parent 7838189843
commit e9edd37cdb
5 changed files with 69 additions and 203 deletions

View File

@ -262,57 +262,6 @@ size_t LLSettingsBase::getHash() const
return boost::hash<LLSD>{}(hash_settings);
}
#ifdef VALIDATION_DEBUG
namespace
{
bool compare_llsd(LLSD valA, LLSD valB)
{
if (valA.type() != valB.type())
return false;
switch (valA.type())
{
// case LLSD::TypeMap:
// newSettings[key_name] = combineSDMaps(value, LLSD());
// break;
case LLSD::TypeArray:
if (valA.size() != valB.size())
return false;
for (S32 idx = 0; idx < valA.size(); ++idx)
{
if (!compare_llsd(valA[idx], valB[idx]))
return false;
}
return true;
case LLSD::TypeInteger:
return valA.asInteger() == valB.asInteger();
case LLSD::TypeReal:
return is_approx_equal(valA.asReal(), valB.asReal());
case LLSD::TypeBoolean:
return valA.asBoolean() == valB.asBoolean();
case LLSD::TypeString:
return valA.asString() == valB.asString();
case LLSD::TypeUUID:
return valA.asUUID() == valB.asUUID();
case LLSD::TypeURI:
return valA.asString() == valB.asString();
case LLSD::TypeDate:
return valA.asDate() == valB.asDate();
}
return true;
}
}
#endif
bool LLSettingsBase::validate()
{
validation_list_t validations = getValidationList();
@ -378,35 +327,17 @@ LLSD LLSettingsBase::settingValidation(LLSD &settings, validation_list_t &valida
validated.insert(validateType.getName());
// Fields for specific settings.
for (validation_list_t::iterator itv = validations.begin(); itv != validations.end(); ++itv)
for (auto &test: validations)
{
#ifdef VALIDATION_DEBUG
LLSD oldvalue;
if (settings.has((*itv).getName()))
{
oldvalue = llsd_clone(mSettings[(*itv).getName()]);
}
#endif
if (!(*itv).verify(settings))
if (!test.verify(settings))
{
std::stringstream errtext;
errtext << "Settings LLSD fails validation and could not be corrected for '" << (*itv).getName() << "'!";
errtext << "Settings LLSD fails validation and could not be corrected for '" << test.getName() << "'!";
errors.append( errtext.str() );
isValid = false;
}
validated.insert((*itv).getName());
#ifdef VALIDATION_DEBUG
if (!oldvalue.isUndefined())
{
if (!compare_llsd(settings[(*itv).getName()], oldvalue))
{
LL_WARNS("SETTINGS") << "Setting '" << (*itv).getName() << "' was changed: " << oldvalue << " -> " << settings[(*itv).getName()] << LL_ENDL;
}
}
#endif
validated.insert(test.getName());
}
// strip extra entries
@ -422,9 +353,9 @@ LLSD LLSettingsBase::settingValidation(LLSD &settings, validation_list_t &valida
}
}
for (stringset_t::iterator its = strip.begin(); its != strip.end(); ++its)
for (const std::string &its: strip)
{
settings.erase(*its);
settings.erase(its);
}
return LLSDMap("success", LLSD::Boolean(isValid))

View File

@ -131,20 +131,20 @@ LLSD LLSettingsDay::getSettings() const
LLSD tracks(LLSD::emptyArray());
for (CycleList_t::const_iterator itTrack = mDayTracks.begin(); itTrack != mDayTracks.end(); ++itTrack)
for (auto &track: mDayTracks)
{
LLSD trackout(LLSD::emptyArray());
for (CycleTrack_t::const_iterator itFrame = (*itTrack).begin(); itFrame != (*itTrack).end(); ++itFrame)
for (auto &frame: track)
{
F32 frame = (*itFrame).first;
LLSettingsBase::ptr_t data = (*itFrame).second;
F32 frame_time = frame.first;
LLSettingsBase::ptr_t data = frame.second;
size_t datahash = data->getHash();
std::stringstream keyname;
keyname << datahash;
trackout.append(LLSD(LLSDMap(SETTING_KEYKFRAME, LLSD::Real(frame))(SETTING_KEYNAME, keyname.str())));
trackout.append(LLSD(LLSDMap(SETTING_KEYKFRAME, LLSD::Real(frame_time))(SETTING_KEYNAME, keyname.str())));
in_use[keyname.str()] = data;
}
tracks.append(trackout);
@ -152,12 +152,12 @@ LLSD LLSettingsDay::getSettings() const
settings[SETTING_TRACKS] = tracks;
LLSD frames(LLSD::emptyMap());
for (std::map<std::string, LLSettingsBase::ptr_t>::iterator itFrame = in_use.begin(); itFrame != in_use.end(); ++itFrame)
for (auto &used_frame: in_use)
{
LLSD framesettings = llsd_clone((*itFrame).second->getSettings(),
LLSD framesettings = llsd_clone(used_frame.second->getSettings(),
LLSDMap("*", true)(SETTING_NAME, false)(SETTING_ID, false)(SETTING_HASH, false));
frames[(*itFrame).first] = framesettings;
frames[used_frame.first] = framesettings;
}
settings[SETTING_FRAMES] = frames;
@ -465,9 +465,9 @@ LLSettingsDay::KeyframeList_t LLSettingsDay::getTrackKeyframes(S32 trackno)
keyframes.reserve(track.size());
for (CycleTrack_t::iterator it = track.begin(); it != track.end(); ++it)
for (auto &frame: track)
{
keyframes.push_back((*it).first);
keyframes.push_back(frame.first);
}
return keyframes;

View File

@ -367,23 +367,6 @@ void LLEnvironment::updateEnvironment(F64Seconds transition)
trans->animate();
mCurrentEnvironment = trans;
//
// LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky();
// LLSettingsWater::ptr_t pwater = mCurrentEnvironment->getWater();
//
// LLSettingsSky::ptr_t ptargetsky = psky->buildClone();
// LLSettingsWater::ptr_t ptargetwater = pwater->buildClone();
//
// LLSettingsBlender::ptr_t skyblend = std::make_shared<LLSettingsBlender>(ptargetsky, psky, pinstance->getSky(), transition);
// skyblend->setOnFinished(boost::bind(&LLEnvironment::onTransitionDone, this, _1, true));
// LLSettingsBlender::ptr_t waterblend = std::make_shared<LLSettingsBlender>(ptargetwater, pwater, pinstance->getWater(), transition);
// waterblend->setOnFinished(boost::bind(&LLEnvironment::onTransitionDone, this, _1, false));
//
// pinstance->setBlenders(skyblend, waterblend);
//
// mCurrentEnvironment = pinstance;
//
// mCurrentEnvironment->animate();
}
}
@ -402,11 +385,6 @@ void LLEnvironment::update(const LLViewerCamera * cam)
F32Seconds delta(timer.getElapsedTimeAndResetF32());
// for (InstanceArray_t::reverse_iterator it = mEnvironments.rbegin(); it != mEnvironments.rend(); ++it)
// {
// if (*it)
// (*it)->update(delta);
// }
mCurrentEnvironment->update(delta);
// update clouds, sun, and general
@ -460,28 +438,28 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS
//_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL;
LLSettingsBase::parammapping_t params = psetting->getParameterMap();
for (LLSettingsBase::parammapping_t::iterator it = params.begin(); it != params.end(); ++it)
for (auto &it: params)
{
if (!psetting->mSettings.has((*it).first))
if (!psetting->mSettings.has(it.first))
continue;
LLSD value = psetting->mSettings[(*it).first];
LLSD value = psetting->mSettings[it.first];
LLSD::Type setting_type = value.type();
stop_glerror();
switch (setting_type)
{
case LLSD::TypeInteger:
shader->uniform1i((*it).second, value.asInteger());
shader->uniform1i(it.second, value.asInteger());
//_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL;
break;
case LLSD::TypeReal:
shader->uniform1f((*it).second, value.asReal());
shader->uniform1f(it.second, value.asReal());
//_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL;
break;
case LLSD::TypeBoolean:
shader->uniform1i((*it).second, value.asBoolean() ? 1 : 0);
shader->uniform1i(it.second, value.asBoolean() ? 1 : 0);
//_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL;
break;
@ -489,7 +467,7 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS
{
LLVector4 vect4(value);
//_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << vect4 << LL_ENDL;
shader->uniform4fv((*it).second, 1, vect4.mV);
shader->uniform4fv(it.second, 1, vect4.mV);
break;
}
@ -551,9 +529,9 @@ LLEnvironment::list_name_id_t LLEnvironment::getSkyList() const
list.reserve(mSkysByName.size());
for (namedSettingMap_t::const_iterator it = mSkysByName.begin(); it != mSkysByName.end(); ++it)
for (auto &it: mSkysByName)
{
list.push_back(std::vector<name_id_t>::value_type((*it).second->getName(), (*it).second->getId()));
list.push_back(std::vector<name_id_t>::value_type(it.second->getName(), it.second->getId()));
}
return list;
@ -565,9 +543,9 @@ LLEnvironment::list_name_id_t LLEnvironment::getWaterList() const
list.reserve(mWaterByName.size());
for (namedSettingMap_t::const_iterator it = mWaterByName.begin(); it != mWaterByName.end(); ++it)
for (auto &it : mWaterByName)
{
list.push_back(std::vector<name_id_t>::value_type((*it).second->getName(), (*it).second->getId()));
list.push_back(std::vector<name_id_t>::value_type(it.second->getName(), it.second->getId()));
}
return list;
@ -579,9 +557,9 @@ LLEnvironment::list_name_id_t LLEnvironment::getDayCycleList() const
list.reserve(mDayCycleByName.size());
for (namedSettingMap_t::const_iterator it = mDayCycleByName.begin(); it != mDayCycleByName.end(); ++it)
for (auto &it: mDayCycleByName)
{
list.push_back(std::vector<name_id_t>::value_type((*it).second->getName(), (*it).second->getId()));
list.push_back(std::vector<name_id_t>::value_type(it.second->getName(), it.second->getId()));
}
return list;
@ -593,8 +571,7 @@ void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky)
LL_WARNS("RIDER") << "Adding sky as '" << name << "'" << LL_ENDL;
std::pair<namedSettingMap_t::iterator, bool> result;
result = mSkysByName.insert(namedSettingMap_t::value_type(name, sky));
auto result = mSkysByName.insert(namedSettingMap_t::value_type(name, sky)); // auto should be: std::pair<namedSettingMap_t::iterator, bool>
if (!result.second)
(*(result.first)).second = sky;
@ -603,7 +580,7 @@ void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky)
void LLEnvironment::removeSky(const std::string &name)
{
namedSettingMap_t::iterator it = mSkysByName.find(name);
auto it = mSkysByName.find(name);
if (it != mSkysByName.end())
mSkysByName.erase(it);
mSkyListChange();
@ -622,8 +599,7 @@ void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water)
LL_WARNS("RIDER") << "Adding water as '" << name << "'" << LL_ENDL;
std::pair<namedSettingMap_t::iterator, bool> result;
result = mWaterByName.insert(namedSettingMap_t::value_type(name, water));
auto result = mWaterByName.insert(namedSettingMap_t::value_type(name, water));
if (!result.second)
(*(result.first)).second = water;
@ -633,7 +609,7 @@ void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water)
void LLEnvironment::removeWater(const std::string &name)
{
namedSettingMap_t::iterator it = mWaterByName.find(name);
auto it = mWaterByName.find(name);
if (it != mWaterByName.end())
mWaterByName.erase(it);
mWaterListChange();
@ -652,8 +628,7 @@ void LLEnvironment::addDayCycle(const LLSettingsDay::ptr_t &daycycle)
LL_WARNS("RIDER") << "Adding daycycle as '" << name << "'" << LL_ENDL;
std::pair<namedSettingMap_t::iterator, bool> result;
result = mDayCycleByName.insert(namedSettingMap_t::value_type(name, daycycle));
auto result = mDayCycleByName.insert(namedSettingMap_t::value_type(name, daycycle));
if (!result.second)
(*(result.first)).second = daycycle;
@ -664,7 +639,7 @@ void LLEnvironment::addDayCycle(const LLSettingsDay::ptr_t &daycycle)
void LLEnvironment::removeDayCycle(const std::string &name)
{
namedSettingMap_t::iterator it = mDayCycleByName.find(name);
auto it = mDayCycleByName.find(name);
if (it != mDayCycleByName.end())
mDayCycleByName.erase(it);
mDayCycleListChange();
@ -680,7 +655,7 @@ void LLEnvironment::clearAllDayCycles()
LLSettingsSky::ptr_t LLEnvironment::findSkyByName(std::string name) const
{
namedSettingMap_t::const_iterator it = mSkysByName.find(name);
auto it = mSkysByName.find(name);
if (it == mSkysByName.end())
{
@ -693,7 +668,7 @@ LLSettingsSky::ptr_t LLEnvironment::findSkyByName(std::string name) const
LLSettingsWater::ptr_t LLEnvironment::findWaterByName(std::string name) const
{
namedSettingMap_t::const_iterator it = mWaterByName.find(name);
auto it = mWaterByName.find(name);
if (it == mWaterByName.end())
{
@ -706,7 +681,7 @@ LLSettingsWater::ptr_t LLEnvironment::findWaterByName(std::string name) const
LLSettingsDay::ptr_t LLEnvironment::findDayCycleByName(std::string name) const
{
namedSettingMap_t::const_iterator it = mDayCycleByName.find(name);
auto it = mDayCycleByName.find(name);
if (it == mDayCycleByName.end())
{
@ -735,27 +710,6 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI
LL_WARNS("LAPRAS") << "Had requested parcel environment #" << parcel_id << " but got region." << LL_ENDL;
clearEnvironment(ENV_PARCEL);
}
// LLViewerRegion *pRegion = gAgent.getRegion();
//
// pRegion->setDayLength(envinfo->mDayLength);
// pRegion->setDayOffset(envinfo->mDayOffset);
// pRegion->setIsDefaultDayCycle(envinfo->mIsDefault);
// if (pRegion->getRegionDayCycleHash() != envinfo->mDayHash)
// {
// pRegion->setRegionDayCycle(pday);
// pRegion->setRegionDayCycleHash(envinfo->mDayHash);
// }
//
// if (parcel_id != INVALID_PARCEL_ID)
// { // We requested a parcel environment but got back the region's. If this is the parcel we are in
// // clear it out.
// LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel();
//
// if (parcel->getLocalID() == parcel_id)
// {
// parcel->clearParcelDayCycleInfo();
// }
// }
}
else
{
@ -769,20 +723,6 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI
}
setEnvironment(ENV_PARCEL, pday, envinfo->mDayLength, envinfo->mDayOffset);
// LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel();
//
// if (parcel->getLocalID() == parcel_id)
// {
// parcel->setDayLength(envinfo->mDayLength);
// parcel->setDayOffset(envinfo->mDayOffset);
// parcel->setUsesDefaultDayCycle(envinfo->mIsDefault);
// if (parcel->getParcelDayCycleHash() != envinfo->mDayHash)
// {
// parcel->setParcelDayCycle(pday);
// parcel->setParcelDayCycleHash(envinfo->mDayHash);
// }
//
// }
}
/*TODO: track_altitudes*/
@ -819,32 +759,27 @@ void LLEnvironment::resetRegion()
void LLEnvironment::requestParcel(S32 parcel_id)
{
environment_apply_fn apply = boost::bind(&LLEnvironment::recordEnvironment, this, _1, _2);
std::string coroname =
LLCoros::instance().launch("LLEnvironment::coroRequestEnvironment",
boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id, apply));
boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id,
[this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }));
}
void LLEnvironment::updateParcel(S32 parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset)
{
environment_apply_fn apply = boost::bind(&LLEnvironment::recordEnvironment, this, _1, _2);
std::string coroname =
LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment",
boost::bind(&LLEnvironment::coroUpdateEnvironment, this, parcel_id,
pday, day_length, day_offset, apply));
pday, day_length, day_offset,
[this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }));
}
void LLEnvironment::resetParcel(S32 parcel_id)
{
environment_apply_fn apply = boost::bind(&LLEnvironment::recordEnvironment, this, _1, _2);
std::string coroname =
LLCoros::instance().launch("LLEnvironment::coroResetEnvironment",
boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id, apply));
boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id,
[this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }));
}
void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environment_apply_fn apply)
@ -890,7 +825,7 @@ void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environ
else
{
LLSD environment = result["environment"];
if (environment.isDefined() && !apply.empty())
if (environment.isDefined() && apply)
{
EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment);
apply(parcel_id, envinfo);
@ -953,7 +888,7 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pd
else
{
LLSD environment = result["environment"];
if (environment.isDefined() && !apply.empty())
if (environment.isDefined() && apply)
{
EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment);
apply(parcel_id, envinfo);
@ -1004,7 +939,7 @@ void LLEnvironment::coroResetEnvironment(S32 parcel_id, environment_apply_fn app
else
{
LLSD environment = result["environment"];
if (environment.isDefined() && !apply.empty())
if (environment.isDefined() && apply)
{
EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment);
apply(parcel_id, envinfo);
@ -1456,7 +1391,10 @@ void LLEnvironment::DayInstance::animate()
mWater = std::static_pointer_cast<LLSettingsVOWater>((*bounds.first).second)->buildClone();
mBlenderWater = std::make_shared<LLSettingsBlender>(mWater,
(*bounds.first).second, (*bounds.second).second, timespan);
mBlenderWater->setOnFinished(boost::bind(&LLEnvironment::DayInstance::onTrackTransitionDone, this, 0, _1));
mBlenderWater->setOnFinished(
[this](LLSettingsBlender::ptr_t blender) { onTrackTransitionDone(0, blender); });
}
// Day track 1 only for the moment
@ -1481,7 +1419,8 @@ void LLEnvironment::DayInstance::animate()
mSky = std::static_pointer_cast<LLSettingsVOSky>((*bounds.first).second)->buildClone();
mBlenderSky = std::make_shared<LLSettingsBlender>(mSky,
(*bounds.first).second, (*bounds.second).second, timespan);
mBlenderSky->setOnFinished(boost::bind(&LLEnvironment::DayInstance::onTrackTransitionDone, this, 1, _1));
mBlenderSky->setOnFinished(
[this](LLSettingsBlender::ptr_t blender) { onTrackTransitionDone(1, blender); });
}
}
@ -1530,23 +1469,21 @@ void LLEnvironment::DayTransition::animate()
mWater = mStartWater->buildClone();
mBlenderWater = std::make_shared<LLSettingsBlender>(mWater, mStartWater, mNextInstance->getWater(), mTransitionTime);
mBlenderWater->setOnFinished(boost::bind(&LLEnvironment::DayTransition::onTransitonDone, this, LLSettingsDay::TRACK_WATER, _1));
mBlenderWater->setOnFinished(
[this](LLSettingsBlender::ptr_t blender) {
mBlenderWater.reset();
if (!mBlenderSky && !mBlenderWater)
LLEnvironment::instance().mCurrentEnvironment = mNextInstance;
});
mSky = mStartSky->buildClone();
mBlenderSky = std::make_shared<LLSettingsBlender>(mSky, mStartSky, mNextInstance->getSky(), mTransitionTime);
mBlenderSky->setOnFinished(boost::bind(&LLEnvironment::DayTransition::onTransitonDone, this, LLSettingsDay::TRACK_MAX, _1));
}
void LLEnvironment::DayTransition::onTransitonDone(S32 trackno, const LLSettingsBlender::ptr_t blender)
{
if (trackno == LLSettingsDay::TRACK_WATER)
mBlenderWater.reset();
else
mBlenderSky->setOnFinished(
[this](LLSettingsBlender::ptr_t blender) {
mBlenderSky.reset();
if (!mBlenderSky && !mBlenderWater)
{
LLEnvironment::instance().mCurrentEnvironment = mNextInstance;
}
if (!mBlenderSky && !mBlenderWater)
LLEnvironment::instance().mCurrentEnvironment = mNextInstance;
});
}

View File

@ -124,7 +124,7 @@ public:
typedef std::pair<std::string, LLUUID> name_id_t;
typedef std::vector<name_id_t> list_name_id_t;
typedef boost::signals2::signal<void()> change_signal_t;
typedef boost::function<void(S32, EnvironmentInfo::ptr_t)> environment_apply_fn;
typedef std::function<void(S32, EnvironmentInfo::ptr_t)> environment_apply_fn;
virtual ~LLEnvironment();
@ -278,8 +278,6 @@ private:
LLSettingsWater::ptr_t mStartWater;
DayInstance::ptr_t mNextInstance;
S64Seconds mTransitionTime;
void onTransitonDone(S32 trackno, const LLSettingsBlender::ptr_t blender);
};
static const F32 SUN_DELTA_YAW;

View File

@ -52,7 +52,7 @@ bool LLEnvironmentRequest::initiate()
if (!cur_region->capabilitiesReceived())
{
LL_INFOS("WindlightCaps") << "Deferring windlight settings request until we've got region caps" << LL_ENDL;
cur_region->setCapabilitiesReceivedCallback(boost::bind(&LLEnvironmentRequest::onRegionCapsReceived, _1));
cur_region->setCapabilitiesReceivedCallback([](LLUUID region_id) { LLEnvironmentRequest::onRegionCapsReceived(region_id); });
return false;
}
@ -85,7 +85,7 @@ bool LLEnvironmentRequest::doRequest()
std::string coroname =
LLCoros::instance().launch("LLEnvironmentRequest::environmentRequestCoro",
boost::bind(&LLEnvironmentRequest::environmentRequestCoro, url));
[url]() { LLEnvironmentRequest::environmentRequestCoro(url); });
LL_INFOS("WindlightCaps") << "Requesting region windlight settings via " << url << LL_ENDL;
return true;
@ -178,7 +178,7 @@ bool LLEnvironmentApply::initiateRequest(const LLSD& content)
std::string coroname =
LLCoros::instance().launch("LLEnvironmentApply::environmentApplyCoro",
boost::bind(&LLEnvironmentApply::environmentApplyCoro, url, content));
[url, content]() { LLEnvironmentApply::environmentApplyCoro(url, content); });
return true;
}