SL-17685 Drag and drop material support

master
Dave Parks 2022-06-29 21:42:44 -05:00
parent 56ae3e0a08
commit 6f6df8ed71
10 changed files with 40 additions and 6 deletions

View File

@ -53,6 +53,8 @@ public:
F32 mMetallicFactor = 0.f;
F32 mRoughnessFactor = 0.f;
F32 mAlphaCutoff = 0.f;
bool mDoubleSided = false;
AlphaMode mAlphaMode = ALPHA_MODE_OPAQUE;

View File

@ -2430,7 +2430,7 @@ void LLRenderMaterialParams::setMaterial(U8 te, const LLUUID& id)
mEntries.push_back({ te, id });
}
LLUUID LLRenderMaterialParams::getMaterial(U8 te) const
const LLUUID& LLRenderMaterialParams::getMaterial(U8 te) const
{
for (int i = 0; i < mEntries.size(); ++i)
{

View File

@ -387,7 +387,7 @@ public:
bool fromLLSD(LLSD& sd);
void setMaterial(U8 te_idx, const LLUUID& id);
LLUUID getMaterial(U8 te_idx) const;
const LLUUID& getMaterial(U8 te_idx) const;
bool isEmpty() { return mEntries.empty(); }
};

View File

@ -344,6 +344,7 @@ set(viewer_SOURCE_FILES
llgesturemgr.cpp
llgiveinventory.cpp
llglsandbox.cpp
llgltfmateriallist.cpp
llgroupactions.cpp
llgroupiconctrl.cpp
llgrouplist.cpp
@ -986,6 +987,7 @@ set(viewer_HEADER_FILES
llgesturelistener.h
llgesturemgr.h
llgiveinventory.h
llgltfmateriallist.h
llgroupactions.h
llgroupiconctrl.h
llgrouplist.h

View File

@ -43,7 +43,6 @@
#include "llviewerregion.h"
#include "llvovolume.h"
#include "roles_constants.h"
#include "tinygltf/tiny_gltf.h"
#include "llviewerobjectlist.h"
#include "llfloaterreg.h"
#include "llfilesystem.h"
@ -52,6 +51,7 @@
#include "llviewertexturelist.h"
#include "llfloaterperms.h"
#include "tinygltf/tiny_gltf.h"
#include <strstream>
///----------------------------------------------------------------------------

View File

@ -1083,8 +1083,6 @@ void LLToolDragAndDrop::dropMaterialOneFace(LLViewerObject* hit_obj,
{
return;
}
LLTextureEntry* tep = hit_obj ? (hit_obj->getTE(hit_face)) : NULL;
hit_obj->setRenderMaterialID(hit_face, asset_id);

View File

@ -107,6 +107,7 @@
#include "llcleanup.h"
#include "llcallstack.h"
#include "llmeshrepository.h"
#include "llgltfmateriallist.h"
#include "llgl.h"
//#define DEBUG_UPDATE_TYPE
@ -4906,6 +4907,18 @@ void LLViewerObject::updateTEMaterialTextures(U8 te)
};
LLGLTFMaterial* mat = getTE(te)->getGLTFMaterial();
LLUUID mat_id = getRenderMaterialID(te);
if (mat == nullptr && mat_id.notNull())
{
mat = gGLTFMaterialList.getMaterial(mat_id);
getTE(te)->setGLTFMaterial(mat);
}
else if (mat_id.isNull() && mat != nullptr)
{
mat = nullptr;
getTE(te)->setGLTFMaterial(nullptr);
}
if (mat != nullptr)
{
mGLTFAlbedoMaps[te] = fetch_texture(mat->mAlbedoId);
@ -4913,6 +4926,14 @@ void LLViewerObject::updateTEMaterialTextures(U8 te)
mGLTFMetallicRoughnessMaps[te] = fetch_texture(mat->mMetallicRoughnessId);
mGLTFEmissiveMaps[te] = fetch_texture(mat->mEmissiveId);
}
else
{
mGLTFAlbedoMaps[te] = nullptr;
mGLTFNormalMaps[te] = nullptr;
mGLTFMetallicRoughnessMaps[te] = nullptr;
mGLTFEmissiveMaps[te] = nullptr;
}
}
void LLViewerObject::refreshBakeTexture()
@ -7028,8 +7049,16 @@ void LLViewerObject::setRenderMaterialID(U8 te, const LLUUID& id)
{
if (id.notNull())
{
getTE(te)->setGLTFMaterial(gGLTFMaterialList.getMaterial(id));
setHasRenderMaterialParams(true);
}
else
{
getTE(te)->setGLTFMaterial(nullptr);
}
faceMappingChanged();
gPipeline.markTextured(mDrawable);
LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL);
if (param_block)

View File

@ -207,6 +207,7 @@ public:
// Graphical stuff for objects - maybe broken out into render class later?
virtual void updateTextures();
virtual void faceMappingChanged() {}
virtual void boostTexturePriority(BOOL boost_children = TRUE); // When you just want to boost priority of this object
virtual LLDrawable* createDrawable(LLPipeline *pipeline);

View File

@ -5861,6 +5861,8 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
continue;
}
// HACK -- brute force this check every time a drawable gets rebuilt
vobj->updateTEMaterialTextures(i);
#if 0
#if LL_RELEASE_WITH_DEBUG_INFO
const LLUUID pbr_id( "49c88210-7238-2a6b-70ac-92d4f35963cf" );

View File

@ -172,7 +172,7 @@ public:
void markForUpdate(BOOL priority) override;
void markForUnload() { LLViewerObject::markForUnload(TRUE); mVolumeChanged = TRUE; }
void faceMappingChanged() { mFaceMappingChanged=TRUE; };
void faceMappingChanged() override { mFaceMappingChanged=TRUE; }
/*virtual*/ void onShift(const LLVector4a &shift_vector) override; // Called when the drawable shifts