From d8dd4d9c0cd4554704cbe15b5502f4d87a4674ad Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Tue, 27 Jun 2023 20:01:52 -0700 Subject: Just about got hero reflection maps working. DRTVWR-583 --- indra/newview/llvovolume.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 8160785d75..8eacdd2162 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -2344,6 +2344,16 @@ S32 LLVOVolume::setTEFullbright(const U8 te, const U8 fullbright) return res; } +S32 LLVOVolume::setTERenderableTarget(const U8 te, const LLTextureEntry::eRenderableTarget mirror) +{ + S32 res = LLViewerObject::setTERenderableTarget(te, mirror); + if (res) + { + //gPipeline.markMirror(mDrawable); + } + return res; +} + S32 LLVOVolume::setTEBumpShinyFullbright(const U8 te, const U8 bump) { S32 res = LLViewerObject::setTEBumpShinyFullbright(te, bump); -- cgit v1.3 From b861832102abf469963bd3c56f7b009ba4432d6a Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Sun, 6 Aug 2023 23:33:29 -0700 Subject: Making more progress, need to add the heroprobe manager. DRTVWR-583 --- indra/llprimitive/lltextureentry.cpp | 8 ------ .../shaders/class3/deferred/softenLightF.glsl | 4 ++- indra/newview/lldrawable.h | 1 + indra/newview/llreflectionmapmanager.cpp | 20 +++++++++------ indra/newview/llreflectionmapmanager.h | 4 ++- indra/newview/llviewerobject.h | 1 + indra/newview/llvovolume.cpp | 30 +++++++++++++++++++++- indra/newview/llvovolume.h | 2 ++ indra/newview/pipeline.cpp | 22 ++++++++++++++++ indra/newview/pipeline.h | 5 ++++ 10 files changed, 78 insertions(+), 19 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index d057e5ab29..fdf3774bfa 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -696,14 +696,6 @@ S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) } mMaterial = pMaterialParams; - // TODO: GZ: We should avoid magic UUIDs in the future, but for development we're using one for the time being. Remove this later. - if (mMaterial->getSpecularID().asString() == "da7ecda1-e780-423f-ce27-26df7dc69cb6") - { - setRenderableTarget(RT_MIRROR); - } else { - setRenderableTarget(RT_DISABLED); - } - return TEM_CHANGE_TEXTURE; } diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 0152c0612a..e485c26e9b 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -217,7 +217,9 @@ void main() { color = atmosFragLightingLinear(color, additive, atten); } - color = texture(heroProbes, vec4(norm.xyz * env_mat, 0), 0).xyz; + + vec3 refnormpersp = reflect(pos.xyz, norm.xyz); + color = texture(heroProbes, vec4(env_mat * refnormpersp, 0), 0).xyz; } else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS)) { diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index 970e8c8b2a..fc182fc2e2 100644 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -286,6 +286,7 @@ public: ANIMATED_CHILD = 0x01000000, ACTIVE_CHILD = 0x02000000, FOR_UNLOAD = 0x04000000, //should be unload from memory + MIRROR = 0x08000000, // Used as a mirror, needs a hero probe position to be calculated. } EDrawableFlags; public: diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 99ebcf5231..ad4d3d94e2 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -140,7 +140,7 @@ void LLReflectionMapManager::update() if (mMipChain.empty()) { - U32 res = mProbeResolution; + U32 res = mHeroProbeResolution; U32 count = log2((F32)res) + 0.5f; mMipChain.resize(count); @@ -326,7 +326,7 @@ void LLReflectionMapManager::update() mRadiancePass = mRealtimeRadiancePass; for (U32 i = 0; i < 6; ++i) { - updateProbeFace(closestDynamic, i, mProbeResolution, mTexture); + updateProbeFace(closestDynamic, i, mProbeResolution, mTexture, mMipChain, mReflectionProbeCount); } mRealtimeRadiancePass = !mRealtimeRadiancePass; @@ -343,7 +343,7 @@ void LLReflectionMapManager::update() mRadiancePass = true; for (U32 i = 0; i < 6; ++i) { - updateProbeFace(mHeroProbe, i, mHeroProbeResolution, mHeroArray); + updateProbeFace(mHeroProbe, i, mHeroProbeResolution, mHeroArray, mMipChain, mHeroProbeCount); } // restore "isRadiancePass" @@ -555,7 +555,7 @@ void LLReflectionMapManager::doProbeUpdate() LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; llassert(mUpdatingProbe != nullptr); - updateProbeFace(mUpdatingProbe, mUpdatingFace, mProbeResolution, mTexture); + updateProbeFace(mUpdatingProbe, mUpdatingFace, mProbeResolution, mTexture, mMipChain, mReflectionProbeCount); if (++mUpdatingFace == 6) { @@ -582,14 +582,14 @@ void LLReflectionMapManager::doProbeUpdate() // The next six passes render the scene with both radiance and irradiance into the same scratch space cube map and generate a simple mip chain. // At the end of these passes, a radiance map is generated for this probe and placed into the radiance cube map array at the index for this probe. // In effect this simulates single-bounce lighting. -void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face, U32 probeResolution, LLPointer cubeArray) +void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face, U32 probeResolution, LLPointer cubeArray, std::vector &mipChain, U32 probeCount) { // hacky hot-swap of camera specific render targets gPipeline.mRT = &gPipeline.mAuxillaryRT; LLRenderTarget* target = &mRenderTarget; - S32 sourceIdx = mReflectionProbeCount; + S32 sourceIdx = probeCount; if (probeResolution == mHeroProbeResolution) { @@ -1327,9 +1327,13 @@ void LLReflectionMapManager::initReflectionMaps() mHeroProbeResolution = 128; - mHeroArray = new LLCubeMapArray(); // Revise when we have both water and mirrors in hero probes. - mHeroArray->allocate(mHeroProbeResolution, 3, 2, true); + mHeroProbeCount = 1; + + mHeroArray = new LLCubeMapArray(); + + // We use an extra probe for scratch space on these. + mHeroArray->allocate(mHeroProbeResolution, 3, mHeroProbeCount + 1, true); if (mHeroProbe.isNull()) { mHeroProbe = new LLReflectionMap(); diff --git a/indra/newview/llreflectionmapmanager.h b/indra/newview/llreflectionmapmanager.h index 81b0ef8ed8..9f48ce3cfd 100644 --- a/indra/newview/llreflectionmapmanager.h +++ b/indra/newview/llreflectionmapmanager.h @@ -148,7 +148,7 @@ private: void doProbeUpdate(); // update the specified face of the specified probe - void updateProbeFace(LLReflectionMap* probe, U32 face, U32 probeResolution, LLPointer cubeArray); + void updateProbeFace(LLReflectionMap* probe, U32 face, U32 probeResolution, LLPointer cubeArray, std::vector &mipChain, U32 probeCount); // list of active reflection maps std::vector > mProbes; @@ -188,6 +188,8 @@ private: // number of reflection probes to use for rendering U32 mReflectionProbeCount; + + U32 mHeroProbeCount; // resolution of reflection probes U32 mProbeResolution = 128; diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 4d49c61b23..fe33047218 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -257,6 +257,7 @@ public: virtual BOOL isRiggedMesh() const { return FALSE; } virtual BOOL hasLightTexture() const { return FALSE; } virtual BOOL isReflectionProbe() const { return FALSE; } + virtual BOOL isMirror() const { return FALSE; } // This method returns true if the object is over land owned by // the agent, one of its groups, or it encroaches and diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 556ec083a7..254e945243 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1044,7 +1044,9 @@ LLDrawable *LLVOVolume::createDrawable(LLPipeline *pipeline) { updateReflectionProbePtr(); } - + + gPipeline.setMirror(mDrawable, isMirror()); + updateRadius(); bool force_update = true; // avoid non-alpha mDistance update being optimized away mDrawable->updateDistance(*LLViewerCamera::getInstance(), force_update); @@ -3377,6 +3379,30 @@ F32 LLVOVolume::getLightCutoff() const } } +BOOL LLVOVolume::isMirror() const +{ + S32 faceCount = getNumFaces(); + + // Temporary hack to set the object to mirror. + for (int i = 0; i < faceCount; i++) + { + const LLTextureEntry* te = getTE(i); + + if (te->getMaterialParams().notNull()) + { + LLViewerTexture* specularp = getTESpecularMap(0); + + if (specularp && specularp->getID() == "da7ecda1-e780-423f-ce27-26df7dc69cb6") + { + LL_INFOS() << "BELLADONNA OF SADNESS" << LL_ENDL; + return TRUE; + } + } + } + + return FALSE; +} + BOOL LLVOVolume::isReflectionProbe() const { return getParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE); @@ -4427,6 +4453,8 @@ void LLVOVolume::parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_u } updateReflectionProbePtr(); + + gPipeline.setMirror(mDrawable, isMirror()); } void LLVOVolume::updateReflectionProbePtr() diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 93aba9b8cb..cecf726763 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -308,6 +308,8 @@ public: F32 getReflectionProbeNearClip() const; bool getReflectionProbeIsBox() const; bool getReflectionProbeIsDynamic() const; + + BOOL isMirror() const override; // Flexible Objects U32 getVolumeInterfaceID() const; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index d7188c0fe7..e742992c1d 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2761,6 +2761,23 @@ void LLPipeline::markShift(LLDrawable *drawablep) } } +void LLPipeline::setMirror(LLDrawable *drawablep, bool is_mirror) +{ + if (drawablep && assertInitialized()) + { + if (is_mirror) + { + drawablep->setState(LLDrawable::MIRROR); + mMirrorList.insert(drawablep); + } + else + { + mMirrorList.erase(drawablep); + drawablep->clearState(LLDrawable::MIRROR); + } + } +} + void LLPipeline::shiftObjects(const LLVector3 &offset) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; @@ -5812,6 +5829,11 @@ void LLPipeline::findReferences(LLDrawable *drawablep) { LL_INFOS() << "In mRetexturedList" << LL_ENDL; } + + if (std::find(mMirrorList.begin(), mMirrorList.end(), drawablep) != mMirrorList.end()) + { + LL_INFOS() << "In mMirrorList" << LL_ENDL; + } if (std::find(mBuildQ1.begin(), mBuildQ1.end(), drawablep) != mBuildQ1.end()) { diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index c0559ce83b..f3b35e0325 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -357,6 +357,7 @@ public: void shiftObjects(const LLVector3 &offset); void setLight(LLDrawable *drawablep, bool is_light); + void setMirror(LLDrawable *drawablep, bool is_mirror); bool hasRenderBatches(const U32 type) const; LLCullResult::drawinfo_iterator beginRenderMap(U32 type); @@ -818,6 +819,10 @@ protected: LLDrawable::ordered_drawable_set_t mLights; light_set_t mNearbyLights; // lights near camera LLColor4 mHWLightColors[8]; + + + LLDrawable::ordered_drawable_set_t mMirrorList; + LLDrawable* mNearestMirror; ///////////////////////////////////////////// // -- cgit v1.3 From 0eba1396dcc7ec5c32124dbfd48abb75c1a5b524 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Mon, 21 Aug 2023 07:59:06 -0700 Subject: Experiment with placement a bit when there's no drawable. DRTVWR-583 --- .../shaders/class3/deferred/softenLightF.glsl | 5 +- indra/newview/llheroprobemanager.cpp | 80 ++++++++++++++++++++-- indra/newview/llheroprobemanager.h | 10 ++- indra/newview/llvovolume.cpp | 7 +- indra/newview/pipeline.cpp | 22 ------ indra/newview/pipeline.h | 5 -- 6 files changed, 88 insertions(+), 41 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index e485c26e9b..742b52b074 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -213,13 +213,14 @@ void main() vec3 v = -normalize(pos.xyz); color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten); + vec3 refnormpersp = reflect(pos.xyz, norm.xyz); + color = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0 - gloss) * 11).xyz * specularColor; + if (do_atmospherics) { color = atmosFragLightingLinear(color, additive, atten); } - vec3 refnormpersp = reflect(pos.xyz, norm.xyz); - color = texture(heroProbes, vec4(env_mat * refnormpersp, 0), 0).xyz; } else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS)) { diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp index 33a54c797e..0d2e8da294 100644 --- a/indra/newview/llheroprobemanager.cpp +++ b/indra/newview/llheroprobemanager.cpp @@ -36,6 +36,11 @@ #include "llviewercontrol.h" #include "llenvironment.h" #include "llstartup.h" +#include "llagent.h" +#include "llagentcamera.h" +#include "llviewerwindow.h" +#include "llviewerjoystick.h" +#include "llviewermediafocus.h" extern BOOL gCubeSnapshot; extern BOOL gTeleportDisplay; @@ -98,16 +103,60 @@ void LLHeroProbeManager::update() llassert(mProbes[0] == mDefaultProbe); - LLVector4a camera_pos; - camera_pos.load3(LLViewerCamera::instance().getOrigin().mV); + LLVector3 camera_pos = LLViewerCamera::instance().getOrigin(); + LLVector4a probe_pos; + + LLVector3 focus_point; + + LLViewerObject* obj = LLViewerMediaFocus::getInstance()->getFocusedObject(); + if (obj && obj->mDrawable && obj->isSelected()) + { // focus on selected media object + S32 face_idx = LLViewerMediaFocus::getInstance()->getFocusedFace(); + if (obj && obj->mDrawable) + { + LLFace* face = obj->mDrawable->getFace(face_idx); + if (face) + { + focus_point = face->getPositionAgent(); + } + } + } + + if (focus_point.isExactlyZero()) + { + if (LLViewerJoystick::getInstance()->getOverrideCamera()) + { // focus on point under cursor + focus_point.set(gDebugRaycastIntersection.getF32ptr()); + } + else if (gAgentCamera.cameraMouselook()) + { // focus on point under mouselook crosshairs + LLVector4a result; + result.clear(); + + gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, NULL, &result); + + focus_point.set(result.getF32ptr()); + } + else + { + // focus on alt-zoom target + LLViewerRegion* region = gAgent.getRegion(); + if (region) + { + focus_point = LLVector3(gAgentCamera.getFocusGlobal() - region->getOriginGlobal()); + } + } + } + + probe_pos.load3(((focus_point + camera_pos) / 2).mV); static LLCachedControl sDetail(gSavedSettings, "RenderHeroReflectionProbeDetail", -1); static LLCachedControl sLevel(gSavedSettings, "RenderHeroReflectionProbeLevel", 3); { - LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("rmmu - realtime"); - // Probe 0 is always our mirror probe. Probe N - 1 is our water probe. - mProbes[0]->mOrigin.load3(LLViewerCamera::instance().mOrigin.mV); + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("hpmu - realtime"); + // Probe 0 is always our mirror probe. + mProbes[0]->mOrigin = probe_pos; for (U32 j = 0; j < mProbes.size(); j++) { for (U32 i = 0; i < 6; ++i) @@ -131,8 +180,6 @@ void LLHeroProbeManager::updateProbeFace(LLReflectionMap* probe, U32 face) // hacky hot-swap of camera specific render targets gPipeline.mRT = &gPipeline.mAuxillaryRT; - mLightScale = 1.f; - probe->update(mRenderTarget.getWidth(), face); gPipeline.mRT = &gPipeline.mMainRT; @@ -458,6 +505,9 @@ void LLHeroProbeManager::cleanup() glDeleteBuffers(1, &mUBO); mUBO = 0; + + mHeroList.clear(); + mNearestHero = nullptr; } void LLHeroProbeManager::doOcclusion() @@ -473,3 +523,19 @@ void LLHeroProbeManager::doOcclusion() } } } + +void LLHeroProbeManager::registerHeroDrawable(LLDrawable* drawablep) +{ + if (mHeroList.find(drawablep) == mHeroList.end()) + { + mHeroList.insert(drawablep); + } +} + +void LLHeroProbeManager::unregisterHeroDrawable(LLDrawable *drawablep) +{ + if (mHeroList.find(drawablep) != mHeroList.end()) + { + mHeroList.erase(drawablep); + } +} diff --git a/indra/newview/llheroprobemanager.h b/indra/newview/llheroprobemanager.h index 95e3963d1a..c6df963cfd 100644 --- a/indra/newview/llheroprobemanager.h +++ b/indra/newview/llheroprobemanager.h @@ -30,6 +30,7 @@ #include "llrendertarget.h" #include "llcubemaparray.h" #include "llcubemap.h" +#include "lldrawable.h" class LLSpatialGroup; class LLViewerObject; @@ -67,6 +68,9 @@ public: // perform occlusion culling on all active reflection probes void doOcclusion(); + void registerHeroDrawable(LLDrawable* drawablep); + void unregisterHeroDrawable(LLDrawable* drawablep); + private: friend class LLPipeline; @@ -118,10 +122,10 @@ private: // maximum LoD of reflection probes (mip levels - 1) F32 mMaxProbeLOD = 6.f; - // amount to scale local lights during an irradiance map update (set during updateProbeFace and used by LLPipeline) - F32 mLightScale = 1.f; - // if true, reset all probe render state on the next update (for teleports and sky changes) bool mReset = false; + + LLDrawable::ordered_drawable_set_t mHeroList; + LLDrawable* mNearestHero; }; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 254e945243..2589beefe9 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1045,7 +1045,7 @@ LLDrawable *LLVOVolume::createDrawable(LLPipeline *pipeline) updateReflectionProbePtr(); } - gPipeline.setMirror(mDrawable, isMirror()); + gPipeline.mHeroProbeManager.registerHeroDrawable(mDrawable); updateRadius(); bool force_update = true; // avoid non-alpha mDistance update being optimized away @@ -4454,7 +4454,10 @@ void LLVOVolume::parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_u updateReflectionProbePtr(); - gPipeline.setMirror(mDrawable, isMirror()); + if (isMirror()) + gPipeline.mHeroProbeManager.registerHeroDrawable(mDrawable); + else + gPipeline.mHeroProbeManager.unregisterHeroDrawable(mDrawable); } void LLVOVolume::updateReflectionProbePtr() diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4c951a9dea..792cad02bd 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2783,23 +2783,6 @@ void LLPipeline::markShift(LLDrawable *drawablep) } } -void LLPipeline::setMirror(LLDrawable *drawablep, bool is_mirror) -{ - if (drawablep && assertInitialized()) - { - if (is_mirror) - { - drawablep->setState(LLDrawable::MIRROR); - mMirrorList.insert(drawablep); - } - else - { - mMirrorList.erase(drawablep); - drawablep->clearState(LLDrawable::MIRROR); - } - } -} - void LLPipeline::shiftObjects(const LLVector3 &offset) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; @@ -5852,11 +5835,6 @@ void LLPipeline::findReferences(LLDrawable *drawablep) { LL_INFOS() << "In mRetexturedList" << LL_ENDL; } - - if (std::find(mMirrorList.begin(), mMirrorList.end(), drawablep) != mMirrorList.end()) - { - LL_INFOS() << "In mMirrorList" << LL_ENDL; - } if (std::find(mBuildQ1.begin(), mBuildQ1.end(), drawablep) != mBuildQ1.end()) { diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index bfb9b95f4d..1361441844 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -358,7 +358,6 @@ public: void shiftObjects(const LLVector3 &offset); void setLight(LLDrawable *drawablep, bool is_light); - void setMirror(LLDrawable *drawablep, bool is_mirror); bool hasRenderBatches(const U32 type) const; LLCullResult::drawinfo_iterator beginRenderMap(U32 type); @@ -821,10 +820,6 @@ protected: LLDrawable::ordered_drawable_set_t mLights; light_set_t mNearbyLights; // lights near camera LLColor4 mHWLightColors[8]; - - - LLDrawable::ordered_drawable_set_t mMirrorList; - LLDrawable* mNearestMirror; ///////////////////////////////////////////// // -- cgit v1.3 From fbecd348f897ee91a5639e7e9fe4f0578d72b8e2 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Tue, 29 Aug 2023 03:04:04 -0700 Subject: Add protocol level mirror support, and UI. --- indra/llprimitive/llprimitive.cpp | 39 ++++++++-- indra/llprimitive/llprimitive.h | 12 ++- indra/llprimitive/llprimtexturelist.cpp | 10 --- indra/llprimitive/llprimtexturelist.h | 1 - indra/llprimitive/lltextureentry.cpp | 10 --- indra/llprimitive/lltextureentry.h | 10 --- indra/newview/llheroprobemanager.cpp | 87 +++++++++++++--------- indra/newview/llpanelface.cpp | 17 ----- indra/newview/llpanelface.h | 2 - indra/newview/llpanelvolume.cpp | 34 +++++++++ indra/newview/llpanelvolume.h | 2 + indra/newview/llselectmgr.cpp | 41 ---------- indra/newview/llselectmgr.h | 1 - indra/newview/llviewerobject.cpp | 28 ++----- indra/newview/llviewerobject.h | 1 - indra/newview/llvovolume.cpp | 60 ++++++++------- indra/newview/llvovolume.h | 5 +- .../newview/skins/default/xui/en/floater_tools.xml | 10 ++- 18 files changed, 185 insertions(+), 185 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index b45ead92d3..703584ed62 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -404,11 +404,6 @@ S32 LLPrimitive::setTEFullbright(const U8 index, const U8 fullbright) return mTextureList.setFullbright(index, fullbright); } -S32 LLPrimitive::setTERenderableTarget(const U8 te, const LLTextureEntry::eRenderableTarget target) -{ - return mTextureList.setRenderableTarget(te, target); -} - S32 LLPrimitive::setTEMediaFlags(const U8 index, const U8 media_flags) { return mTextureList.setMediaFlags(index, media_flags); @@ -1828,6 +1823,40 @@ bool LLLightParams::fromLLSD(LLSD& sd) //============================================================================ +LLMirrorParams::LLMirrorParams() +{ + mType = PARAMS_MIRROR; +} + +BOOL LLMirrorParams::pack(LLDataPacker &dp) const +{ + return TRUE; +} + +BOOL LLMirrorParams::unpack(LLDataPacker &dp) +{ + return TRUE; +} + +bool LLMirrorParams::operator==(const LLNetworkData& data) const +{ + if (data.mType != PARAMS_REFLECTION_PROBE) + { + return false; + } + return true; +} + +void LLMirrorParams::copy(const LLNetworkData& data) +{ + const LLMirrorParams *param = (LLMirrorParams*)&data; + mType = param->mType; +} + +//============================================================================ + +//============================================================================ + LLReflectionProbeParams::LLReflectionProbeParams() { mType = PARAMS_REFLECTION_PROBE; diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 520c7c7ac8..1af9bca42e 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -109,6 +109,7 @@ public: PARAMS_EXTENDED_MESH = 0x70, PARAMS_RENDER_MATERIAL = 0x80, PARAMS_REFLECTION_PROBE = 0x90, + PARAMS_MIRROR = 0x100, }; public: @@ -172,6 +173,16 @@ public: F32 getCutoff() const { return mCutoff; } }; +class LLMirrorParams : public LLNetworkData +{ +public: + LLMirrorParams(); + /*virtual*/ BOOL pack(LLDataPacker &dp) const; + /*virtual*/ BOOL unpack(LLDataPacker &dp); + /*virtual*/ bool operator==(const LLNetworkData& data) const; + /*virtual*/ void copy(const LLNetworkData& data); +}; + extern const F32 REFLECTION_PROBE_MIN_AMBIANCE; extern const F32 REFLECTION_PROBE_MAX_AMBIANCE; extern const F32 REFLECTION_PROBE_DEFAULT_AMBIANCE; @@ -485,7 +496,6 @@ public: virtual S32 setTETexGen(const U8 te, const U8 texgen); virtual S32 setTEShiny(const U8 te, const U8 shiny); virtual S32 setTEFullbright(const U8 te, const U8 fullbright); - virtual S32 setTERenderableTarget(const U8 te, const LLTextureEntry::eRenderableTarget target); 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); diff --git a/indra/llprimitive/llprimtexturelist.cpp b/indra/llprimitive/llprimtexturelist.cpp index 49b59e35cb..f4f08248b8 100644 --- a/indra/llprimitive/llprimtexturelist.cpp +++ b/indra/llprimitive/llprimtexturelist.cpp @@ -341,16 +341,6 @@ S32 LLPrimTextureList::setFullbright(const U8 index, const U8 fullbright) return TEM_CHANGE_NONE; } -S32 LLPrimTextureList::setRenderableTarget(const U8 index, const U8 target) -{ - if (index < mEntryList.size()) - { - return mEntryList[index]->setRenderableTarget((LLTextureEntry::eRenderableTarget)target); - } - - return TEM_CHANGE_NONE; -} - S32 LLPrimTextureList::setMediaFlags(const U8 index, const U8 media_flags) { if (index < mEntryList.size()) diff --git a/indra/llprimitive/llprimtexturelist.h b/indra/llprimitive/llprimtexturelist.h index 34b87d879f..49c636e40f 100644 --- a/indra/llprimitive/llprimtexturelist.h +++ b/indra/llprimitive/llprimtexturelist.h @@ -102,7 +102,6 @@ public: S32 setTexGen(const U8 index, const U8 texgen); S32 setShiny(const U8 index, const U8 shiny); S32 setFullbright(const U8 index, const U8 t); - S32 setRenderableTarget(const U8 index, const U8 target); 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); diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index fdf3774bfa..ee2a4c769a 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -504,16 +504,6 @@ S32 LLTextureEntry::setFullbright(U8 fullbright) return TEM_CHANGE_NONE; } -S32 LLTextureEntry::setRenderableTarget(eRenderableTarget target) -{ - if (getRenderableTarget() != target) { - mRenderableTarget = target; - return TEM_CHANGE_TEXTURE; - } - - return TEM_CHANGE_NONE; -} - S32 LLTextureEntry::setShiny(U8 shiny) { shiny &= TEM_SHINY_MASK; diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index 2c0832e1d4..0935147688 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -80,12 +80,6 @@ public: TEX_GEN_SPHERICAL = 0x04, TEX_GEN_CYLINDRICAL = 0x06 } eTexGen; - - - typedef enum e_renderable_target { - RT_DISABLED = 0x00, - RT_MIRROR = 0x02 - } eRenderableTarget; LLTextureEntry(); LLTextureEntry(const LLUUID& tex_id); @@ -141,8 +135,6 @@ public: S32 setMaterialID(const LLMaterialID& pMaterialID); S32 setMaterialParams(const LLMaterialPtr pMaterialParams); - S32 setRenderableTarget(eRenderableTarget target); - virtual const LLUUID &getID() const { return mID; } const LLColor4 &getColor() const { return mColor; } const F32 getAlpha() const { return mColor.mV[VALPHA]; } @@ -160,7 +152,6 @@ public: U8 getBumpmap() const { return mBump & TEM_BUMP_MASK; } U8 getFullbright() const { return (mBump>>TEM_FULLBRIGHT_SHIFT) & TEM_FULLBRIGHT_MASK; } - eRenderableTarget getRenderableTarget() const { return mRenderableTarget; } U8 getShiny() const { return (mBump>>TEM_SHINY_SHIFT) & TEM_SHINY_MASK; } U8 getBumpShiny() const { return mBump & TEM_BUMP_SHINY_MASK; } U8 getBumpShinyFullbright() const { return mBump; } @@ -242,7 +233,6 @@ protected: LLColor4 mColor; U8 mBump; // Bump map, shiny, and fullbright U8 mMediaFlags; // replace with web page, movie, etc. - eRenderableTarget mRenderableTarget; F32 mGlow; bool mMaterialUpdatePending; LLMaterialID mMaterialID; diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp index 729603e960..6374b10823 100644 --- a/indra/newview/llheroprobemanager.cpp +++ b/indra/newview/llheroprobemanager.cpp @@ -103,53 +103,71 @@ void LLHeroProbeManager::update() llassert(mProbes[0] == mDefaultProbe); - LLVector3 camera_pos = LLViewerCamera::instance().getOrigin(); - LLVector4a probe_pos; - LLVector3 focus_point; - - LLViewerObject* obj = LLViewerMediaFocus::getInstance()->getFocusedObject(); - if (obj && obj->mDrawable && obj->isSelected()) - { // focus on selected media object - S32 face_idx = LLViewerMediaFocus::getInstance()->getFocusedFace(); - if (obj && obj->mDrawable) + if (mHeroList.empty()) + { + LLVector3 focus_point; + + LLViewerObject* obj = LLViewerMediaFocus::getInstance()->getFocusedObject(); + if (obj && obj->mDrawable && obj->isSelected()) + { // focus on selected media object + S32 face_idx = LLViewerMediaFocus::getInstance()->getFocusedFace(); + if (obj && obj->mDrawable) + { + LLFace* face = obj->mDrawable->getFace(face_idx); + if (face) + { + focus_point = face->getPositionAgent(); + } + } + } + + if (focus_point.isExactlyZero()) { - LLFace* face = obj->mDrawable->getFace(face_idx); - if (face) + if (LLViewerJoystick::getInstance()->getOverrideCamera()) + { // focus on point under cursor + focus_point.set(gDebugRaycastIntersection.getF32ptr()); + } + else if (gAgentCamera.cameraMouselook()) + { // focus on point under mouselook crosshairs + LLVector4a result; + result.clear(); + + gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, NULL, &result); + + focus_point.set(result.getF32ptr()); + } + else { - focus_point = face->getPositionAgent(); + // focus on alt-zoom target + LLViewerRegion* region = gAgent.getRegion(); + if (region) + { + focus_point = LLVector3(gAgentCamera.getFocusGlobal() - region->getOriginGlobal()); + } } } + + probe_pos.load3(((focus_point)).mV); } - - if (focus_point.isExactlyZero()) + else { - if (LLViewerJoystick::getInstance()->getOverrideCamera()) - { // focus on point under cursor - focus_point.set(gDebugRaycastIntersection.getF32ptr()); - } - else if (gAgentCamera.cameraMouselook()) - { // focus on point under mouselook crosshairs - LLVector4a result; - result.clear(); - - gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, NULL, &result); - - focus_point.set(result.getF32ptr()); - } - else + // Get the nearest hero. + float distance = F32_MAX; + + for (auto drawable : mHeroList) { - // focus on alt-zoom target - LLViewerRegion* region = gAgent.getRegion(); - if (region) + if (drawable.notNull()) { - focus_point = LLVector3(gAgentCamera.getFocusGlobal() - region->getOriginGlobal()); + if (drawable->mDistanceWRTCamera < distance) + { + probe_pos.load3(drawable->mXform.getPosition().mV); + } } } } - probe_pos.load3(((focus_point + camera_pos) / 2).mV); static LLCachedControl sDetail(gSavedSettings, "RenderHeroReflectionProbeDetail", -1); static LLCachedControl sLevel(gSavedSettings, "RenderHeroReflectionProbeLevel", 3); @@ -464,7 +482,7 @@ void LLHeroProbeManager::initReflectionMaps() mDefaultProbe->mCubeIndex = 0; mDefaultProbe->mCubeArray = mTexture; - mDefaultProbe->mDistance = 64.f; + mDefaultProbe->mDistance = 12.f; mDefaultProbe->mRadius = 4096.f; mDefaultProbe->mProbeIndex = 0; touch_default_probe(mDefaultProbe); @@ -536,6 +554,7 @@ void LLHeroProbeManager::registerHeroDrawable(LLDrawable* drawablep) if (mHeroList.find(drawablep) == mHeroList.end()) { mHeroList.insert(drawablep); + LL_INFOS() << "Added hero drawable." << LL_ENDL; } } diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 9233ec6277..25f42e6dae 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -596,17 +596,6 @@ void LLPanelFace::sendFullbright() LLSelectMgr::getInstance()->selectionSetFullbright( fullbright ); } -void LLPanelFace::sendMirror() -{ - LLCheckBoxCtrl* mCheckMirror = getChild("checkbox mirror"); - - if (!mCheckMirror) - return; - - LLTextureEntry::eRenderableTarget target = mCheckMirror->get() ? LLTextureEntry::RT_MIRROR : LLTextureEntry::RT_DISABLED; - LLSelectMgr::getInstance()->selectionSetRenderableTarget(target); -} - void LLPanelFace::sendColor() { @@ -3007,12 +2996,6 @@ void LLPanelFace::onCommitFullbright(LLUICtrl* ctrl, void* userdata) self->sendFullbright(); } -void LLPanelFace::onCommitMirror(LLUICtrl* ctrl, void* userdata) -{ - LLPanelFace* self = (LLPanelFace*) userdata; - self->sendMirror(); -} - // static void LLPanelFace::onCommitGlow(LLUICtrl* ctrl, void* userdata) { diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 0b7486232d..5cad8cefcf 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -139,7 +139,6 @@ protected: void sendShiny(U32 shininess); // applies and sends shininess void sendFullbright(); // applies and sends full bright - void sendMirror(); void sendGlow(); void alignTestureLayer(); @@ -229,7 +228,6 @@ protected: static void onCommitShiny( LLUICtrl* ctrl, void* userdata); static void onCommitAlphaMode( LLUICtrl* ctrl, void* userdata); static void onCommitFullbright( LLUICtrl* ctrl, void* userdata); - static void onCommitMirror(LLUICtrl* ctrl, void* userdata); static void onCommitGlow( LLUICtrl* ctrl, void *userdata); static void onCommitPlanarAlign( LLUICtrl* ctrl, void* userdata); static void onCommitRepeatsPerMeter( LLUICtrl* ctrl, void* userinfo); diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index ed244f773c..d62a640b5c 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -114,6 +114,11 @@ BOOL LLPanelVolume::postBuild() getChild("FlexForceZ")->setValidateBeforeCommit(precommitValidate); } + // Mirror Parameters + { + childSetCommitCallback("Mirror Checkbox Ctrl", onCommitIsMirror, this); + } + // LIGHT Parameters { childSetCommitCallback("Light Checkbox Ctrl",onCommitIsLight,this); @@ -305,6 +310,10 @@ void LLPanelVolume::getState( ) getChildView("select_single")->setEnabled(true); } + BOOL is_mirror = volobjp && volobjp->isMirror(); + getChild("Mirror Checkbox Ctrl")->setValue(is_mirror); + getChildView("Mirror Checkbox Ctrl")->setEnabled(editable && single_volume && volobjp); + // Light properties BOOL is_light = volobjp && volobjp->getIsLight(); getChild("Light Checkbox Ctrl")->setValue(is_light); @@ -737,6 +746,25 @@ void LLPanelVolume::sendIsLight() LL_INFOS() << "update light sent" << LL_ENDL; } +void LLPanelVolume::sendIsMirror() +{ + LLViewerObject* objectp = mObject; + if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME)) + { + return; + } + LLVOVolume *volobjp = (LLVOVolume *)objectp; + + // Quick hack to set the mirror locally. + + gPipeline.mHeroProbeManager.registerHeroDrawable(volobjp->mDrawable); + + BOOL value = getChild("Mirror Checkbox Ctrl")->getValue(); + volobjp->setIsMirror(value); + LL_INFOS() << "update mirror sent" << LL_ENDL; +} + + void LLPanelVolume::sendIsReflectionProbe() { LLViewerObject* objectp = mObject; @@ -1403,6 +1431,12 @@ void LLPanelVolume::onCommitIsLight( LLUICtrl* ctrl, void* userdata ) self->sendIsLight(); } +void LLPanelVolume::onCommitIsMirror( LLUICtrl* ctrl, void* userdata ) +{ + LLPanelVolume* self = (LLPanelVolume*) userdata; + self->sendIsMirror(); +} + // static void LLPanelVolume::setLightTextureID(const LLUUID &asset_id, const LLUUID &item_id, LLVOVolume* volobjp) { diff --git a/indra/newview/llpanelvolume.h b/indra/newview/llpanelvolume.h index 01b7ebb75c..a658351624 100644 --- a/indra/newview/llpanelvolume.h +++ b/indra/newview/llpanelvolume.h @@ -58,6 +58,7 @@ public: void sendIsLight(); + void sendIsMirror(); // when an object is becoming a refleciton probe, present a dialog asking for confirmation // otherwise, send the reflection probe update immediately void sendIsReflectionProbe(); @@ -71,6 +72,7 @@ public: static void onCommitIsLight( LLUICtrl* ctrl, void* userdata); static void onCommitLight( LLUICtrl* ctrl, void* userdata); + static void onCommitIsMirror( LLUICtrl* ctrl, void* userdata); static void onCommitIsReflectionProbe(LLUICtrl* ctrl, void* userdata); static void onCommitProbe(LLUICtrl* ctrl, void* userdata); void onCommitIsFlexible( LLUICtrl* ctrl, void* userdata); diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 2b1b4b79b2..5c1a339570 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2355,47 +2355,6 @@ void LLSelectMgr::selectionSetFullbright(U8 fullbright) getSelection()->applyToObjects(&sendfunc); } -void LLSelectMgr::selectionSetRenderableTarget(LLTextureEntry::eRenderableTarget target) -{ - struct f : public LLSelectedTEFunctor - { - LLTextureEntry::eRenderableTarget mRenderableTarget; - - f(const LLTextureEntry::eRenderableTarget& t) : mRenderableTarget(t) {} - - bool apply(LLViewerObject* object, S32 te) - { - if (object->permModify()) - { - object->setTERenderableTarget(te, mRenderableTarget); - } - - return true; - } - } setfunc(target); - - getSelection()->applyToTEs(&setfunc); - - struct g : public LLSelectedObjectFunctor - { - LLTextureEntry::eRenderableTarget mRenderableTarget; - - g(const LLTextureEntry::eRenderableTarget& t) : mRenderableTarget(t) {} - - virtual bool apply(LLViewerObject* object) - { - if (object->permModify()) - { - object->sendTEUpdate(); - } - - return true; - } - } sendfunc(target); - - getSelection()->applyToObjects(&sendfunc); -} - // This function expects media_data to be a map containing relevant // media data name/value pairs (e.g. home_url, etc.) void LLSelectMgr::selectionSetMedia(U8 media_type, const LLSD &media_data) diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index 8ce59c6654..327134a487 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -653,7 +653,6 @@ public: void selectionSetGlow(const F32 glow); void selectionSetMaterialParams(LLSelectedTEMaterialFunctor* material_func, int specific_te = -1); void selectionRemoveMaterial(); - void selectionSetRenderableTarget(LLTextureEntry::eRenderableTarget target); void selectionSetObjectPermissions(U8 perm_field, BOOL set, U32 perm_mask, BOOL override = FALSE); void selectionSetObjectName(const std::string& name); diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 7871815fda..68162f83c0 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -5296,29 +5296,6 @@ S32 LLViewerObject::setTEFullbright(const U8 te, const U8 fullbright) return retval; } -S32 LLViewerObject::setTERenderableTarget(const U8 te, const LLTextureEntry::eRenderableTarget target) -{ - S32 retval = 0; - - const LLTextureEntry *tep = getTE(te); - if (!tep) - { - LL_WARNS() << "No texture entry for te " << (S32)te << ", object " << mID << LL_ENDL; - } - else if (target != tep->getRenderableTarget()) - { - retval = LLPrimitive::setTERenderableTarget(te, target); - setChanged(TEXTURE); - if (mDrawable.notNull() && retval) - { - //gPipeline.markMirror(mDrawable); - } - } - - return retval; -} - - S32 LLViewerObject::setTEMediaFlags(const U8 te, const U8 media_flags) { // this might need work for media type @@ -6251,6 +6228,11 @@ LLViewerObject::ExtraParameter* LLViewerObject::createNewParameterEntry(U16 para { new_block = new LLReflectionProbeParams(); break; + } + case LLNetworkData::PARAMS_MIRROR: + { + new_block = new LLMirrorParams(); + break; } default: { diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index fe33047218..a87644476f 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -360,7 +360,6 @@ public: /*virtual*/ S32 setTEMediaTexGen(const U8 te, const U8 media ); // *FIXME: this confusingly acts upon a superset of setTETexGen's flags without absorbing its semantics /*virtual*/ S32 setTEShiny(const U8 te, const U8 shiny ); /*virtual*/ S32 setTEFullbright(const U8 te, const U8 fullbright ); - /*virtual*/ S32 setTERenderableTarget(const U8 te, const LLTextureEntry::eRenderableTarget target); /*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); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 2589beefe9..175ce93b14 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1045,7 +1045,10 @@ LLDrawable *LLVOVolume::createDrawable(LLPipeline *pipeline) updateReflectionProbePtr(); } - gPipeline.mHeroProbeManager.registerHeroDrawable(mDrawable); + if (isMirror()) + { + gPipeline.mHeroProbeManager.registerHeroDrawable(mDrawable); + } updateRadius(); bool force_update = true; // avoid non-alpha mDistance update being optimized away @@ -2369,16 +2372,6 @@ S32 LLVOVolume::setTEFullbright(const U8 te, const U8 fullbright) return res; } -S32 LLVOVolume::setTERenderableTarget(const U8 te, const LLTextureEntry::eRenderableTarget mirror) -{ - S32 res = LLViewerObject::setTERenderableTarget(te, mirror); - if (res) - { - //gPipeline.markMirror(mDrawable); - } - return res; -} - S32 LLVOVolume::setTEBumpShinyFullbright(const U8 te, const U8 bump) { S32 res = LLViewerObject::setTEBumpShinyFullbright(te, bump); @@ -3379,28 +3372,41 @@ F32 LLVOVolume::getLightCutoff() const } } -BOOL LLVOVolume::isMirror() const +bool LLVOVolume::setIsMirror(BOOL is_mirror) { - S32 faceCount = getNumFaces(); - - // Temporary hack to set the object to mirror. - for (int i = 0; i < faceCount; i++) + BOOL was_mirror = isMirror(); + if (is_mirror != was_mirror) { - const LLTextureEntry* te = getTE(i); - - if (te->getMaterialParams().notNull()) + if (is_mirror) { - LLViewerTexture* specularp = getTESpecularMap(0); - - if (specularp && specularp->getID() == "da7ecda1-e780-423f-ce27-26df7dc69cb6") - { - LL_INFOS() << "BELLADONNA OF SADNESS" << LL_ENDL; - return TRUE; - } + setParameterEntryInUse(LLNetworkData::PARAMS_MIRROR, TRUE, true); + } + else + { + setParameterEntryInUse(LLNetworkData::PARAMS_MIRROR, FALSE, true); } } - return FALSE; + updateMirrorDrawable(); + + return was_mirror != is_mirror; +} + +void LLVOVolume::updateMirrorDrawable() +{ + if (isMirror()) + { + gPipeline.mHeroProbeManager.registerHeroDrawable(mDrawable); + } + else + { + gPipeline.mHeroProbeManager.unregisterHeroDrawable(mDrawable); + } +} + +BOOL LLVOVolume::isMirror() const +{ + return getParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE); } BOOL LLVOVolume::isReflectionProbe() const diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index cecf726763..32c89ddae2 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -209,7 +209,6 @@ public: /*virtual*/ S32 setTEBumpmap(const U8 te, const U8 bump) override; /*virtual*/ S32 setTEShiny(const U8 te, const U8 shiny) override; /*virtual*/ S32 setTEFullbright(const U8 te, const U8 fullbright) override; - /*virtual*/ S32 setTERenderableTarget(const U8 te, const LLTextureEntry::eRenderableTarget target) override; /*virtual*/ S32 setTEBumpShinyFullbright(const U8 te, const U8 bump) override; /*virtual*/ S32 setTEMediaFlags(const U8 te, const U8 media_flags) override; /*virtual*/ S32 setTEGlow(const U8 te, const F32 glow) override; @@ -295,6 +294,10 @@ public: F32 getLightRadius() const; F32 getLightFalloff(const F32 fudge_factor = 1.f) const; F32 getLightCutoff() const; + + // Mirrors + bool setIsMirror(BOOL is_mirror); + void updateMirrorDrawable(); // Reflection Probes bool setIsReflectionProbe(BOOL is_probe); diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml index 5e999ed245..4094a487a9 100644 --- a/indra/newview/skins/default/xui/en/floater_tools.xml +++ b/indra/newview/skins/default/xui/en/floater_tools.xml @@ -2406,7 +2406,15 @@ even though the user gets a free copy. name="object_horizontal" top_pad="10" width="278" /> - + Date: Tue, 29 Aug 2023 05:08:47 -0700 Subject: Add a probe strength uniform for hero probes. On standard reflection probes this doesn't really do anything. DRTVWR-583 --- indra/llrender/llshadermgr.cpp | 1 + indra/llrender/llshadermgr.h | 1 + .../shaders/class1/interface/radianceGenF.glsl | 2 + indra/newview/llheroprobemanager.cpp | 73 +++++++--------------- indra/newview/llheroprobemanager.h | 7 ++- indra/newview/llreflectionmapmanager.cpp | 1 + indra/newview/llvovolume.cpp | 2 +- 7 files changed, 34 insertions(+), 53 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 6730a12d6c..8bb5be0332 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1460,6 +1460,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("cloud_variance"); mReservedUniforms.push_back("reflection_probe_ambiance"); mReservedUniforms.push_back("max_probe_lod"); + mReservedUniforms.push_back("probe_strength"); mReservedUniforms.push_back("sh_input_r"); mReservedUniforms.push_back("sh_input_g"); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 53c8323cff..6a5243a898 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -278,6 +278,7 @@ public: REFLECTION_PROBE_AMBIANCE, // "reflection_probe_ambiance" REFLECTION_PROBE_MAX_LOD, // "max_probe_lod" + REFLECTION_PROBE_STRENGTH, // "probe_strength" SH_INPUT_L1R, // "sh_input_r" SH_INPUT_L1G, // "sh_input_g" SH_INPUT_L1B, // "sh_input_b" diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl index 9ecdf0bf77..cb6f34713c 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -38,6 +38,7 @@ in vec3 vary_dir; uniform float mipLevel; uniform int u_width; uniform float max_probe_lod; +uniform float probe_strength; // ============================================================================================================= @@ -163,5 +164,6 @@ void main() { vec3 N = normalize(vary_dir); frag_color = max(prefilterEnvMap(N), vec4(0)); + frag_color.a *= probe_strength; } // ============================================================================================================= diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp index 6374b10823..c385c9a99f 100644 --- a/indra/newview/llheroprobemanager.cpp +++ b/indra/newview/llheroprobemanager.cpp @@ -104,68 +104,41 @@ void LLHeroProbeManager::update() llassert(mProbes[0] == mDefaultProbe); LLVector4a probe_pos; - - if (mHeroList.empty()) + LLVector3 camera_pos = LLViewerCamera::instance().mOrigin; { - LLVector3 focus_point; + // Get the nearest hero. + float distance = F32_MAX; - LLViewerObject* obj = LLViewerMediaFocus::getInstance()->getFocusedObject(); - if (obj && obj->mDrawable && obj->isSelected()) - { // focus on selected media object - S32 face_idx = LLViewerMediaFocus::getInstance()->getFocusedFace(); - if (obj && obj->mDrawable) - { - LLFace* face = obj->mDrawable->getFace(face_idx); - if (face) - { - focus_point = face->getPositionAgent(); - } - } + if (mNearestHero.notNull()) + { + distance = mNearestHero->mDistanceWRTCamera; } - if (focus_point.isExactlyZero()) + for (auto drawable : mHeroList) { - if (LLViewerJoystick::getInstance()->getOverrideCamera()) - { // focus on point under cursor - focus_point.set(gDebugRaycastIntersection.getF32ptr()); - } - else if (gAgentCamera.cameraMouselook()) - { // focus on point under mouselook crosshairs - LLVector4a result; - result.clear(); - - gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, NULL, &result); - - focus_point.set(result.getF32ptr()); - } - else + if (drawable.notNull() && drawable != mNearestHero) { - // focus on alt-zoom target - LLViewerRegion* region = gAgent.getRegion(); - if (region) + if (drawable->mDistanceWRTCamera < distance) { - focus_point = LLVector3(gAgentCamera.getFocusGlobal() - region->getOriginGlobal()); + mIsInTransition = true; + mNearestHero = drawable; } } } - - probe_pos.load3(((focus_point)).mV); + } + + if (mIsInTransition && mHeroProbeStrength > 0.f) + { + mHeroProbeStrength -= 0.05f; } else { - // Get the nearest hero. - float distance = F32_MAX; + if (mNearestHero.notNull()) + probe_pos.set(mNearestHero->mXform.getPosition().mV[0], mNearestHero->mXform.getPosition().mV[1], camera_pos.mV[2]); - for (auto drawable : mHeroList) - { - if (drawable.notNull()) - { - if (drawable->mDistanceWRTCamera < distance) - { - probe_pos.load3(drawable->mXform.getPosition().mV); - } - } - } + + if (mHeroProbeStrength < 1.f) + mHeroProbeStrength += 0.05f; } static LLCachedControl sDetail(gSavedSettings, "RenderHeroReflectionProbeDetail", -1); @@ -328,7 +301,8 @@ void LLHeroProbeManager::updateProbeFace(LLReflectionMap* probe, U32 face) mTexture->bind(channel); gRadianceGenProgram.uniform1i(sSourceIdx, sourceIdx); gRadianceGenProgram.uniform1f(LLShaderMgr::REFLECTION_PROBE_MAX_LOD, mMaxProbeLOD); - + gRadianceGenProgram.uniform1f(LLShaderMgr::REFLECTION_PROBE_STRENGTH, mHeroProbeStrength); + U32 res = mMipChain[0].getWidth(); for (int i = 0; i < mMipChain.size(); ++i) @@ -554,7 +528,6 @@ void LLHeroProbeManager::registerHeroDrawable(LLDrawable* drawablep) if (mHeroList.find(drawablep) == mHeroList.end()) { mHeroList.insert(drawablep); - LL_INFOS() << "Added hero drawable." << LL_ENDL; } } diff --git a/indra/newview/llheroprobemanager.h b/indra/newview/llheroprobemanager.h index c6df963cfd..24246af3d3 100644 --- a/indra/newview/llheroprobemanager.h +++ b/indra/newview/llheroprobemanager.h @@ -117,15 +117,18 @@ private: U32 mReflectionProbeCount; // resolution of reflection probes - U32 mProbeResolution = 128; + U32 mProbeResolution = 1024; // maximum LoD of reflection probes (mip levels - 1) F32 mMaxProbeLOD = 6.f; + + F32 mHeroProbeStrength = 1.f; + bool mIsInTransition = false; // if true, reset all probe render state on the next update (for teleports and sky changes) bool mReset = false; LLDrawable::ordered_drawable_set_t mHeroList; - LLDrawable* mNearestHero; + LLPointer mNearestHero; }; diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index e855be8fbd..61143c61e8 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -714,6 +714,7 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face) mTexture->bind(channel); gRadianceGenProgram.uniform1i(sSourceIdx, sourceIdx); gRadianceGenProgram.uniform1f(LLShaderMgr::REFLECTION_PROBE_MAX_LOD, mMaxProbeLOD); + gRadianceGenProgram.uniform1f(LLShaderMgr::REFLECTION_PROBE_STRENGTH, 1.f); U32 res = mMipChain[0].getWidth(); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 6db1ae07de..3c3d8d5123 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1045,7 +1045,7 @@ LLDrawable *LLVOVolume::createDrawable(LLPipeline *pipeline) updateReflectionProbePtr(); } - if (isMirror()) + //if (isMirror()) { gPipeline.mHeroProbeManager.registerHeroDrawable(mDrawable); } -- cgit v1.3 From 32d1984bf98dce6e4938534342e67dbc40fbb073 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Fri, 1 Sep 2023 08:28:57 -0700 Subject: Temporary data model shenanigans. Should help tweak and tune placement with direct community guidance. DRTVWR-583 --- indra/newview/llheroprobemanager.cpp | 66 +++++++++++++++++++++++++++--------- indra/newview/llheroprobemanager.h | 8 ++--- indra/newview/llpanelvolume.cpp | 4 --- indra/newview/llviewerobject.cpp | 34 ++++++++++++++++++- indra/newview/llviewerobject.h | 4 +++ indra/newview/llvovolume.cpp | 22 ++++++++---- indra/newview/llvovolume.h | 1 + 7 files changed, 107 insertions(+), 32 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp index c385c9a99f..166321930f 100644 --- a/indra/newview/llheroprobemanager.cpp +++ b/indra/newview/llheroprobemanager.cpp @@ -109,16 +109,16 @@ void LLHeroProbeManager::update() // Get the nearest hero. float distance = F32_MAX; - if (mNearestHero.notNull()) + if (mNearestHero != nullptr) { - distance = mNearestHero->mDistanceWRTCamera; + distance = mNearestHero->mDrawable->mDistanceWRTCamera; } - for (auto drawable : mHeroList) + for (auto drawable : mHeroVOList) { - if (drawable.notNull() && drawable != mNearestHero) + if (drawable != nullptr && drawable != mNearestHero && drawable->mDrawable.notNull()) { - if (drawable->mDistanceWRTCamera < distance) + if (drawable->mDrawable->mDistanceWRTCamera < distance) { mIsInTransition = true; mNearestHero = drawable; @@ -133,8 +133,41 @@ void LLHeroProbeManager::update() } else { - if (mNearestHero.notNull()) - probe_pos.set(mNearestHero->mXform.getPosition().mV[0], mNearestHero->mXform.getPosition().mV[1], camera_pos.mV[2]); + + if (mNearestHero != nullptr && mNearestHero->mDrawable.notNull()) + { + + LLVector3 hero_pos = mNearestHero->mDrawable->mXform.getPosition(); + switch (mNearestHero->mirrorPlacementMode()) { + case 0: + probe_pos.set(camera_pos.mV[0], hero_pos.mV[1], hero_pos.mV[2]); + break; + case 1: + + probe_pos.set(hero_pos.mV[0], camera_pos.mV[1], hero_pos.mV[2]); + break; + case 2: + + probe_pos.set(hero_pos.mV[0], hero_pos.mV[1], camera_pos.mV[2]); + break; + + case 3: + // Find the nearest point relative to the camera on the VOVolume. + LLVector4a hit_pos; + bool hit = mNearestHero->lineSegmentIntersect(LLVector4a(camera_pos.mV[0], camera_pos.mV[1], camera_pos.mV[2]), + LLVector4a(hero_pos.mV[0], hero_pos.mV[1], hero_pos.mV[2]), + -1, + FALSE, + FALSE, + FALSE, + NULL, + &hit_pos); + if (hit) + probe_pos = hit_pos; + + break; + } + } if (mHeroProbeStrength < 1.f) @@ -505,7 +538,7 @@ void LLHeroProbeManager::cleanup() glDeleteBuffers(1, &mUBO); mUBO = 0; - mHeroList.clear(); + mHeroVOList.clear(); mNearestHero = nullptr; } @@ -523,18 +556,19 @@ void LLHeroProbeManager::doOcclusion() } } -void LLHeroProbeManager::registerHeroDrawable(LLDrawable* drawablep) +void LLHeroProbeManager::registerHeroDrawable(LLVOVolume* drawablep) { - if (mHeroList.find(drawablep) == mHeroList.end()) - { - mHeroList.insert(drawablep); - } + if (mHeroVOList.find(drawablep) == mHeroVOList.end()) + { + mHeroVOList.insert(drawablep); + LL_INFOS() << "Mirror drawable registered." << LL_ENDL; + } } -void LLHeroProbeManager::unregisterHeroDrawable(LLDrawable *drawablep) +void LLHeroProbeManager::unregisterHeroDrawable(LLVOVolume* drawablep) { - if (mHeroList.find(drawablep) != mHeroList.end()) + if (mHeroVOList.find(drawablep) != mHeroVOList.end()) { - mHeroList.erase(drawablep); + mHeroVOList.erase(drawablep); } } diff --git a/indra/newview/llheroprobemanager.h b/indra/newview/llheroprobemanager.h index 24246af3d3..b817b2396f 100644 --- a/indra/newview/llheroprobemanager.h +++ b/indra/newview/llheroprobemanager.h @@ -68,8 +68,8 @@ public: // perform occlusion culling on all active reflection probes void doOcclusion(); - void registerHeroDrawable(LLDrawable* drawablep); - void unregisterHeroDrawable(LLDrawable* drawablep); + void registerHeroDrawable(LLVOVolume* drawablep); + void unregisterHeroDrawable(LLVOVolume* drawablep); private: friend class LLPipeline; @@ -128,7 +128,7 @@ private: // if true, reset all probe render state on the next update (for teleports and sky changes) bool mReset = false; - LLDrawable::ordered_drawable_set_t mHeroList; - LLPointer mNearestHero; + std::set mHeroVOList; + LLVOVolume* mNearestHero; }; diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index d62a640b5c..74c02099f8 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -755,10 +755,6 @@ void LLPanelVolume::sendIsMirror() } LLVOVolume *volobjp = (LLVOVolume *)objectp; - // Quick hack to set the mirror locally. - - gPipeline.mHeroProbeManager.registerHeroDrawable(volobjp->mDrawable); - BOOL value = getChild("Mirror Checkbox Ctrl")->getValue(); volobjp->setIsMirror(value); LL_INFOS() << "update mirror sent" << LL_ENDL; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 59a61f0c63..7032ce41d5 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -1524,11 +1524,43 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, std::string temp_string; mesgsys->getStringFast(_PREHASH_ObjectData, _PREHASH_Text, temp_string, block_num ); + std::stringstream ss(temp_string); + std::string word; + bool mirror_detected = false; + while (ss >> word) + { + if (word == "Mirror") + { + mirror_detected = true; + mIsMirror = true; + } + else if (word == "XAlign" && mIsMirror) + { + mMirrorPlacementMode = 0; + } + else if (word == "YAlign" && mIsMirror) + { + mMirrorPlacementMode = 1; + } + else if (word == "ZAlign" && mIsMirror) + { + mMirrorPlacementMode = 2; + } + else if (word == "NearestPoint" && mIsMirror) + { + mMirrorPlacementMode = 3; + } + } + LLColor4U coloru; mesgsys->getBinaryDataFast(_PREHASH_ObjectData, _PREHASH_TextColor, coloru.mV, 4, block_num); - + // alpha was flipped so that it zero encoded better coloru.mV[3] = 255 - coloru.mV[3]; + + if (mirror_detected) + coloru.mV[3] = 0; + mText->setColor(LLColor4(coloru)); mText->setString(temp_string); diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 7175b088d9..c165f164a8 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -258,6 +258,7 @@ public: virtual BOOL hasLightTexture() const { return FALSE; } virtual BOOL isReflectionProbe() const { return FALSE; } virtual BOOL isMirror() const { return FALSE; } + virtual U8 mirrorPlacementMode() const { return 0; } // This method returns true if the object is over land owned by // the agent, one of its groups, or it encroaches and @@ -878,6 +879,9 @@ protected: F32 mPhysicsCost; F32 mLinksetPhysicsCost; + bool mIsMirror; + U8 mMirrorPlacementMode; + // If true, "shrink wrap" this volume in its spatial partition. See "shrinkWrap" bool mShouldShrinkWrap = false; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 3c3d8d5123..23580c4ec0 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -249,6 +249,9 @@ LLVOVolume::~LLVOVolume() mTextureAnimp = NULL; delete mVolumeImpl; mVolumeImpl = NULL; + + if (mIsMirror) + gPipeline.mHeroProbeManager.unregisterHeroDrawable(this); gMeshRepo.unregisterMesh(this); @@ -1045,9 +1048,9 @@ LLDrawable *LLVOVolume::createDrawable(LLPipeline *pipeline) updateReflectionProbePtr(); } - //if (isMirror()) + if (isMirror()) { - gPipeline.mHeroProbeManager.registerHeroDrawable(mDrawable); + gPipeline.mHeroProbeManager.registerHeroDrawable(this); } updateRadius(); @@ -3396,17 +3399,22 @@ void LLVOVolume::updateMirrorDrawable() { if (isMirror()) { - gPipeline.mHeroProbeManager.registerHeroDrawable(mDrawable); + gPipeline.mHeroProbeManager.registerHeroDrawable(this); } else { - gPipeline.mHeroProbeManager.unregisterHeroDrawable(mDrawable); + gPipeline.mHeroProbeManager.unregisterHeroDrawable(this); } } BOOL LLVOVolume::isMirror() const { - return getParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE); + return mIsMirror; +} + +U8 LLVOVolume::mirrorPlacementMode() const +{ + return mMirrorPlacementMode; } BOOL LLVOVolume::isReflectionProbe() const @@ -4461,9 +4469,9 @@ void LLVOVolume::parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_u updateReflectionProbePtr(); if (isMirror()) - gPipeline.mHeroProbeManager.registerHeroDrawable(mDrawable); + gPipeline.mHeroProbeManager.registerHeroDrawable(this); else - gPipeline.mHeroProbeManager.unregisterHeroDrawable(mDrawable); + gPipeline.mHeroProbeManager.unregisterHeroDrawable(this); } void LLVOVolume::updateReflectionProbePtr() diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 32c89ddae2..848f455e2a 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -298,6 +298,7 @@ public: // Mirrors bool setIsMirror(BOOL is_mirror); void updateMirrorDrawable(); + U8 mirrorPlacementMode() const override; // Reflection Probes bool setIsReflectionProbe(BOOL is_probe); -- cgit v1.3 From a888531fd1fbf7de0d71b4d04195d4267c882154 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Wed, 24 Jan 2024 16:22:45 -0800 Subject: https://github.com/secondlife/viewer-issues/issues/23 Make the face selection for mirrors actually reflect what it does --- indra/newview/llheroprobemanager.cpp | 2 +- indra/newview/llviewerobject.cpp | 8 ++++---- indra/newview/llviewerobject.h | 4 ++-- indra/newview/llvovolume.cpp | 4 ++-- indra/newview/llvovolume.h | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp index fdf782adee..1ecafd4f54 100644 --- a/indra/newview/llheroprobemanager.cpp +++ b/indra/newview/llheroprobemanager.cpp @@ -138,7 +138,7 @@ void LLHeroProbeManager::update() if (mNearestHero != nullptr && mNearestHero->mDrawable.notNull()) { - U8 mode = mNearestHero->mirrorPlacementMode(); + U8 mode = mNearestHero->mirrorFace(); mode = llmin(mNearestHero->mDrawable->getNumFaces() - 1, mode); mCurrentFace = mNearestHero->mDrawable->getFace(mode); diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 88494f419c..691a2e14d3 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -314,8 +314,8 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe mCachedMuteListUpdateTime(0), mCachedOwnerInMuteList(false), mRiggedAttachedWarned(false), -mIsMirror(false), -mMirrorPlacementMode(3) + mIsMirror(false), + mMirrorFace(3) { if (!is_global) { @@ -1558,7 +1558,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, std::string temp_string; mesgsys->getStringFast(_PREHASH_ObjectData, _PREHASH_Text, temp_string, block_num ); - detectMirror(temp_string, mIsMirror, mMirrorPlacementMode); + detectMirror(temp_string, mIsMirror, mMirrorFace); LLColor4U coloru; mesgsys->getBinaryDataFast(_PREHASH_ObjectData, _PREHASH_TextColor, coloru.mV, 4, block_num); @@ -1946,7 +1946,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, std::string temp_string; dp->unpackString(temp_string, "Text"); - detectMirror(temp_string, mIsMirror, mMirrorPlacementMode); + detectMirror(temp_string, mIsMirror, mMirrorFace); LLColor4U coloru; dp->unpackBinaryDataFixed(coloru.mV, 4, "Color"); diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 6ed37bf014..f3c00e83dc 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -258,7 +258,7 @@ public: virtual BOOL hasLightTexture() const { return FALSE; } virtual BOOL isReflectionProbe() const { return FALSE; } virtual BOOL isMirror() const { return FALSE; } - virtual U8 mirrorPlacementMode() const { return 0; } + virtual U8 mirrorFace() const { return 0; } // This method returns true if the object is over land owned by // the agent, one of its groups, or it encroaches and @@ -881,7 +881,7 @@ protected: F32 mLinksetPhysicsCost; bool mIsMirror; - U8 mMirrorPlacementMode; + U8 mMirrorFace; // If true, "shrink wrap" this volume in its spatial partition. See "shrinkWrap" bool mShouldShrinkWrap = false; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 91e64d611c..9813039145 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -3364,9 +3364,9 @@ BOOL LLVOVolume::isMirror() const return mIsMirror; } -U8 LLVOVolume::mirrorPlacementMode() const +U8 LLVOVolume::mirrorFace() const { - return mMirrorPlacementMode; + return mMirrorFace; } BOOL LLVOVolume::isReflectionProbe() const diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 848f455e2a..b03fc4b862 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -298,7 +298,7 @@ public: // Mirrors bool setIsMirror(BOOL is_mirror); void updateMirrorDrawable(); - U8 mirrorPlacementMode() const override; + U8 mirrorFace() const override; // Reflection Probes bool setIsReflectionProbe(BOOL is_probe); -- cgit v1.3 From 086249191078bcfb81d2697509c325fb34ffaf94 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Tue, 6 Feb 2024 01:31:13 -0800 Subject: #679 Add mirror update params to the volume floater. #740 Add support for FLAG_MIRROR in the viewer for mirror probes. --- indra/llprimitive/llprimitive.cpp | 13 ++++++ indra/llprimitive/llprimitive.h | 3 ++ indra/newview/llpanelvolume.cpp | 38 ++++++++++++++--- indra/newview/llvovolume.cpp | 44 ++++++++++++++++++++ indra/newview/llvovolume.h | 4 ++ .../newview/skins/default/xui/en/floater_tools.xml | 47 ++++++++++++++-------- 6 files changed, 127 insertions(+), 22 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index f67959de5b..0f538ffd0c 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1968,6 +1968,19 @@ void LLReflectionProbeParams::setIsDynamic(bool is_dynamic) } } + +void LLReflectionProbeParams::setIsMirror(bool is_mirror) +{ + if (is_mirror) + { + mFlags |= FLAG_MIRROR; + } + else + { + mFlags &= ~FLAG_MIRROR; + } +} + //============================================================================ LLFlexibleObjectData::LLFlexibleObjectData() { diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 88bac34ef2..db4f4ddeba 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -197,6 +197,7 @@ public: { FLAG_BOX_VOLUME = 0x01, // use a box influence volume FLAG_DYNAMIC = 0x02, // render dynamic objects (avatars) into this Reflection Probe + FLAG_MIRROR = 0x04, // This probe is used for reflections on realtime mirrors. }; protected: @@ -220,11 +221,13 @@ public: void setClipDistance(F32 distance) { mClipDistance = llclamp(distance, REFLECTION_PROBE_MIN_CLIP_DISTANCE, REFLECTION_PROBE_MAX_CLIP_DISTANCE); } void setIsBox(bool is_box); void setIsDynamic(bool is_dynamic); + void setIsMirror(bool is_mirror); F32 getAmbiance() const { return mAmbiance; } F32 getClipDistance() const { return mClipDistance; } bool getIsBox() const { return (mFlags & FLAG_BOX_VOLUME) != 0; } bool getIsDynamic() const { return (mFlags & FLAG_DYNAMIC) != 0; } + bool getIsMirror() const { return (mFlags & FLAG_MIRROR) != 0; } }; //------------------------------------------------- diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index a306a0a9ac..c03f52d23f 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -155,7 +155,7 @@ BOOL LLPanelVolume::postBuild() // REFLECTION PROBE Parameters { childSetCommitCallback("Reflection Probe", onCommitIsReflectionProbe, this); - childSetCommitCallback("Probe Dynamic", onCommitProbe, this); + childSetCommitCallback("Probe Update Type", onCommitProbe, this); childSetCommitCallback("Probe Volume Type", onCommitProbe, this); childSetCommitCallback("Probe Ambiance", onCommitProbe, this); childSetCommitCallback("Probe Near Clip", onCommitProbe, this); @@ -401,17 +401,18 @@ void LLPanelVolume::getState( ) bool probe_enabled = is_probe && editable && single_volume; - getChildView("Probe Dynamic")->setEnabled(probe_enabled); + getChildView("Probe Update Type")->setEnabled(probe_enabled); getChildView("Probe Volume Type")->setEnabled(probe_enabled); getChildView("Probe Ambiance")->setEnabled(probe_enabled); getChildView("Probe Near Clip")->setEnabled(probe_enabled); + getChildView("Probe Update Label")->setEnabled(probe_enabled); if (!probe_enabled) { getChild("Probe Volume Type", true)->clear(); getChild("Probe Ambiance", true)->clear(); getChild("Probe Near Clip", true)->clear(); - getChild("Probe Dynamic", true)->clear(); + getChild("Probe Update Type", true)->clear(); } else { @@ -425,10 +426,28 @@ void LLPanelVolume::getState( ) volume_type = "Sphere"; } + std::string update_type; + if (volobjp->getReflectionProbeIsDynamic()) + { + update_type = "Dynamic"; + } + else if (volobjp->getReflectionProbeIsMirror()) + { + update_type = "Mirror"; + + } + else + { + update_type = "Static"; + } + + getChildView("Probe Ambiance")->setEnabled(update_type != "Mirror"); + getChildView("Probe Near Clip")->setEnabled(update_type != "Mirror"); + getChild("Probe Volume Type", true)->setValue(volume_type); getChild("Probe Ambiance", true)->setValue(volobjp->getReflectionProbeAmbiance()); getChild("Probe Near Clip", true)->setValue(volobjp->getReflectionProbeNearClip()); - getChild("Probe Dynamic", true)->setValue(volobjp->getReflectionProbeIsDynamic()); + getChild("Probe Update Type", true)->setValue(update_type); } // Animated Mesh @@ -715,7 +734,7 @@ void LLPanelVolume::clearCtrls() getChildView("Reflection Probe")->setEnabled(false);; getChildView("Probe Volume Type")->setEnabled(false); - getChildView("Probe Dynamic")->setEnabled(false); + getChildView("Probe Update Type")->setEnabled(false); getChildView("Probe Ambiance")->setEnabled(false); getChildView("Probe Near Clip")->setEnabled(false); getChildView("Animated Mesh Checkbox Ctrl")->setEnabled(false); @@ -1422,7 +1441,14 @@ void LLPanelVolume::onCommitProbe(LLUICtrl* ctrl, void* userdata) volobjp->setReflectionProbeAmbiance((F32)self->getChild("Probe Ambiance")->getValue().asReal()); volobjp->setReflectionProbeNearClip((F32)self->getChild("Probe Near Clip")->getValue().asReal()); - volobjp->setReflectionProbeIsDynamic(self->getChild("Probe Dynamic")->getValue().asBoolean()); + + std::string update_type = self->getChild("Probe Update Type")->getValue().asString(); + + volobjp->setReflectionProbeIsDynamic(update_type == "Dynamic"); + volobjp->setReflectionProbeIsMirror(update_type == "Mirror"); + + self->getChildView("Probe Ambiance")->setEnabled(update_type != "Mirror"); + self->getChildView("Probe Near Clip")->setEnabled(update_type != "Mirror"); std::string shape_type = self->getChild("Probe Volume Type")->getValue().asString(); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 9813039145..77f654be23 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -3442,6 +3442,22 @@ bool LLVOVolume::setReflectionProbeIsBox(bool is_box) return false; } +bool LLVOVolume::setReflectionProbeIsPlane(bool is_plane) +{ + LLReflectionProbeParams *param_block = (LLReflectionProbeParams *) getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + if (param_block->getIsBox() != is_plane) + { + param_block->setIsBox(is_plane); + parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); + return true; + } + } + + return false; +} + bool LLVOVolume::setReflectionProbeIsDynamic(bool is_dynamic) { LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); @@ -3458,6 +3474,22 @@ bool LLVOVolume::setReflectionProbeIsDynamic(bool is_dynamic) return false; } +bool LLVOVolume::setReflectionProbeIsMirror(bool is_mirror) +{ + LLReflectionProbeParams *param_block = (LLReflectionProbeParams *) getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + if (param_block->getIsMirror() != is_mirror) + { + param_block->setIsMirror(is_mirror); + parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); + return true; + } + } + + return false; +} + F32 LLVOVolume::getReflectionProbeAmbiance() const { const LLReflectionProbeParams* param_block = (const LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); @@ -3506,6 +3538,18 @@ bool LLVOVolume::getReflectionProbeIsDynamic() const return false; } +bool LLVOVolume::getReflectionProbeIsMirror() const +{ + const LLReflectionProbeParams *param_block = + (const LLReflectionProbeParams *) getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + return param_block->getIsMirror(); + } + + return false; +} + U32 LLVOVolume::getVolumeInterfaceID() const { if (mVolumeImpl) diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index b03fc4b862..89ef1d7d7a 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -305,13 +305,17 @@ public: bool setReflectionProbeAmbiance(F32 ambiance); bool setReflectionProbeNearClip(F32 near_clip); bool setReflectionProbeIsBox(bool is_box); + bool setReflectionProbeIsPlane(bool is_plane); bool setReflectionProbeIsDynamic(bool is_dynamic); + bool setReflectionProbeIsMirror(bool is_mirror); BOOL isReflectionProbe() const override; F32 getReflectionProbeAmbiance() const; F32 getReflectionProbeNearClip() const; bool getReflectionProbeIsBox() const; + bool getReflectionProbeIsPlane() const; bool getReflectionProbeIsDynamic() const; + bool getReflectionProbeIsMirror() const; BOOL isMirror() const override; diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml index 510351b471..4f4216c85a 100644 --- a/indra/newview/skins/default/xui/en/floater_tools.xml +++ b/indra/newview/skins/default/xui/en/floater_tools.xml @@ -2410,15 +2410,6 @@ even though the user gets a free copy. name="object_horizontal" top_pad="10" width="278" /> - - + name="Probe Update Label" + text_readonly_color="LabelDisabledColor" + width="100"> + Probe Update + + + + + + Date: Tue, 6 Feb 2024 02:53:57 -0800 Subject: #740 Make sure we evaluate if the probe is a mirror probe or not. #682 Re-enable gaussian filtering, and reduce the mirror resolution back to 1024. Also just generally clean up the code a bit. --- indra/llprimitive/llprimitive.cpp | 34 ------------ indra/llprimitive/llprimitive.h | 11 ---- indra/newview/app_settings/settings.xml | 2 +- indra/newview/llheroprobemanager.cpp | 65 ++++++++++++----------- indra/newview/llheroprobemanager.h | 7 +-- indra/newview/llpanelvolume.cpp | 29 ----------- indra/newview/llpanelvolume.h | 4 +- indra/newview/llviewerobject.cpp | 46 +---------------- indra/newview/llviewerobject.h | 5 -- indra/newview/llvovolume.cpp | 91 ++++++--------------------------- indra/newview/llvovolume.h | 9 ---- 11 files changed, 57 insertions(+), 246 deletions(-) (limited to 'indra/newview/llvovolume.cpp') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 0f538ffd0c..53d09df618 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1825,40 +1825,6 @@ bool LLLightParams::fromLLSD(LLSD& sd) //============================================================================ -LLMirrorParams::LLMirrorParams() -{ - mType = PARAMS_MIRROR; -} - -BOOL LLMirrorParams::pack(LLDataPacker &dp) const -{ - return TRUE; -} - -BOOL LLMirrorParams::unpack(LLDataPacker &dp) -{ - return TRUE; -} - -bool LLMirrorParams::operator==(const LLNetworkData& data) const -{ - if (data.mType != PARAMS_REFLECTION_PROBE) - { - return false; - } - return true; -} - -void LLMirrorParams::copy(const LLNetworkData& data) -{ - const LLMirrorParams *param = (LLMirrorParams*)&data; - mType = param->mType; -} - -//============================================================================ - -//============================================================================ - LLReflectionProbeParams::LLReflectionProbeParams() { mType = PARAMS_REFLECTION_PROBE; diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index db4f4ddeba..5622483861 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -109,7 +109,6 @@ public: PARAMS_EXTENDED_MESH = 0x70, PARAMS_RENDER_MATERIAL = 0x80, PARAMS_REFLECTION_PROBE = 0x90, - PARAMS_MIRROR = 0x100, }; public: @@ -173,16 +172,6 @@ public: F32 getCutoff() const { return mCutoff; } }; -class LLMirrorParams : public LLNetworkData -{ -public: - LLMirrorParams(); - /*virtual*/ BOOL pack(LLDataPacker &dp) const; - /*virtual*/ BOOL unpack(LLDataPacker &dp); - /*virtual*/ bool operator==(const LLNetworkData& data) const; - /*virtual*/ void copy(const LLNetworkData& data); -}; - extern const F32 REFLECTION_PROBE_MIN_AMBIANCE; extern const F32 REFLECTION_PROBE_MAX_AMBIANCE; extern const F32 REFLECTION_PROBE_DEFAULT_AMBIANCE; diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index f2ba4ba29e..ef51c7f0dc 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10421,7 +10421,7 @@ Type S32 Value - 2048 + 1024 RenderHeroProbeDistance diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp index 39f5bdec5a..c9728b8d93 100644 --- a/indra/newview/llheroprobemanager.cpp +++ b/indra/newview/llheroprobemanager.cpp @@ -127,38 +127,22 @@ void LLHeroProbeManager::update() else { // Valid drawables only please. Unregister this one. - unregisterHeroDrawable(vo); + unregisterViewerObject(vo); } } else { - unregisterHeroDrawable(vo); + unregisterViewerObject(vo); } } if (mNearestHero != nullptr && mNearestHero->mDrawable.notNull()) { - U8 mode = mNearestHero->mirrorFace(); - mode = llmin(mNearestHero->mDrawable->getNumFaces() - 1, mode); - - mCurrentFace = mNearestHero->mDrawable->getFace(mode); - LLVector3 hero_pos = mCurrentFace->getPositionAgent(); - - - // Calculate the average normal. - LLVector4a *posp = mCurrentFace->getViewerObject()->getVolume()->getVolumeFace(mCurrentFace->getTEOffset()).mPositions; - U16 *indp = mCurrentFace->getViewerObject()->getVolume()->getVolumeFace(mCurrentFace->getTEOffset()).mIndices; - // get first three vertices (first triangle) - LLVector4a v0 = posp[indp[0]]; - LLVector4a v1 = posp[indp[1]]; - LLVector4a v2 = posp[indp[2]]; - - v1.sub(v0); - v2.sub(v0); - LLVector3 face_normal = LLVector3(v1[0], v1[1], v1[2]) % LLVector3(v2[0], v2[1], v2[2]); + LLVector3 hero_pos = mNearestHero->getPositionAgent(); + LLVector3 face_normal = LLVector3(0, 0, 1); + face_normal *= mNearestHero->mDrawable->getXform()->getWorldRotation(); face_normal.normalize(); - face_normal *= mCurrentFace->getXform()->getWorldRotation(); LLVector3 offset = camera_pos - hero_pos; LLVector3 project = face_normal * (offset * face_normal); @@ -166,7 +150,7 @@ void LLHeroProbeManager::update() LLVector3 point = (reject - project) + hero_pos; mCurrentClipPlane.setVec(hero_pos, face_normal); - mMirrorPosition = mNearestHero->getPositionAgent(); + mMirrorPosition = hero_pos; mMirrorNormal = face_normal; @@ -254,6 +238,30 @@ void LLHeroProbeManager::updateProbeFace(LLReflectionMap* probe, U32 face, F32 n LLRenderTarget *screen_rt = &gPipeline.mHeroProbeRT.screen; LLRenderTarget *depth_rt = &gPipeline.mHeroProbeRT.deferredScreen; + + // perform a gaussian blur on the super sampled render before downsampling + { + gGaussianProgram.bind(); + gGaussianProgram.uniform1f(resScale, 1.f / (mProbeResolution * 2)); + S32 diffuseChannel = gGaussianProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, LLTexUnit::TT_TEXTURE); + + // horizontal + gGaussianProgram.uniform2f(direction, 1.f, 0.f); + gGL.getTexUnit(diffuseChannel)->bind(screen_rt); + mRenderTarget.bindTarget(); + gPipeline.mScreenTriangleVB->setBuffer(); + gPipeline.mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + mRenderTarget.flush(); + + // vertical + gGaussianProgram.uniform2f(direction, 0.f, 1.f); + gGL.getTexUnit(diffuseChannel)->bind(&mRenderTarget); + screen_rt->bindTarget(); + gPipeline.mScreenTriangleVB->setBuffer(); + gPipeline.mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + screen_rt->flush(); + gGaussianProgram.unbind(); + } S32 mips = log2((F32)mProbeResolution) + 0.5f; @@ -527,24 +535,21 @@ void LLHeroProbeManager::doOcclusion() } } -void LLHeroProbeManager::registerHeroDrawable(LLVOVolume* drawablep) +void LLHeroProbeManager::registerViewerObject(LLVOVolume* drawablep) { + llassert(drawablep != nullptr); + if (mHeroVOList.find(drawablep) == mHeroVOList.end()) { + // Probe isn't in our list for consideration. Add it. mHeroVOList.insert(drawablep); - LL_INFOS() << "Mirror drawable registered." << LL_ENDL; } } -void LLHeroProbeManager::unregisterHeroDrawable(LLVOVolume* drawablep) +void LLHeroProbeManager::unregisterViewerObject(LLVOVolume* drawablep) { if (mHeroVOList.find(drawablep) != mHeroVOList.end()) { mHeroVOList.erase(drawablep); } } - -bool LLHeroProbeManager::isViableMirror(LLFace* face) const -{ - return face == mCurrentFace; -} diff --git a/indra/newview/llheroprobemanager.h b/indra/newview/llheroprobemanager.h index 0b32768bb1..7485a8cd72 100644 --- a/indra/newview/llheroprobemanager.h +++ b/indra/newview/llheroprobemanager.h @@ -68,10 +68,8 @@ public: // perform occlusion culling on all active reflection probes void doOcclusion(); - void registerHeroDrawable(LLVOVolume* drawablep); - void unregisterHeroDrawable(LLVOVolume* drawablep); - - bool isViableMirror(LLFace* face) const; + void registerViewerObject(LLVOVolume *drawablep); + void unregisterViewerObject(LLVOVolume* drawablep); bool isMirrorPass() const { return mRenderingMirror; } @@ -140,6 +138,5 @@ private: std::set mHeroVOList; LLVOVolume* mNearestHero; - LLFace* mCurrentFace; }; diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index c03f52d23f..e0d95c5386 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -114,11 +114,6 @@ BOOL LLPanelVolume::postBuild() getChild("FlexForceZ")->setValidateBeforeCommit(precommitValidate); } - // Mirror Parameters - { - childSetCommitCallback("Mirror Checkbox Ctrl", onCommitIsMirror, this); - } - // LIGHT Parameters { childSetCommitCallback("Light Checkbox Ctrl",onCommitIsLight,this); @@ -309,10 +304,6 @@ void LLPanelVolume::getState( ) getChildView("select_single")->setVisible(true); getChildView("select_single")->setEnabled(true); } - - BOOL is_mirror = volobjp && volobjp->isMirror(); - getChild("Mirror Checkbox Ctrl")->setValue(is_mirror); - getChildView("Mirror Checkbox Ctrl")->setEnabled(editable && single_volume && volobjp); // Light properties BOOL is_light = volobjp && volobjp->getIsLight(); @@ -774,20 +765,6 @@ void LLPanelVolume::sendIsLight() LL_INFOS() << "update light sent" << LL_ENDL; } -void LLPanelVolume::sendIsMirror() -{ - LLViewerObject* objectp = mObject; - if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME)) - { - return; - } - LLVOVolume *volobjp = (LLVOVolume *)objectp; - - BOOL value = getChild("Mirror Checkbox Ctrl")->getValue(); - volobjp->setIsMirror(value); - LL_INFOS() << "update mirror sent" << LL_ENDL; -} - void notify_cant_select_reflection_probe() { if (!gSavedSettings.getBOOL("SelectReflectionProbes")) @@ -1495,12 +1472,6 @@ void LLPanelVolume::onCommitIsLight( LLUICtrl* ctrl, void* userdata ) self->sendIsLight(); } -void LLPanelVolume::onCommitIsMirror( LLUICtrl* ctrl, void* userdata ) -{ - LLPanelVolume* self = (LLPanelVolume*) userdata; - self->sendIsMirror(); -} - // static void LLPanelVolume::setLightTextureID(const LLUUID &asset_id, const LLUUID &item_id, LLVOVolume* volobjp) { diff --git a/indra/newview/llpanelvolume.h b/indra/newview/llpanelvolume.h index a658351624..aafefa918f 100644 --- a/indra/newview/llpanelvolume.h +++ b/indra/newview/llpanelvolume.h @@ -57,8 +57,7 @@ public: void refresh(); void sendIsLight(); - - void sendIsMirror(); + // when an object is becoming a refleciton probe, present a dialog asking for confirmation // otherwise, send the reflection probe update immediately void sendIsReflectionProbe(); @@ -72,7 +71,6 @@ public: static void onCommitIsLight( LLUICtrl* ctrl, void* userdata); static void onCommitLight( LLUICtrl* ctrl, void* userdata); - static void onCommitIsMirror( LLUICtrl* ctrl, void* userdata); static void onCommitIsReflectionProbe(LLUICtrl* ctrl, void* userdata); static void onCommitProbe(LLUICtrl* ctrl, void* userdata); void onCommitIsFlexible( LLUICtrl* ctrl, void* userdata); diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 691a2e14d3..d71814bd3f 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -313,9 +313,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe mLastUpdateCached(FALSE), mCachedMuteListUpdateTime(0), mCachedOwnerInMuteList(false), - mRiggedAttachedWarned(false), - mIsMirror(false), - mMirrorFace(3) + mRiggedAttachedWarned(false) { if (!is_global) { @@ -1149,39 +1147,6 @@ U32 LLViewerObject::extractSpatialExtents(LLDataPackerBinaryBuffer *dp, LLVector return parent_id; } -void detectMirror(const std::string &str, bool &mirror, U8 &mode) -{ - - std::stringstream ss(str); - std::string word; - while (ss >> word) - { - if (word == "IsMirror") - { - mirror = true; - } - - if (mirror) - { - bool num = false; - std::string::const_iterator it = word.begin(); - while (it != word.end()) - { - num = std::isdigit(*it); - ++it; - - if (!num) - break; - } - - if (num) - { - mode = atoi(word.c_str()); - } - } - } -} - U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, void **user_data, U32 block_num, @@ -1557,8 +1522,6 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, std::string temp_string; mesgsys->getStringFast(_PREHASH_ObjectData, _PREHASH_Text, temp_string, block_num ); - - detectMirror(temp_string, mIsMirror, mMirrorFace); LLColor4U coloru; mesgsys->getBinaryDataFast(_PREHASH_ObjectData, _PREHASH_TextColor, coloru.mV, 4, block_num); @@ -1946,8 +1909,6 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, std::string temp_string; dp->unpackString(temp_string, "Text"); - detectMirror(temp_string, mIsMirror, mMirrorFace); - LLColor4U coloru; dp->unpackBinaryDataFixed(coloru.mV, 4, "Color"); coloru.mV[3] = 255 - coloru.mV[3]; @@ -6327,11 +6288,6 @@ LLViewerObject::ExtraParameter* LLViewerObject::createNewParameterEntry(U16 para { new_block = new LLReflectionProbeParams(); break; - } - case LLNetworkData::PARAMS_MIRROR: - { - new_block = new LLMirrorParams(); - break; } default: { diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index f3c00e83dc..80da7b2f73 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -257,8 +257,6 @@ public: virtual BOOL isRiggedMesh() const { return FALSE; } virtual BOOL hasLightTexture() const { return FALSE; } virtual BOOL isReflectionProbe() const { return FALSE; } - virtual BOOL isMirror() const { return FALSE; } - virtual U8 mirrorFace() const { return 0; } // This method returns true if the object is over land owned by // the agent, one of its groups, or it encroaches and @@ -880,9 +878,6 @@ protected: F32 mPhysicsCost; F32 mLinksetPhysicsCost; - bool mIsMirror; - U8 mMirrorFace; - // If true, "shrink wrap" this volume in its spatial partition. See "shrinkWrap" bool mShouldShrinkWrap = false; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 77f654be23..54e0a0113d 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -249,9 +249,6 @@ LLVOVolume::~LLVOVolume() mTextureAnimp = NULL; delete mVolumeImpl; mVolumeImpl = NULL; - - if (mIsMirror) - gPipeline.mHeroProbeManager.unregisterHeroDrawable(this); gMeshRepo.unregisterMesh(this); @@ -1000,11 +997,6 @@ LLDrawable *LLVOVolume::createDrawable(LLPipeline *pipeline) updateReflectionProbePtr(); } - if (isMirror()) - { - gPipeline.mHeroProbeManager.registerHeroDrawable(this); - } - updateRadius(); bool force_update = true; // avoid non-alpha mDistance update being optimized away mDrawable->updateDistance(*LLViewerCamera::getInstance(), force_update); @@ -3327,48 +3319,6 @@ F32 LLVOVolume::getLightCutoff() const } } -bool LLVOVolume::setIsMirror(BOOL is_mirror) -{ - BOOL was_mirror = isMirror(); - if (is_mirror != was_mirror) - { - if (is_mirror) - { - setParameterEntryInUse(LLNetworkData::PARAMS_MIRROR, TRUE, true); - } - else - { - setParameterEntryInUse(LLNetworkData::PARAMS_MIRROR, FALSE, true); - } - } - - updateMirrorDrawable(); - - return was_mirror != is_mirror; -} - -void LLVOVolume::updateMirrorDrawable() -{ - if (isMirror()) - { - gPipeline.mHeroProbeManager.registerHeroDrawable(this); - } - else - { - gPipeline.mHeroProbeManager.unregisterHeroDrawable(this); - } -} - -BOOL LLVOVolume::isMirror() const -{ - return mIsMirror; -} - -U8 LLVOVolume::mirrorFace() const -{ - return mMirrorFace; -} - BOOL LLVOVolume::isReflectionProbe() const { return getParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE); @@ -3442,22 +3392,6 @@ bool LLVOVolume::setReflectionProbeIsBox(bool is_box) return false; } -bool LLVOVolume::setReflectionProbeIsPlane(bool is_plane) -{ - LLReflectionProbeParams *param_block = (LLReflectionProbeParams *) getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); - if (param_block) - { - if (param_block->getIsBox() != is_plane) - { - param_block->setIsBox(is_plane); - parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); - return true; - } - } - - return false; -} - bool LLVOVolume::setReflectionProbeIsDynamic(bool is_dynamic) { LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); @@ -4463,25 +4397,34 @@ void LLVOVolume::parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_u } updateReflectionProbePtr(); - - if (isMirror()) - gPipeline.mHeroProbeManager.registerHeroDrawable(this); - else - gPipeline.mHeroProbeManager.unregisterHeroDrawable(this); } void LLVOVolume::updateReflectionProbePtr() { if (isReflectionProbe()) { - if (mReflectionProbe.isNull()) + if (mReflectionProbe.isNull() && !getReflectionProbeIsMirror()) { mReflectionProbe = gPipeline.mReflectionMapManager.registerViewerObject(this); } + else if (mReflectionProbe.isNull() && getReflectionProbeIsMirror()) + { + // Geenz: This is a special case - what we want here is a hero probe. + // What we want to do here is instantiate a hero probe from the hero probe manager. + gPipeline.mHeroProbeManager.registerViewerObject(this); + } } - else if (mReflectionProbe.notNull()) + else if (mReflectionProbe.notNull() || getReflectionProbeIsMirror()) { - mReflectionProbe = nullptr; + if (mReflectionProbe.notNull()) + { + mReflectionProbe = nullptr; + } + + if (getReflectionProbeIsMirror()) + { + gPipeline.mHeroProbeManager.unregisterViewerObject(this); + } } } diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 89ef1d7d7a..cac09609b3 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -294,18 +294,12 @@ public: F32 getLightRadius() const; F32 getLightFalloff(const F32 fudge_factor = 1.f) const; F32 getLightCutoff() const; - - // Mirrors - bool setIsMirror(BOOL is_mirror); - void updateMirrorDrawable(); - U8 mirrorFace() const override; // Reflection Probes bool setIsReflectionProbe(BOOL is_probe); bool setReflectionProbeAmbiance(F32 ambiance); bool setReflectionProbeNearClip(F32 near_clip); bool setReflectionProbeIsBox(bool is_box); - bool setReflectionProbeIsPlane(bool is_plane); bool setReflectionProbeIsDynamic(bool is_dynamic); bool setReflectionProbeIsMirror(bool is_mirror); @@ -313,11 +307,8 @@ public: F32 getReflectionProbeAmbiance() const; F32 getReflectionProbeNearClip() const; bool getReflectionProbeIsBox() const; - bool getReflectionProbeIsPlane() const; bool getReflectionProbeIsDynamic() const; bool getReflectionProbeIsMirror() const; - - BOOL isMirror() const override; // Flexible Objects U32 getVolumeInterfaceID() const; -- cgit v1.3