From 38a565f71a54aaa66300a0ab593e366731aac769 Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Tue, 9 Oct 2012 12:30:38 -0700 Subject: Initial pass at getting a list of viewer objects with non-null material IDs. --- indra/llprimitive/lltextureentry.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/llprimitive/lltextureentry.h') diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index 437b85e03f..b681ce8ca7 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -30,6 +30,7 @@ #include "lluuid.h" #include "v4color.h" #include "llsd.h" +#include "llmaterialid.h" // These bits are used while unpacking TEM messages to tell which aspects of // the texture entry changed. @@ -121,6 +122,7 @@ public: S32 setTexGen(U8 texGen); S32 setMediaTexGen(U8 media); S32 setGlow(F32 glow); + S32 setMaterialID(const LLMaterialID& pMaterialID); virtual const LLUUID &getID() const { return mID; } const LLColor4 &getColor() const { return mColor; } @@ -139,6 +141,7 @@ public: U8 getTexGen() const { return mMediaFlags & TEM_TEX_GEN_MASK; } U8 getMediaTexGen() const { return mMediaFlags; } F32 getGlow() const { return mGlow; } + const LLMaterialID& getMaterialID() const { return mMaterialID; }; // *NOTE: it is possible for hasMedia() to return true, but getMediaData() to return NULL. // CONVERSELY, it is also possible for hasMedia() to return false, but getMediaData() @@ -193,6 +196,7 @@ protected: U8 mBump; // Bump map, shiny, and fullbright U8 mMediaFlags; // replace with web page, movie, etc. F32 mGlow; + LLMaterialID mMaterialID; // Note the media data is not sent via the same message structure as the rest of the TE LLMediaEntry* mMediaEntry; // The media data for the face -- cgit v1.3 From eda11a25a465dd87b187f63da661f2ce02925deb Mon Sep 17 00:00:00 2001 From: Geenz Date: Fri, 11 Jan 2013 06:37:21 -0500 Subject: Initial (largely complete) gamma correct rendering implementation. --- autobuild.xml | 60 ++++++++++++++++++++-- indra/llprimitive/lltextureentry.h | 2 + indra/llrender/llshadermgr.cpp | 3 ++ indra/llrender/llshadermgr.h | 4 ++ .../shaders/class1/deferred/alphaF.glsl | 1 + .../shaders/class1/deferred/fullbrightF.glsl | 1 + .../shaders/class1/deferred/pointLightF.glsl | 1 + .../shaders/class1/deferred/postDeferredF.glsl | 3 +- .../class1/deferred/postDeferredNoDoFF.glsl | 3 +- .../shaders/class1/deferred/softenLightF.glsl | 14 +++-- .../class1/lighting/lightFullbrightAlphaMaskF.glsl | 4 +- .../shaders/class2/deferred/alphaF.glsl | 1 + .../shaders/class2/deferred/softenLightF.glsl | 13 +++-- .../class2/windlight/atmosphericsVarsF.glsl | 4 +- .../class2/windlight/atmosphericsVarsV.glsl | 8 +-- indra/newview/lldrawpoolalpha.cpp | 17 ++++++ indra/newview/llviewerdisplay.cpp | 2 + indra/newview/llwlparamset.cpp | 8 +++ indra/newview/pipeline.cpp | 29 ++++++++--- indra/newview/pipeline.h | 3 +- 20 files changed, 152 insertions(+), 29 deletions(-) (limited to 'indra/llprimitive/lltextureentry.h') diff --git a/autobuild.xml b/autobuild.xml index 017427278e..0af41b578b 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -498,9 +498,9 @@ archive hash - 61ead113e6479452e6b690c84b4e9d30 + 481a87c5a964a4fa33b7411036d4c71d url - http://s3-proxy.lindenlab.com/private-builds-secondlife-com/hg/repo/3p-fmod-private/rev/221852/arch/Darwin/installer/fmod-3.75-darwin-20110222.tar.bz2 + file:///Users/geenz/Devel/3p-fmod/fmod-3.75-darwin-20120315.tar.bz2 name darwin @@ -1062,9 +1062,9 @@ archive hash - a5b2dff0d97b643227a58473e5c57906 + 691008f5ec3cec2d7fc9d8814036d25b url - http://s3-proxy.lindenlab.com/private-builds-secondlife-com/hg/repo/3p-kdu-private/rev/256978/arch/Darwin/installer/kdu-7.0.0-darwin-20120515.tar.bz2 + file:///Users/geenz/Devel/kakadu/lib/Mac-x86-32-gcc/kdu.tar.bz2 name darwin @@ -1343,6 +1343,58 @@ version 0.2 + llphysicsextensions_tpv + + license + TEMPORARY + license_file + LICENSES/llphysicsextensions.txt + name + llphysicsextensions_tpv + platforms + + darwin + + archive + + hash + 51313d6a13b946b1b8dd14412057344c + hash_algorithm + md5 + url + file:///Users/geenz/Devel/llphysicsextensions_tpv-0.3-darwin-20121227.tar.bz2 + + name + darwin + + linux + + archive + + hash + 3fba5443cb0b869005591b143fa48a42 + url + file:///build/llPhysicsExtensions/llphysicsextensions_tpv-0.3-linux-20120814.tar.bz2 + + name + linux + + windows + + archive + + hash + 1444bf3b1305a5e6909123d691991d4b + url + file:///c:/static/llphysicsextensions_tpv-0.3-windows-20120814.tar.bz2 + + name + windows + + + version + 0.3 + llqtwebkit license diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index b681ce8ca7..ff1cc65bba 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -31,6 +31,7 @@ #include "v4color.h" #include "llsd.h" #include "llmaterialid.h" +#include "llmaterial.h" // These bits are used while unpacking TEM messages to tell which aspects of // the texture entry changed. @@ -197,6 +198,7 @@ protected: U8 mMediaFlags; // replace with web page, movie, etc. F32 mGlow; LLMaterialID mMaterialID; + LLMaterialPtr mMaterial; // Note the media data is not sent via the same message structure as the rest of the TE LLMediaEntry* mMediaEntry; // The media data for the face diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 3b1ec281c9..e52411ebe5 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1121,6 +1121,9 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("lightMap"); mReservedUniforms.push_back("bloomMap"); mReservedUniforms.push_back("projectionMap"); + + mReservedUniforms.push_back("global_gamma"); + mReservedUniforms.push_back("texture_gamma"); llassert(mReservedUniforms.size() == END_RESERVED_UNIFORMS); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 4b93aae735..a711a64919 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -164,6 +164,10 @@ public: DEFERRED_LIGHT, DEFERRED_BLOOM, DEFERRED_PROJECTION, + + GLOBAL_GAMMA, + TEXTURE_GAMMA, + END_RESERVED_UNIFORMS } eGLSLReservedUniforms; diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index dd87ddb330..ef04ef5ce6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -59,6 +59,7 @@ void main() vec4 pos = vec4(vary_position, 1.0); vec4 diff= diffuseLookup(vary_texcoord0.xy); + diff.rgb = pow(diff.rgb, vec3(2.2)); vec4 col = vec4(vary_ambient + vary_directional.rgb, vertex_color.a); vec4 color = diff * col; diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index 36433a5827..b6a9417fe7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -43,6 +43,7 @@ void main() float shadow = 1.0; vec4 color = diffuseLookup(vary_texcoord0.xy)*vertex_color; + color.rgb = pow(color.rgb, vec3(2.2)); color.rgb = fullbrightAtmosTransport(color.rgb); diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index 6e5ac8317b..fa1572e692 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -108,6 +108,7 @@ void main() if (spec.a > 0.0) { float sa = dot(normalize(lv-normalize(pos)),norm); + spec.rgb += pow(1 - dot(-normalize(pos), norm), 2) * da * 3; if (sa > 0.0) { sa = texture2D(lightFunc, vec2(sa, spec.a)).r * min(dist_atten*4.0, 1.0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl index bf362e21a4..3f57b006cd 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl @@ -37,6 +37,7 @@ uniform mat4 inv_proj; uniform vec2 screen_res; uniform float max_cof; uniform float res_scale; +uniform float global_gamma; VARYING vec2 vary_fragcoord; @@ -123,6 +124,6 @@ void main() diff /= w; } - + diff.rgb = pow(diff.rgb, vec3(1.0/global_gamma)); frag_color = diff; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl index eb5beeef39..c891c4e445 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl @@ -35,12 +35,13 @@ uniform sampler2DRect diffuseRect; uniform sampler2D bloomMap; uniform vec2 screen_res; +uniform float global_gamma; VARYING vec2 vary_fragcoord; void main() { vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy); - + diff.rgb = pow(diff.rgb, vec3(1.0/global_gamma)); vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy/screen_res); frag_color = diff + bloom; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 14eaafeb68..87cdf1026f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -77,6 +77,11 @@ vec3 vary_AtmosAttenuation; uniform mat4 inv_proj; uniform vec2 screen_res; +vec3 samplesRGB(vec3 color) +{ + return pow(color, vec3(2.2)); +} + vec4 getPosition_d(vec2 pos_screen, float depth) { vec2 sc = pos_screen.xy*2.0; @@ -101,22 +106,21 @@ vec3 getPositionEye() } vec3 getSunlitColor() { - return vary_SunlitColor; + return samplesRGB(vary_SunlitColor) * 4.4; } vec3 getAmblitColor() { - return vary_AmblitColor; + return samplesRGB((vary_AmblitColor)) * 2.2; } vec3 getAdditiveColor() { - return vary_AdditiveColor; + return samplesRGB(vary_AdditiveColor) * 2.2; } vec3 getAtmosAttenuation() { return vary_AtmosAttenuation; } - void setPositionEye(vec3 v) { vary_PositionEye = v; @@ -310,7 +314,7 @@ void main() //add environmentmap vec3 env_vec = env_mat * refnormpersp; - col = mix(col.rgb, textureCube(environmentMap, env_vec).rgb, + col = mix(col.rgb, samplesRGB(textureCube(environmentMap, env_vec).rgb) * 2.2, max(spec.a-diffuse.a*2.0, 0.0)); } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl index 6c34643aab..9543be562b 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl @@ -37,6 +37,8 @@ vec3 fullbrightScaleSoftClip(vec3 light); VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; +uniform float texture_gamma; + void fullbright_lighting() { vec4 color = diffuseLookup(vary_texcoord0.xy) * vertex_color; @@ -45,7 +47,7 @@ void fullbright_lighting() { discard; } - + color.rgb = pow(color.rgb, vec3(texture_gamma)); color.rgb = fullbrightAtmosTransport(color.rgb); color.rgb = fullbrightScaleSoftClip(color.rgb); diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 12706f130b..359864556d 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -149,6 +149,7 @@ void main() } vec4 diff = diffuseLookup(vary_texcoord0.xy); + diff.rgb = pow(diff.rgb, vec3(2.2)); vec4 col = vec4(vary_ambient + vary_directional.rgb*shadow, vertex_color.a); vec4 color = diff * col; diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 457189b48e..bf4c476138 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -79,6 +79,11 @@ vec3 vary_AmblitColor; vec3 vary_AdditiveColor; vec3 vary_AtmosAttenuation; +vec3 samplesRGB(vec3 color) +{ + return pow(color, vec3(2.2)); +} + vec4 getPosition_d(vec2 pos_screen, float depth) { vec2 sc = pos_screen.xy*2.0; @@ -103,15 +108,15 @@ vec3 getPositionEye() } vec3 getSunlitColor() { - return vary_SunlitColor; + return samplesRGB(vary_SunlitColor) * 4.4; } vec3 getAmblitColor() { - return vary_AmblitColor; + return samplesRGB(vary_AmblitColor) * 2.2; } vec3 getAdditiveColor() { - return vary_AdditiveColor; + return samplesRGB(vary_AdditiveColor) * 2.2; } vec3 getAtmosAttenuation() { @@ -318,7 +323,7 @@ void main() //add environmentmap vec3 env_vec = env_mat * refnormpersp; - col = mix(col.rgb, textureCube(environmentMap, env_vec).rgb, + col = mix(col.rgb, samplesRGB(textureCube(environmentMap, env_vec).rgb) * 2.2, max(spec.a-diffuse.a*2.0, 0.0)); } diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsF.glsl index 765b0927c3..dd7de9f123 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsF.glsl @@ -27,7 +27,7 @@ VARYING vec3 vary_SunlitColor; VARYING vec3 vary_AdditiveColor; VARYING vec3 vary_AtmosAttenuation; - +uniform float global_gamma; vec3 getSunlitColor() { return vec3(0,0,0); @@ -38,7 +38,7 @@ vec3 getAmblitColor() } vec3 getAdditiveColor() { - return vary_AdditiveColor; + return pow(vary_AdditiveColor, vec3(global_gamma)) * global_gamma; } vec3 getAtmosAttenuation() { diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsV.glsl index 99dbee15ee..61f3088648 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsV.glsl @@ -33,18 +33,20 @@ vec3 sunlit_color; vec3 amblit_color; vec3 position_eye; +uniform float global_gamma; + vec3 getSunlitColor() { - return sunlit_color; + return pow(sunlit_color, vec3(global_gamma)) * global_gamma; } vec3 getAmblitColor() { - return amblit_color; + return pow(amblit_color, vec3(global_gamma)) * global_gamma; } vec3 getAdditiveColor() { - return additive_color; + return pow(additive_color, vec3(global_gamma)) * global_gamma; } vec3 getAtmosAttenuation() { diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 313b310e1e..33615eb075 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -240,6 +240,12 @@ void LLDrawPoolAlpha::render(S32 pass) { fullbright_shader->bind(); fullbright_shader->setMinimumAlpha(0.33f); + if (LLPipeline::sRenderingHUDs || !LLPipeline::sRenderDeferred) + { + fullbright_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0f); + } else { + fullbright_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + } } pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); //LLGLSLShader::bindNoShader(); @@ -423,6 +429,17 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) if (use_shaders) { target_shader = fullbright_shader; + if (LLPipeline::sRenderDeferred) + { + if (params.mFace->getViewerObject()->isHUDAttachment()) + { + target_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0); + } else { + target_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2); + } + } else { + target_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0); + } } else { diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index d58ee05fb6..feceee5709 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -1051,6 +1051,7 @@ void render_hud_attachments() if (LLPipeline::sShowHUDAttachments && !gDisconnected && setup_hud_matrices()) { + LLPipeline::sRenderingHUDs = TRUE; LLCamera hud_cam = *LLViewerCamera::getInstance(); LLVector3 origin = hud_cam.getOrigin(); hud_cam.setOrigin(-1.f,0,0); @@ -1124,6 +1125,7 @@ void render_hud_attachments() gPipeline.toggleRenderDebugFeature((void*) LLPipeline::RENDER_DEBUG_FEATURE_UI); } LLPipeline::sUseOcclusion = use_occlusion; + LLPipeline::sRenderingHUDs = FALSE; } gGL.matrixMode(LLRender::MM_PROJECTION); gGL.popMatrix(); diff --git a/indra/newview/llwlparamset.cpp b/indra/newview/llwlparamset.cpp index b04d30db55..0b5e0235ee 100644 --- a/indra/newview/llwlparamset.cpp +++ b/indra/newview/llwlparamset.cpp @@ -33,6 +33,7 @@ #include "llglslshader.h" #include "lluictrlfactory.h" #include "llsliderctrl.h" +#include "pipeline.h" #include @@ -127,6 +128,13 @@ void LLWLParamSet::update(LLGLSLShader * shader) const } } } + + if (LLPipeline::sRenderDeferred && !LLPipeline::sReflectionRender) + { + shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 2.2); + } else { + shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 1.0); + } } void LLWLParamSet::set(const std::string& paramName, float x) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 24144382dc..205598060a 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -377,6 +377,7 @@ BOOL LLPipeline::sRenderDeferred = FALSE; BOOL LLPipeline::sMemAllocationThrottled = FALSE; S32 LLPipeline::sVisibleLightCount = 0; F32 LLPipeline::sMinRenderSize = 0.f; +BOOL LLPipeline::sRenderingHUDs; static LLCullResult* sCull = NULL; @@ -396,7 +397,7 @@ void validate_framebuffer_object(); bool addDeferredAttachments(LLRenderTarget& target) { - return target.addColorAttachment(GL_RGBA) && //specular + return target.addColorAttachment(GL_SRGB_ALPHA) && //specular target.addColorAttachment(GL_RGB10_A2); //normal+z } @@ -898,11 +899,11 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) BOOL ssao = RenderDeferredSSAO; //allocate deferred rendering color buffers - if (!mDeferredScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; + if (!mDeferredScreen.allocate(resX, resY, GL_SRGB8_ALPHA8, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; if (!mDeferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; if (!addDeferredAttachments(mDeferredScreen)) return false; - if (!mScreen.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; + if (!mScreen.allocate(resX, resY, GL_RGBA12, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; if (samples > 0) { if (!mFXAABuffer.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; @@ -3602,8 +3603,8 @@ void LLPipeline::postSort(LLCamera& camera) for (LLCullResult::sg_iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i) { LLSpatialGroup* group = *i; - if (sUseOcclusion && - group->isOcclusionState(LLSpatialGroup::OCCLUDED) || + if ((sUseOcclusion && + group->isOcclusionState(LLSpatialGroup::OCCLUDED)) || (RenderAutoHideSurfaceAreaLimit > 0.f && group->mSurfaceArea > RenderAutoHideSurfaceAreaLimit*llmax(group->mObjectBoxSize, 10.f))) { @@ -5034,8 +5035,8 @@ void LLPipeline::renderDebug() LLSpatialPartition* part = region->getSpatialPartition(i); if (part) { - if ( hud_only && (part->mDrawableType == RENDER_TYPE_HUD || part->mDrawableType == RENDER_TYPE_HUD_PARTICLES) || - !hud_only && hasRenderType(part->mDrawableType) ) + if ( (hud_only && (part->mDrawableType == RENDER_TYPE_HUD || part->mDrawableType == RENDER_TYPE_HUD_PARTICLES)) || + (!hud_only && hasRenderType(part->mDrawableType)) ) { part->renderDebug(); } @@ -7382,6 +7383,13 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) mScreen.bindTexture(0, channel); gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); } + + if (!LLViewerCamera::getInstance()->cameraUnderWater()) + { + shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 2.2); + } else { + shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 1.0); + } shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); @@ -7423,6 +7431,13 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) { mScreen.bindTexture(0, channel); } + + if (!LLViewerCamera::getInstance()->cameraUnderWater()) + { + shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 2.2); + } else { + shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 1.0); + } gGL.begin(LLRender::TRIANGLE_STRIP); gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 36abeca295..e264081910 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -554,7 +554,8 @@ public: static BOOL sRenderDeferred; static BOOL sMemAllocationThrottled; static S32 sVisibleLightCount; - static F32 sMinRenderSize; + static F32 sMinRenderSize; + static BOOL sRenderingHUDs; //screen texture U32 mScreenWidth; -- cgit v1.3 From 5f03e197f4cfb43de93dc42b16b54beafccd376a Mon Sep 17 00:00:00 2001 From: Geenz Date: Fri, 25 Jan 2013 17:54:38 -0500 Subject: Trying to set materials up for rendering! Yay! --- indra/llprimitive/llmaterial.h | 2 +- indra/llprimitive/llprimitive.cpp | 6 +- indra/llprimitive/llprimitive.h | 1 + indra/llprimitive/llprimtexturelist.cpp | 9 ++ indra/llprimitive/llprimtexturelist.h | 2 + indra/llprimitive/lltextureentry.cpp | 10 ++ indra/llprimitive/lltextureentry.h | 2 + indra/llrender/llshadermgr.cpp | 2 + indra/llrender/llshadermgr.h | 2 + indra/newview/lldrawable.cpp | 47 ++++++++++ indra/newview/lldrawable.h | 2 + indra/newview/lldrawpoolbump.cpp | 13 ++- indra/newview/lldrawpoolbump.h | 5 +- indra/newview/llface.cpp | 42 +++++++++ indra/newview/llface.h | 6 ++ indra/newview/llselectmgr.cpp | 2 +- indra/newview/llspatialpartition.h | 13 ++- indra/newview/llviewerobject.cpp | 157 ++++++++++++++++++++++++++++++-- indra/newview/llviewerobject.h | 10 ++ indra/newview/llvovolume.cpp | 64 +++++++++++-- indra/newview/llvovolume.h | 1 + 21 files changed, 378 insertions(+), 20 deletions(-) (limited to 'indra/llprimitive/lltextureentry.h') diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index da364e548c..6f94cfda17 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -60,7 +60,7 @@ public: F32 getSpecularRotation() const { return mSpecularRotation; } void setSpecularRotation(F32 rot) { mSpecularRotation = rot; } - const LLColor4U& getSpecularLightColor() const { return mSpecularLightColor; } + const LLColor4U getSpecularLightColor() const { return mSpecularLightColor; } void setSpecularLightColor(const LLColor4U& color) { mSpecularLightColor = color; } U8 getSpecularLightExponent() const { return mSpecularLightExponent; } void setSpecularLightExponent(U8 exponent) { mSpecularLightExponent = exponent; } diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 86aa371368..94df529b25 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -271,7 +271,6 @@ S32 LLPrimitive::setTEScale(const U8 index, const F32 s, const F32 t) return mTextureList.setScale(index, s, t); } - // BUG: slow - done this way because texture entries have some // voodoo related to texture coords S32 LLPrimitive::setTEScaleS(const U8 index, const F32 s) @@ -372,6 +371,10 @@ S32 LLPrimitive::setTEMaterialID(const U8 index, const LLMaterialID& pMaterialID return mTextureList.setMaterialID(index, pMaterialID); } +S32 LLPrimitive::setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams) +{ + return mTextureList.setMaterialParams(index, pMaterialParams); +} LLPCode LLPrimitive::legacyToPCode(const U8 legacy) { @@ -1349,6 +1352,7 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam retval |= setTEMediaTexGen(i, media_flags[i]); retval |= setTEGlow(i, (F32)glow[i] / (F32)0xFF); retval |= setTEMaterialID(i, material_ids[i]); + coloru = LLColor4U(colors + 4*i); // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f) diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index e1635740ef..6a9c5e9639 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -355,6 +355,7 @@ public: virtual S32 setTEMediaFlags(const U8 te, const U8 flags); virtual S32 setTEGlow(const U8 te, const F32 glow); virtual S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); + virtual S32 setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed void copyTEs(const LLPrimitive *primitive); diff --git a/indra/llprimitive/llprimtexturelist.cpp b/indra/llprimitive/llprimtexturelist.cpp index 20438578b3..c0923315cb 100644 --- a/indra/llprimitive/llprimtexturelist.cpp +++ b/indra/llprimitive/llprimtexturelist.cpp @@ -369,6 +369,15 @@ S32 LLPrimTextureList::setMaterialID(const U8 index, const LLMaterialID& pMateri return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams) +{ + if (index < mEntryList.size()) + { + return mEntryList[index]->setMaterialParams(pMaterialParams); + } + return TEM_CHANGE_NONE; +} + S32 LLPrimTextureList::size() const { return mEntryList.size(); diff --git a/indra/llprimitive/llprimtexturelist.h b/indra/llprimitive/llprimtexturelist.h index 691df44c18..d7fabbbb79 100644 --- a/indra/llprimitive/llprimtexturelist.h +++ b/indra/llprimitive/llprimtexturelist.h @@ -31,6 +31,7 @@ #include "lluuid.h" #include "v3color.h" #include "v4color.h" +#include "llmaterial.h" class LLTextureEntry; @@ -104,6 +105,7 @@ public: S32 setMediaFlags(const U8 index, const U8 media_flags); S32 setGlow(const U8 index, const F32 glow); S32 setMaterialID(const U8 index, const LLMaterialID& pMaterialID); + S32 setMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); S32 size() const; diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index b04fa809d2..23b15b697c 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -540,6 +540,16 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) return TEM_CHANGE_NONE; } +S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) +{ + if (mMaterial != pMaterialParams) + { + mMaterial = pMaterialParams; + return TEM_CHANGE_TEXTURE; + } + return TEM_CHANGE_NONE; +} + void LLTextureEntry::setMediaData(const LLMediaEntry &media_entry) { mMediaFlags |= MF_HAS_MEDIA; diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index ff1cc65bba..c443ebcb30 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -124,6 +124,7 @@ public: S32 setMediaTexGen(U8 media); S32 setGlow(F32 glow); S32 setMaterialID(const LLMaterialID& pMaterialID); + S32 setMaterialParams(const LLMaterialPtr pMaterialParams); virtual const LLUUID &getID() const { return mID; } const LLColor4 &getColor() const { return mColor; } @@ -143,6 +144,7 @@ public: U8 getMediaTexGen() const { return mMediaFlags; } F32 getGlow() const { return mGlow; } const LLMaterialID& getMaterialID() const { return mMaterialID; }; + const LLMaterialPtr getMaterialParams() const { return mMaterial; }; // *NOTE: it is possible for hasMedia() to return true, but getMediaData() to return NULL. // CONVERSELY, it is also possible for hasMedia() to return false, but getMediaData() diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index e52411ebe5..b6b39028d3 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1124,6 +1124,8 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("global_gamma"); mReservedUniforms.push_back("texture_gamma"); + + mReservedUniforms.push_back("specular_color"); llassert(mReservedUniforms.size() == END_RESERVED_UNIFORMS); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index a711a64919..a89e031906 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -168,6 +168,8 @@ public: GLOBAL_GAMMA, TEXTURE_GAMMA, + SPECULAR_COLOR, + END_RESERVED_UNIFORMS } eGLSLReservedUniforms; diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 4894d63e13..1ca2344c41 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -300,6 +300,53 @@ LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep) } +LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLViewerTexture *normalp) +{ + LLMemType mt(LLMemType::MTYPE_DRAWABLE); + + LLFace *face; + face = new LLFace(this, mVObjp); + + face->setTEOffset(mFaces.size()); + face->setTexture(texturep); + face->setNormalMap(normalp); + face->setPoolType(gPipeline.getPoolTypeFromTE(te, texturep)); + + mFaces.push_back(face); + + if (isState(UNLIT)) + { + face->setState(LLFace::FULLBRIGHT); + } + + return face; + +} + +LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLViewerTexture *normalp, LLViewerTexture *specularp) +{ + LLMemType mt(LLMemType::MTYPE_DRAWABLE); + + LLFace *face; + face = new LLFace(this, mVObjp); + + face->setTEOffset(mFaces.size()); + face->setTexture(texturep); + face->setNormalMap(normalp); + face->setSpecularMap(specularp); + face->setPoolType(gPipeline.getPoolTypeFromTE(te, texturep)); + + mFaces.push_back(face); + + if (isState(UNLIT)) + { + face->setState(LLFace::FULLBRIGHT); + } + + return face; + +} + void LLDrawable::setNumFaces(const S32 newFaces, LLFacePool *poolp, LLViewerTexture *texturep) { if (newFaces == (S32)mFaces.size()) diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index b1e32bdb5b..13089f4f26 100644 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -147,6 +147,8 @@ public: //void removeFace(const S32 i); // SJB: Avoid using this, it's slow LLFace* addFace(LLFacePool *poolp, LLViewerTexture *texturep); LLFace* addFace(const LLTextureEntry *te, LLViewerTexture *texturep); + LLFace* addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLViewerTexture *normalp); + LLFace* addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLViewerTexture *normalp, LLViewerTexture *specularp); void deleteFaces(S32 offset, S32 count); void setNumFaces(const S32 numFaces, LLFacePool *poolp, LLViewerTexture *texturep); void setNumFacesFast(const S32 numFaces, LLFacePool *poolp, LLViewerTexture *texturep); diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 718133ba29..d613def1bd 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -632,6 +632,11 @@ void LLDrawPoolBump::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL BOOL LLDrawPoolBump::bindBumpMap(LLDrawInfo& params, S32 channel) { U8 bump_code = params.mBump; + if (params.mNormalMap.notNull()) + { + bump_code = BE_CUSTOM; + return bindBumpMap(bump_code, params.mNormalMap, params.mVSize, channel); + } return bindBumpMap(bump_code, params.mTexture, params.mVSize, channel); } @@ -670,7 +675,9 @@ BOOL LLDrawPoolBump::bindBumpMap(U8 bump_code, LLViewerTexture* texture, F32 vsi case BE_DARKNESS: bump = gBumpImageList.getBrightnessDarknessImage( tex, bump_code ); break; - + case BE_CUSTOM: + bump = tex; + break; default: if( bump_code < LLStandardBumpmap::sStandardBumpmapCount ) { @@ -855,7 +862,9 @@ void LLDrawPoolBump::renderDeferred(S32 pass) for (LLCullResult::drawinfo_iterator i = begin; i != end; ++i) { LLDrawInfo& params = **i; - + + gDeferredBumpProgram.uniform4fv(LLShaderMgr::SPECULAR_COLOR, 4, (GLfloat*)params.mSpecColor.mV); + LLDrawPoolBump::bindBumpMap(params, bump_channel); pushBatch(params, mask, TRUE); } diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h index 476b1d41b7..aaf0bdf36f 100644 --- a/indra/newview/lldrawpoolbump.h +++ b/indra/newview/lldrawpoolbump.h @@ -100,8 +100,9 @@ enum EBumpEffect BE_NO_BUMP = 0, BE_BRIGHTNESS = 1, BE_DARKNESS = 2, - BE_STANDARD_0 = 3, // Standard must always be the last one - BE_COUNT = 4 + BE_CUSTOM = 3, + BE_STANDARD_0 = 4, // Standard must always be the last one + BE_COUNT = 5 }; //////////////////////////////////////////////////////////////// diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 605cb81c10..01cbfafe16 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -316,6 +316,48 @@ void LLFace::setTexture(LLViewerTexture* tex) mTexture = tex ; } +void LLFace::setNormalMap(LLViewerTexture* tex) +{ + if(mNormalMap == tex) + { + return ; + } + + if(mNormalMap.notNull()) + { + mNormalMap->removeFace(this) ; + removeAtlas() ; + } + + if(tex) + { + tex->addFace(this) ; + } + + mNormalMap = tex ; +} + +void LLFace::setSpecularMap(LLViewerTexture* tex) +{ + if(mSpecMap == tex) + { + return ; + } + + if(mSpecMap.notNull()) + { + mSpecMap->removeFace(this) ; + removeAtlas() ; + } + + if(tex) + { + tex->addFace(this) ; + } + + mSpecMap = tex ; +} + void LLFace::dirtyTexture() { LLDrawable* drawablep = getDrawable(); diff --git a/indra/newview/llface.h b/indra/newview/llface.h index de4d03351c..cb76c6e8a6 100644 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -111,6 +111,8 @@ public: void setTextureIndex(U8 index); U8 getTextureIndex() const { return mTextureIndex; } void setTexture(LLViewerTexture* tex) ; + void setNormalMap(LLViewerTexture* tex); + void setSpecularMap(LLViewerTexture* tex); void switchTexture(LLViewerTexture* new_texture); void dirtyTexture(); LLXformMatrix* getXform() const { return mXform; } @@ -266,6 +268,8 @@ public: F32 mLastSkinTime; F32 mLastMoveTime; LLMatrix4* mTextureMatrix; + LLMatrix4* mSpecMapMatrix; + LLMatrix4* mNormalMapMatrix; LLDrawInfo* mDrawInfo; private: @@ -285,6 +289,8 @@ private: LLXformMatrix* mXform; LLPointer mTexture; + LLPointer mSpecMap; + LLPointer mNormalMap; LLPointer mDrawablep; LLPointer mVObjp; S32 mTEOffset; diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index c3c37141ed..ff4c120623 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -1927,7 +1927,7 @@ void LLSelectMgr::selectionSetMedia(U8 media_type, const LLSD &media_data) llassert(mMediaData.isMap()); const LLTextureEntry *texture_entry = object->getTE(te); if (!mMediaData.isMap() || - (NULL != texture_entry) && !texture_entry->hasMedia() && !mMediaData.has(LLMediaEntry::HOME_URL_KEY)) + ((NULL != texture_entry) && !texture_entry->hasMedia() && !mMediaData.has(LLMediaEntry::HOME_URL_KEY))) { // skip adding/updating media } diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index b1706d9d35..2c4f6754ec 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -119,6 +119,17 @@ public: LL_ALIGN_16(LLFace* mFace); //associated face F32 mDistance; U32 mDrawMode; + + LLMaterialID *mMaterialID; // If this is false, the following parameters are unused. + LLPointer mSpecularMap; + const LLMatrix4* mSpecularMapMatrix; + LLPointer mNormalMap; + const LLMatrix4* mNormalMapMatrix; + LLVector4 mSpecColor; // XYZ = Specular RGB, W = Specular Exponent + F32 mEnvIntensity; + F32 mAlphaMaskCutoff; + U8 mDiffuseAlphaMode; + struct CompareTexture { @@ -169,7 +180,7 @@ public: } }; - + struct CompareBump { bool operator()(const LLPointer& lhs, const LLPointer& rhs) diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 347d82d492..4490e51493 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -202,6 +202,8 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe mTotalCRC(0), mListIndex(-1), mTEImages(NULL), + mTENormalMaps(NULL), + mTESpecularMaps(NULL), mGLName(0), mbCanSelect(TRUE), mFlags(0), @@ -322,6 +324,18 @@ void LLViewerObject::deleteTEImages() { delete[] mTEImages; mTEImages = NULL; + + if (mTENormalMaps != NULL) + { + delete[] mTENormalMaps; + mTENormalMaps = NULL; + } + + if (mTESpecularMaps != NULL) + { + delete[] mTESpecularMaps; + mTESpecularMaps = NULL; + } } void LLViewerObject::markDead() @@ -3935,25 +3949,39 @@ void LLViewerObject::setNumTEs(const U8 num_tes) { LLPointer *new_images; new_images = new LLPointer[num_tes]; + + LLPointer *new_normmaps; + new_normmaps = new LLPointer[num_tes]; + + LLPointer *new_specmaps; + new_specmaps = new LLPointer[num_tes]; for (i = 0; i < num_tes; i++) { if (i < getNumTEs()) { new_images[i] = mTEImages[i]; + new_normmaps[i] = mTENormalMaps[i]; + new_specmaps[i] = mTESpecularMaps[i]; } else if (getNumTEs()) { new_images[i] = mTEImages[getNumTEs()-1]; + new_normmaps[i] = mTENormalMaps[i]; + new_specmaps[i] = mTESpecularMaps[i]; } else { new_images[i] = NULL; + new_normmaps[i] = NULL; + new_specmaps[i] = NULL; } } deleteTEImages(); mTEImages = new_images; + mTENormalMaps = new_normmaps; + mTESpecularMaps = new_specmaps; } else { @@ -4032,12 +4060,18 @@ void LLViewerObject::sendTEUpdate() const void LLViewerObject::setTE(const U8 te, const LLTextureEntry &texture_entry) { LLPrimitive::setTE(te, texture_entry); -// This doesn't work, don't get any textures. -// if (mDrawable.notNull() && mDrawable->isVisible()) -// { - const LLUUID& image_id = getTE(te)->getID(); - mTEImages[te] = LLViewerTextureManager::getFetchedTexture(image_id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); -// } + + const LLUUID& image_id = getTE(te)->getID(); + mTEImages[te] = LLViewerTextureManager::getFetchedTexture(image_id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + + if (getTE(te)->getMaterialParams() != NULL) + { + const LLUUID& norm_id = getTE(te)->getMaterialParams()->getNormalID(); + mTENormalMaps[te] = LLViewerTextureManager::getFetchedTexture(norm_id, TRUE, LLViewerTexture::BOOST_BUMP, LLViewerTexture::LOD_TEXTURE); + + const LLUUID& spec_id = getTE(te)->getMaterialParams()->getSpecularID(); + mTESpecularMaps[te] = LLViewerTextureManager::getFetchedTexture(spec_id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + } } void LLViewerObject::setTEImage(const U8 te, LLViewerTexture *imagep) @@ -4072,6 +4106,46 @@ S32 LLViewerObject::setTETextureCore(const U8 te, const LLUUID& uuid, LLHost hos return retval; } +S32 LLViewerObject::setTENormalMapCore(const U8 te, const LLUUID& uuid, LLHost host) +{ + LL_INFOS("Materials") << "Maybe normal maps! " << uuid << LL_ENDL; + S32 retval = 0; + if (uuid != getTE(te)->getMaterialParams()->getNormalID() || + uuid == LLUUID::null) + { + LL_INFOS("Materials") << "Normal maps! " << uuid << LL_ENDL; + retval = TEM_CHANGE_TEXTURE; + getTE(te)->getMaterialParams()->setNormalID(uuid); + mTENormalMaps[te] = LLViewerTextureManager::getFetchedTexture(uuid, TRUE, LLViewerTexture::BOOST_BUMP, LLViewerTexture::LOD_TEXTURE, 0, 0, host); + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); + } + } + return retval; +} + +S32 LLViewerObject::setTESpecularMapCore(const U8 te, const LLUUID& uuid, LLHost host) +{ + LL_INFOS("Materials") << "Maybe specular maps! " << uuid << LL_ENDL; + S32 retval = 0; + if (uuid != getTE(te)->getMaterialParams()->getSpecularID() || + uuid == LLUUID::null) + { + LL_INFOS("Materials") << "Specular maps! " << uuid << LL_ENDL; + retval = TEM_CHANGE_TEXTURE; + getTE(te)->getMaterialParams()->setSpecularID(uuid); + mTESpecularMaps[te] = LLViewerTextureManager::getFetchedTexture(uuid, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, host); + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); + } + } + return retval; +} + //virtual void LLViewerObject::changeTEImage(S32 index, LLViewerTexture* new_image) { @@ -4082,12 +4156,39 @@ void LLViewerObject::changeTEImage(S32 index, LLViewerTexture* new_image) mTEImages[index] = new_image ; } +void LLViewerObject::changeTENormalMap(S32 index, LLViewerTexture* new_image) +{ + if(index < 0 || index >= getNumTEs()) + { + return ; + } + mTENormalMaps[index] = new_image ; +} + +void LLViewerObject::changeTESpecularMap(S32 index, LLViewerTexture* new_image) +{ + if(index < 0 || index >= getNumTEs()) + { + return ; + } + mTESpecularMaps[index] = new_image ; +} + S32 LLViewerObject::setTETexture(const U8 te, const LLUUID& uuid) { // Invalid host == get from the agent's sim return setTETextureCore(te, uuid, LLHost::invalid); } +S32 LLViewerObject::setTENormalMap(const U8 te, const LLUUID& uuid) +{ + return setTENormalMapCore(te, uuid, LLHost::invalid); +} + +S32 LLViewerObject::setTESpecularMap(const U8 te, const LLUUID& uuid) +{ + return setTESpecularMapCore(te, uuid, LLHost::invalid); +} S32 LLViewerObject::setTEColor(const U8 te, const LLColor3& color) { @@ -4369,6 +4470,50 @@ LLViewerTexture *LLViewerObject::getTEImage(const U8 face) const } +LLViewerTexture *LLViewerObject::getTENormalMap(const U8 face) const +{ + // llassert(mTEImages); + + if (face < getNumTEs()) + { + LLViewerTexture* image = mTENormalMaps[face]; + if (image) + { + return image; + } + else + { + return (LLViewerTexture*)(LLViewerFetchedTexture::sDefaultImagep); + } + } + + llerrs << llformat("Requested Image from invalid face: %d/%d",face,getNumTEs()) << llendl; + + return NULL; +} + +LLViewerTexture *LLViewerObject::getTESpecularMap(const U8 face) const +{ + // llassert(mTEImages); + + if (face < getNumTEs()) + { + LLViewerTexture* image = mTESpecularMaps[face]; + if (image) + { + return image; + } + else + { + return (LLViewerTexture*)(LLViewerFetchedTexture::sDefaultImagep); + } + } + + llerrs << llformat("Requested Image from invalid face: %d/%d",face,getNumTEs()) << llendl; + + return NULL; +} + void LLViewerObject::fitFaceTexture(const U8 face) { llinfos << "fitFaceTexture not implemented" << llendl; diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 255d0cd080..7b98c01243 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -292,7 +292,11 @@ public: /*virtual*/ void setNumTEs(const U8 num_tes); /*virtual*/ void setTE(const U8 te, const LLTextureEntry &texture_entry); /*virtual*/ S32 setTETexture(const U8 te, const LLUUID &uuid); + /*virtual*/ S32 setTENormalMap(const U8 te, const LLUUID &uuid); + /*virtual*/ S32 setTESpecularMap(const U8 te, const LLUUID &uuid); S32 setTETextureCore(const U8 te, const LLUUID& uuid, LLHost host); + S32 setTENormalMapCore(const U8 te, const LLUUID& uuid, LLHost host); + S32 setTESpecularMapCore(const U8 te, const LLUUID& uuid, LLHost host); /*virtual*/ S32 setTEColor(const U8 te, const LLColor3 &color); /*virtual*/ S32 setTEColor(const U8 te, const LLColor4 &color); /*virtual*/ S32 setTEScale(const U8 te, const F32 s, const F32 t); @@ -313,7 +317,11 @@ public: /*virtual*/ BOOL setMaterial(const U8 material); virtual void setTEImage(const U8 te, LLViewerTexture *imagep); // Not derived from LLPrimitive virtual void changeTEImage(S32 index, LLViewerTexture* new_image) ; + virtual void changeTENormalMap(S32 index, LLViewerTexture* new_image) ; + virtual void changeTESpecularMap(S32 index, LLViewerTexture* new_image) ; LLViewerTexture *getTEImage(const U8 te) const; + LLViewerTexture *getTENormalMap(const U8 te) const; + LLViewerTexture *getTESpecularMap(const U8 te) const; void fitFaceTexture(const U8 face); void sendTEUpdate() const; // Sends packed representation of all texture entry information @@ -588,6 +596,8 @@ public: S32 mListIndex; LLPointer *mTEImages; + LLPointer *mTENormalMaps; + LLPointer *mTESpecularMaps; // Selection, picking and rendering variables U32 mGLName; // GL "name" used by selection code diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index a37dea4a60..c90ca48b01 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -77,6 +77,7 @@ #include "llviewershadermgr.h" #include "llvoavatar.h" #include "llvocache.h" +#include "llmaterialmgr.h" const S32 MIN_QUIET_FRAMES_COALESCE = 30; const F32 FORCE_SIMPLE_RENDER_AREA = 512.f; @@ -919,6 +920,12 @@ LLFace* LLVOVolume::addFace(S32 f) { const LLTextureEntry* te = getTE(f); LLViewerTexture* imagep = getTEImage(f); + if (te->getMaterialParams() != NULL) + { + LLViewerTexture* normalp = getTENormalMap(f); + LLViewerTexture* specularp = getTESpecularMap(f); + return mDrawable->addFace(te, imagep, normalp, specularp); + } return mDrawable->addFace(te, imagep); } @@ -1404,6 +1411,11 @@ void LLVOVolume::regenFaces() facep->setTEOffset(i); facep->setTexture(getTEImage(i)); + if (facep->getTextureEntry()->getMaterialParams() != NULL) + { + facep->setNormalMap(getTENormalMap(i)); + facep->setSpecularMap(getTESpecularMap(i)); + } facep->setViewerObject(this); // If the face had media on it, this will have broken the link between the LLViewerMediaTexture and the face. @@ -1979,13 +1991,33 @@ S32 LLVOVolume::setTEGlow(const U8 te, const F32 glow) S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) { - S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID); + if (!pMaterialID.isNull()) + { + LL_INFOS("Materials") << "Oh god it's a material! " << pMaterialID.asString() << LL_ENDL; + S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID); + if (res) + { + LL_INFOS("Materials") << "We have a material!" << LL_ENDL; + LLMaterialPtr pMatParam = LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID); + setTEMaterialParams(te, pMatParam); + gPipeline.markTextured(mDrawable); + mFaceMappingChanged = TRUE; + } + return res; + } + return 0; +} + +S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) +{ + S32 res = LLViewerObject::setTEMaterialParams(te, pMaterialParams); if (res) { gPipeline.markTextured(mDrawable); mFaceMappingChanged = TRUE; } - return res; + + return res; } S32 LLVOVolume::setTEScale(const U8 te, const F32 s, const F32 t) @@ -4050,6 +4082,8 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, LLViewerTexture* tex = facep->getTexture(); U8 index = facep->getTextureIndex(); + + LLMaterialID matid = facep->getTextureEntry()->getMaterialID(); bool batchable = false; @@ -4106,12 +4140,30 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, U32 offset = facep->getIndicesStart(); U32 count = facep->getIndicesCount(); LLPointer draw_info = new LLDrawInfo(start,end,count,offset, tex, - facep->getVertexBuffer(), fullbright, bump); + facep->getVertexBuffer(), fullbright, bump); draw_info->mGroup = group; draw_info->mVSize = facep->getVirtualSize(); draw_vec.push_back(draw_info); draw_info->mTextureMatrix = tex_mat; draw_info->mModelMatrix = model_mat; + + if (!facep->getTextureEntry()->getMaterialID().isNull() && facep->getTextureEntry()->getMaterialParams() != NULL) + { + // We have a material. Update our draw info accordingly. + //draw_info->mMaterialID = facep->getTextureEntry()->getMaterialID(); + LLVector4 specColor; + specColor.mV[0] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[0] * (1.0 / 255); + specColor.mV[1] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[1] * (1.0 / 255); + specColor.mV[2] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[2] * (1.0 / 255); + specColor.mV[3] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightExponent() * (1.0 / 255); + draw_info->mSpecColor = specColor; + draw_info->mEnvIntensity = facep->getTextureEntry()->getMaterialParams()->getEnvironmentIntensity() * (1.0 / 255); + draw_info->mAlphaMaskCutoff = facep->getTextureEntry()->getMaterialParams()->getAlphaMaskCutoff() * (1.0 / 255); + draw_info->mDiffuseAlphaMode = facep->getTextureEntry()->getMaterialParams()->getDiffuseAlphaMode(); + draw_info->mNormalMap = facep->getViewerObject()->getTENormalMap(facep->getTextureIndex()); + draw_info->mSpecularMap = facep->getViewerObject()->getTESpecularMap(facep->getTextureIndex()); + } + if (type == LLRenderPass::PASS_ALPHA) { //for alpha sorting facep->setDrawInfo(draw_info); @@ -4267,7 +4319,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) } if (vobj->isMesh() && - (vobj->getVolume() && !vobj->getVolume()->isMeshAssetLoaded() || !gMeshRepo.meshRezEnabled())) + ((vobj->getVolume() && !vobj->getVolume()->isMeshAssetLoaded()) || !gMeshRepo.meshRezEnabled())) { continue; } @@ -5134,7 +5186,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: registerFace(group, facep, LLRenderPass::PASS_POST_BUMP); } } - else if (te->getBumpmap()) + else if (te->getBumpmap() || te->getMaterialParams() != NULL) { //register in deferred bump pass registerFace(group, facep, LLRenderPass::PASS_BUMP); } @@ -5169,7 +5221,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: } else { - if (LLPipeline::sRenderDeferred && LLPipeline::sRenderBump && te->getBumpmap()) + if (LLPipeline::sRenderDeferred && LLPipeline::sRenderBump && (te->getBumpmap() || te->getMaterialParams() != NULL)) { //non-shiny or fullbright deferred bump registerFace(group, facep, LLRenderPass::PASS_BUMP); } diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index ff6dca9737..c996fac6f2 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -187,6 +187,7 @@ public: /*virtual*/ S32 setTEMediaFlags(const U8 te, const U8 media_flags); /*virtual*/ S32 setTEGlow(const U8 te, const F32 glow); /*virtual*/ S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); + /*virtual*/ S32 setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams); /*virtual*/ S32 setTEScale(const U8 te, const F32 s, const F32 t); /*virtual*/ S32 setTEScaleS(const U8 te, const F32 s); /*virtual*/ S32 setTEScaleT(const U8 te, const F32 t); -- cgit v1.3 From f356d7eb9fd730f5f6f5a29fb0706e20876ad3bd Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Sat, 11 May 2013 19:58:56 -0700 Subject: Fix many issues with selection misapplication and rendering not matching applied materials --- indra/llprimitive/llprimitive.cpp | 18 ++ indra/llprimitive/llprimitive.h | 2 + indra/llprimitive/lltextureentry.cpp | 25 +- indra/llprimitive/lltextureentry.h | 6 + indra/newview/llmaterialmgr.cpp | 61 ++++ indra/newview/llmaterialmgr.h | 24 ++ indra/newview/llpanelface.cpp | 318 +++++++++------------ indra/newview/llpanelface.h | 2 +- indra/newview/llselectmgr.cpp | 5 + indra/newview/llviewerobject.cpp | 78 ++--- indra/newview/llviewerobject.h | 2 +- indra/newview/llvovolume.cpp | 47 +-- indra/newview/llvovolume.h | 2 +- .../skins/default/xui/en/panel_tools_texture.xml | 8 +- 14 files changed, 338 insertions(+), 260 deletions(-) (limited to 'indra/llprimitive/lltextureentry.h') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index e5905c3a3b..2fa77177f5 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -374,6 +374,24 @@ S32 LLPrimitive::setTEGlow(const U8 index, const F32 glow) return mTextureList.setGlow(index, glow); } +void LLPrimitive::setAllTESelected(bool sel) +{ + for (int i = 0, cnt = getNumTEs(); i < cnt; i++) + { + setTESelected(i, sel); + } +} + +void LLPrimitive::setTESelected(const U8 te, bool sel) +{ + LLTextureEntry* tep = getTE(te); + if ( (tep) && (tep->setSelected(sel)) && (!sel) && (tep->hasPendingMaterialUpdate()) ) + { + LLMaterialID material_id = tep->getMaterialID(); + setTEMaterialID(te, material_id); + } +} + LLPCode LLPrimitive::legacyToPCode(const U8 legacy) { // TODO: Should this default to something valid? diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index b1f8090416..47a21beaaf 100755 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -361,6 +361,7 @@ public: LLTextureEntry* getTE(const U8 te_num) const; virtual void setNumTEs(const U8 num_tes); + virtual void setAllTESelected(bool sel); virtual void setAllTETextures(const LLUUID &tex_id); virtual void setTE(const U8 index, const LLTextureEntry& te); virtual S32 setTEColor(const U8 te, const LLColor4 &color); @@ -386,6 +387,7 @@ public: virtual S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); virtual S32 setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed + virtual void setTESelected(const U8 te, bool sel); void copyTEs(const LLPrimitive *primitive); S32 packTEField(U8 *cur_ptr, U8 *data_ptr, U8 data_size, U8 last_face_index, EMsgVariableType type) const; diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 53816266eb..1d581da897 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -67,12 +67,16 @@ LLTextureEntry::LLTextureEntry() LLTextureEntry::LLTextureEntry(const LLUUID& tex_id) : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { init(tex_id,1.f,1.f,0.f,0.f,0.f,DEFAULT_BUMP_CODE); } LLTextureEntry::LLTextureEntry(const LLTextureEntry &rhs) : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { mID = rhs.mID; mScaleS = rhs.mScaleS; @@ -536,23 +540,20 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) if (mMaterialID != pMaterialID) { mMaterialID = pMaterialID; - if (mMaterialID.isNull()) - { - setMaterialParams(NULL); - } - return TEM_CHANGE_TEXTURE; + } - return TEM_CHANGE_NONE; + if (mMaterialID.isNull()) + { + setMaterialParams(NULL); + } + return TEM_CHANGE_TEXTURE; } S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) { - if (mMaterial != pMaterialParams) - { - mMaterial = pMaterialParams; - return TEM_CHANGE_TEXTURE; - } - return TEM_CHANGE_NONE; + + mMaterial = pMaterialParams; + return TEM_CHANGE_TEXTURE; } void LLTextureEntry::setMediaData(const LLMediaEntry &media_entry) diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index c443ebcb30..5cc76cfe82 100755 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -100,6 +100,10 @@ public: void init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 offset_s, F32 offset_t, F32 rotation, U8 bump); + bool hasPendingMaterialUpdate() const { return mMaterialUpdatePending; } + bool isSelected() const { return mSelected; } + bool setSelected(bool sel) { bool prev_sel = mSelected; mSelected = sel; return prev_sel; } + // These return a TEM_ flag from above to indicate if something changed. S32 setID (const LLUUID &tex_id); S32 setColor(const LLColor4 &color); @@ -194,11 +198,13 @@ public: static const char* TEXTURE_MEDIA_DATA_KEY; protected: + bool mSelected; LLUUID mID; // Texture GUID LLColor4 mColor; U8 mBump; // Bump map, shiny, and fullbright U8 mMediaFlags; // replace with web page, movie, etc. F32 mGlow; + bool mMaterialUpdatePending; LLMaterialID mMaterialID; LLMaterialPtr mMaterial; diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index fb8cffa4ef..e41a46038f 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -216,6 +216,51 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL return connection; } +boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, LLMaterialMgr::get_callback_te_t::slot_type cb) +{ + boost::signals2::connection connection; + + material_map_t::const_iterator itMaterial = mMaterials.find(material_id); + if (itMaterial != mMaterials.end()) + { + LL_DEBUGS("Materials") << "region " << region_id << " found materialid " << material_id << LL_ENDL; + get_callback_te_t signal; + signal.connect(cb); + signal(material_id, itMaterial->second, te); + connection = boost::signals2::connection(); + } + else + { + if (!isGetPending(region_id, material_id)) + { + get_queue_t::iterator itQueue = mGetQueue.find(region_id); + if (mGetQueue.end() == itQueue) + { + LL_DEBUGS("Materials") << "mGetQueue inserting region "< ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); + itQueue = ret.first; + } + LL_DEBUGS("Materials") << "adding material id " << material_id << LL_ENDL; + itQueue->second.insert(material_id); + markGetPending(region_id, material_id); + } + + TEMaterialPair te_mat_pair; + te_mat_pair.te = te; + te_mat_pair.materialID = material_id; + + get_callback_te_map_t::iterator itCallback = mGetTECallbacks.find(te_mat_pair); + if (itCallback == mGetTECallbacks.end()) + { + std::pair ret = mGetTECallbacks.insert(std::pair(te_mat_pair, new get_callback_te_t())); + itCallback = ret.first; + } + connection = itCallback->second->connect(cb); + } + + return connection; +} + bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) const { getall_pending_map_t::const_iterator itPending = mGetAllPending.find(region_id); @@ -300,6 +345,22 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL mGetCallbacks.erase(itCallback); } + TEMaterialPair te_mat_pair; + te_mat_pair.materialID = material_id; + + U32 i = 0; + while (i < LLTEContents::MAX_TES) + { + te_mat_pair.te = i++; + get_callback_te_map_t::iterator itCallbackTE = mGetTECallbacks.find(te_mat_pair); + if (itCallbackTE != mGetTECallbacks.end()) + { + (*itCallbackTE->second)(material_id, itMaterial->second, te_mat_pair.te); + delete itCallbackTE->second; + mGetTECallbacks.erase(itCallbackTE); + } + } + return itMaterial->second; } diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 39be5cab29..922b16f1cf 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -44,8 +44,12 @@ public: typedef std::map material_map_t; typedef boost::signals2::signal get_callback_t; + typedef boost::signals2::signal get_callback_te_t; + const LLMaterialPtr get(const LLUUID& region_id, const LLMaterialID& material_id); boost::signals2::connection get(const LLUUID& region_id, const LLMaterialID& material_id, get_callback_t::slot_type cb); + boost::signals2::connection getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, get_callback_te_t::slot_type cb); + typedef boost::signals2::signal getall_callback_t; void getAll(const LLUUID& region_id); boost::signals2::connection getAll(const LLUUID& region_id, getall_callback_t::slot_type cb); @@ -78,6 +82,26 @@ protected: typedef std::map get_callback_map_t; get_callback_map_t mGetCallbacks; + // struct for TE-specific material ID query + struct TEMaterialPair + { + U32 te; + LLMaterialID materialID; + }; + + // needed for std::map compliance only + // + friend inline bool operator<( + const struct LLMaterialMgr::TEMaterialPair& lhs, + const struct LLMaterialMgr::TEMaterialPair& rhs) + { + return (lhs.materialID < rhs.materialID) ? TRUE : + (lhs.te < rhs.te) ? TRUE : FALSE; + } + + typedef std::map get_callback_te_map_t; + get_callback_te_map_t mGetTECallbacks; + typedef std::set getall_queue_t; getall_queue_t mGetAllQueue; getall_queue_t mGetAllRequested; diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 9c40ff06cc..837b8687e8 100755 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1562,36 +1562,108 @@ void LLPanelFace::getState() // Materials { - mMaterialID = LLMaterialID::null; - mMaterial = NULL; + struct f1 : public LLSelectedTEGetFunctor + { + LLMaterialPtr get(LLViewerObject* object, S32 te_index) + { + return object->getTE(te_index)->getMaterialParams(); + } + } func; - struct f1 : public LLSelectedTEGetFunctor + LLMaterialPtr material; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, mMaterial ); + + if (mMaterial && editable) { - LLMaterialID get(LLViewerObject* object, S32 te_index) + LL_DEBUGS("Materials: OnMatererialsLoaded:") << material->asLLSD() << LL_ENDL; + + // Alpha + LLCtrlSelectionInterface* combobox_alphamode = + childGetSelectionInterface("combobox alphamode"); + if (combobox_alphamode) { - LLMaterialID material_id; + combobox_alphamode->selectNthItem(mMaterial->getDiffuseAlphaMode()); + } + else + { + llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; + } + getChild("maskcutoff")->setValue(mMaterial->getAlphaMaskCutoff()); + updateAlphaControls(getChild("combobox alphamode"),this); + + LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; + bool identical_texgen = true; + bool identical_planar_texgen = false; - return object->getTE(te_index)->getMaterialID(); + struct f44 : public LLSelectedTEGetFunctor + { + LLTextureEntry::e_texgen get(LLViewerObject* object, S32 face) + { + return (LLTextureEntry::e_texgen)(object->getTE(face)->getTexGen()); + } + } func; + identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen ); + identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)); + + // Shiny (specular) + F32 offset_x, offset_y, repeat_x, repeat_y, rot; + LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); + texture_ctrl->setImageAssetID(material->getSpecularID()); + LLComboBox* combobox_shininess = getChild("combobox shininess"); + if (!material->getSpecularID().isNull()) + { + mMaterial->getSpecularOffset(offset_x,offset_y); + mMaterial->getSpecularRepeat(repeat_x,repeat_y); + + if (identical_planar_texgen) + { + repeat_x *= 2.0f; + repeat_y *= 2.0f; + } + + rot = mMaterial->getSpecularRotation(); + getChild("shinyScaleU")->setValue(repeat_x); + getChild("shinyScaleV")->setValue(repeat_y); + getChild("shinyRot")->setValue(rot*RAD_TO_DEG); + getChild("shinyOffsetU")->setValue(offset_x); + getChild("shinyOffsetV")->setValue(offset_y); + getChild("glossiness")->setValue(mMaterial->getSpecularLightExponent()); + getChild("environment")->setValue(mMaterial->getEnvironmentIntensity()); } - } func; + updateShinyControls(combobox_shininess,this, !mMaterial->getSpecularID().isNull(), true); - LLObjectSelectionHandle sel = LLSelectMgr::getInstance()->getSelection(); - LLSelectNode* node = sel->getFirstNode(); - if (node) - { - int selected_te = node->getLastSelectedTE(); - if (selected_te >= 0) + // Assert desired colorswatch color to match material AFTER updateShinyControls + // to avoid getting overwritten with the default on some UI state changes. + // + if (!material->getSpecularID().isNull()) { - mMaterialID = node->getObject()->getTE(selected_te)->getMaterialID(); + getChild("shinycolorswatch")->setOriginal(mMaterial->getSpecularLightColor()); + getChild("shinycolorswatch")->set(mMaterial->getSpecularLightColor(),TRUE); } - } - llinfos << "Material ID returned: '" << mMaterialID.asString() << "', isNull? " << (mMaterialID.isNull()?"TRUE":"FALSE") << llendl; + // Bumpy (normal) + texture_ctrl = getChild("bumpytexture control"); + texture_ctrl->setImageAssetID(mMaterial->getNormalID()); + LLComboBox* combobox_bumpiness = getChild("combobox bumpiness"); + if (!mMaterial->getNormalID().isNull()) + { + mMaterial->getNormalOffset(offset_x,offset_y); + mMaterial->getNormalRepeat(repeat_x,repeat_y); - if (!mMaterialID.isNull() && editable) - { - llinfos << "Requesting material ID " << mMaterialID.asString() << llendl; - LLMaterialMgr::getInstance()->get(objectp->getRegion()->getRegionID(),mMaterialID,boost::bind(&LLPanelFace::onMaterialLoaded, this, _1, _2)); + if (identical_planar_texgen) + { + repeat_x *= 2.0f; + repeat_y *= 2.0f; + } + + rot = material->getNormalRotation(); + getChild("bumpyScaleU")->setValue(repeat_x); + getChild("bumpyScaleV")->setValue(repeat_y); + getChild("bumpyRot")->setValue(rot*RAD_TO_DEG); + getChild("bumpyOffsetU")->setValue(offset_x); + getChild("bumpyOffsetV")->setValue(offset_y); + } + updateBumpyControls(combobox_bumpiness,this, !mMaterial->getNormalID().isNull(), true); } } @@ -1658,104 +1730,6 @@ void LLPanelFace::refresh() getState(); } -void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMaterialPtr material) -{ //laying out UI based on material parameters (calls setVisible on various components) - LL_DEBUGS("Materials") << "material id " << material_id.asString() << " data " << material->asLLSD() << LL_ENDL; - - //make a local copy of the material for editing - // (prevents local edits from overwriting client state on shared materials) - mMaterial = new LLMaterial(*material); - mMaterialID = material_id; - - // Alpha - LLCtrlSelectionInterface* combobox_alphamode = - childGetSelectionInterface("combobox alphamode"); - if (combobox_alphamode) - { - combobox_alphamode->selectNthItem(material->getDiffuseAlphaMode()); - } - else - { - llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; - } - getChild("maskcutoff")->setValue(material->getAlphaMaskCutoff()); - updateAlphaControls(getChild("combobox alphamode"),this); - - LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; - bool identical_texgen = true; - bool identical_planar_texgen = false; - - struct f44 : public LLSelectedTEGetFunctor - { - LLTextureEntry::e_texgen get(LLViewerObject* object, S32 face) - { - return (LLTextureEntry::e_texgen)(object->getTE(face)->getTexGen()); - } - } func; - identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen ); - identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)); - - // Shiny (specular) - F32 offset_x, offset_y, repeat_x, repeat_y, rot; - LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); - texture_ctrl->setImageAssetID(material->getSpecularID()); - LLComboBox* combobox_shininess = getChild("combobox shininess"); - if (!material->getSpecularID().isNull()) - { - material->getSpecularOffset(offset_x,offset_y); - material->getSpecularRepeat(repeat_x,repeat_y); - - if (identical_planar_texgen) - { - repeat_x *= 2.0f; - repeat_y *= 2.0f; - } - - rot = material->getSpecularRotation(); - getChild("shinyScaleU")->setValue(repeat_x); - getChild("shinyScaleV")->setValue(repeat_y); - getChild("shinyRot")->setValue(rot*RAD_TO_DEG); - getChild("shinyOffsetU")->setValue(offset_x); - getChild("shinyOffsetV")->setValue(offset_y); - getChild("glossiness")->setValue(material->getSpecularLightExponent()); - getChild("environment")->setValue(material->getEnvironmentIntensity()); - } - updateShinyControls(combobox_shininess,this, !material->getSpecularID().isNull(), true); - - // Assert desired colorswatch color to match material AFTER updateShinyControls - // to avoid getting overwritten with the default on some UI state changes. - // - if (!material->getSpecularID().isNull()) - { - getChild("shinycolorswatch")->setOriginal(material->getSpecularLightColor()); - getChild("shinycolorswatch")->set(material->getSpecularLightColor(),TRUE); - } - - // Bumpy (normal) - texture_ctrl = getChild("bumpytexture control"); - texture_ctrl->setImageAssetID(material->getNormalID()); - LLComboBox* combobox_bumpiness = getChild("combobox bumpiness"); - if (!material->getNormalID().isNull()) - { - material->getNormalOffset(offset_x,offset_y); - material->getNormalRepeat(repeat_x,repeat_y); - - if (identical_planar_texgen) - { - repeat_x *= 2.0f; - repeat_y *= 2.0f; - } - - rot = material->getNormalRotation(); - getChild("bumpyScaleU")->setValue(repeat_x); - getChild("bumpyScaleV")->setValue(repeat_y); - getChild("bumpyRot")->setValue(rot*RAD_TO_DEG); - getChild("bumpyOffsetU")->setValue(offset_x); - getChild("bumpyOffsetV")->setValue(offset_y); - } - updateBumpyControls(combobox_bumpiness,this, !material->getNormalID().isNull(), true); -} - void LLPanelFace::updateMaterial() { // assign current state of UI to material definition for submit to sim LL_DEBUGS("Materials") << "Entered." << LL_ENDL; @@ -1781,53 +1755,38 @@ void LLPanelFace::updateMaterial() bool identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen ); bool identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)); - if ((mIsAlpha && (alpha_mode != LLMaterial::DIFFUSE_ALPHA_MODE_BLEND)) + bool is_default_blend_mode = mIsAlpha ? (alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) + : (alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_NONE); + + if ( !is_default_blend_mode || (bumpiness == BUMPY_TEXTURE) || (shininess == SHINY_TEXTURE)) { // The user's specified something that needs a material. bool new_material = false; - if (!mMaterial) + + // Create new or clone material + // + if (mMaterial.isNull()) { - new_material = true; mMaterial = LLMaterialPtr(new LLMaterial()); + new_material = true; } - - LLMaterialPtr material_to_set = mMaterial; - - bool subselection = false; - - // If we're editing a single face and not the entire material for an object, - // we need to clone the material so that our changes to the material's settings - // don't automatically propagate to the non-selected faces - // NORSPEC-92 - // - LLObjectSelectionHandle sel = LLSelectMgr::getInstance()->getSelection(); - LLSelectNode* node = sel->getFirstNode(); - if (node) + else { - if (node->getTESelectMask() != TE_SELECT_MASK_ALL) - { - llinfos << "Cloning material to apply to subselection." << llendl; - material_to_set = new LLMaterial(mMaterial->asLLSD()); - subselection = true; - } - else - { - llinfos << "Apply material change to whole selection." << llendl; - } + mMaterial = LLMaterialPtr(new LLMaterial(mMaterial->asLLSD())); } - llassert(!material_to_set.isNull()); + llassert_always(mMaterial); - material_to_set->setDiffuseAlphaMode(getChild("combobox alphamode")->getCurrentIndex()); - material_to_set->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); + mMaterial->setDiffuseAlphaMode(getChild("combobox alphamode")->getCurrentIndex()); + mMaterial->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); LLUUID norm_map_id = getChild("bumpytexture control")->getImageAssetID(); if (!norm_map_id.isNull() && (bumpiness == BUMPY_TEXTURE)) { LL_DEBUGS("Materials") << "Setting bumpy texture, bumpiness = " << bumpiness << LL_ENDL; - material_to_set->setNormalID(norm_map_id); + mMaterial->setNormalID(norm_map_id); F32 bumpy_scale_u = getChild("bumpyScaleU")->getValue().asReal(); F32 bumpy_scale_v = getChild("bumpyScaleV")->getValue().asReal(); @@ -1838,18 +1797,18 @@ void LLPanelFace::updateMaterial() bumpy_scale_v *= 0.5f; } - material_to_set->setNormalOffset(getChild("bumpyOffsetU")->getValue().asReal(), + mMaterial->setNormalOffset(getChild("bumpyOffsetU")->getValue().asReal(), getChild("bumpyOffsetV")->getValue().asReal()); - material_to_set->setNormalRepeat(bumpy_scale_u, bumpy_scale_v); - material_to_set->setNormalRotation(getChild("bumpyRot")->getValue().asReal()*DEG_TO_RAD); + mMaterial->setNormalRepeat(bumpy_scale_u, bumpy_scale_v); + mMaterial->setNormalRotation(getChild("bumpyRot")->getValue().asReal()*DEG_TO_RAD); } else { LL_DEBUGS("Materials") << "Removing bumpy texture, bumpiness = " << bumpiness << LL_ENDL; - material_to_set->setNormalID(LLUUID()); - material_to_set->setNormalOffset(0.0f,0.0f); - material_to_set->setNormalRepeat(1.0f,1.0f); - material_to_set->setNormalRotation(0.0f); + mMaterial->setNormalID(LLUUID()); + mMaterial->setNormalOffset(0.0f,0.0f); + mMaterial->setNormalRepeat(1.0f,1.0f); + mMaterial->setNormalRotation(0.0f); } LLUUID spec_map_id = getChild("shinytexture control")->getImageAssetID(); @@ -1857,8 +1816,8 @@ void LLPanelFace::updateMaterial() if (!spec_map_id.isNull() && (shininess == SHINY_TEXTURE)) { LL_DEBUGS("Materials") << "Setting shiny texture, shininess = " << shininess << LL_ENDL; - material_to_set->setSpecularID(spec_map_id); - material_to_set->setSpecularOffset(getChild("shinyOffsetU")->getValue().asReal(), + mMaterial->setSpecularID(spec_map_id); + mMaterial->setSpecularOffset(getChild("shinyOffsetU")->getValue().asReal(), getChild("shinyOffsetV")->getValue().asReal()); F32 shiny_scale_u = getChild("shinyScaleU")->getValue().asReal(); @@ -1870,55 +1829,42 @@ void LLPanelFace::updateMaterial() shiny_scale_v *= 0.5f; } - material_to_set->setSpecularRepeat(shiny_scale_u, shiny_scale_v); - material_to_set->setSpecularRotation(getChild("shinyRot")->getValue().asReal()*DEG_TO_RAD); + mMaterial->setSpecularRepeat(shiny_scale_u, shiny_scale_v); + mMaterial->setSpecularRotation(getChild("shinyRot")->getValue().asReal()*DEG_TO_RAD); //override shininess to 0.2f if this is a new material if (!new_material) { - material_to_set->setSpecularLightColor(getChild("shinycolorswatch")->get()); - material_to_set->setSpecularLightExponent(getChild("glossiness")->getValue().asInteger()); - material_to_set->setEnvironmentIntensity(getChild("environment")->getValue().asInteger()); + mMaterial->setSpecularLightColor(getChild("shinycolorswatch")->get()); + mMaterial->setSpecularLightExponent(getChild("glossiness")->getValue().asInteger()); + mMaterial->setEnvironmentIntensity(getChild("environment")->getValue().asInteger()); } } else { LL_DEBUGS("Materials") << "Removing shiny texture, shininess = " << shininess << LL_ENDL; - material_to_set->setSpecularID(LLUUID()); - material_to_set->setSpecularOffset(0.0f,0.0f); - material_to_set->setSpecularRepeat(1.0f,1.0f); - material_to_set->setSpecularRotation(0.0f); - material_to_set->setSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR); - material_to_set->setSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT); - material_to_set->setEnvironmentIntensity(0); + mMaterial->setSpecularID(LLUUID()); + mMaterial->setSpecularOffset(0.0f,0.0f); + mMaterial->setSpecularRepeat(1.0f,1.0f); + mMaterial->setSpecularRotation(0.0f); + mMaterial->setSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR); + mMaterial->setSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT); + mMaterial->setEnvironmentIntensity(0); } - LL_DEBUGS("Materials") << "Updating material: " << material_to_set->asLLSD() << LL_ENDL; - + LL_DEBUGS("Materials") << "Updating material: " << mMaterial->asLLSD() << LL_ENDL; - if (node && node->getObject() && node->getObject()->permModify() && subselection) - { - int selected_te = node->getLastSelectedTE(); - if (selected_te >= 0) - { - LLMaterialMgr::getInstance()->put(node->getObject()->getID(),selected_te,*material_to_set); - node->getObject()->getTE(selected_te)->setMaterialParams(material_to_set); - node->getObject()->sendTEUpdate(); - } - } - else - { - LLSelectMgr::getInstance()->selectionSetMaterial( material_to_set ); - } + LLSelectMgr::getInstance()->selectionSetMaterial( mMaterial ); } else { // The user has specified settings that don't need a material. - if (mMaterial || !mMaterialID.isNull()) + //if (mMaterial || !mMaterialID.isNull()) { LL_DEBUGS("Materials") << "Resetting material entry" << LL_ENDL; mMaterial = NULL; mMaterialID = LLMaterialID::null; + // Delete existing material entry... LLSelectMgr::getInstance()->selectionRemoveMaterial(); } diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 7fbeef223b..401dbd1e94 100755 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -87,7 +87,7 @@ protected: void onCommitAlpha(const LLSD& data); void onCancelColor(const LLSD& data); void onSelectColor(const LLSD& data); - void onMaterialLoaded(const LLMaterialID& material_id, const LLMaterialPtr material); + void updateMaterial(); static void onCommitTextureInfo( LLUICtrl* ctrl, void* userdata); diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 5a65623b91..3f60b5f642 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -815,6 +815,7 @@ void LLSelectMgr::addAsFamily(std::vector& objects, BOOL add_to if (objectp->getNumTEs() > 0) { nodep->selectAllTEs(TRUE); + objectp->setAllTESelected(true); } else { @@ -872,10 +873,12 @@ void LLSelectMgr::addAsIndividual(LLViewerObject *objectp, S32 face, BOOL undoab else if (face == SELECT_ALL_TES) { nodep->selectAllTEs(TRUE); + objectp->setAllTESelected(true); } else if (0 <= face && face < SELECT_MAX_TES) { nodep->selectTE(face, TRUE); + objectp->setTESelected(face, true); } else { @@ -1095,6 +1098,7 @@ LLObjectSelectionHandle LLSelectMgr::selectHighlightedObjects() // flag this object as selected objectp->setSelected(TRUE); + objectp->setAllTESelected(true); mSelectedObjects->mSelectType = getSelectTypeForObject(objectp); @@ -1318,6 +1322,7 @@ void LLSelectMgr::remove(LLViewerObject *objectp, S32 te, BOOL undoable) if (nodep->isTESelected(te)) { nodep->selectTE(te, FALSE); + objectp->setTESelected(te, false); } else { diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 2965d968a3..548fb236d6 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -530,6 +530,17 @@ void LLViewerObject::setNameValueList(const std::string& name_value_list) } } +void LLViewerObject::setSelected(BOOL sel) +{ + mUserSelected = sel; + resetRot(); + + if (!sel) + { + setAllTESelected(false); + } +} + // This method returns true if the object is over land owned by the // agent. bool LLViewerObject::isReturnable() @@ -4116,14 +4127,8 @@ S32 LLViewerObject::setTENormalMapCore(const U8 te, LLViewerTexture *image) { mat->setNormalID(uuid); } - - setChanged(TEXTURE); - if (mDrawable.notNull()) - { - gPipeline.markTextured(mDrawable); - } } - mTENormalMaps[te] = image; + changeTENormalMap(te,image); return retval; } @@ -4144,14 +4149,9 @@ S32 LLViewerObject::setTESpecularMapCore(const U8 te, LLViewerTexture *image) if (mat) { mat->setSpecularID(uuid); - } - setChanged(TEXTURE); - if (mDrawable.notNull()) - { - gPipeline.markTextured(mDrawable); } } - mTESpecularMaps[te] = image; + changeTESpecularMap(te, image); return retval; } @@ -4171,6 +4171,11 @@ void LLViewerObject::changeTENormalMap(S32 index, LLViewerTexture* new_image) { return ; } + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); + } mTENormalMaps[index] = new_image ; } @@ -4180,6 +4185,11 @@ void LLViewerObject::changeTESpecularMap(S32 index, LLViewerTexture* new_image) { return ; } + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); + } mTESpecularMaps[index] = new_image ; } @@ -4375,18 +4385,21 @@ S32 LLViewerObject::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID << ", material " << pMaterialID << LL_ENDL; } - else if (pMaterialID != tep->getMaterialID()) + //else if (pMaterialID != tep->getMaterialID()) { LL_DEBUGS("Material") << "Changing texture entry for te " << (S32)te << ", object " << mID << ", material " << pMaterialID << LL_ENDL; retval = LLPrimitive::setTEMaterialID(te, pMaterialID); - setChanged(TEXTURE); - if (mDrawable.notNull() && retval) - { - gPipeline.markTextured(mDrawable); - } + } + // Kitty would like to know if this is necessary? + // Since we should get a setTEMaterialParams that does it anyway? + // + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); } return retval; } @@ -4398,22 +4411,23 @@ S32 LLViewerObject::setTEMaterialParams(const U8 te, const LLMaterialPtr pMateri if (!tep) { llwarns << "No texture entry for te " << (S32)te << ", object " << mID << llendl; + return 0; } - else if (pMaterialParams != tep->getMaterialParams()) + + retval = LLPrimitive::setTEMaterialParams(te, pMaterialParams); + LL_DEBUGS("Material") << "Changing material params for te " << (S32)te + << ", object " << mID + << " (" << retval << ")" + << LL_ENDL; + setTENormalMap(te, tep->getMaterialParams()->getNormalID()); + setTESpecularMap(te, tep->getMaterialParams()->getSpecularID()); + + setChanged(TEXTURE); + if (mDrawable.notNull()) { - retval = LLPrimitive::setTEMaterialParams(te, pMaterialParams); - LL_DEBUGS("Material") << "Changing material params for te " << (S32)te - << ", object " << mID - << " (" << retval << ")" - << LL_ENDL; - setTENormalMap(te, tep->getMaterialParams()->getNormalID()); - setTESpecularMap(te, tep->getMaterialParams()->getSpecularID()); - setChanged(TEXTURE); - if (mDrawable.notNull() && retval) - { - gPipeline.markTextured(mDrawable); - } + gPipeline.markTextured(mDrawable); } + return retval; } diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index ba23ad97b0..bcb74a8d1f 100755 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -211,7 +211,7 @@ public: LLViewerRegion* getRegion() const { return mRegionp; } BOOL isSelected() const { return mUserSelected; } - virtual void setSelected(BOOL sel) { mUserSelected = sel; resetRot();} + virtual void setSelected(BOOL sel); const LLUUID &getID() const { return mID; } U32 getLocalID() const { return mLocalID; } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 941892a597..df014513ad 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1973,33 +1973,34 @@ S32 LLVOVolume::setTEGlow(const U8 te, const F32 glow) return res; } -void LLVOVolume::setTEMaterialParamsCallback(const LLMaterialID &pMaterialID, const LLMaterialPtr pMaterialParams) +void LLVOVolume::setTEMaterialParamsCallback(const LLMaterialID &pMaterialID, const LLMaterialPtr pMaterialParams, U32 te) { - LL_DEBUGS("MaterialTEs") << "materialid " << pMaterialID.asString() << LL_ENDL; - for (U8 i = 0; i < getNumTEs(); i++) + LL_DEBUGS("MaterialTEs") << "materialid " << pMaterialID.asString() << " to TE " << te << LL_ENDL; + LLTextureEntry* texture_entry = getTE(te); + if (texture_entry && (texture_entry->getMaterialID().isNull() || (texture_entry->getMaterialID() == pMaterialID))) { - if (getTE(i) && (getTE(i)->getMaterialID().isNull() || (getTE(i)->getMaterialID() == pMaterialID))) - { - setTEMaterialParams(i, pMaterialParams); - } + setTEMaterialParams(te, pMaterialParams); } } S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) { - S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID); - LL_DEBUGS("MaterialTEs") << "te "<< (S32)te << " materialid " << pMaterialID.asString() << " res " << res - << ( LLSelectMgr::getInstance()->getSelection()->contains(const_cast(this), te) ? " selected" : " not selected" ) - << LL_ENDL; - if (res) - { - LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; - LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2)); - gPipeline.markTextured(mDrawable); - mFaceMappingChanged = TRUE; - } - return res; + S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID); + LL_DEBUGS("MaterialTEs") << "te "<< (S32)te << " materialid " << pMaterialID.asString() << " res " << res + << ( LLSelectMgr::getInstance()->getSelection()->contains(const_cast(this), te) ? " selected" : " not selected" ) + << LL_ENDL; + + LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; + // Use TE-specific version of boost CB hook-up to avoid cross-contaminatin' + LLMaterialMgr::instance().getTE(getRegion()->getRegionID(), pMaterialID, te, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, _3)); + setChanged(TEXTURE); + if (!mDrawable.isNull()) + { + gPipeline.markTextured(mDrawable); } + mFaceMappingChanged = TRUE; + return TEM_CHANGE_TEXTURE; +} S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) { @@ -2007,13 +2008,13 @@ S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialPa LL_DEBUGS("MaterialTEs") << "te " << (S32)te << " material " << pMaterialParams->asLLSD() << " res " << res << ( LLSelectMgr::getInstance()->getSelection()->contains(const_cast(this), te) ? " selected" : " not selected" ) << LL_ENDL; - if (res) + setChanged(TEXTURE); + if (!mDrawable.isNull()) { gPipeline.markTextured(mDrawable); - mFaceMappingChanged = TRUE; } - - return res; + mFaceMappingChanged = TRUE; + return TEM_CHANGE_TEXTURE; } S32 LLVOVolume::setTEScale(const U8 te, const F32 s, const F32 t) diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index d1bfefdc70..a5f933c319 100755 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -187,7 +187,7 @@ public: /*virtual*/ S32 setTEMediaFlags(const U8 te, const U8 media_flags); /*virtual*/ S32 setTEGlow(const U8 te, const F32 glow); /*virtual*/ S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); - void setTEMaterialParamsCallback(const LLMaterialID& pMaterialID, const LLMaterialPtr pMaterialParams); + void setTEMaterialParamsCallback(const LLMaterialID& pMaterialID, const LLMaterialPtr pMaterialParams, U32 te); /*virtual*/ S32 setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams); /*virtual*/ S32 setTEScale(const U8 te, const F32 s, const F32 t); /*virtual*/ S32 setTEScaleS(const U8 te, const F32 s); diff --git a/indra/newview/skins/default/xui/en/panel_tools_texture.xml b/indra/newview/skins/default/xui/en/panel_tools_texture.xml index b6fc48212a..a5425062ec 100644 --- a/indra/newview/skins/default/xui/en/panel_tools_texture.xml +++ b/indra/newview/skins/default/xui/en/panel_tools_texture.xml @@ -644,8 +644,8 @@ layout="topleft" label_width="205" left="10" - max_val="9999" - min_val="-9999" + max_val="180" + min_val="-180" name="bumpyRot" width="265" /> @@ -707,8 +707,8 @@ layout="topleft" label_width="205" left="10" - max_val="9999" - min_val="-9999" + max_val="180" + min_val="-180" name="shinyRot" width="265" /> -- cgit v1.3 From 7e4e59470f36ae7a0e01b8d2613af4c8fb6b0101 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 7 Jun 2013 08:58:15 -0700 Subject: NORSPEC-233 WIP for individual material param edits across hetero object selections --- indra/llprimitive/llmaterial.h | 28 +- indra/llprimitive/lltextureentry.h | 8 +- indra/newview/llpanelface.cpp | 1427 ++++++++++++++++-------------------- indra/newview/llpanelface.h | 290 +++++++- indra/newview/llselectmgr.cpp | 27 +- indra/newview/llselectmgr.h | 8 +- 6 files changed, 974 insertions(+), 814 deletions(-) (limited to 'indra/llprimitive/lltextureentry.h') diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index b265732adc..9f52a3f6c1 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -69,19 +69,43 @@ public: const LLUUID& getNormalID() const { return mNormalID; } void setNormalID(const LLUUID& normal_id) { mNormalID = normal_id; } void getNormalOffset(F32& offset_x, F32& offset_y) const { offset_x = mNormalOffsetX; offset_y = mNormalOffsetY; } + F32 getNormalOffsetX() const { return mNormalOffsetX; } + F32 getNormalOffsetY() const { return mNormalOffsetY; } + void setNormalOffset(F32 offset_x, F32 offset_y) { mNormalOffsetX = offset_x; mNormalOffsetY = offset_y; } + void setNormalOffsetX(F32 offset_x) { mNormalOffsetX = offset_x; } + void setNormalOffsetY(F32 offset_y) { mNormalOffsetY = offset_y; } + void getNormalRepeat(F32& repeat_x, F32& repeat_y) const { repeat_x = mNormalRepeatX; repeat_y = mNormalRepeatY; } + F32 getNormalRepeatX() const { return mNormalRepeatX; } + F32 getNormalRepeatY() const { return mNormalRepeatY; } + void setNormalRepeat(F32 repeat_x, F32 repeat_y) { mNormalRepeatX = repeat_x; mNormalRepeatY = repeat_y; } - F32 getNormalRotation() const { return mNormalRotation; } + void setNormalRepeatX(F32 repeat_x) { mNormalRepeatX = repeat_x; } + void setNormalRepeatY(F32 repeat_y) { mNormalRepeatY = repeat_y; } + + F32 getNormalRotation() const { return mNormalRotation; } void setNormalRotation(F32 rot) { mNormalRotation = rot; } const LLUUID& getSpecularID() const { return mSpecularID; } void setSpecularID(const LLUUID& specular_id) { mSpecularID = specular_id; } void getSpecularOffset(F32& offset_x, F32& offset_y) const { offset_x = mSpecularOffsetX; offset_y = mSpecularOffsetY; } + F32 getSpecularOffsetX() const { return mSpecularOffsetX; } + F32 getSpecularOffsetY() const { return mSpecularOffsetY; } + void setSpecularOffset(F32 offset_x, F32 offset_y) { mSpecularOffsetX = offset_x; mSpecularOffsetY = offset_y; } + void setSpecularOffsetX(F32 offset_x) { mSpecularOffsetX = offset_x; } + void setSpecularOffsetY(F32 offset_y) { mSpecularOffsetY = offset_y; } + void getSpecularRepeat(F32& repeat_x, F32& repeat_y) const { repeat_x = mSpecularRepeatX; repeat_y = mSpecularRepeatY; } + F32 getSpecularRepeatX() const { return mSpecularRepeatX; } + F32 getSpecularRepeatY() const { return mSpecularRepeatY; } + void setSpecularRepeat(F32 repeat_x, F32 repeat_y) { mSpecularRepeatX = repeat_x; mSpecularRepeatY = repeat_y; } - F32 getSpecularRotation() const { return mSpecularRotation; } + void setSpecularRepeatX(F32 repeat_x) { mSpecularRepeatX = repeat_x; } + void setSpecularRepeatY(F32 repeat_y) { mSpecularRepeatY = repeat_y; } + + F32 getSpecularRotation() const { return mSpecularRotation; } void setSpecularRotation(F32 rot) { mSpecularRotation = rot; } const LLColor4U getSpecularLightColor() const { return mSpecularLightColor; } diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index 5cc76cfe82..59364cb913 100755 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -133,7 +133,13 @@ public: virtual const LLUUID &getID() const { return mID; } const LLColor4 &getColor() const { return mColor; } void getScale(F32 *s, F32 *t) const { *s = mScaleS; *t = mScaleT; } + void getScaleS(F32 *s) const { *s = mScaleS; } + void getScaleT(F32 *t) const { *t = mScaleT; } + void getOffset(F32 *s, F32 *t) const { *s = mOffsetS; *t = mOffsetT; } + F32 getOffsetS() const { return mOffsetS; } + F32 getOffsetT() const { return mOffsetT; } + F32 getRotation() const { return mRotation; } void getRotation(F32 *theta) const { *theta = mRotation; } @@ -144,7 +150,7 @@ public: U8 getBumpShinyFullbright() const { return mBump; } U8 getMediaFlags() const { return mMediaFlags & TEM_MEDIA_MASK; } - U8 getTexGen() const { return mMediaFlags & TEM_TEX_GEN_MASK; } + LLTextureEntry::e_texgen getTexGen() const { return LLTextureEntry::e_texgen(mMediaFlags & TEM_TEX_GEN_MASK); } U8 getMediaTexGen() const { return mMediaFlags; } F32 getGlow() const { return mGlow; } const LLMaterialID& getMaterialID() const { return mMaterialID; }; diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 01ed6e84b8..a26b9ed237 100755 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -89,6 +89,27 @@ const S32 SHINY_TEXTURE = 4; // use supplied specular map // std::string USE_TEXTURE; +// Things the UI provides... +// +LLUUID LLPanelFace::getCurrentNormalMap() { return getChild("bumpytexture control")->getImageAssetID(); } +LLUUID LLPanelFace::getCurrentSpecularMap() { return getChild("shinytexture control")->getImageAssetID(); } +U32 LLPanelFace::getCurrentShininess() { return getChild("combobox shininess")->getCurrentIndex(); } +U32 LLPanelFace::getCurrentBumpiness() { return getChild("combobox bumpiness")->getCurrentIndex(); } +U8 LLPanelFace::getCurrentDiffuseAlphaMode() { return (U8)getChild("combobox alphamode")->getCurrentIndex(); } +U8 LLPanelFace::getCurrentAlphaMaskCutoff() { return (U8)getChild("maskcutoff")->getValue().asInteger(); } +U8 LLPanelFace::getCurrentEnvIntensity() { return (U8)getChild("environment")->getValue().asInteger(); } +U8 LLPanelFace::getCurrentGlossiness() { return (U8)getChild("glossiness")->getValue().asInteger(); } +F32 LLPanelFace::getCurrentBumpyRot() { return getChild("bumpyRot")->getValue().asReal(); } +F32 LLPanelFace::getCurrentBumpyScaleU() { return getChild("bumpyScaleU")->getValue().asReal(); } +F32 LLPanelFace::getCurrentBumpyScaleV() { return getChild("bumpyScaleV")->getValue().asReal(); } +F32 LLPanelFace::getCurrentBumpyOffsetU() { return getChild("bumpyOffsetU")->getValue().asReal(); } +F32 LLPanelFace::getCurrentBumpyOffsetV() { return getChild("bumpyOffsetV")->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyRot() { return getChild("shinyRot")->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyScaleU() { return getChild("shinyScaleU")->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyScaleV() { return getChild("shinyScaleV")->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyOffsetU() { return getChild("shinyOffsetU")->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyOffsetV() { return getChild("shinyOffsetV")->getValue().asReal(); } + // // Methods // @@ -105,19 +126,21 @@ BOOL LLPanelFace::postBuild() childSetCommitCallback("checkbox planar align",&LLPanelFace::onCommitPlanarAlign, this); childSetCommitCallback("TexOffsetU",LLPanelFace::onCommitTextureInfo, this); childSetCommitCallback("TexOffsetV",LLPanelFace::onCommitTextureInfo, this); - childSetCommitCallback("bumpyScaleU",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("bumpyScaleV",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("bumpyRot",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("bumpyOffsetU",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("bumpyOffsetV",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("shinyScaleU",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("shinyScaleV",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("shinyRot",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("shinyOffsetU",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("shinyOffsetV",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("glossiness",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("environment",&LLPanelFace::onCommitMaterial, this); - childSetCommitCallback("maskcutoff",&LLPanelFace::onCommitMaterial, this); + + childSetCommitCallback("bumpyScaleU",&LLPanelFace::onCommitMaterialBumpyScaleX, this); + childSetCommitCallback("bumpyScaleV",&LLPanelFace::onCommitMaterialBumpyScaleY, this); + childSetCommitCallback("bumpyRot",&LLPanelFace::onCommitMaterialBumpyRot, this); + childSetCommitCallback("bumpyOffsetU",&LLPanelFace::onCommitMaterialBumpyOffsetX, this); + childSetCommitCallback("bumpyOffsetV",&LLPanelFace::onCommitMaterialBumpyOffsetY, this); + childSetCommitCallback("shinyScaleU",&LLPanelFace::onCommitMaterialShinyScaleX, this); + childSetCommitCallback("shinyScaleV",&LLPanelFace::onCommitMaterialShinyScaleY, this); + childSetCommitCallback("shinyRot",&LLPanelFace::onCommitMaterialShinyRot, this); + childSetCommitCallback("shinyOffsetU",&LLPanelFace::onCommitMaterialShinyOffsetX, this); + childSetCommitCallback("shinyOffsetV",&LLPanelFace::onCommitMaterialShinyOffsetY, this); + childSetCommitCallback("glossiness",&LLPanelFace::onCommitMaterialGloss, this); + childSetCommitCallback("environment",&LLPanelFace::onCommitMaterialEnv, this); + childSetCommitCallback("maskcutoff",&LLPanelFace::onCommitMaterialMaskCutoff, this); + childSetAction("button align",&LLPanelFace::onClickAutoFix,this); LLTextureCtrl* mTextureCtrl; @@ -293,10 +316,11 @@ void LLPanelFace::sendTexture() void LLPanelFace::sendBump(U32 bumpiness) { + LLTextureCtrl* bumpytexture_ctrl = getChild("bumpytexture control"); + if (bumpiness < BUMPY_TEXTURE) { - LL_DEBUGS("Materials") << "clearing bumptexture control" << LL_ENDL; - LLTextureCtrl* bumpytexture_ctrl = getChild("bumpytexture control"); + LL_DEBUGS("Materials") << "clearing bumptexture control" << LL_ENDL; bumpytexture_ctrl->clear(); bumpytexture_ctrl->setImageAssetID(LLUUID()); } @@ -305,7 +329,7 @@ void LLPanelFace::sendBump(U32 bumpiness) LLSelectMgr::getInstance()->selectionSetBumpmap( bump ); updateBumpyControls(bumpiness == BUMPY_TEXTURE, true); - updateMaterial(); + LLSelectedTEMaterial::setNormalID(this, bumpytexture_ctrl->getImageAssetID()); } void LLPanelFace::sendTexGen() @@ -328,9 +352,8 @@ void LLPanelFace::sendShiny(U32 shininess) U8 shiny = (U8) shininess & TEM_SHINY_MASK; LLSelectMgr::getInstance()->selectionSetShiny( shiny ); } - updateShinyControls(!texture_ctrl->getImageAssetID().isNull(), true); - updateMaterial(); + LLSelectedTEMaterial::setSpecularID(this, texture_ctrl->getImageAssetID()); } void LLPanelFace::sendFullbright() @@ -568,16 +591,9 @@ void LLPanelFace::sendTextureInfo() { if ((bool)childGetValue("checkbox planar align").asBoolean()) { - struct f1 : public LLSelectedTEGetFunctor - { - LLFace* get(LLViewerObject* object, S32 te) - { - return (object->mDrawable) ? object->mDrawable->getFace(te): NULL; - } - } get_last_face_func; - LLFace* last_face; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&get_last_face_func, last_face); - + LLFace* last_face = NULL; + bool identical_face =false; + LLSelectedTE::getFace(last_face, identical_face); LLPanelFaceSetAlignedTEFunctor setfunc(this, last_face); LLSelectMgr::getInstance()->getSelection()->applyToTEs(&setfunc); } @@ -639,12 +655,12 @@ void LLPanelFace::updateUI() updateVisibility(); - bool identical; - bool identical_diffuse; - bool identical_norm; - bool identical_spec; + bool identical = true; // true because it is anded below + bool identical_diffuse = false; + bool identical_norm = false; + bool identical_spec = false; - LLTextureCtrl* texture_ctrl = getChild("texture control"); + LLTextureCtrl* texture_ctrl = getChild("texture control"); LLTextureCtrl* shinytexture_ctrl = getChild("shinytexture control"); LLTextureCtrl* bumpytexture_ctrl = getChild("bumpytexture control"); @@ -657,18 +673,14 @@ void LLPanelFace::updateUI() getChildView("color label")->setEnabled(editable); } LLColorSwatchCtrl* mColorSwatch = getChild("colorswatch"); - LLColor4 color = LLColor4::white; + + LLColor4 color = LLColor4::white; + bool identical_color = false; + if(mColorSwatch) { - struct f7 : public LLSelectedTEGetFunctor - { - LLColor4 get(LLViewerObject* object, S32 face) - { - return object->getTE(face)->getColor(); - } - } func; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, color ); - + LLSelectedTE::getColor(color, identical_color); + mColorSwatch->setOriginal(color); mColorSwatch->set(color, TRUE); @@ -689,42 +701,19 @@ void LLPanelFace::updateUI() } // Specular map - struct spec_get : public LLSelectedTEGetFunctor - { - LLUUID get(LLViewerObject* object, S32 te_index) - { - LLUUID id; - - LLMaterial* mat = object->getTE(te_index)->getMaterialParams().get(); - - if (mat) - { - id = mat->getSpecularID(); - } - - return id; - } - } spec_get_func; - identical_spec = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &spec_get_func, specmap_id ); - + LLSelectedTEMaterial::getSpecularID(specmap_id, identical_spec); + U8 shiny = 0; + bool identical_shiny = false; // Shiny { - struct f9 : public LLSelectedTEGetFunctor - { - U8 get(LLViewerObject* object, S32 face) - { - return (U8)(object->getTE(face)->getShiny()); - } - } func; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, shiny ); - - LLCtrlSelectionInterface* combobox_shininess = - childGetSelectionInterface("combobox shininess"); + LLSelectedTE::getShiny(shiny, identical_shiny); + identical = identical && identical_shiny; shiny = specmap_id.isNull() ? shiny : SHINY_TEXTURE; + LLCtrlSelectionInterface* combobox_shininess = childGetSelectionInterface("combobox shininess"); if (combobox_shininess) { combobox_shininess->selectNthItem((S32)shiny); @@ -733,17 +722,22 @@ void LLPanelFace::updateUI() { llwarns << "failed childGetSelectionInterface for 'combobox shininess'" << llendl; } - getChildView("combobox shininess")->setEnabled(editable); - getChild("combobox shininess")->setTentative(!identical); + + getChildView("label shininess")->setEnabled(editable); + getChildView("combobox shininess")->setEnabled(editable); + + getChildView("label glossiness")->setEnabled(editable); getChildView("glossiness")->setEnabled(editable); - getChild("glossiness")->setTentative(!identical); - getChildView("label glossiness")->setEnabled(editable); - getChildView("environment")->setEnabled(editable); - getChild("environment")->setTentative(!identical); + getChildView("label environment")->setEnabled(editable); - getChild("shinycolorswatch")->setTentative(!identical); + getChildView("environment")->setEnabled(editable); getChildView("label shinycolor")->setEnabled(editable); + + getChild("combobox shininess")->setTentative(!identical); + getChild("glossiness")->setTentative(!identical); + getChild("environment")->setTentative(!identical); + getChild("shinycolorswatch")->setTentative(!identical); } LLColorSwatchCtrl* mShinyColorSwatch = getChild("shinycolorswatch"); @@ -757,17 +751,11 @@ void LLPanelFace::updateUI() U8 bumpy = 0; // Bumpy - { - struct f10 : public LLSelectedTEGetFunctor - { - U8 get(LLViewerObject* object, S32 face) - { - return object->getTE(face)->getBumpmap(); - } - } func; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, bumpy ); + { + U8 bumpy; + LLSelectedTE::getBumpmap(bumpy,identical); - LLUUID norm_map_id = getChild("bumpytexture control")->getImageAssetID(); + LLUUID norm_map_id = getCurrentNormalMap(); LLCtrlSelectionInterface* combobox_bumpiness = childGetSelectionInterface("combobox bumpiness"); if (combobox_bumpiness) @@ -785,72 +773,18 @@ void LLPanelFace::updateUI() // Texture { - struct f1 : public LLSelectedTEGetFunctor - { - LLUUID get(LLViewerObject* object, S32 te_index) - { - LLUUID id; - - LLViewerTexture* image = object->getTEImage(te_index); - if (image) id = image->getID(); - - if (!id.isNull() && LLViewerMedia::textureHasMedia(id)) - { - LLTextureEntry *te = object->getTE(te_index); - if (te) - { - LLViewerTexture* tex = te->getID().notNull() ? gTextureList.findImage(te->getID()) : NULL ; - if(!tex) - { - tex = LLViewerFetchedTexture::sDefaultImagep; - } - if (tex) - { - id = tex->getID(); - } - } - } - return id; - } - } func; - identical_diffuse = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, id ); + LLSelectedTE::getTexId(id,identical_diffuse); // Normal map - struct norm_get : public LLSelectedTEGetFunctor - { - LLUUID get(LLViewerObject* object, S32 te_index) - { - LLUUID id; - - LLMaterial* mat = object->getTE(te_index)->getMaterialParams().get(); - - if (mat) - { - id = mat->getNormalID(); - } - - return id; - } - } norm_get_func; - identical_norm = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &norm_get_func, normmap_id ); - + LLSelectedTEMaterial::getNormalID(normmap_id, identical_norm); + if (bumpy != BUMPY_TEXTURE) normmap_id = LLUUID::null; mIsAlpha = FALSE; LLGLenum image_format; - struct f2 : public LLSelectedTEGetFunctor - { - LLGLenum get(LLViewerObject* object, S32 te_index) - { - LLGLenum image_format = GL_RGB; - - LLViewerTexture* image = object->getTEImage(te_index); - if (image) image_format = image->getPrimaryFormat(); - return image_format; - } - } func2; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func2, image_format ); + bool identical_image_format = false; + LLSelectedTE::getImageFormat(image_format, identical_image_format); mIsAlpha = FALSE; switch (image_format) @@ -876,53 +810,27 @@ void LLPanelFace::updateUI() } // Diffuse Alpha Mode - struct alpha_get : public LLSelectedTEGetFunctor - { - U8 get(LLViewerObject* object, S32 te_index) - { - U8 ret = 1; - - LLMaterial* mat = object->getTE(te_index)->getMaterialParams().get(); + U8 alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_NONE; + bool identical_alpha_mode = false; + LLSelectedTEMaterial::getDiffuseAlphaMode(alpha_mode, identical_alpha_mode); - if (mat) - { - ret = mat->getDiffuseAlphaMode(); - } - - return ret; - } - } alpha_get_func; - - U8 alpha_mode = 1; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &alpha_get_func, alpha_mode); - + LLCtrlSelectionInterface* combobox_alphamode = childGetSelectionInterface("combobox alphamode"); + if (combobox_alphamode) { - LLCtrlSelectionInterface* combobox_alphamode = - childGetSelectionInterface("combobox alphamode"); + //it is invalid to have any alpha mode other than blend if transparency is greater than zero ... + alpha_mode = (transparency > 0.f) ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : alpha_mode; - if (combobox_alphamode) - { - - if (transparency > 0.f) - { //it is invalid to have any alpha mode other than blend if transparency is greater than zero ... - alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_BLEND; - } - - if (!mIsAlpha) - { // ... unless there is no alpha channel in the texture, in which case alpha mode MUST ebe none - alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_NONE; - } - - - combobox_alphamode->selectNthItem(alpha_mode); - } - else - { - llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; - } + // ... unless there is no alpha channel in the texture, in which case alpha mode MUST ebe none + alpha_mode = mIsAlpha ? alpha_mode : LLMaterial::DIFFUSE_ALPHA_MODE_NONE; - updateAlphaControls(); + combobox_alphamode->selectNthItem(alpha_mode); + } + else + { + llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; } + + updateAlphaControls(); if(texture_ctrl && !texture_ctrl->isPickerShown()) { @@ -1010,34 +918,20 @@ void LLPanelFace::updateUI() // planar align bool align_planar = false; bool identical_planar_aligned = false; - bool is_planar = false; { LLCheckBoxCtrl* cb_planar_align = getChild("checkbox planar align"); align_planar = (cb_planar_align && cb_planar_align->get()); - struct f1 : public LLSelectedTEGetFunctor - { - bool get(LLViewerObject* object, S32 face) - { - return (object->getTE(face)->getTexGen() == LLTextureEntry::TEX_GEN_PLANAR); - } - } func; - - bool texgens_identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, is_planar ); - bool enabled = (editable && texgens_identical && is_planar); + + bool enabled = (editable && isIdenticalPlanarTexgen()); childSetValue("checkbox planar align", align_planar && enabled); childSetEnabled("checkbox planar align", enabled); if (align_planar && enabled) { - struct f2 : public LLSelectedTEGetFunctor - { - LLFace* get(LLViewerObject* object, S32 te) - { - return (object->mDrawable) ? object->mDrawable->getFace(te): NULL; - } - } get_te_face_func; - LLFace* last_face; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&get_te_face_func, last_face); + LLFace* last_face = NULL; + bool identical_face = false; + LLSelectedTE::getFace(last_face, identical_face); + LLPanelFaceGetIsAlignedTEFunctor get_is_aligend_func(last_face); // this will determine if the texture param controls are tentative: identical_planar_aligned = LLSelectMgr::getInstance()->getSelection()->applyToTEs(&get_is_aligend_func); @@ -1052,386 +946,214 @@ void LLPanelFace::updateUI() bool identical_texgen = true; bool identical_planar_texgen = false; - { - struct f11 : public LLSelectedTEGetFunctor - { - LLTextureEntry::e_texgen get(LLViewerObject* object, S32 face) - { - return (LLTextureEntry::e_texgen)(object->getTE(face)->getTexGen()); - } - } func; - identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen ); + { + LLSelectedTE::getTexGen(selected_texgen, identical_texgen); identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)); } // Texture scale { - F32 scale_s = 1.f; - struct f2 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - return object->getTE(face)->mScaleS; - } - } func; + bool identical_diff_scale_s = false; + bool identical_spec_scale_s = false; + bool identical_norm_scale_s = false; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, scale_s ); identical = align_planar ? identical_planar_aligned : identical; - F32 scale_u = editable ? scale_s : 0; - scale_u *= identical_planar_texgen ? 2.0f : 1.0f; + F32 diff_scale_s = 1.f; + F32 spec_scale_s = 1.f; + F32 norm_scale_s = 1.f; - getChild("TexScaleU")->setValue(scale_u); - getChild("TexScaleU")->setTentative(LLSD((BOOL)(!identical))); - getChildView("TexScaleU")->setEnabled(editable); - - scale_s = 1.f; - struct f3 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 s = 1.f, t = 1.f; + LLSelectedTE::getOffsetS( diff_scale_s, identical_diff_scale_s); + LLSelectedTEMaterial::getSpecularRepeatX( spec_scale_s, identical_spec_scale_s); + LLSelectedTEMaterial::getNormalRepeatX( norm_scale_s, identical_norm_scale_s); - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - mat->getSpecularRepeat(s, t); - } - return s; - } - } shiny_func; + diff_scale_s = editable ? diff_scale_s : 1.0f; + diff_scale_s *= identical_planar_texgen ? 2.0f : 1.0f; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &shiny_func, scale_s ); - identical = align_planar ? identical_planar_aligned : identical; - - F32 scale_s_value = editable ? scale_s : 0; - scale_s_value *= identical_planar_texgen ? 2.0f : 1.0f; + norm_scale_s = editable ? norm_scale_s : 1.0f; + norm_scale_s *= identical_planar_texgen ? 2.0f : 1.0f; - getChild("shinyScaleU")->setValue(scale_s_value); - getChild("shinyScaleU")->setTentative(LLSD((BOOL)(!identical))); - getChildView("shinyScaleU")->setEnabled(editable && specmap_id.notNull()); + spec_scale_s = editable ? spec_scale_s : 1.0f; + spec_scale_s *= identical_planar_texgen ? 2.0f : 1.0f; - scale_s = 1.f; - struct f4 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 s = 1.f, t = 1.f; + getChild("TexScaleU")->setValue(diff_scale_s); + getChild("shinyScaleU")->setValue(spec_scale_s); + getChild("bumpyScaleU")->setValue(norm_scale_s); - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - mat->getNormalRepeat(s, t); - } - return s; - } - } bump_func; - - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &bump_func, scale_s ); - identical = align_planar ? identical_planar_aligned : identical; + getChildView("TexScaleU")->setEnabled(editable); + getChildView("shinyScaleU")->setEnabled(editable && specmap_id.notNull()); + getChildView("bumpyScaleU")->setEnabled(editable && normmap_id.notNull()); - scale_s_value = editable ? scale_s : 0; - scale_s_value *= identical_planar_texgen ? 2.0f : 1.0f; + BOOL diff_scale_tentative = !(identical && identical_diff_scale_s); + BOOL norm_scale_tentative = !(identical && identical_norm_scale_s); + BOOL spec_scale_tentative = !(identical && identical_spec_scale_s); - getChild("bumpyScaleU")->setValue(scale_s_value); - getChild("bumpyScaleU")->setTentative(LLSD((BOOL)(!identical))); - getChildView("bumpyScaleU")->setEnabled(editable && normmap_id.notNull()); + getChild("TexScaleU")->setTentative( LLSD(diff_scale_tentative)); + getChild("shinyScaleU")->setTentative(LLSD(spec_scale_tentative)); + getChild("bumpyScaleU")->setTentative(LLSD(norm_scale_tentative)); } { - F32 scale_t = 1.f; - struct f3 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - return object->getTE(face)->mScaleT; - } - } func; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, scale_t ); - identical = align_planar ? identical_planar_aligned : identical; + bool identical_diff_scale_t = false; + bool identical_spec_scale_t = false; + bool identical_norm_scale_t = false; - F32 scale_t_value = editable ? scale_t : 0; - scale_t_value *= identical_planar_texgen ? 2.0f : 1.0f; + F32 diff_scale_t = 1.f; + F32 spec_scale_t = 1.f; + F32 norm_scale_t = 1.f; - getChild("TexScaleV")->setValue(scale_t_value); - getChild("TexScaleV")->setTentative(LLSD((BOOL)(!identical))); - getChildView("TexScaleV")->setEnabled(editable); - - scale_t = 1.f; - struct f4 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 s = 1.f, t = 1.f; + LLSelectedTE::getOffsetT(diff_scale_t, identical_diff_scale_t); + LLSelectedTEMaterial::getSpecularRepeatY(spec_scale_t, identical_spec_scale_t); + LLSelectedTEMaterial::getNormalRepeatY(norm_scale_t, identical_norm_scale_t); - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - mat->getSpecularRepeat(s, t); - } - return t; - } - } shiny_func; - - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &shiny_func, scale_t ); - identical = align_planar ? identical_planar_aligned : identical; + diff_scale_t = editable ? diff_scale_t : 1.0f; + diff_scale_t *= identical_planar_texgen ? 2.0f : 1.0f; - scale_t_value = editable ? scale_t : 0; - scale_t_value *= identical_planar_texgen ? 2.0f : 1.0f; + norm_scale_t = editable ? norm_scale_t : 1.0f; + norm_scale_t *= identical_planar_texgen ? 2.0f : 1.0f; - getChild("shinyScaleV")->setValue(scale_t_value); - getChild("shinyScaleV")->setTentative(LLSD((BOOL)(!identical))); - getChildView("shinyScaleV")->setEnabled(editable && specmap_id.notNull()); + spec_scale_t = editable ? spec_scale_t : 1.0f; + spec_scale_t *= identical_planar_texgen ? 2.0f : 1.0f; - scale_t = 1.f; - struct f5 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 s = 1.f, t = 1.f; + BOOL diff_scale_tentative = !(identical && identical_diff_scale_t); + BOOL norm_scale_tentative = !(identical && identical_norm_scale_t); + BOOL spec_scale_tentative = !(identical && identical_spec_scale_t); - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - mat->getNormalRepeat(s, t); - } - return t; - } - } bump_func; - - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &bump_func, scale_t ); - identical = align_planar ? identical_planar_aligned : identical; + getChildView("TexScaleV")->setEnabled(editable); + getChildView("shinyScaleV")->setEnabled(editable && specmap_id.notNull()); + getChildView("bumpyScaleV")->setEnabled(editable && normmap_id.notNull()); - scale_t_value = editable ? scale_t : 0.0f; - scale_t_value *= identical_planar_texgen ? 2.0f : 1.0f; + getChild("TexScaleV")->setValue(diff_scale_t); + getChild("shinyScaleV")->setValue(norm_scale_t); + getChild("bumpyScaleV")->setValue(spec_scale_t); - getChild("bumpyScaleV")->setValue(scale_t_value); - getChild("bumpyScaleV")->setTentative(LLSD((BOOL)(!identical))); - getChildView("bumpyScaleV")->setEnabled(editable && normmap_id.notNull()); - + getChild("TexScaleV")->setTentative(LLSD(diff_scale_tentative)); + getChild("shinyScaleV")->setTentative(LLSD(norm_scale_tentative)); + getChild("bumpyScaleV")->setTentative(LLSD(spec_scale_tentative)); } // Texture offset { - getChildView("tex offset")->setEnabled(editable); - F32 offset_s = 0.f; - struct f4 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - return object->getTE(face)->mOffsetS; - } - } func; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, offset_s ); - identical = align_planar ? identical_planar_aligned : identical; - getChild("TexOffsetU")->setValue(editable ? offset_s : 0); - getChild("TexOffsetU")->setTentative(!identical); - getChildView("TexOffsetU")->setEnabled(editable); + bool identical_diff_offset_s = false; + bool identical_norm_offset_s = false; + bool identical_spec_offset_s = false; - offset_s = 1.f; - struct f3 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 s = 0.f, t = 0.f; + F32 diff_offset_s = 0.0f; + F32 norm_offset_s = 0.0f; + F32 spec_offset_s = 0.0f; - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - mat->getSpecularOffset(s, t); - } - return s; - } - } shiny_func; - - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &shiny_func, offset_s ); - identical = align_planar ? identical_planar_aligned : identical; - getChild("shinyOffsetU")->setValue(editable ? offset_s : 0); - getChild("shinyOffsetU")->setTentative(LLSD((BOOL)(!identical))); - getChildView("shinyOffsetU")->setEnabled(editable && specmap_id.notNull()); + LLSelectedTE::getOffsetS(diff_offset_s, identical_diff_offset_s); + LLSelectedTEMaterial::getNormalOffsetX(norm_offset_s, identical_norm_offset_s); + LLSelectedTEMaterial::getSpecularOffsetX(spec_offset_s, identical_spec_offset_s); - offset_s = 1.f; - struct f5 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 s = 0.f, t = 0.f; + BOOL diff_offset_u_tentative = !(align_planar ? identical_planar_aligned : identical_diff_offset_s); + BOOL norm_offset_u_tentative = !(align_planar ? identical_planar_aligned : identical_norm_offset_s); + BOOL spec_offset_u_tentative = !(align_planar ? identical_planar_aligned : identical_spec_offset_s); - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - mat->getNormalOffset(s, t); - } - return s; - } - } bump_func; - - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &bump_func, offset_s ); - identical = align_planar ? identical_planar_aligned : identical; + getChild("TexOffsetU")->setValue( editable ? diff_offset_s : 0.0f); + getChild("bumpyOffsetU")->setValue(editable ? norm_offset_s : 0.0f); + getChild("shinyOffsetU")->setValue(editable ? spec_offset_s : 0.0f); + + getChild("TexOffsetU")->setTentative(LLSD(diff_offset_u_tentative)); + getChild("shinyOffsetU")->setTentative(LLSD(norm_offset_u_tentative)); + getChild("bumpyOffsetU")->setTentative(LLSD(spec_offset_u_tentative)); - getChild("bumpyOffsetU")->setValue(editable ? offset_s : 0); - getChild("bumpyOffsetU")->setTentative(LLSD((BOOL)(!identical))); + getChildView("TexOffsetU")->setEnabled(editable); + getChildView("shinyOffsetU")->setEnabled(editable && specmap_id.notNull()); getChildView("bumpyOffsetU")->setEnabled(editable && normmap_id.notNull()); } { - F32 offset_t = 0.f; - struct f5 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - return object->getTE(face)->mOffsetT; - } - } func; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, offset_t ); - identical = align_planar ? identical_planar_aligned : identical; - getChild("TexOffsetV")->setValue(editable ? offset_t : 0); - getChild("TexOffsetV")->setTentative(!identical); - getChildView("TexOffsetV")->setEnabled(editable); - - - offset_t = 1.f; - struct f3 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 s = 0.f, t = 0.f; + bool identical_diff_offset_t = false; + bool identical_norm_offset_t = false; + bool identical_spec_offset_t = false; - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - mat->getSpecularOffset(s, t); - } - return t; - } - } shiny_func; + F32 diff_offset_t = 0.0f; + F32 norm_offset_t = 0.0f; + F32 spec_offset_t = 0.0f; + + LLSelectedTE::getOffsetT(diff_offset_t, identical_diff_offset_t); + LLSelectedTEMaterial::getNormalOffsetY(norm_offset_t, identical_norm_offset_t); + LLSelectedTEMaterial::getSpecularOffsetY(spec_offset_t, identical_spec_offset_t); - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &shiny_func, offset_t ); - identical = align_planar ? identical_planar_aligned : identical; - getChild("shinyOffsetV")->setValue(editable ? offset_t : 0); - getChild("shinyOffsetV")->setTentative(LLSD((BOOL)(!identical))); - getChildView("shinyOffsetV")->setEnabled(editable && specmap_id.notNull()); + BOOL diff_offset_v_tentative = !(align_planar ? identical_planar_aligned : identical_diff_offset_t); + BOOL norm_offset_v_tentative = !(align_planar ? identical_planar_aligned : identical_norm_offset_t); + BOOL spec_offset_v_tentative = !(align_planar ? identical_planar_aligned : identical_spec_offset_t); - offset_t = 1.f; - struct f4 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 s = 0.f, t = 0.f; + getChild("TexOffsetV")->setValue( editable ? diff_offset_t : 0.0f); + getChild("bumpyOffsetV")->setValue(editable ? norm_offset_t : 0.0f); + getChild("shinyOffsetV")->setValue(editable ? spec_offset_t : 0.0f); - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - mat->getNormalOffset(s, t); - } - return t; - } - } bump_func; - - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &bump_func, offset_t ); - identical = align_planar ? identical_planar_aligned : identical; + getChild("TexOffsetV")->setTentative(LLSD(diff_offset_v_tentative)); + getChild("shinyOffsetV")->setTentative(LLSD(norm_offset_v_tentative)); + getChild("bumpyOffsetV")->setTentative(LLSD(spec_offset_v_tentative)); - getChild("bumpyOffsetV")->setValue(editable ? offset_t : 0); - getChild("bumpyOffsetV")->setTentative(LLSD((BOOL)(!identical))); + getChildView("TexOffsetV")->setEnabled(editable); + getChildView("shinyOffsetV")->setEnabled(editable && specmap_id.notNull()); getChildView("bumpyOffsetV")->setEnabled(editable && normmap_id.notNull()); } // Texture rotation { - F32 rotation = 0.f; - struct f6 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - return object->getTE(face)->mRotation; - } - } func; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, rotation ); - identical = align_planar ? identical_planar_aligned : identical; - getChild("TexRot")->setValue(editable ? rotation * RAD_TO_DEG : 0); - getChild("TexRot")->setTentative(!identical); - getChildView("TexRot")->setEnabled(editable); + bool identical_diff_rotation = false; + bool identical_norm_rotation = false; + bool identical_spec_rotation = false; + F32 diff_rotation = 0.f; + F32 norm_rotation = 0.f; + F32 spec_rotation = 0.f; - - rotation = 1.f; - struct f3 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 ret = 0.f; + LLSelectedTE::getRotation(diff_rotation,identical_diff_rotation); + LLSelectedTEMaterial::getSpecularRotation(spec_rotation,identical_spec_rotation); + LLSelectedTEMaterial::getNormalRotation(norm_rotation,identical_norm_rotation); - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - ret = mat->getSpecularRotation(); - } - return ret; - } - } shiny_func; - - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &shiny_func, rotation ); - identical = align_planar ? identical_planar_aligned : identical; - getChild("shinyRot")->setValue(editable ? rotation * RAD_TO_DEG : 0); - getChild("shinyRot")->setTentative(LLSD((BOOL)(!identical))); - getChildView("shinyRot")->setEnabled(editable && specmap_id.notNull()); + BOOL diff_rot_tentative = !(align_planar ? identical_planar_aligned : identical_diff_rotation); + BOOL norm_rot_tentative = !(align_planar ? identical_planar_aligned : identical_norm_rotation); + BOOL spec_rot_tentative = !(align_planar ? identical_planar_aligned : identical_spec_rotation); - rotation = 1.f; - struct f4 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - F32 ret = 0.f; + F32 diff_rot_deg = diff_rotation * RAD_TO_DEG; + F32 norm_rot_deg = norm_rotation * RAD_TO_DEG; + F32 spec_rot_deg = spec_rotation * RAD_TO_DEG; - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - if (mat) - { - ret = mat->getNormalRotation(); - } - return ret; - } - } bump_func; - - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &bump_func, rotation ); - identical = align_planar ? identical_planar_aligned : identical; - - F32 normal_rot_deg = rotation * RAD_TO_DEG; - getChild("bumpyRot")->setValue(editable ? normal_rot_deg : 0.0f); - getChild("bumpyRot")->setTentative(LLSD((BOOL)(!identical))); + getChildView("TexRot")->setEnabled(editable); + getChildView("shinyRot")->setEnabled(editable && specmap_id.notNull()); getChildView("bumpyRot")->setEnabled(editable && normmap_id.notNull()); + + getChild("TexRot")->setTentative(diff_rot_tentative); + getChild("shinyRot")->setTentative(LLSD(norm_rot_tentative)); + getChild("bumpyRot")->setTentative(LLSD(spec_rot_tentative)); + + getChild("TexRot")->setValue( editable ? diff_rot_deg : 0.0f); + getChild("shinyRot")->setValue(editable ? spec_rot_deg : 0.0f); + getChild("bumpyRot")->setValue(editable ? norm_rot_deg : 0.0f); } { F32 glow = 0.f; - struct f8 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - return object->getTE(face)->getGlow(); - } - } func; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, glow ); + bool identical_glow = false; + + LLSelectedTE::getGlow(glow,identical_glow); + + identical = identical && identical_glow; getChild("glow")->setValue(glow); getChildView("glow")->setEnabled(editable); getChild("glow")->setTentative(!identical); getChildView("glow label")->setEnabled(editable); - } - - { - LLCtrlSelectionInterface* combobox_texgen = - childGetSelectionInterface("combobox texgen"); + LLCtrlSelectionInterface* combobox_texgen = childGetSelectionInterface("combobox texgen"); if (combobox_texgen) { - combobox_texgen->selectNthItem(((S32)selected_texgen) >> 1); // Maps from enum to combobox entry index + // Maps from enum to combobox entry index + combobox_texgen->selectNthItem(((S32)selected_texgen) >> 1); } else { llwarns << "failed childGetSelectionInterface for 'combobox texgen'" << llendl; } + getChildView("combobox texgen")->setEnabled(editable); getChild("combobox texgen")->setTentative(!identical); getChildView("tex gen")->setEnabled(editable); @@ -1450,14 +1172,11 @@ void LLPanelFace::updateUI() { U8 fullbright_flag = 0; - struct f12 : public LLSelectedTEGetFunctor - { - U8 get(LLViewerObject* object, S32 face) - { - return object->getTE(face)->getFullbright(); - } - } func; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, fullbright_flag ); + bool identical_fullbright = false; + + LLSelectedTE::getFullbright(fullbright_flag,identical_fullbright); + + identical = identical && identical_fullbright; getChild("checkbox fullbright")->setValue((S32)(fullbright_flag != 0)); getChildView("checkbox fullbright")->setEnabled(editable); @@ -1470,65 +1189,13 @@ void LLPanelFace::updateUI() F32 repeats_norm = 1.f; F32 repeats_spec = 1.f; - struct f13 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - U32 s_axis = VX; - U32 t_axis = VY; - // BUG: Only repeats along S axis - // BUG: Only works for boxes. - LLPrimitive::getTESTAxes(face, &s_axis, &t_axis); - F32 repeats_s = object->getTE(face)->mScaleS / object->getScale().mV[s_axis]; - F32 repeats_t = object->getTE(face)->mScaleT / object->getScale().mV[t_axis]; - return llmax(repeats_s, repeats_t); - } - - } func_diff; - bool identical_diff_repeats = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func_diff, repeats_diff ); - - struct f14 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - U32 s_axis = VX; - U32 t_axis = VY; - F32 repeats_s = 1.0f; - F32 repeats_t = 1.0f; - if (mat) - { - mat->getNormalRepeat(repeats_s, repeats_t); - repeats_s /= object->getScale().mV[s_axis]; - repeats_t /= object->getScale().mV[t_axis]; - } - return llmax(repeats_s, repeats_t); - } - - } func_norm; - BOOL identical_norm_repeats = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func_norm, repeats_norm ); + bool identical_diff_repeats = false; + bool identical_norm_repeats = false; + bool identical_spec_repeats = false; - struct f15 : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); - U32 s_axis = VX; - U32 t_axis = VY; - F32 repeats_s = 1.0f; - F32 repeats_t = 1.0f; - if (mat) - { - mat->getSpecularRepeat(repeats_s, repeats_t); - repeats_s /= object->getScale().mV[s_axis]; - repeats_t /= object->getScale().mV[t_axis]; - } - return llmax(repeats_s, repeats_t); - } - - } func_spec; - BOOL identical_spec_repeats = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func_spec, repeats_spec ); - + LLSelectedTE::getMaxDiffuseRepeats(repeats_spec, identical_spec_repeats); + LLSelectedTEMaterial::getMaxNormalRepeats(repeats_spec, identical_spec_repeats); + LLSelectedTEMaterial::getMaxSpecularRepeats(repeats_spec, identical_spec_repeats); LLComboBox* mComboTexGen = getChild("combobox texgen"); if (mComboTexGen) @@ -1575,16 +1242,8 @@ void LLPanelFace::updateUI() // Materials { - struct f1 : public LLSelectedTEGetFunctor - { - LLMaterialPtr get(LLViewerObject* object, S32 te_index) - { - return object->getTE(te_index)->getMaterialParams(); - } - } func; - LLMaterialPtr material; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, material ); + LLSelectedTEMaterial::getCurrent(material, identical); if (material && editable) { @@ -1616,19 +1275,7 @@ void LLPanelFace::updateUI() getChild("maskcutoff")->setValue(material->getAlphaMaskCutoff()); updateAlphaControls(); - LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; - bool identical_texgen = true; - bool identical_planar_texgen = false; - - struct f44 : public LLSelectedTEGetFunctor - { - LLTextureEntry::e_texgen get(LLViewerObject* object, S32 face) - { - return (LLTextureEntry::e_texgen)(object->getTE(face)->getTexGen()); - } - } func; - identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen ); - identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)); + identical_planar_texgen = isIdenticalPlanarTexgen(); // Shiny (specular) F32 offset_x, offset_y, repeat_x, repeat_y, rot; @@ -1771,143 +1418,75 @@ void LLPanelFace::refresh() getState(); } -void LLPanelFace::updateMaterial() -{ // assign current state of UI to material definition for submit to sim - LL_DEBUGS("Materials") << "Entered." << LL_ENDL; - LLComboBox* comboAlphaMode = getChild("combobox alphamode"); - LLComboBox* comboBumpiness = getChild("combobox bumpiness"); - LLComboBox* comboShininess = getChild("combobox shininess"); - if (!comboAlphaMode || !comboBumpiness || !comboShininess) - { +/* +void LLPanelFace::updateMaterialParams(LLMaterialEditFunctorBase* edit_func) +{ + if (!edit_func) return; - } - U32 alpha_mode = comboAlphaMode->getCurrentIndex(); - U32 bumpiness = comboBumpiness->getCurrentIndex(); - U32 shininess = comboShininess->getCurrentIndex(); - - LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; - struct f45 : public LLSelectedTEGetFunctor - { - LLTextureEntry::e_texgen get(LLViewerObject* object, S32 face) - { - return (LLTextureEntry::e_texgen)(object->getTE(face)->getTexGen()); - } - } func; - bool identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen ); - bool identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)); - - bool is_default_blend_mode = mIsAlpha ? (alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) - : (alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_NONE); - - LLUUID norm_map_id = getChild("bumpytexture control")->getImageAssetID(); - LLUUID spec_map_id = getChild("shinytexture control")->getImageAssetID(); - if ( !is_default_blend_mode - || !norm_map_id.isNull() - || !spec_map_id.isNull()) + struct LLSelectedTEEditMaterial : public LLSelectedTEMaterialFunctor { - // This should match getState() - struct f1 : public LLSelectedTEGetFunctor + LLSelectedTEEditMaterial(LLPanelFace* panel, LLMaterialEditFunctorBase* edit) : _panel(panel), _edit(edit) {}; + virtual ~LLSelectedTEEditMaterial() {}; + virtual LLMaterialPtr apply(LLViewerObject* object, S32 face, LLTextureEntry* tep, LLMaterialPtr& current_material) { - LLMaterialPtr get(LLViewerObject* object, S32 te_index) + if (_edit) { - return object->getTE(te_index)->getMaterialParams(); - } - } func; - LLMaterialPtr cur_material; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, cur_material); - - bool new_material = cur_material.isNull(); - - LLMaterialPtr material( (!new_material) ? new LLMaterial(cur_material->asLLSD()) : new LLMaterial()); - llassert_always(material); - - material->setDiffuseAlphaMode(getChild("combobox alphamode")->getCurrentIndex()); - material->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); - - if (!norm_map_id.isNull() && (bumpiness == BUMPY_TEXTURE)) - { - LL_DEBUGS("Materials") << "Setting bumpy texture, bumpiness = " << bumpiness << LL_ENDL; - material->setNormalID(norm_map_id); + // Yesterday's news... + // + //U32 current_alpha_mode = _panel->getCurrentDiffuseAlphaMode(); + //LLUUID old_normal_map_id = _panel->getCurrentNormalMap(); + //LLUUID old_spec_map_id = _panel->getCurrentSpecularMap(); + //bool was_default_blend_mode = (current_alpha_mode == (_panel->isAlpha() ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE)); + //bool was_need_material = !was_default_blend_mode || !old_normal_map_id.isNull() || !old_spec_map_id.isNull(); - F32 bumpy_scale_u = getChild("bumpyScaleU")->getValue().asReal(); - F32 bumpy_scale_v = getChild("bumpyScaleV")->getValue().asReal(); + LLMaterialPtr new_material(!current_material.isNull() ? new LLMaterial(current_material->asLLSD()) : new LLMaterial()); + llassert_always(new_material); - if (identical_planar_texgen) - { - bumpy_scale_u *= 0.5f; - bumpy_scale_v *= 0.5f; - } + // Do "It"! + // + _edit->apply(new_material); - material->setNormalOffset(getChild("bumpyOffsetU")->getValue().asReal(), - getChild("bumpyOffsetV")->getValue().asReal()); - material->setNormalRepeat(bumpy_scale_u, bumpy_scale_v); - F32 normal_rot_rads = getChild("bumpyRot")->getValue().asReal()*DEG_TO_RAD; - material->setNormalRotation(normal_rot_rads); - } - else - { - LL_DEBUGS("Materials") << "Removing bumpy texture, bumpiness = " << bumpiness << LL_ENDL; - material->setNormalID(LLUUID()); - material->setNormalOffset(0.0f,0.0f); - material->setNormalRepeat(1.0f,1.0f); - material->setNormalRotation(0.0f); - } - - + U32 new_alpha_mode = new_material->getDiffuseAlphaMode(); + LLUUID new_normal_map_id = new_material->getNormalID(); + LLUUID new_spec_map_id = new_material->getSpecularID(); - if (!spec_map_id.isNull() && (shininess == SHINY_TEXTURE)) - { - LL_DEBUGS("Materials") << "Setting shiny texture, shininess = " << shininess << LL_ENDL; - material->setSpecularID(spec_map_id); - material->setSpecularOffset(getChild("shinyOffsetU")->getValue().asReal(), - getChild("shinyOffsetV")->getValue().asReal()); + bool is_default_blend_mode = (new_alpha_mode == (_panel->isAlpha() ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE)); + bool is_need_material = !is_default_blend_mode || !new_normal_map_id.isNull() || !new_spec_map_id.isNull(); - F32 shiny_scale_u = getChild("shinyScaleU")->getValue().asReal(); - F32 shiny_scale_v = getChild("shinyScaleV")->getValue().asReal(); + if (!current_material.isNull() && !is_need_material) + { + LL_DEBUGS("Materials") << "Removing material from object " << object->getID() << " face " << face << LL_ENDL; + LLMaterialMgr::getInstance()->remove(object->getID(),face); + } + else + { + // Replicate old init behavior + // + if (current_material.isNull()) + { + U8 current_alpha_mode = _panel->getCurrentDiffuseAlphaMode(); + U8 current_alpha_mask_cutoff = _panel->getCurrentAlphaMaskCutoff(); - if (identical_planar_texgen) - { - shiny_scale_u *= 0.5f; - shiny_scale_v *= 0.5f; - } + new_material->setDiffuseAlphaMode(current_alpha_mode); + new_material->setAlphaMaskCutoff(current_alpha_mask_cutoff); + } - material->setSpecularRepeat(shiny_scale_u, shiny_scale_v); - material->setSpecularRotation(getChild("shinyRot")->getValue().asReal()*DEG_TO_RAD); + LL_DEBUGS("Materials") << "Putting material on object " << object->getID() << " face " << face << ", material: " << new_material->asLLSD() << LL_ENDL; + LLMaterialMgr::getInstance()->put(object->getID(),face,*new_material); + } - //override shininess to 0.2f if this is a new material - if (!new_material) - { - material->setSpecularLightColor(getChild("shinycolorswatch")->get()); - material->setSpecularLightExponent(getChild("glossiness")->getValue().asInteger()); - material->setEnvironmentIntensity(getChild("environment")->getValue().asInteger()); + object->setTEMaterialParams(face, new_material); + return new_material; } + return NULL; } - else - { - LL_DEBUGS("Materials") << "Removing shiny texture, shininess = " << shininess << LL_ENDL; - material->setSpecularID(LLUUID()); - material->setSpecularOffset(0.0f,0.0f); - material->setSpecularRepeat(1.0f,1.0f); - material->setSpecularRotation(0.0f); - material->setSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR); - material->setSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT); - material->setEnvironmentIntensity(0); - } - - LL_DEBUGS("Materials") << "Updating material: " << material->asLLSD() << LL_ENDL; - - LLSelectMgr::getInstance()->selectionSetMaterial( material ); - } - else - { - // The user has specified settings that don't need a material. - LL_DEBUGS("Materials") << "Resetting material entry" << LL_ENDL; - - // Delete existing material entry... - LLSelectMgr::getInstance()->selectionRemoveMaterial(); - } + LLMaterialEditFunctorBase* _edit; + LLPanelFace* _panel; + } editor(this, edit_func); + LLSelectMgr::getInstance()->selectionSetMaterialParams(&editor); } +*/ // // Static functions @@ -1927,7 +1506,7 @@ void LLPanelFace::onCommitColor(const LLSD& data) void LLPanelFace::onCommitShinyColor(const LLSD& data) { - updateMaterial(); + LLSelectedTEMaterial::setSpecularLightColor(this, getChild("shinycolorswatch")->get()); } void LLPanelFace::onCommitAlpha(const LLSD& data) @@ -2216,7 +1795,7 @@ void LLPanelFace::onCommitAlphaMode(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; self->updateAlphaControls(); - self->updateMaterial(); + LLSelectedTEMaterial::setDiffuseAlphaMode(self,self->getCurrentDiffuseAlphaMode()); } // static @@ -2268,18 +1847,8 @@ void LLPanelFace::onSelectTexture(const LLSD& data) sendTexture(); LLGLenum image_format; - struct f2 : public LLSelectedTEGetFunctor - { - LLGLenum get(LLViewerObject* object, S32 te_index) - { - LLGLenum image_format = GL_RGB; - - LLViewerTexture* image = object->getTEImage(te_index); - if (image) image_format = image->getPrimaryFormat(); - return image_format; - } - } func2; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func2, image_format ); + bool identical_image_format = false; + LLSelectedTE::getImageFormat(image_format, identical_image_format); LLCtrlSelectionInterface* combobox_alphamode = childGetSelectionInterface("combobox alphamode"); @@ -2306,8 +1875,7 @@ void LLPanelFace::onSelectTexture(const LLSD& data) combobox_alphamode->selectNthItem(alpha_mode); } - - updateMaterial(); + LLSelectedTEMaterial::setDiffuseAlphaMode(this, getCurrentDiffuseAlphaMode()); } void LLPanelFace::onCommitSpecularTexture( const LLSD& data ) @@ -2324,17 +1892,9 @@ void LLPanelFace::onCommitNormalTexture( const LLSD& data ) void LLPanelFace::onCancelSpecularTexture(const LLSD& data) { - - U8 shiny = 0; - struct get_shiny : public LLSelectedTEGetFunctor - { - U8 get(LLViewerObject* object, S32 face) - { - return (U8)(object->getTE(face)->getShiny()); - } - } func; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, shiny ); - + U8 shiny = 0; + bool identical_shiny = false; + LLSelectedTE::getShiny(shiny, identical_shiny); LLUUID spec_map_id = getChild("shinytexture control")->getImageAssetID(); shiny = spec_map_id.isNull() ? shiny : SHINY_TEXTURE; sendShiny(shiny); @@ -2342,16 +1902,9 @@ void LLPanelFace::onCancelSpecularTexture(const LLSD& data) void LLPanelFace::onCancelNormalTexture(const LLSD& data) { - U8 bumpy = 0; - struct get_bumpy : public LLSelectedTEGetFunctor - { - U8 get(LLViewerObject* object, S32 face) - { - return (U8)(object->getTE(face)->getBumpmap()); - } - - } func; - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, bumpy ); + U8 bumpy = 0; + bool identical_bumpy = false; + LLSelectedTE::getBumpmap(bumpy, identical_bumpy); sendBump(bumpy); } @@ -2368,10 +1921,126 @@ void LLPanelFace::onSelectNormalTexture(const LLSD& data) } //static -void LLPanelFace::onCommitMaterial(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitMaterialBumpyOffsetX(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + LLSelectedTEMaterial::setNormalOffsetX(self,self->getCurrentBumpyOffsetU()); +} + +//static +void LLPanelFace::onCommitMaterialBumpyOffsetY(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + LLSelectedTEMaterial::setNormalOffsetY(self,self->getCurrentBumpyOffsetV()); +} + +//static +void LLPanelFace::onCommitMaterialShinyOffsetX(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + LLSelectedTEMaterial::setSpecularOffsetX(self,self->getCurrentShinyOffsetU()); +} + +//static +void LLPanelFace::onCommitMaterialShinyOffsetY(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + LLSelectedTEMaterial::setSpecularOffsetY(self,self->getCurrentShinyOffsetV()); +} + +//static +void LLPanelFace::onCommitMaterialBumpyScaleX(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + F32 bumpy_scale_u = self->getCurrentBumpyScaleU(); + if (self->isIdenticalPlanarTexgen()) + { + bumpy_scale_u *= 0.5f; + } + LLSelectedTEMaterial::setNormalRepeatX(self,bumpy_scale_u); +} + +//static +void LLPanelFace::onCommitMaterialBumpyScaleY(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + F32 bumpy_scale_v = self->getCurrentBumpyScaleV(); + if (self->isIdenticalPlanarTexgen()) + { + bumpy_scale_v *= 0.5f; + } + LLSelectedTEMaterial::setNormalRepeatY(self,bumpy_scale_v); +} + +//static +void LLPanelFace::onCommitMaterialShinyScaleX(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + F32 shiny_scale_u = self->getCurrentShinyScaleU(); + if (self->isIdenticalPlanarTexgen()) + { + shiny_scale_u *= 0.5f; + } + LLSelectedTEMaterial::setSpecularRepeatX(self,shiny_scale_u); +} + +//static +void LLPanelFace::onCommitMaterialShinyScaleY(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + F32 shiny_scale_v = self->getCurrentShinyScaleV(); + if (self->isIdenticalPlanarTexgen()) + { + shiny_scale_v *= 0.5f; + } + LLSelectedTEMaterial::setSpecularRepeatY(self,shiny_scale_v); +} + +//static +void LLPanelFace::onCommitMaterialBumpyRot(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + LLSelectedTEMaterial::setNormalRotation(self,self->getCurrentBumpyRot()); +} + +//static +void LLPanelFace::onCommitMaterialShinyRot(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + LLSelectedTEMaterial::setSpecularRotation(self,self->getCurrentShinyRot()); +} + +//static +void LLPanelFace::onCommitMaterialGloss(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + LLSelectedTEMaterial::setSpecularLightExponent(self,self->getCurrentGlossiness()); +} + +//static +void LLPanelFace::onCommitMaterialEnv(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + llassert_always(self); + LLSelectedTEMaterial::setEnvironmentIntensity(self,self->getCurrentEnvIntensity()); +} + +//static +void LLPanelFace::onCommitMaterialMaskCutoff(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; - self->updateMaterial(); + LLSelectedTEMaterial::setAlphaMaskCutoff(self,self->getCurrentAlphaMaskCutoff()); } // static @@ -2387,44 +2056,21 @@ void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; - LLUICtrl* repeats_ctrl = self->getChild("rptctrl"); + LLUICtrl* repeats_ctrl = self->getChild("rptctrl"); + LLComboBox* combo_mattype = self->getChild("combobox mattype"); - F32 repeats_per_meter = repeats_ctrl->getValue().asReal(); - - LLComboBox* combo_mattype = self->getChild("combobox mattype"); + U32 material_type = combo_mattype->getCurrentIndex(); + F32 repeats_per_meter = repeats_ctrl->getValue().asReal(); - F32 obj_scale_s = 1.0f; - F32 obj_scale_t = 1.0f; - - U32 material_type = combo_mattype->getCurrentIndex(); + F32 obj_scale_s = 1.0f; + F32 obj_scale_t = 1.0f; - struct f_objscale_s : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - U32 s_axis = VX; - U32 t_axis = VY; - LLPrimitive::getTESTAxes(face, &s_axis, &t_axis); - return object->getScale().mV[s_axis]; - } - - } scale_s_func; - - struct f_objscale_t : public LLSelectedTEGetFunctor - { - F32 get(LLViewerObject* object, S32 face) - { - U32 s_axis = VX; - U32 t_axis = VY; - LLPrimitive::getTESTAxes(face, &s_axis, &t_axis); - return object->getScale().mV[t_axis]; - } - - } scale_t_func; - - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &scale_s_func, obj_scale_s ); - LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &scale_t_func, obj_scale_t ); - + bool identical_scale_s = false; + bool identical_scale_t = false; + + LLSelectedTE::getObjectScaleS(obj_scale_s, identical_scale_s); + LLSelectedTE::getObjectScaleS(obj_scale_t, identical_scale_t); + switch (material_type) { case MATTYPE_DIFFUSE: @@ -2437,9 +2083,12 @@ void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata) { LLUICtrl* bumpy_scale_u = self->getChild("bumpyScaleU"); LLUICtrl* bumpy_scale_v = self->getChild("bumpyScaleV"); + bumpy_scale_u->setValue(obj_scale_s * repeats_per_meter); bumpy_scale_v->setValue(obj_scale_t * repeats_per_meter); - self->updateMaterial(); + + LLSelectedTEMaterial::setNormalRepeatX(self,obj_scale_s * repeats_per_meter); + LLSelectedTEMaterial::setNormalRepeatY(self,obj_scale_t * repeats_per_meter); } break; @@ -2447,9 +2096,12 @@ void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata) { LLUICtrl* shiny_scale_u = self->getChild("shinyScaleU"); LLUICtrl* shiny_scale_v = self->getChild("shinyScaleV"); + shiny_scale_u->setValue(obj_scale_s * repeats_per_meter); shiny_scale_v->setValue(obj_scale_t * repeats_per_meter); - self->updateMaterial(); + + LLSelectedTEMaterial::setSpecularRepeatX(self,obj_scale_s * repeats_per_meter); + LLSelectedTEMaterial::setSpecularRepeatY(self,obj_scale_t * repeats_per_meter); } break; @@ -2580,3 +2232,180 @@ void LLPanelFace::onTextureSelectionChanged(LLInventoryItem* itemp) } } +bool LLPanelFace::isIdenticalPlanarTexgen() +{ + LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; + bool identical_texgen = false; + LLSelectedTE::getTexGen(selected_texgen, identical_texgen); + return (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)); +} + +void LLPanelFace::LLSelectedTE::getFace(LLFace*& face_to_return, bool& identical_face) +{ + struct LLSelectedTEGetFace : public LLSelectedTEGetFunctor + { + LLFace* get(LLViewerObject* object, S32 te) + { + return (object->mDrawable) ? object->mDrawable->getFace(te): NULL; + } + } get_te_face_func; + identical_face = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&get_te_face_func, face_to_return); +} + +void LLPanelFace::LLSelectedTE::getImageFormat(LLGLenum& image_format_to_return, bool& identical_face) +{ + struct LLSelectedTEGetImageFormat : public LLSelectedTEGetFunctor + { + LLGLenum get(LLViewerObject* object, S32 te_index) + { + LLViewerTexture* image = object->getTEImage(te_index); + return image ? image->getPrimaryFormat() : GL_RGB; + } + } get_glenum; + identical_face = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&get_glenum, image_format_to_return); +} + +void LLPanelFace::LLSelectedTE::getTexId(LLUUID& id, bool& identical) +{ + struct LLSelectedTEGetTexId : public LLSelectedTEGetFunctor + { + LLUUID get(LLViewerObject* object, S32 te_index) + { + LLUUID id; + LLViewerTexture* image = object->getTEImage(te_index); + if (image) + { + id = image->getID(); + } + + if (!id.isNull() && LLViewerMedia::textureHasMedia(id)) + { + LLTextureEntry *te = object->getTE(te_index); + if (te) + { + LLViewerTexture* tex = te->getID().notNull() ? gTextureList.findImage(te->getID()) : NULL; + if(!tex) + { + tex = LLViewerFetchedTexture::sDefaultImagep; + } + if (tex) + { + id = tex->getID(); + } + } + } + return id; + } + } func; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, id ); +} + +void LLPanelFace::LLSelectedTEMaterial::getCurrent(LLMaterialPtr& material_ptr, bool& identical_material) +{ + struct MaterialFunctor : public LLSelectedTEGetFunctor + { + LLMaterialPtr get(LLViewerObject* object, S32 te_index) + { + return object->getTE(te_index)->getMaterialParams(); + } + } func; + identical_material = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, material_ptr); +} + +void LLPanelFace::LLSelectedTEMaterial::getMaxSpecularRepeats(F32& repeats, bool& identical) +{ + struct LLSelectedTEGetMaxSpecRepeats : public LLSelectedTEGetFunctor + { + F32 get(LLViewerObject* object, S32 face) + { + LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); + U32 s_axis = VX; + U32 t_axis = VY; + F32 repeats_s = 1.0f; + F32 repeats_t = 1.0f; + if (mat) + { + mat->getSpecularRepeat(repeats_s, repeats_t); + repeats_s /= object->getScale().mV[s_axis]; + repeats_t /= object->getScale().mV[t_axis]; + } + return llmax(repeats_s, repeats_t); + } + + } max_spec_repeats_func; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &max_spec_repeats_func, repeats); +} + +void LLPanelFace::LLSelectedTEMaterial::getMaxNormalRepeats(F32& repeats, bool& identical) +{ + struct LLSelectedTEGetMaxNormRepeats : public LLSelectedTEGetFunctor + { + F32 get(LLViewerObject* object, S32 face) + { + LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); + U32 s_axis = VX; + U32 t_axis = VY; + F32 repeats_s = 1.0f; + F32 repeats_t = 1.0f; + if (mat) + { + mat->getNormalRepeat(repeats_s, repeats_t); + repeats_s /= object->getScale().mV[s_axis]; + repeats_t /= object->getScale().mV[t_axis]; + } + return llmax(repeats_s, repeats_t); + } + + } max_norm_repeats_func; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &max_norm_repeats_func, repeats); +} + +void LLPanelFace::LLSelectedTE::getObjectScaleS(F32& scale_s, bool& identical) +{ + struct LLSelectedTEGetObjectScaleS : public LLSelectedTEGetFunctor + { + F32 get(LLViewerObject* object, S32 face) + { + U32 s_axis = VX; + U32 t_axis = VY; + LLPrimitive::getTESTAxes(face, &s_axis, &t_axis); + return object->getScale().mV[s_axis]; + } + + } scale_s_func; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &scale_s_func, scale_s ); +} + +void LLPanelFace::LLSelectedTE::getObjectScaleT(F32& scale_t, bool& identical) +{ + struct LLSelectedTEGetObjectScaleS : public LLSelectedTEGetFunctor + { + F32 get(LLViewerObject* object, S32 face) + { + U32 s_axis = VX; + U32 t_axis = VY; + LLPrimitive::getTESTAxes(face, &s_axis, &t_axis); + return object->getScale().mV[t_axis]; + } + + } scale_t_func; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &scale_t_func, scale_t ); +} + +void LLPanelFace::LLSelectedTE::getMaxDiffuseRepeats(F32& repeats, bool& identical) +{ + struct LLSelectedTEGetMaxDiffuseRepeats : public LLSelectedTEGetFunctor + { + F32 get(LLViewerObject* object, S32 face) + { + U32 s_axis = VX; + U32 t_axis = VY; + LLPrimitive::getTESTAxes(face, &s_axis, &t_axis); + F32 repeats_s = object->getTE(face)->mScaleS / object->getScale().mV[s_axis]; + F32 repeats_t = object->getTE(face)->mScaleT / object->getScale().mV[t_axis]; + return llmax(repeats_s, repeats_t); + } + + } max_diff_repeats_func; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &max_diff_repeats_func, repeats ); +} \ No newline at end of file diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index f64564c9a0..b93e214326 100755 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -30,6 +30,9 @@ #include "v4color.h" #include "llpanel.h" #include "llmaterial.h" +#include "llmaterialmgr.h" +#include "lltextureentry.h" +#include "llselectmgr.h" class LLButton; class LLCheckBoxCtrl; @@ -45,6 +48,48 @@ class LLViewerObject; class LLFloater; class LLMaterialID; +// Represents an edit for use in replicating the op across one or more materials in the selection set. +// +// The apply function optionally performs the edit which it implements +// as a functor taking Data that calls member func MaterialFunc taking SetValueType +// on an instance of the LLMaterial class. +// +// boost who? +// +template< + typename DataType, + typename SetValueType, + void (LLMaterial::*MaterialEditFunc)(SetValueType data) > +class LLMaterialEditFunctor +{ +public: + LLMaterialEditFunctor(const DataType& data) : _data(data) {} + virtual ~LLMaterialEditFunctor() {} + virtual void apply(LLMaterialPtr& material) { (material->*(MaterialEditFunc))(_data); } + DataType _data; +}; + +template< + typename DataType, + DataType (LLMaterial::*MaterialGetFunc)() > +class LLMaterialGetFunctor +{ +public: + LLMaterialGetFunctor() : {} + virtual DataType get(LLMaterialPtr& material) { return (material->*(MaterialGetFunc)); } +}; + +template< + typename DataType, + DataType (LLTextureEntry::*TEGetFunc)() > +class LLTEGetFunctor +{ +public: + LLTEGetFunctor() : _data(data) {} + virtual DataType get(LLTextureEntry* entry) { return (entry*(TEGetFunc)); } + DataType _data; +}; + class LLPanelFace : public LLPanel { public: @@ -93,10 +138,31 @@ protected: // void updateUI(); + // Convenience func to determine if all faces in selection have + // identical planar texgen settings during edits + // + bool isIdenticalPlanarTexgen(); + // Callback funcs for individual controls // static void onCommitTextureInfo( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterial( LLUICtrl* ctrl, void* userdata); + + static void onCommitMaterialBumpyScaleX( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialBumpyScaleY( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialBumpyRot( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialBumpyOffsetX( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialBumpyOffsetY( LLUICtrl* ctrl, void* userdata); + + static void onCommitMaterialShinyScaleX( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialShinyScaleY( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialShinyRot( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialShinyOffsetX( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialShinyOffsetY( LLUICtrl* ctrl, void* userdata); + + static void onCommitMaterialGloss( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialEnv( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialMaskCutoff( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialsMedia( LLUICtrl* ctrl, void* userdata); static void onCommitMaterialType( LLUICtrl* ctrl, void* userdata); static void onCommitBump( LLUICtrl* ctrl, void* userdata); @@ -113,6 +179,29 @@ protected: private: + bool isAlpha() { return mIsAlpha; } + + // Convenience funcs to keep the visual flack to a minimum + // + LLUUID getCurrentNormalMap(); + LLUUID getCurrentSpecularMap(); + U32 getCurrentShininess(); + U32 getCurrentBumpiness(); + U8 getCurrentDiffuseAlphaMode(); + U8 getCurrentAlphaMaskCutoff(); + U8 getCurrentEnvIntensity(); + U8 getCurrentGlossiness(); + F32 getCurrentBumpyRot(); + F32 getCurrentBumpyScaleU(); + F32 getCurrentBumpyScaleV(); + F32 getCurrentBumpyOffsetU(); + F32 getCurrentBumpyOffsetV(); + F32 getCurrentShinyRot(); + F32 getCurrentShinyScaleU(); + F32 getCurrentShinyScaleV(); + F32 getCurrentShinyOffsetU(); + F32 getCurrentShinyOffsetV(); + // Update visibility of controls to match current UI mode // (e.g. materials vs media editing) // @@ -120,10 +209,106 @@ private: // void updateVisibility(); - // Make material reflect current state of UI (apply edit) + // Make material(s) reflect current state of UI (apply edit) // void updateMaterial(); + // Hey look everyone, a type-safe alternative to copy and paste! :) + // + + // Update material parameters by applying 'edit_func' to selected TEs + // + template< + typename DataType, + typename SetValueType, + void (LLMaterial::*MaterialEditFunc)(SetValueType data) > + static void edit(LLPanelFace* p, DataType data) + { + LLMaterialEditFunctor< DataType, SetValueType, MaterialEditFunc > edit(data); + struct LLSelectedTEEditMaterial : public LLSelectedTEMaterialFunctor + { + LLSelectedTEEditMaterial(LLPanelFace* panel, LLMaterialEditFunctor< DataType, SetValueType, MaterialEditFunc >* editp) : _panel(panel), _edit(editp) {} + virtual ~LLSelectedTEEditMaterial() {}; + virtual LLMaterialPtr apply(LLViewerObject* object, S32 face, LLTextureEntry* tep, LLMaterialPtr& current_material) + { + if (_edit) + { + LLMaterialPtr new_material(!current_material.isNull() ? new LLMaterial(current_material->asLLSD()) : new LLMaterial()); + llassert_always(new_material); + + // Do "It"! + // + _edit->apply(new_material); + + U32 new_alpha_mode = new_material->getDiffuseAlphaMode(); + LLUUID new_normal_map_id = new_material->getNormalID(); + LLUUID new_spec_map_id = new_material->getSpecularID(); + + bool is_default_blend_mode = (new_alpha_mode == (_panel->isAlpha() ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE)); + bool is_need_material = !is_default_blend_mode || !new_normal_map_id.isNull() || !new_spec_map_id.isNull(); + + if (!current_material.isNull() && !is_need_material) + { + LL_DEBUGS("Materials") << "Removing material from object " << object->getID() << " face " << face << LL_ENDL; + LLMaterialMgr::getInstance()->remove(object->getID(),face); + } + else + { + // Replicate old init behavior + // + if (current_material.isNull()) + { + U8 current_alpha_mode = _panel->getCurrentDiffuseAlphaMode(); + U8 current_alpha_mask_cutoff = _panel->getCurrentAlphaMaskCutoff(); + + new_material->setDiffuseAlphaMode(current_alpha_mode); + new_material->setAlphaMaskCutoff(current_alpha_mask_cutoff); + } + + LL_DEBUGS("Materials") << "Putting material on object " << object->getID() << " face " << face << ", material: " << new_material->asLLSD() << LL_ENDL; + LLMaterialMgr::getInstance()->put(object->getID(),face,*new_material); + } + + object->setTEMaterialParams(face, new_material); + return new_material; + } + return NULL; + } + LLMaterialEditFunctor< DataType, SetValueType, MaterialEditFunc >* _edit; + LLPanelFace* _panel; + } editor(p, &edit); + LLSelectMgr::getInstance()->selectionSetMaterialParams(&editor); + } + + template< + typename DataType, + typename ReturnType, + ReturnType (LLMaterial::* const MaterialGetFunc)() const > + static void getTEMaterialValue(DataType& data_to_return, bool& identical) + { + struct GetTEMaterialVal : public LLSelectedTEGetFunctor + { + DataType get(LLViewerObject* object, S32 face) { return (object && object->getTE(face)) ? ((object->getTE(face)->getMaterialParams()->*(MaterialGetFunc))()) : DataType(); } + } GetFunc; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &GetFunc, data_to_return); + } + + template< + typename DataType, + typename ReturnType, // some kids just have to different... + ReturnType (LLTextureEntry::* const TEGetFunc)() const > + static void getTEValue(DataType& data_to_return, bool& identical) + { + struct GetTEVal : public LLSelectedTEGetFunctor + { + DataType get(LLViewerObject* object, S32 face) { + LLTextureEntry* tep = object ? object->getTE(face) : NULL; + return tep ? ((tep->*(TEGetFunc))()) : DataType(); + } + } GetTEValFunc; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &GetTEValFunc, data_to_return ); + } + // Update vis and enabling of specific subsets of controls based on material params // (e.g. hide the spec controls if no spec texture is applied) // @@ -152,6 +337,107 @@ private: */ bool mUpdateInFlight; bool mUpdatePending; + + #if defined(DEF_GET_MAT_STATE) + #undef DEF_GET_MAT_STATE + #endif + + #if defined(DEF_GET_TE_STATE) + #undef DEF_GET_TE_STATE + #endif + + // Accessors for selected TE material state + // + #define DEF_GET_MAT_STATE(DataType,ReturnType,MaterialMemberFunc) \ + static void MaterialMemberFunc(DataType& data, bool& identical) \ + { \ + getTEMaterialValue< DataType, ReturnType, &LLMaterial::##MaterialMemberFunc >(data, identical); \ + } + + // Mutators for selected TE material + // + #define DEF_EDIT_MAT_STATE(DataType,ReturnType,MaterialMemberFunc) \ + static void MaterialMemberFunc(LLPanelFace* p,DataType data) \ + { \ + edit< DataType, ReturnType, &LLMaterial::##MaterialMemberFunc >(p,data); \ + } + + + // Accessors for selected TE state proper (legacy settings etc) + // + #define DEF_GET_TE_STATE(DataType,ReturnType,TexEntryMemberFunc) \ + static void TexEntryMemberFunc(DataType& data, bool& identical) \ + { \ + getTEValue< DataType, ReturnType, &LLTextureEntry::##TexEntryMemberFunc >(data, identical); \ + } + + class LLSelectedTEMaterial + { + public: + static void getCurrent(LLMaterialPtr& material_ptr, bool& identical_material); + static void getMaxSpecularRepeats(F32& repeats, bool& identical); + static void getMaxNormalRepeats(F32& repeats, bool& identical); + + DEF_GET_MAT_STATE(LLUUID,const LLUUID&,getNormalID) + DEF_GET_MAT_STATE(LLUUID,const LLUUID&,getSpecularID) + DEF_GET_MAT_STATE(U8,U8,getDiffuseAlphaMode) + + DEF_GET_MAT_STATE(F32,F32,getSpecularRepeatX) + DEF_GET_MAT_STATE(F32,F32,getSpecularRepeatY) + DEF_GET_MAT_STATE(F32,F32,getSpecularOffsetX) + DEF_GET_MAT_STATE(F32,F32,getSpecularOffsetY) + DEF_GET_MAT_STATE(F32,F32,getSpecularRotation) + + DEF_GET_MAT_STATE(F32,F32,getNormalRepeatX) + DEF_GET_MAT_STATE(F32,F32,getNormalRepeatY) + DEF_GET_MAT_STATE(F32,F32,getNormalOffsetX) + DEF_GET_MAT_STATE(F32,F32,getNormalOffsetY) + DEF_GET_MAT_STATE(F32,F32,getNormalRotation) + + DEF_EDIT_MAT_STATE(U8,U8,setDiffuseAlphaMode); + DEF_EDIT_MAT_STATE(U8,U8,setAlphaMaskCutoff); + + DEF_EDIT_MAT_STATE(F32,F32,setNormalOffsetX); + DEF_EDIT_MAT_STATE(F32,F32,setNormalOffsetY); + DEF_EDIT_MAT_STATE(F32,F32,setNormalRepeatX); + DEF_EDIT_MAT_STATE(F32,F32,setNormalRepeatY); + DEF_EDIT_MAT_STATE(F32,F32,setNormalRotation); + + DEF_EDIT_MAT_STATE(F32,F32,setSpecularOffsetX); + DEF_EDIT_MAT_STATE(F32,F32,setSpecularOffsetY); + DEF_EDIT_MAT_STATE(F32,F32,setSpecularRepeatX); + DEF_EDIT_MAT_STATE(F32,F32,setSpecularRepeatY); + DEF_EDIT_MAT_STATE(F32,F32,setSpecularRotation); + + DEF_EDIT_MAT_STATE(U8,U8,setEnvironmentIntensity); + DEF_EDIT_MAT_STATE(U8,U8,setSpecularLightExponent); + + DEF_EDIT_MAT_STATE(LLUUID,const LLUUID&,setNormalID); + DEF_EDIT_MAT_STATE(LLUUID,const LLUUID&,setSpecularID); + DEF_EDIT_MAT_STATE(LLColor4U, const LLColor4U&,setSpecularLightColor); + }; + + class LLSelectedTE + { + public: + + static void getFace(LLFace*& face_to_return, bool& identical_face); + static void getImageFormat(LLGLenum& image_format_to_return, bool& identical_face); + static void getTexId(LLUUID& id, bool& identical); + static void getObjectScaleS(F32& scale_s, bool& identical); + static void getObjectScaleT(F32& scale_t, bool& identical); + static void getMaxDiffuseRepeats(F32& repeats, bool& identical); + + DEF_GET_TE_STATE(U8,U8,getBumpmap) + DEF_GET_TE_STATE(U8,U8,getShiny) + DEF_GET_TE_STATE(U8,U8,getFullbright) + DEF_GET_TE_STATE(F32,F32,getRotation) + DEF_GET_TE_STATE(F32,F32,getOffsetS) + DEF_GET_TE_STATE(F32,F32,getOffsetT) + DEF_GET_TE_STATE(F32,F32,getGlow) + DEF_GET_TE_STATE(LLTextureEntry::e_texgen,LLTextureEntry::e_texgen,getTexGen) + DEF_GET_TE_STATE(LLColor4,const LLColor4&,getColor) + }; }; #endif diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 37c11bd027..0cbdbe16a3 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2016,23 +2016,29 @@ void LLSelectMgr::selectionSetGlow(F32 glow) mSelectedObjects->applyToObjects( &func2 ); } -void LLSelectMgr::selectionSetMaterial(LLMaterialPtr material) +void LLSelectMgr::selectionSetMaterialParams(LLSelectedTEMaterialFunctor* material_func) { struct f1 : public LLSelectedTEFunctor { LLMaterialPtr mMaterial; - f1(LLMaterialPtr material) : mMaterial(material) {}; + f1(LLSelectedTEMaterialFunctor* material_func) : _material_func(material_func) {} + bool apply(LLViewerObject* object, S32 face) { - if (object->permModify()) + if (object && object->permModify() && _material_func) { - LL_DEBUGS("Materials") << "Putting material on object " << object->getID() << " face " << face << ", material: " << mMaterial->asLLSD() << LL_ENDL; - LLMaterialMgr::getInstance()->put(object->getID(),face,*mMaterial); - object->setTEMaterialParams(face,mMaterial); + LLTextureEntry* tep = object->getTE(face); + if (tep) + { + LLMaterialPtr current_material = tep->getMaterialParams(); + _material_func->apply(object, face, tep, current_material); + } } return true; } - } func1(material); + + LLSelectedTEMaterialFunctor* _material_func; + } func1(material_func); mSelectedObjects->applyToTEs( &func1 ); struct f2 : public LLSelectedObjectFunctor @@ -2531,7 +2537,8 @@ void LLSelectMgr::adjustTexturesByScale(BOOL send_to_sim, BOOL stretch) LLMaterialPtr p = new LLMaterial(orig->asLLSD()); p->setNormalRepeat(normal_scale_s, normal_scale_t); p->setSpecularRepeat(specular_scale_s, specular_scale_t); - selectionSetMaterial( p ); + + LLMaterialMgr::getInstance()->put(object->getID(), te_num, *p); } } else @@ -2553,10 +2560,12 @@ void LLSelectMgr::adjustTexturesByScale(BOOL send_to_sim, BOOL stretch) if (tep && !tep->getMaterialParams().isNull()) { LLMaterialPtr orig = tep->getMaterialParams(); + LLMaterialPtr p = new LLMaterial(orig->asLLSD()); p->setNormalRepeat(normal_scale_s, normal_scale_t); p->setSpecularRepeat(specular_scale_s, specular_scale_t); - selectionSetMaterial( p ); + + LLMaterialMgr::getInstance()->put(object->getID(), te_num, *p); } } send = send_to_sim; diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index f9b97cebdd..d4b736640c 100755 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -85,6 +85,12 @@ struct LLSelectedTEFunctor virtual bool apply(LLViewerObject* object, S32 face) = 0; }; +struct LLSelectedTEMaterialFunctor +{ + virtual ~LLSelectedTEMaterialFunctor() {}; + virtual LLMaterialPtr apply(LLViewerObject* object, S32 face, LLTextureEntry* tep, LLMaterialPtr& current_material) = 0; +}; + template struct LLSelectedTEGetFunctor { virtual ~LLSelectedTEGetFunctor() {}; @@ -549,7 +555,7 @@ public: void selectionSetClickAction(U8 action); void selectionSetIncludeInSearch(bool include_in_search); void selectionSetGlow(const F32 glow); - void selectionSetMaterial(LLMaterialPtr material); + void selectionSetMaterialParams(LLSelectedTEMaterialFunctor* material_func); void selectionRemoveMaterial(); void selectionSetObjectPermissions(U8 perm_field, BOOL set, U32 perm_mask, BOOL override = FALSE); -- cgit v1.3 From c78cd1aae63a7c7c0bf6a9c21380818aa9cd47b7 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 7 Jun 2013 14:37:39 -0700 Subject: NORSPEC-233 WIP fix completely bogus substitution of offsets for scales and make scale accessors get with the program --- indra/llprimitive/lltextureentry.h | 4 ++-- indra/newview/llpanelface.cpp | 4 ++-- indra/newview/llpanelface.h | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'indra/llprimitive/lltextureentry.h') diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index 59364cb913..19edcaa27d 100755 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -133,8 +133,8 @@ public: virtual const LLUUID &getID() const { return mID; } const LLColor4 &getColor() const { return mColor; } void getScale(F32 *s, F32 *t) const { *s = mScaleS; *t = mScaleT; } - void getScaleS(F32 *s) const { *s = mScaleS; } - void getScaleT(F32 *t) const { *t = mScaleT; } + F32 getScaleS() const { return mScaleS; } + F32 getScaleT() const { return mScaleT; } void getOffset(F32 *s, F32 *t) const { *s = mOffsetS; *t = mOffsetT; } F32 getOffsetS() const { return mOffsetS; } diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 51d1f82603..afc9d5b123 100755 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -951,7 +951,7 @@ void LLPanelFace::updateUI() F32 spec_scale_s = 1.f; F32 norm_scale_s = 1.f; - LLSelectedTE::getOffsetS( diff_scale_s, identical_diff_scale_s); + LLSelectedTE::getScaleS( diff_scale_s, identical_diff_scale_s); LLSelectedTEMaterial::getSpecularRepeatX( spec_scale_s, identical_spec_scale_s); LLSelectedTEMaterial::getNormalRepeatX( norm_scale_s, identical_norm_scale_s); @@ -990,7 +990,7 @@ void LLPanelFace::updateUI() F32 spec_scale_t = 1.f; F32 norm_scale_t = 1.f; - LLSelectedTE::getOffsetT(diff_scale_t, identical_diff_scale_t); + LLSelectedTE::getScaleT(diff_scale_t, identical_diff_scale_t); LLSelectedTEMaterial::getSpecularRepeatY(spec_scale_t, identical_spec_scale_t); LLSelectedTEMaterial::getNormalRepeatY(norm_scale_t, identical_norm_scale_t); diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index d76d940d5c..8d267fe723 100755 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -447,6 +447,8 @@ private: DEF_GET_TE_STATE(F32,F32,getRotation) DEF_GET_TE_STATE(F32,F32,getOffsetS) DEF_GET_TE_STATE(F32,F32,getOffsetT) + DEF_GET_TE_STATE(F32,F32,getScaleS) + DEF_GET_TE_STATE(F32,F32,getScaleT) DEF_GET_TE_STATE(F32,F32,getGlow) DEF_GET_TE_STATE(LLTextureEntry::e_texgen,LLTextureEntry::e_texgen,getTexGen) DEF_GET_TE_STATE(LLColor4,const LLColor4&,getColor) -- cgit v1.3