SL-18932 Canceling material selection only reverts override
parent
7c1ccdc9a4
commit
f8f119e4a8
|
|
@ -433,6 +433,19 @@ void LLGLTFMaterialList::queueApply(const LLViewerObject* obj, S32 side, const L
|
|||
}
|
||||
}
|
||||
|
||||
void LLGLTFMaterialList::queueApply(const LLViewerObject* obj, S32 side, const LLUUID& asset_id, const LLGLTFMaterial* material_override)
|
||||
{
|
||||
if (asset_id.isNull() || material_override == nullptr)
|
||||
{
|
||||
queueApply(obj, side, asset_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
LLGLTFMaterial* material = new LLGLTFMaterial(*material_override);
|
||||
sApplyQueue.push_back({ obj->getID(), side, asset_id, material });
|
||||
}
|
||||
}
|
||||
|
||||
void LLGLTFMaterialList::queueUpdate(const LLSD& data)
|
||||
{
|
||||
llassert(is_valid_update(data));
|
||||
|
|
@ -477,7 +490,7 @@ void LLGLTFMaterialList::flushUpdates(void(*done_callback)(bool))
|
|||
}
|
||||
sModifyQueue.clear();
|
||||
|
||||
for (auto& e : sApplyQueue)
|
||||
for (ApplyMaterialAssetData& e : sApplyQueue)
|
||||
{
|
||||
data[i]["object_id"] = e.object_id;
|
||||
data[i]["side"] = e.side;
|
||||
|
|
|
|||
|
|
@ -70,6 +70,13 @@ public:
|
|||
// NOTE: Implicitly clears most override data if present
|
||||
static void queueApply(const LLViewerObject* obj, S32 side, const LLUUID& asset_id);
|
||||
|
||||
// Queue an application of a material asset we want to send to the simulator. Call "flushUpdates" to flush pending updates.
|
||||
// object_id - ID of object to apply material asset to
|
||||
// side - TextureEntry index to apply material to, or -1 for all sides
|
||||
// asset_id - ID of material asset to apply, or LLUUID::null to disassociate current material asset
|
||||
// mat - override material, if null, will clear most override data
|
||||
static void queueApply(const LLViewerObject* obj, S32 side, const LLUUID& asset_id, const LLGLTFMaterial* mat);
|
||||
|
||||
// flush pending material updates to the simulator
|
||||
// Automatically called once per frame, but may be called explicitly
|
||||
// for cases that care about the done_callback forwarded to LLCoros::instance().launch
|
||||
|
|
|
|||
|
|
@ -2188,8 +2188,8 @@ void LLSelectMgr::selectionRevertGLTFMaterials()
|
|||
// Enqueue update to server
|
||||
if (asset_id.notNull())
|
||||
{
|
||||
// Restore overrides
|
||||
LLGLTFMaterialList::queueModify(objectp, te, nodep->mSavedGLTFOverrideMaterials[te]);
|
||||
// Restore overrides and base material
|
||||
LLGLTFMaterialList::queueApply(objectp, te, asset_id, nodep->mSavedGLTFOverrideMaterials[te]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -5797,7 +5797,7 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data
|
|||
if (can_copy && can_transfer && node->getObject()->getVolume())
|
||||
{
|
||||
uuid_vec_t material_ids;
|
||||
gltf_materials_vec_t materials;
|
||||
gltf_materials_vec_t override_materials;
|
||||
LLVOVolume* vobjp = (LLVOVolume*)node->getObject();
|
||||
for (int i = 0; i < vobjp->getNumTEs(); ++i)
|
||||
{
|
||||
|
|
@ -5812,18 +5812,16 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data
|
|||
if (old_override)
|
||||
{
|
||||
LLPointer<LLGLTFMaterial> mat = new LLGLTFMaterial(*old_override);
|
||||
materials.push_back(mat);
|
||||
override_materials.push_back(mat);
|
||||
}
|
||||
else
|
||||
{
|
||||
materials.push_back(nullptr);
|
||||
override_materials.push_back(nullptr);
|
||||
}
|
||||
}
|
||||
node->saveGLTFMaterialIds(material_ids);
|
||||
|
||||
// processObjectProperties does not include overrides so this
|
||||
// might need to be moved to LLGLTFMaterialOverrideDispatchHandler
|
||||
node->saveGLTFOverrideMaterials(materials);
|
||||
node->saveGLTFMaterials(material_ids, override_materials);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -6576,8 +6574,7 @@ LLSelectNode::LLSelectNode(const LLSelectNode& nodep)
|
|||
}
|
||||
|
||||
saveTextures(nodep.mSavedTextures);
|
||||
saveGLTFMaterialIds(nodep.mSavedGLTFMaterialIds);
|
||||
saveGLTFOverrideMaterials(nodep.mSavedGLTFOverrideMaterials);
|
||||
saveGLTFMaterials(nodep.mSavedGLTFMaterialIds, nodep.mSavedGLTFOverrideMaterials);
|
||||
}
|
||||
|
||||
LLSelectNode::~LLSelectNode()
|
||||
|
|
@ -6711,28 +6708,21 @@ void LLSelectNode::saveTextures(const uuid_vec_t& textures)
|
|||
}
|
||||
}
|
||||
|
||||
void LLSelectNode::saveGLTFMaterialIds(const uuid_vec_t& materials)
|
||||
void LLSelectNode::saveGLTFMaterials(const uuid_vec_t& materials, const gltf_materials_vec_t& override_materials)
|
||||
{
|
||||
if (mObject.notNull())
|
||||
{
|
||||
mSavedGLTFMaterialIds.clear();
|
||||
mSavedGLTFOverrideMaterials.clear();
|
||||
|
||||
for (uuid_vec_t::const_iterator materials_it = materials.begin();
|
||||
materials_it != materials.end(); ++materials_it)
|
||||
{
|
||||
mSavedGLTFMaterialIds.push_back(*materials_it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LLSelectNode::saveGLTFOverrideMaterials(const gltf_materials_vec_t& materials)
|
||||
{
|
||||
if (mObject.notNull())
|
||||
{
|
||||
mSavedGLTFOverrideMaterials.clear();
|
||||
|
||||
for (gltf_materials_vec_t::const_iterator mat_it = materials.begin();
|
||||
mat_it != materials.end(); ++mat_it)
|
||||
for (gltf_materials_vec_t::const_iterator mat_it = override_materials.begin();
|
||||
mat_it != override_materials.end(); ++mat_it)
|
||||
{
|
||||
mSavedGLTFOverrideMaterials.push_back(*mat_it);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -197,8 +197,7 @@ public:
|
|||
// final gltf material that users see.
|
||||
// Ids get applied and restored by tools floater,
|
||||
// overrides get applied in live material editor
|
||||
void saveGLTFMaterialIds(const uuid_vec_t& materials);
|
||||
void saveGLTFOverrideMaterials(const gltf_materials_vec_t& materials);
|
||||
void saveGLTFMaterials(const uuid_vec_t& materials, const gltf_materials_vec_t& override_materials);
|
||||
|
||||
BOOL allowOperationOnNode(PermissionBit op, U64 group_proxy_power) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -2150,12 +2150,14 @@ EAcceptance LLToolDragAndDrop::dad3dApplyToObject(
|
|||
if (nodep)
|
||||
{
|
||||
uuid_vec_t material_ids;
|
||||
gltf_materials_vec_t override_materials;
|
||||
S32 num_faces = obj->getNumTEs();
|
||||
for (S32 face = 0; face < num_faces; face++)
|
||||
{
|
||||
material_ids.push_back(obj->getRenderMaterialID(face));
|
||||
override_materials.push_back(nullptr);
|
||||
}
|
||||
nodep->saveGLTFMaterialIds(material_ids);
|
||||
nodep->saveGLTFMaterials(material_ids, override_materials);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -2169,6 +2171,7 @@ EAcceptance LLToolDragAndDrop::dad3dApplyToObject(
|
|||
&& nodep->mSavedGLTFMaterialIds.size() > face)
|
||||
{
|
||||
nodep->mSavedGLTFMaterialIds[face] = obj->getRenderMaterialID(face);
|
||||
nodep->mSavedGLTFOverrideMaterials[face] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue