summaryrefslogtreecommitdiff
path: root/indra/newview/llgltfmateriallist.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llgltfmateriallist.h')
-rw-r--r--indra/newview/llgltfmateriallist.h52
1 files changed, 40 insertions, 12 deletions
diff --git a/indra/newview/llgltfmateriallist.h b/indra/newview/llgltfmateriallist.h
index e035d2108d..9e8b3cf8e3 100644
--- a/indra/newview/llgltfmateriallist.h
+++ b/indra/newview/llgltfmateriallist.h
@@ -51,25 +51,45 @@ public:
static void registerCallbacks();
- // save an override update that we want to send to the simulator for later
- static void queueModifyMaterial(const LLUUID& id, S32 side, const LLGLTFMaterial& mat);
+ // Queue an override update that we want to send to the simulator. Call "flushUpdates" to flush pending updates.
+ // id - ID of object to modify
+ // side - TexureEntry index to modify, or -1 for all sides
+ // mat - material to apply as override, or nullptr to remove existing overrides and revert to asset
+ //
+ // NOTE: do not use to revert to asset when applying a new asset id, use queueApplyMaterialAsset below
+ static void queueModifyMaterial(const LLUUID& id, S32 side, const LLGLTFMaterial* mat);
+
+ // 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
+ //
+ // NOTE: implicitly removes any override data if present
+ static void queueApplyMaterialAsset(const LLUUID& object_id, S32 side, const LLUUID& asset_id);
// flush pending material updates to the simulator
- static void flushModifyMaterialQueue(void(*done_callback)(bool));
+ static void flushUpdates(void(*done_callback)(bool) = nullptr);
// apply given override data via given cap url
// cap_url -- should be gAgent.getRegionCapability("ModifyMaterialParams")
- // overrides -- LLSD map in the format
- // "object_id": LLUUID - object to be modified
- // "side": integer - index of face to be modified
- // "gltf_json" : string - GLTF compliant json of override data (optional, if omitted any existing override data will be cleared)
+ // overrides -- LLSD map (or array of maps) in the format:
+ // object_id UUID(required) id of object
+ // side integer(required) TE index of face to set, or -1 for all faces
+ // gltf_json string(optional) override data to set, empty string nulls out override data, omissions of this parameter keeps existing data
+ // asset_id UUID(optional) id of material asset to set, omission of this parameter keeps existing material asset id
+ //
+ // NOTE: if you're calling this from outside of flushUpdates, you're probably doing it wrong. Use the "queue"/"flush" API above.
+ // If the queue/flush API is insufficient, extend it.
static void modifyMaterialCoro(std::string cap_url, LLSD overrides, void(*done_callback)(bool));
-
- // save an override update that we got from the simulator for later (for example, if an override arrived for an unknown object)
- void queueOverrideUpdate(const LLUUID& id, S32 side, LLGLTFMaterial* override_data);
void applyQueuedOverrides(LLViewerObject* obj);
+
private:
+ friend class LLGLTFMaterialOverrideDispatchHandler;
+ // save an override update that we got from the simulator for later (for example, if an override arrived for an unknown object)
+ // NOTE: this is NOT for applying overrides from the UI, see queueModifyMaterial above
+ void queueOverrideUpdate(const LLUUID& id, S32 side, LLGLTFMaterial* override_data);
+
typedef std::unordered_map<LLUUID, LLPointer<LLFetchedGLTFMaterial > > uuid_mat_map_t;
uuid_mat_map_t mList;
@@ -84,15 +104,23 @@ private:
LLUUID object_id;
S32 side = -1;
LLGLTFMaterial override_data;
- LLUUID asset_id;
bool has_override = false;
- bool has_asset_id = false;
};
typedef std::list<ModifyMaterialData> modify_queue_t;
static modify_queue_t sModifyQueue;
+ struct ApplyMaterialAssetData
+ {
+ LLUUID object_id;
+ S32 side = -1;
+ LLUUID asset_id;
+ };
+
+ typedef std::list<ApplyMaterialAssetData> apply_queue_t;
+ static apply_queue_t sApplyQueue;
+
};
extern LLGLTFMaterialList gGLTFMaterialList;