summaryrefslogtreecommitdiff
path: root/indra/llprimitive
diff options
context:
space:
mode:
authorJonathan "Geenz" Goodman <geenz@geenzo.com>2024-01-24 14:37:33 -0800
committerJonathan "Geenz" Goodman <geenz@geenzo.com>2024-01-24 14:37:33 -0800
commit373b06398c274eee476e4aa9c35b9c6327f9d45f (patch)
tree4a324b36ab896d9507374e71e15f9ec064b41add /indra/llprimitive
parentbd9c0a2e658e183bb8a321cdce546f10b6d76afe (diff)
parentc22aefafb3d05be37965361913c02568fa10adf6 (diff)
Merge remote-tracking branch 'origin/release/materials_featurette' into DRTVWR-583
Diffstat (limited to 'indra/llprimitive')
-rw-r--r--indra/llprimitive/lldaeloader.cpp3
-rw-r--r--indra/llprimitive/llgltfmaterial.cpp78
-rw-r--r--indra/llprimitive/llgltfmaterial.h14
-rw-r--r--indra/llprimitive/llmodel.cpp3
-rw-r--r--indra/llprimitive/llprimitive.cpp36
-rw-r--r--indra/llprimitive/llprimitive.h5
6 files changed, 96 insertions, 43 deletions
diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp
index 46e1cb4922..2e4b013b77 100644
--- a/indra/llprimitive/lldaeloader.cpp
+++ b/indra/llprimitive/lldaeloader.cpp
@@ -2584,7 +2584,8 @@ bool LLDAELoader::loadModelsFromDomMesh(domMesh* mesh, std::vector<LLModel*>& mo
next->mLabel = model_name + (char)((int)'a' + next->mSubmodelID) + lod_suffix[mLod];
next->getVolumeFaces() = remainder;
next->mNormalizedScale = ret->mNormalizedScale;
-
+ next->mNormalizedTranslation = ret->mNormalizedTranslation;
+
if ( ret->mMaterialList.size() > LL_SCULPT_MESH_MAX_FACES)
{
next->mMaterialList.assign(ret->mMaterialList.begin() + LL_SCULPT_MESH_MAX_FACES, ret->mMaterialList.end());
diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp
index f42c11ee21..237636bd0b 100644
--- a/indra/llprimitive/llgltfmaterial.cpp
+++ b/indra/llprimitive/llgltfmaterial.cpp
@@ -89,6 +89,10 @@ LLGLTFMaterial& LLGLTFMaterial::operator=(const LLGLTFMaterial& rhs)
mOverrideDoubleSided = rhs.mOverrideDoubleSided;
mOverrideAlphaMode = rhs.mOverrideAlphaMode;
+ mTrackingIdToLocalTexture = rhs.mTrackingIdToLocalTexture;
+
+ updateTextureTracking();
+
return *this;
}
@@ -601,6 +605,10 @@ void LLGLTFMaterial::applyOverride(const LLGLTFMaterial& override_mat)
mTextureTransform[i].mRotation = override_mat.mTextureTransform[i].mRotation;
}
}
+
+ mTrackingIdToLocalTexture.insert(override_mat.mTrackingIdToLocalTexture.begin(), override_mat.mTrackingIdToLocalTexture.begin());
+
+ updateTextureTracking();
}
void LLGLTFMaterial::getOverrideLLSD(const LLGLTFMaterial& override_mat, LLSD& data)
@@ -691,36 +699,62 @@ void LLGLTFMaterial::applyOverrideLLSD(const LLSD& data)
if (bc.isDefined())
{
mBaseColor.setValue(bc);
+ if (mBaseColor == getDefaultBaseColor())
+ {
+ // HACK -- nudge by epsilon if we receive a default value (indicates override to default)
+ mBaseColor.mV[3] -= FLT_EPSILON;
+ }
}
const LLSD& ec = data["ec"];
if (ec.isDefined())
{
mEmissiveColor.setValue(ec);
+ if (mEmissiveColor == getDefaultEmissiveColor())
+ {
+ // HACK -- nudge by epsilon if we receive a default value (indicates override to default)
+ mEmissiveColor.mV[0] += FLT_EPSILON;
+ }
}
const LLSD& mf = data["mf"];
if (mf.isReal())
{
mMetallicFactor = mf.asReal();
+ if (mMetallicFactor == getDefaultMetallicFactor())
+ {
+ // HACK -- nudge by epsilon if we receive a default value (indicates override to default)
+ mMetallicFactor -= FLT_EPSILON;
+ }
}
const LLSD& rf = data["rf"];
if (rf.isReal())
{
mRoughnessFactor = rf.asReal();
+ if (mRoughnessFactor == getDefaultRoughnessFactor())
+ {
+ // HACK -- nudge by epsilon if we receive a default value (indicates override to default)
+ mRoughnessFactor -= FLT_EPSILON;
+ }
}
const LLSD& am = data["am"];
if (am.isInteger())
{
mAlphaMode = (AlphaMode) am.asInteger();
+ mOverrideAlphaMode = true;
}
const LLSD& ac = data["ac"];
if (ac.isReal())
{
mAlphaCutoff = ac.asReal();
+ if (mAlphaCutoff == getDefaultAlphaCutoff())
+ {
+ // HACK -- nudge by epsilon if we receive a default value (indicates override to default)
+ mAlphaCutoff -= FLT_EPSILON;
+ }
}
const LLSD& ds = data["ds"];
@@ -765,3 +799,47 @@ LLUUID LLGLTFMaterial::getHash() const
return hash;
}
+void LLGLTFMaterial::addLocalTextureTracking(const LLUUID& tracking_id, const LLUUID& tex_id)
+{
+ mTrackingIdToLocalTexture[tracking_id] = tex_id;
+}
+
+void LLGLTFMaterial::removeLocalTextureTracking(const LLUUID& tracking_id)
+{
+ mTrackingIdToLocalTexture.erase(tracking_id);
+}
+
+bool LLGLTFMaterial::replaceLocalTexture(const LLUUID& tracking_id, const LLUUID& old_id, const LLUUID& new_id)
+{
+ bool res = false;
+
+ for (int i = 0; i < GLTF_TEXTURE_INFO_COUNT; ++i)
+ {
+ if (mTextureId[i] == old_id)
+ {
+ mTextureId[i] = new_id;
+ res = true;
+ }
+ else if (mTextureId[i] == new_id)
+ {
+ res = true;
+ }
+ }
+
+ if (res)
+ {
+ mTrackingIdToLocalTexture[tracking_id] = new_id;
+ }
+ else
+ {
+ mTrackingIdToLocalTexture.erase(tracking_id);
+ }
+
+ return res;
+}
+
+void LLGLTFMaterial::updateTextureTracking()
+{
+ // setTEGLTFMaterialOverride is responsible for tracking
+ // for material overrides editor will set it
+}
diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h
index a078a530a4..02f62fb08c 100644
--- a/indra/llprimitive/llgltfmaterial.h
+++ b/indra/llprimitive/llgltfmaterial.h
@@ -34,6 +34,7 @@
#include "lluuid.h"
#include "hbxxh.h"
+#include <array>
#include <string>
#include <map>
@@ -195,7 +196,7 @@ public:
// write to given tinygltf::Model
void writeToModel(tinygltf::Model& model, S32 mat_index) const;
- void applyOverride(const LLGLTFMaterial& override_mat);
+ virtual void applyOverride(const LLGLTFMaterial& override_mat);
// apply the given LLSD override data
void applyOverrideLLSD(const LLSD& data);
@@ -221,6 +222,17 @@ public:
virtual void addTextureEntry(LLTextureEntry* te) {};
virtual void removeTextureEntry(LLTextureEntry* te) {};
+ // For local textures so that editor will know to track changes
+ void addLocalTextureTracking(const LLUUID& tracking_id, const LLUUID &tex_id);
+ void removeLocalTextureTracking(const LLUUID& tracking_id);
+ bool hasLocalTextures() { return !mTrackingIdToLocalTexture.empty(); }
+ virtual bool replaceLocalTexture(const LLUUID& tracking_id, const LLUUID &old_id, const LLUUID& new_id);
+ virtual void updateTextureTracking();
+
+ // These fields are local to viewer and are a part of local bitmap support
+ typedef std::map<LLUUID, LLUUID> local_tex_map_t;
+ local_tex_map_t mTrackingIdToLocalTexture;
+
protected:
static LLVector2 vec2FromJson(const std::map<std::string, tinygltf::Value>& object, const char* key, const LLVector2& default_value);
static F32 floatFromJson(const std::map<std::string, tinygltf::Value>& object, const char* key, const F32 default_value);
diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp
index ee493968de..99a5697a84 100644
--- a/indra/llprimitive/llmodel.cpp
+++ b/indra/llprimitive/llmodel.cpp
@@ -52,7 +52,8 @@ const int MODEL_NAMES_LENGTH = sizeof(model_names) / sizeof(std::string);
LLModel::LLModel(LLVolumeParams& params, F32 detail)
: LLVolume(params, detail),
- mNormalizedScale(1,1,1),
+ mNormalizedScale(1,1,1),
+ mNormalizedTranslation(0, 0, 0),
mPelvisOffset( 0.0f ),
mStatus(NO_ERRORS),
mSubmodelID(0)
diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp
index a86434fe65..f67959de5b 100644
--- a/indra/llprimitive/llprimitive.cpp
+++ b/indra/llprimitive/llprimitive.cpp
@@ -2410,42 +2410,6 @@ void LLRenderMaterialParams::copy(const LLNetworkData& data)
mEntries = param.mEntries;
}
-LLSD LLRenderMaterialParams::asLLSD() const
-{
- LLSD ret;
-
- for (int i = 0; i < mEntries.size(); ++i)
- {
- ret[i]["te_idx"] = mEntries[i].te_idx;
- ret[i]["id"] = mEntries[i].id;
- }
-
- return ret;
-}
-
-bool LLRenderMaterialParams::fromLLSD(LLSD& sd)
-{
- if (sd.isArray())
- {
- mEntries.resize(sd.size());
- for (int i = 0; i < sd.size(); ++i)
- {
- if (sd[i].has("te_idx") && sd.has("id"))
- {
- mEntries[i].te_idx = sd[i]["te_idx"].asInteger();
- mEntries[i].id = sd[i]["id"].asUUID();
- }
- else
- {
- return false;
- }
- }
-
- return true;
- }
-
- return false;
-}
void LLRenderMaterialParams::setMaterial(U8 te, const LLUUID& id)
{
diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h
index 1af9bca42e..88bac34ef2 100644
--- a/indra/llprimitive/llprimitive.h
+++ b/indra/llprimitive/llprimitive.h
@@ -393,10 +393,7 @@ public:
BOOL unpack(LLDataPacker& dp) override;
bool operator==(const LLNetworkData& data) const override;
void copy(const LLNetworkData& data) override;
- LLSD asLLSD() const;
- operator LLSD() const { return asLLSD(); }
- bool fromLLSD(LLSD& sd);
-
+
void setMaterial(U8 te_idx, const LLUUID& id);
const LLUUID& getMaterial(U8 te_idx) const;