summaryrefslogtreecommitdiff
path: root/indra/newview/llselectmgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llselectmgr.cpp')
-rw-r--r--indra/newview/llselectmgr.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 9cce47107a..2c1d798d4c 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -3151,6 +3151,8 @@ void LLSelectMgr::adjustTexturesByScale(bool send_to_sim, bool stretch)
F32 scale_x = 1;
F32 scale_y = 1;
+ F32 offset_x = 0;
+ F32 offset_y = 0;
for (U32 i = 0; i < LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; ++i)
{
@@ -3167,6 +3169,21 @@ void LLSelectMgr::adjustTexturesByScale(bool send_to_sim, bool stretch)
scale_y = scale_ratio.mV[t_axis] * object_scale.mV[t_axis];
}
material->mTextureTransform[i].mScale.set(scale_x, scale_y);
+
+ LLVector2 scales = selectNode->mGLTFScales[te_num][i];
+ LLVector2 offsets = selectNode->mGLTFOffsets[te_num][i];
+ F64 int_part = 0;
+ offset_x = (F32)modf((offsets[VX] + (scales[VX] - scale_x)) / 2, &int_part);
+ if (offset_x < 0)
+ {
+ offset_x++;
+ }
+ offset_y = (F32)modf((offsets[VY] + (scales[VY] - scale_y)) / 2, &int_part);
+ if (offset_y < 0)
+ {
+ offset_y++;
+ }
+ material->mTextureTransform[i].mOffset.set(offset_x, offset_y);
}
LLFetchedGLTFMaterial* render_mat = (LLFetchedGLTFMaterial*)tep->getGLTFRenderMaterial();
@@ -6906,6 +6923,8 @@ void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query)
{
mTextureScaleRatios.clear();
mGLTFScaleRatios.clear();
+ mGLTFScales.clear();
+ mGLTFOffsets.clear();
if (mObject.notNull())
{
@@ -6946,6 +6965,8 @@ void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query)
F32 scale_x = 1;
F32 scale_y = 1;
std::vector<LLVector3> material_v_vec;
+ std::vector<LLVector2> material_scales_vec;
+ std::vector<LLVector2> material_offset_vec;
for (U32 i = 0; i < LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; ++i)
{
if (material)
@@ -6953,12 +6974,16 @@ void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query)
LLGLTFMaterial::TextureTransform& transform = material->mTextureTransform[i];
scale_x = transform.mScale[VX];
scale_y = transform.mScale[VY];
+ material_scales_vec.push_back(transform.mScale);
+ material_offset_vec.push_back(transform.mOffset);
}
else
{
// Not having an override doesn't mean that there is no material
scale_x = 1;
scale_y = 1;
+ material_scales_vec.emplace_back(scale_x, scale_y);
+ material_offset_vec.emplace_back(0.f, 0.f);
}
if (tep->getTexGen() == LLTextureEntry::TEX_GEN_PLANAR)
@@ -6974,6 +6999,8 @@ void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query)
material_v_vec.push_back(material_v);
}
mGLTFScaleRatios.push_back(material_v_vec);
+ mGLTFScales.push_back(material_scales_vec);
+ mGLTFOffsets.push_back(material_offset_vec);
}
}
}