diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index ba0a1c7cb..83418d812 100644 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -69,6 +69,11 @@ class LLColor4U; const BOOL NO_PERSIST = FALSE; +// Saved at end of session +class LLControlGroup; //Defined further down +extern LLControlGroup gSavedSettings; //Default control group used in LLCachedControl +extern LLControlGroup *gCOASavedSettings; //Used in LLCachedCOAControl + typedef enum e_control_type { TYPE_U32 = 0, @@ -242,4 +247,165 @@ public: void resetWarnings(); }; +//! Helper function for LLCachedControl +template +eControlType get_control_type(const T& in, LLSD& out) +{ + llerrs << "Usupported control type: " << typeid(T).name() << "." << llendl; + return TYPE_COUNT; +} + +//! Publish/Subscribe object to interact with LLControlGroups. + +//! An LLCachedControl instance to connect to a LLControlVariable +//! without have to manually create and bind a listener to a local +//! object. +template +class LLCachedControl +{ + T mCachedValue; + LLPointer mControl; + boost::signals::connection mConnection; + LLControlGroup *mControlGroup; + +public: + LLCachedControl(const std::string& name, const T& default_value, LLControlGroup *group, const std::string& comment = "Declared In Code") + {Init(name,default_value,comment,*group);} //for gSavedPerAccountSettings, etc + LLCachedControl(const std::string& name, const T& default_value, LLControlGroup &group, const std::string& comment = "Declared In Code") + {Init(name,default_value,comment,group);} //for LLUI::sConfigGroup, etc + LLCachedControl(const std::string& name, + const T& default_value, + const std::string& comment = "Declared In Code", + LLControlGroup &group = gSavedSettings) + {Init(name,default_value,comment,group);} //for default (gSavedSettings) +private: + //Pulled out of ctor due to problems with initializer lists in template classes + void Init( const std::string& name, + const T& default_value, + const std::string& comment, + LLControlGroup &group ) + { + mControlGroup = &group; + mControl = mControlGroup->getControl(name); + if(mControl.isNull()) + { + declareTypedControl(*mControlGroup, name, default_value, comment); + mControl = mControlGroup->getControl(name); + if(mControl.isNull()) + { + llerrs << "The control could not be created!!!" << llendl; + } + + mCachedValue = default_value; + } + else + { + mCachedValue = (const T&)mControl->getValue(); + } + + // Add a listener to the controls signal... + // and store the connection... + mConnection = mControl->getSignal()->connect( + boost::bind(&LLCachedControl::handleValueChange, this, _1) + ); + } +public: + ~LLCachedControl() + { + if(mConnection.connected()) + { + mConnection.disconnect(); + } + } + + LLCachedControl& operator =(const T& newvalue) + { + setTypeValue(*mControl, newvalue); + return *this; + } + + operator const T&() { return mCachedValue; } + + LLPointer getControl() const + { + return mControl; + } +private: + void declareTypedControl(LLControlGroup& group, + const std::string& name, + const T& default_value, + const std::string& comment) + { + LLSD init_value; + eControlType type = get_control_type(default_value, init_value); + if(type < TYPE_COUNT) + { + group.declareControl(name, type, init_value, comment, FALSE); + } + } + + bool handleValueChange(const LLSD& newvalue) + { + mCachedValue = (const T &)newvalue; + return true; + } + + void setTypeValue(LLControlVariable& c, const T& v) + { + // Implicit conversion from T to LLSD... + c.set(v); + } +}; + +//Easiest way without messing with LLCachedControl even more.. +template +class LLCachedCOAControl +{ + LLCachedControl *mCachedControl; + boost::signals::connection mCOAConnection; + const std::string mName; + const std::string mComment; + const T mDefault; +public: + LLCachedCOAControl(const std::string& name, const T& default_value,const std::string& comment = "Declared In Code") + : mName(name),mDefault(default_value),mComment(comment) + { + mCachedControl = new LLCachedControl(mName,mDefault,gCOASavedSettings,mComment); + + static LLCachedControl settings_per_account("AscentStoreSettingsPerAccount",false); + mCOAConnection = settings_per_account.getControl()->getSignal()->connect( + boost::bind(&LLCachedCOAControl::handleCOAValueChange, this, _1)); + } + ~LLCachedCOAControl() + { + if(mCachedControl) + delete mCachedControl; + if(mCOAConnection.connected()) + mCOAConnection.disconnect(); + } + bool handleCOAValueChange(const LLSD& newvalue) + { + if(mCachedControl) + delete mCachedControl; + mCachedControl = new LLCachedControl(mName,mDefault,gCOASavedSettings,mComment); + return true; + } + operator const T&() { return *mCachedControl; } +}; + +//Following is actually defined in newview/llviewercontrol.cpp, but extern access is fine (Unless GCC bites me) +template <> eControlType get_control_type(const U32& in, LLSD& out); +template <> eControlType get_control_type(const S32& in, LLSD& out); +template <> eControlType get_control_type(const F32& in, LLSD& out); +template <> eControlType get_control_type (const bool& in, LLSD& out); +// Yay BOOL, its really an S32. +//template <> eControlType get_control_type (const BOOL& in, LLSD& out) +template <> eControlType get_control_type(const std::string& in, LLSD& out); +template <> eControlType get_control_type(const LLVector3& in, LLSD& out); +template <> eControlType get_control_type(const LLVector3d& in, LLSD& out); +template <> eControlType get_control_type(const LLRect& in, LLSD& out); +template <> eControlType get_control_type(const LLColor4& in, LLSD& out); +template <> eControlType get_control_type(const LLColor3& in, LLSD& out); +template <> eControlType get_control_type(const LLColor4U& in, LLSD& out); +template <> eControlType get_control_type(const LLSD& in, LLSD& out); #endif diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp index 30c0c179f..d2765c128 100644 --- a/indra/newview/llhudtext.cpp +++ b/indra/newview/llhudtext.cpp @@ -294,7 +294,6 @@ void LLHUDText::renderText(BOOL for_select) // *TODO: make this a per-text setting static LLCachedControl background_chat_color("BackgroundChatColor", LLColor4(0,0,0,1.f)); - //static LLColor4 background_chat_color(0,0,0,1.f); static LLCachedControl chat_bubble_opacity("ChatBubbleOpacity", .5); LLColor4 bg_color = background_chat_color; bg_color.setAlpha(chat_bubble_opacity * alpha_factor); diff --git a/indra/newview/llviewercontrol.h b/indra/newview/llviewercontrol.h index 76318ed2c..e06125032 100644 --- a/indra/newview/llviewercontrol.h +++ b/indra/newview/llviewercontrol.h @@ -54,8 +54,6 @@ extern std::map gSettings; void create_graphics_group(LLControlGroup& group); // saved at end of session -extern LLControlGroup gSavedSettings; -extern LLControlGroup *gCOASavedSettings; extern LLControlGroup gSavedPerAccountSettings; // Read-only @@ -68,164 +66,9 @@ extern LLControlGroup gCrashSettings; extern std::string gLastRunVersion; extern std::string gCurrentVersion; -//! Helper function for LLCachedControl -template -eControlType get_control_type(const T& in, LLSD& out) -{ - llerrs << "Usupported control type: " << typeid(T).name() << "." << llendl; - return TYPE_COUNT; -} - bool handleCloudSettingsChanged(const LLSD& newvalue); -//! Publish/Subscribe object to interact with LLControlGroups. - -//! An LLCachedControl instance to connect to a LLControlVariable -//! without have to manually create and bind a listener to a local -//! object. -template -class LLCachedControl -{ - T mCachedValue; - LLPointer mControl; - boost::signals::connection mConnection; - LLControlGroup *mControlGroup; - -public: - LLCachedControl(const std::string& name, const T& default_value, LLControlGroup *group, const std::string& comment = "Declared In Code") - {Init(name,default_value,comment,*group);} //for gSavedPerAccountSettings, etc - LLCachedControl(const std::string& name, const T& default_value, LLControlGroup &group, const std::string& comment = "Declared In Code") - {Init(name,default_value,comment,group);} //for LLUI::sConfigGroup, etc - LLCachedControl(const std::string& name, - const T& default_value, - const std::string& comment = "Declared In Code", - LLControlGroup &group = gSavedSettings) - {Init(name,default_value,comment,group);} //for default (gSavedSettings) -private: - //Pulled out of ctor due to problems with initializer lists in template classes - void Init( const std::string& name, - const T& default_value, - const std::string& comment, - LLControlGroup &group ) - { - mControlGroup = &group; - mControl = mControlGroup->getControl(name); - if(mControl.isNull()) - { - declareTypedControl(*mControlGroup, name, default_value, comment); - mControl = mControlGroup->getControl(name); - if(mControl.isNull()) - { - llerrs << "The control could not be created!!!" << llendl; - } - - mCachedValue = default_value; - } - else - { - mCachedValue = (const T&)mControl->getValue(); - } - - // Add a listener to the controls signal... - // and store the connection... - mConnection = mControl->getSignal()->connect( - boost::bind(&LLCachedControl::handleValueChange, this, _1) - ); - } -public: - ~LLCachedControl() - { - if(mConnection.connected()) - { - mConnection.disconnect(); - } - } - - LLCachedControl& operator =(const T& newvalue) - { - setTypeValue(*mControl, newvalue); - return *this; - } - - operator const T&() { return mCachedValue; } - -private: - void declareTypedControl(LLControlGroup& group, - const std::string& name, - const T& default_value, - const std::string& comment) - { - LLSD init_value; - eControlType type = get_control_type(default_value, init_value); - if(type < TYPE_COUNT) - { - group.declareControl(name, type, init_value, comment, FALSE); - } - } - - bool handleValueChange(const LLSD& newvalue) - { - mCachedValue = (const T &)newvalue; - return true; - } - - void setTypeValue(LLControlVariable& c, const T& v) - { - // Implicit conversion from T to LLSD... - c.set(v); - } -}; - -//Easiest way without messing with LLCachedControl even more.. -template -class LLCachedCOAControl -{ - LLCachedControl *mCachedControl; - boost::signals::connection mCOAConnection; - const std::string mName; - const std::string mComment; - const T mDefault; -public: - LLCachedCOAControl(const std::string& name, const T& default_value,const std::string& comment = "Declared In Code") - : mName(name),mDefault(default_value),mComment(comment) - { - mCachedControl = new LLCachedControl(mName,mDefault,gCOASavedSettings,mComment); - - static LLCachedControl settings_per_account("AscentStoreSettingsPerAccount",false); - mCOAConnection = settings_per_account.getControl()->getSignal()->connect( - boost::bind(&LLCachedCOAControl::handleCOAValueChange, this, _1)); - } - ~LLCachedCOAControl() - { - if(mCachedControl) - delete mCOAConnection; - if(mCOAConnection.connected()) - mCOAConnection.disconnect(); - } - bool handleCOAValueChange(const LLSD& newvalue) - { - if(mCachedControl) - delete mCachedControl; - mCachedControl = new LLCachedControl(mName,mDefault,gCOASavedSettings,mComment); - return true; - } - operator const T&() { return *mCachedControl; } -}; - -template <> eControlType get_control_type(const U32& in, LLSD& out); -template <> eControlType get_control_type(const S32& in, LLSD& out); -template <> eControlType get_control_type(const F32& in, LLSD& out); -template <> eControlType get_control_type (const bool& in, LLSD& out); -// Yay BOOL, its really an S32. -//template <> eControlType get_control_type (const BOOL& in, LLSD& out) -template <> eControlType get_control_type(const std::string& in, LLSD& out); -template <> eControlType get_control_type(const LLVector3& in, LLSD& out); -template <> eControlType get_control_type(const LLVector3d& in, LLSD& out); -template <> eControlType get_control_type(const LLRect& in, LLSD& out); -template <> eControlType get_control_type(const LLColor4& in, LLSD& out); -template <> eControlType get_control_type(const LLColor3& in, LLSD& out); -template <> eControlType get_control_type(const LLColor4U& in, LLSD& out); -template <> eControlType get_control_type(const LLSD& in, LLSD& out); +//NOTE: LLCachedControl moved to llxml/llcontrol.h make it easier to use in other projects. //A template would be a little awkward to use here.. so.. a preprocessor macro. Alas. onCommitControlSetting(gSavedSettings) etc. inline void onCommitControlSetting_gSavedSettings(LLUICtrl* ctrl, void* name) {gSavedSettings.setValue((const char*)name,ctrl->getValue());} diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h index 89303b1a1..61292b343 100644 --- a/indra/newview/llviewerobjectlist.h +++ b/indra/newview/llviewerobjectlist.h @@ -263,7 +263,7 @@ inline LLViewerObject *LLViewerObjectList::findObject(const LLUUID &id) const inline LLVOAvatar *LLViewerObjectList::findAvatar(const LLUUID &id) const { std::map >::const_iterator iter = mUUIDAvatarMap.find(id); - return (iter != mUUIDAvatarMap.end()) ? iter->second : NULL; + return (iter != mUUIDAvatarMap.end()) ? iter->second.get() : NULL; } inline LLViewerObject *LLViewerObjectList::getObject(const S32 index) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index cd920e12b..1df0ebdb4 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -5424,18 +5424,27 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index) } shader.uniform4fv("shadow_clip", 1, mSunClipPlanes.mV); - shader.uniform1f("sun_wash", gSavedSettings.getF32("RenderDeferredSunWash")); - shader.uniform1f("shadow_noise", gSavedSettings.getF32("RenderShadowNoise")); - shader.uniform1f("blur_size", gSavedSettings.getF32("RenderShadowBlurSize")); + static LLCachedControl render_deferred_sun_wash("RenderDeferredSunWash",.5f); + static LLCachedControl render_shadow_noise("RenderShadowNoise",-.0001f); + static LLCachedControl render_shadow_blur_size("RenderShadowBlurSize",.7f); + static LLCachedControl render_ssao_scale("RenderSSAOScale",500); + static LLCachedControl render_ssao_max_scale("RenderSSAOMaxScale",60); + static LLCachedControl render_ssao_factor("RenderSSAOFactor",.3f); + static LLCachedControl render_ssao_effect("RenderSSAOEffect",LLVector3(.4f,1,0)); + static LLCachedControl render_deferred_alpha_soft("RenderDeferredAlphaSoften",.75f); - shader.uniform1f("ssao_radius", gSavedSettings.getF32("RenderSSAOScale")); - shader.uniform1f("ssao_max_radius", gSavedSettings.getU32("RenderSSAOMaxScale")); + shader.uniform1f("sun_wash", render_deferred_sun_wash); + shader.uniform1f("shadow_noise", render_shadow_noise); + shader.uniform1f("blur_size", render_shadow_blur_size); - F32 ssao_factor = gSavedSettings.getF32("RenderSSAOFactor"); + shader.uniform1f("ssao_radius", render_ssao_scale); + shader.uniform1f("ssao_max_radius", render_ssao_max_scale); + + F32 ssao_factor = render_ssao_factor; shader.uniform1f("ssao_factor", ssao_factor); shader.uniform1f("ssao_factor_inv", 1.0/ssao_factor); - LLVector3 ssao_effect = gSavedSettings.getVector3("RenderSSAOEffect"); + LLVector3 ssao_effect = render_ssao_effect; F32 matrix_diag = (ssao_effect[0] + 2.0*ssao_effect[1])/3.0; F32 matrix_nondiag = (ssao_effect[0] - ssao_effect[1])/3.0; // This matrix scales (proj of color onto <1/rt(3),1/rt(3),1/rt(3)>) by @@ -5447,7 +5456,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index) shader.uniform2f("screen_res", mDeferredScreen.getWidth(), mDeferredScreen.getHeight()); shader.uniform1f("near_clip", LLViewerCamera::getInstance()->getNear()*2.f); - shader.uniform1f("alpha_soften", gSavedSettings.getF32("RenderDeferredAlphaSoften")); + shader.uniform1f("alpha_soften", render_deferred_alpha_soft); } void LLPipeline::renderDeferredLighting()