diff options
| author | Maxim Nikolenko <maximnproductengine@lindenlab.com> | 2025-04-30 15:06:56 +0300 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-30 15:06:56 +0300 | 
| commit | 98078b9aade28c8e24f74103f57f96bcdacd4fa4 (patch) | |
| tree | 841b122bb4f43d7dc6b1cc5c89ecb23d234c5fe5 | |
| parent | d9e55c44152064133796bfb08f1da524387c1300 (diff) | |
#3748 Don't allow dropping material onto water exclusion surface
| -rw-r--r-- | indra/newview/lltooldraganddrop.cpp | 49 | ||||
| -rw-r--r-- | indra/newview/skins/default/xui/en/notifications.xml | 9 | 
2 files changed, 57 insertions, 1 deletions
| diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 9d6f44c096..ff4fcc2b0b 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -2351,6 +2351,47 @@ EAcceptance LLToolDragAndDrop::dad3dRezScript(      return rv;  } + +bool is_water_exclusion_face(LLViewerObject* obj, S32 face) +{ +    LLViewerTexture* image = obj->getTEImage(face); +    if (!image) +        return false; + +    // magic texture and alpha blending +    bool exclude_water = (image->getID() == IMG_ALPHA_GRAD) && obj->isImageAlphaBlended(face); + +    // transparency +    exclude_water &= (obj->getTE(face)->getColor().mV[VALPHA] == 1); + +    //absence of normal and specular textures +    image = obj->getTENormalMap(face); +    if (image && image != LLViewerFetchedTexture::sDefaultImagep) +        exclude_water &= image->getID().isNull(); +    image = obj->getTESpecularMap(face); +    if (image && image != LLViewerFetchedTexture::sDefaultImagep) +        exclude_water &= image->getID().isNull(); + +    return exclude_water; +} + +bool is_water_exclusion_surface(LLViewerObject* obj, S32 face, bool all_faces) +{ +    if (all_faces) +    { +        bool exclude_water = false; +        for (S32 it_face = 0; it_face < obj->getNumTEs(); it_face++) +        { +            exclude_water |= is_water_exclusion_face(obj, it_face); +        } +        return exclude_water; +    } +    else +    { +        return is_water_exclusion_face(obj, face); +    } +} +  EAcceptance LLToolDragAndDrop::dad3dApplyToObject(      LLViewerObject* obj, S32 face, MASK mask, bool drop, EDragAndDropType cargo_type)  { @@ -2441,7 +2482,13 @@ EAcceptance LLToolDragAndDrop::dad3dApplyToObject(          else if (cargo_type == DAD_MATERIAL)          {              bool all_faces = mask & MASK_SHIFT; -            if (item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID())) + +            if (is_water_exclusion_surface(obj, face, all_faces)) +            { +                LLNotificationsUtil::add("WaterExclusionNoMaterial"); +                return ACCEPT_NO; +            } +            else if (item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID()))              {                  dropMaterial(obj, face, item, mSource, mSourceID, all_faces);              } diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 1a56d7e3a3..a51feeb7ab 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -12610,4 +12610,13 @@ are wearing now.        notext="Cancel"        yestext="Continue"/>    </notification> + +  <notification +   icon="notify.tga" +   name="WaterExclusionNoMaterial" +   persist="true" +   type="notify"> +    Unable to apply material to the water exclusion surface. +    <tag>fail</tag> +  </notification>  </notifications> | 
