-Moved LLCachedControl stuff to llxui/llcontrol.h to ease usage in other projects.
-Fixed mistakes in LLCachedCOAControl revealed by GCC. Thanks Siana. -LLCacheControl'd stuff related to postprocessing, which I may mess with later. GCC... Sigh.
This commit is contained in:
@@ -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 <class T>
|
||||
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 T>
|
||||
class LLCachedControl
|
||||
{
|
||||
T mCachedValue;
|
||||
LLPointer<LLControlVariable> 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<T>::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<LLControlVariable> 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<T>(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 T>
|
||||
class LLCachedCOAControl
|
||||
{
|
||||
LLCachedControl<T> *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<T>(mName,mDefault,gCOASavedSettings,mComment);
|
||||
|
||||
static LLCachedControl<bool> settings_per_account("AscentStoreSettingsPerAccount",false);
|
||||
mCOAConnection = settings_per_account.getControl()->getSignal()->connect(
|
||||
boost::bind(&LLCachedCOAControl<T>::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<T>(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<U32>(const U32& in, LLSD& out);
|
||||
template <> eControlType get_control_type<S32>(const S32& in, LLSD& out);
|
||||
template <> eControlType get_control_type<F32>(const F32& in, LLSD& out);
|
||||
template <> eControlType get_control_type<bool> (const bool& in, LLSD& out);
|
||||
// Yay BOOL, its really an S32.
|
||||
//template <> eControlType get_control_type<BOOL> (const BOOL& in, LLSD& out)
|
||||
template <> eControlType get_control_type<std::string>(const std::string& in, LLSD& out);
|
||||
template <> eControlType get_control_type<LLVector3>(const LLVector3& in, LLSD& out);
|
||||
template <> eControlType get_control_type<LLVector3d>(const LLVector3d& in, LLSD& out);
|
||||
template <> eControlType get_control_type<LLRect>(const LLRect& in, LLSD& out);
|
||||
template <> eControlType get_control_type<LLColor4>(const LLColor4& in, LLSD& out);
|
||||
template <> eControlType get_control_type<LLColor3>(const LLColor3& in, LLSD& out);
|
||||
template <> eControlType get_control_type<LLColor4U>(const LLColor4U& in, LLSD& out);
|
||||
template <> eControlType get_control_type<LLSD>(const LLSD& in, LLSD& out);
|
||||
#endif
|
||||
|
||||
@@ -294,7 +294,6 @@ void LLHUDText::renderText(BOOL for_select)
|
||||
|
||||
// *TODO: make this a per-text setting
|
||||
static LLCachedControl<LLColor4> background_chat_color("BackgroundChatColor", LLColor4(0,0,0,1.f));
|
||||
//static LLColor4 background_chat_color(0,0,0,1.f);
|
||||
static LLCachedControl<F32> chat_bubble_opacity("ChatBubbleOpacity", .5);
|
||||
LLColor4 bg_color = background_chat_color;
|
||||
bg_color.setAlpha(chat_bubble_opacity * alpha_factor);
|
||||
|
||||
@@ -54,8 +54,6 @@ extern std::map<std::string, LLControlGroup*> 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 <class T>
|
||||
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 T>
|
||||
class LLCachedControl
|
||||
{
|
||||
T mCachedValue;
|
||||
LLPointer<LLControlVariable> 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<T>::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<T>(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 T>
|
||||
class LLCachedCOAControl
|
||||
{
|
||||
LLCachedControl<T> *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<T>(mName,mDefault,gCOASavedSettings,mComment);
|
||||
|
||||
static LLCachedControl<bool> settings_per_account("AscentStoreSettingsPerAccount",false);
|
||||
mCOAConnection = settings_per_account.getControl()->getSignal()->connect(
|
||||
boost::bind(&LLCachedCOAControl<T>::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<T>(mName,mDefault,gCOASavedSettings,mComment);
|
||||
return true;
|
||||
}
|
||||
operator const T&() { return *mCachedControl; }
|
||||
};
|
||||
|
||||
template <> eControlType get_control_type<U32>(const U32& in, LLSD& out);
|
||||
template <> eControlType get_control_type<S32>(const S32& in, LLSD& out);
|
||||
template <> eControlType get_control_type<F32>(const F32& in, LLSD& out);
|
||||
template <> eControlType get_control_type<bool> (const bool& in, LLSD& out);
|
||||
// Yay BOOL, its really an S32.
|
||||
//template <> eControlType get_control_type<BOOL> (const BOOL& in, LLSD& out)
|
||||
template <> eControlType get_control_type<std::string>(const std::string& in, LLSD& out);
|
||||
template <> eControlType get_control_type<LLVector3>(const LLVector3& in, LLSD& out);
|
||||
template <> eControlType get_control_type<LLVector3d>(const LLVector3d& in, LLSD& out);
|
||||
template <> eControlType get_control_type<LLRect>(const LLRect& in, LLSD& out);
|
||||
template <> eControlType get_control_type<LLColor4>(const LLColor4& in, LLSD& out);
|
||||
template <> eControlType get_control_type<LLColor3>(const LLColor3& in, LLSD& out);
|
||||
template <> eControlType get_control_type<LLColor4U>(const LLColor4U& in, LLSD& out);
|
||||
template <> eControlType get_control_type<LLSD>(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());}
|
||||
|
||||
@@ -263,7 +263,7 @@ inline LLViewerObject *LLViewerObjectList::findObject(const LLUUID &id) const
|
||||
inline LLVOAvatar *LLViewerObjectList::findAvatar(const LLUUID &id) const
|
||||
{
|
||||
std::map<LLUUID, LLPointer<LLVOAvatar> >::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)
|
||||
|
||||
@@ -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<F32> render_deferred_sun_wash("RenderDeferredSunWash",.5f);
|
||||
static LLCachedControl<F32> render_shadow_noise("RenderShadowNoise",-.0001f);
|
||||
static LLCachedControl<F32> render_shadow_blur_size("RenderShadowBlurSize",.7f);
|
||||
static LLCachedControl<F32> render_ssao_scale("RenderSSAOScale",500);
|
||||
static LLCachedControl<S32> render_ssao_max_scale("RenderSSAOMaxScale",60);
|
||||
static LLCachedControl<F32> render_ssao_factor("RenderSSAOFactor",.3f);
|
||||
static LLCachedControl<LLVector3> render_ssao_effect("RenderSSAOEffect",LLVector3(.4f,1,0));
|
||||
static LLCachedControl<F32> 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()
|
||||
|
||||
Reference in New Issue
Block a user