/*virtual*/ void post(LLHTTPNode::ResponsePtr response, const LLSD& context, const LLSD& input) const { if (!input || !context || !input.isMap() || !input.has("body")) { llinfos << "malformed WindLightRefresh!" << llendl; return; } //std::string dump = input["body"].asString(); //llwarns << dump << llendl; LLSD body = input["body"]; LLEnvManagerNew *env = &LLEnvManagerNew::instance(); LLViewerRegion* regionp = gAgent.getRegion(); LLUUID region_uuid = regionp ? regionp->getRegionID() : LLUUID::null; env->mNewRegionPrefs.clear(); env->mCurRegionUUID = region_uuid; env->mInterpNextChangeMessage = !body.has("Interpolate") || body["Interpolate"].asInteger() == 1; llinfos << "Windlight Refresh, interpolate:" << env->mInterpNextChangeMessage << llendl; env->requestRegionSettings(); env->mRegionChangeSignal(); }
/*virtual*/ void post( LLHTTPNode::ResponsePtr response, const LLSD& context, const LLSD& input) const { if (!input || !context || !input.isMap() || !input.has("body")) { LL_INFOS() << "malformed WindLightRefresh!" << LL_ENDL; return; } //std::string dump = input["body"].asString(); //LL_WARNS() << dump << LL_ENDL; LLSD body = input["body"]; LLEnvManagerNew *env = &LLEnvManagerNew::instance(); LLViewerRegion* regionp = gAgent.getRegion(); LLUUID region_uuid = regionp ? regionp->getRegionID() : LLUUID::null; env->mNewRegionPrefs.clear(); env->mCurRegionUUID = region_uuid; if(body.has("Interpolate")) { if(body["Interpolate"].asInteger() == 1) { env->mInterpNextChangeMessage = true; } else { env->mInterpNextChangeMessage = false; } } else { env->mInterpNextChangeMessage = true; } LL_INFOS() << "Windlight Refresh , interpolate:" << env->mInterpNextChangeMessage << LL_ENDL; env->requestRegionSettings(); // Ansa: This cause the windlight editor and others to update since the windlight has changed! gAgent.changeRegion(); }
// Checked: 2011-08-29 (RLVa-1.4.1a) | Added: RLVa-1.4.1a bool RlvWindLight::setValue(const std::string& strRlvName, const std::string& strValue) { F32 nValue = 0.0f; // Sanity check - make sure strValue specifies a number for all settings except "preset" and "daycycle" if ( (RlvSettings::getNoSetEnv()) || ( (!LLStringUtil::convertToF32(strValue, nValue)) && (("preset" != strRlvName) && ("daycycle" != strRlvName)) ) ) { return false; } LLWLParamManager* pWLParams = LLWLParamManager::getInstance(); LLEnvManagerNew* pEnvMgr = LLEnvManagerNew::getInstance(); if ("daytime" == strRlvName) { if (0.0f <= nValue) { pWLParams->mAnimator.deactivate(); pWLParams->mAnimator.setDayTime(nValue); pWLParams->mAnimator.update(pWLParams->mCurParams); } else { pEnvMgr->useRegionSettings(); } return true; } else if ("preset" == strRlvName) { std::string strPresetName = pWLParams->findPreset(strValue, LLEnvKey::SCOPE_LOCAL); if (!strPresetName.empty()) pEnvMgr->useSkyPreset(strPresetName); return !strPresetName.empty(); } else if ("daycycle" == strRlvName) { std::string strPresetName = LLDayCycleManager::instance().findPreset(strValue); if (!strPresetName.empty()) pEnvMgr->useDayCycle(strValue, LLEnvKey::SCOPE_LOCAL); return !strPresetName.empty(); } bool fError = false; pWLParams->mAnimator.deactivate(); if (("sunglowfocus" == strRlvName) || ("sunglowsize" == strRlvName)) { pWLParams->mGlow = pWLParams->mCurParams.getVector(pWLParams->mGlow.mName, fError); RLV_ASSERT_DBG(!fError); if ("sunglowfocus" == strRlvName) pWLParams->mGlow.b = -nValue * 5; else pWLParams->mGlow.r = (2 - nValue) * 20; pWLParams->mGlow.update(pWLParams->mCurParams); pWLParams->propagateParameters(); return true; } else if ("starbrightness" == strRlvName) { pWLParams->mCurParams.setStarBrightness(nValue); return true; } else if (("eastangle" == strRlvName) || ("sunmoonposition" == strRlvName)) { if ("eastangle" == strRlvName) pWLParams->mCurParams.setEastAngle(F_TWO_PI * nValue); else pWLParams->mCurParams.setSunAngle(F_TWO_PI * nValue); // Set the sun vector pWLParams->mLightnorm.r = -sin(pWLParams->mCurParams.getEastAngle()) * cos(pWLParams->mCurParams.getSunAngle()); pWLParams->mLightnorm.g = sin(pWLParams->mCurParams.getSunAngle()); pWLParams->mLightnorm.b = cos(pWLParams->mCurParams.getEastAngle()) * cos(pWLParams->mCurParams.getSunAngle()); pWLParams->mLightnorm.i = 1.f; pWLParams->propagateParameters(); return true; } else if ("cloudscrollx" == strRlvName) { pWLParams->mCurParams.setCloudScrollX(nValue + 10.0f); return true; } else if ("cloudscrolly" == strRlvName) { pWLParams->mCurParams.setCloudScrollY(nValue + 10.0f); return true; } std::map<std::string, RlvWindLightControl>::iterator itControl = m_ControlLookupMap.find(strRlvName); if (m_ControlLookupMap.end() != itControl) { switch (itControl->second.getControlType()) { case RlvWindLightControl::TYPE_FLOAT: return itControl->second.setFloat(nValue); case RlvWindLightControl::TYPE_COLOR_R: return itControl->second.setColorComponent(RlvWindLightControl::COMPONENT_R, nValue); default: RLV_ASSERT(false); } } else { // Couldn't find the exact name, check for a color control name RlvWindLightControl::EColorComponent eComponent = RlvWindLightControl::getComponentFromCharacter(strRlvName[strRlvName.length() - 1]); if (RlvWindLightControl::COMPONENT_NONE != eComponent) itControl = m_ControlLookupMap.find(strRlvName.substr(0, strRlvName.length() - 1)); if ( (m_ControlLookupMap.end() != itControl) && (itControl->second.isColorType()) ) return itControl->second.setColorComponent(eComponent, nValue); } return false; }
// Checked: 2011-08-29 (RLVa-1.4.1a) | Added: RLVa-1.4.1a std::string RlvWindLight::getValue(const std::string& strSetting, bool& fError) { LLWLParamManager* pWLParams = LLWLParamManager::getInstance(); LLEnvManagerNew* pEnvMgr = LLEnvManagerNew::getInstance(); fError = false; // Assume we won't fail if ("preset" == strSetting) return (pEnvMgr->getUseFixedSky()) ? pEnvMgr->getSkyPresetName() : std::string(); else if ("daycycle" == strSetting) return (pEnvMgr->getUseDayCycle()) ? pEnvMgr->getDayCycleName() : std::string(); F32 nValue = 0.0f; if ("daytime" == strSetting) { nValue = (pEnvMgr->getUseFixedSky()) ? pWLParams->mCurParams.getFloat("sun_angle", fError) / F_TWO_PI : -1.0f; } else if (("sunglowfocus" == strSetting) || ("sunglowsize" == strSetting)) { pWLParams->mGlow = pWLParams->mCurParams.getVector(pWLParams->mGlow.mName, fError); RLV_ASSERT_DBG(!fError); if ("sunglowfocus" == strSetting) nValue = -pWLParams->mGlow.b / 5.0f; else nValue = 2 - pWLParams->mGlow.r / 20.0f; } else if ("starbrightness" == strSetting) nValue = pWLParams->mCurParams.getStarBrightness(); else if ("eastangle" == strSetting) nValue = pWLParams->mCurParams.getEastAngle() / F_TWO_PI; else if ("sunmoonposition" == strSetting) nValue = pWLParams->mCurParams.getSunAngle() / F_TWO_PI; else if ("cloudscrollx" == strSetting) nValue = pWLParams->mCurParams.getCloudScrollX() - 10.0f; else if ("cloudscrolly" == strSetting) nValue = pWLParams->mCurParams.getCloudScrollY() - 10.0f; else { std::map<std::string, RlvWindLightControl>::const_iterator itControl = m_ControlLookupMap.find(strSetting); if (m_ControlLookupMap.end() != itControl) { switch (itControl->second.getControlType()) { case RlvWindLightControl::TYPE_FLOAT: nValue = itControl->second.getFloat(fError); break; case RlvWindLightControl::TYPE_COLOR_R: nValue = itControl->second.getColorComponent(RlvWindLightControl::COMPONENT_R, fError); break; default: fError = true; break; } } else { // Couldn't find the exact name, check for a color control name RlvWindLightControl::EColorComponent eComponent = RlvWindLightControl::getComponentFromCharacter(strSetting[strSetting.length() - 1]); if (RlvWindLightControl::COMPONENT_NONE != eComponent) itControl = m_ControlLookupMap.find(strSetting.substr(0, strSetting.length() - 1)); if ( (m_ControlLookupMap.end() != itControl) && (itControl->second.isColorType()) ) nValue = itControl->second.getColorComponent(eComponent, fError); else fError = true; } } return llformat("%f", nValue); }