viewer#1299 PBR texture stretches when "stretch textures" is unchecked
parent
89c1767bd3
commit
21f40280ec
|
|
@ -3058,7 +3058,7 @@ void LLSelectMgr::adjustTexturesByScale(bool send_to_sim, bool stretch)
|
|||
|
||||
for (U8 te_num = 0; te_num < object->getNumTEs(); te_num++)
|
||||
{
|
||||
const LLTextureEntry* tep = object->getTE(te_num);
|
||||
LLTextureEntry* tep = object->getTE(te_num);
|
||||
|
||||
bool planar = tep->getTexGen() == LLTextureEntry::TEX_GEN_PLANAR;
|
||||
if (planar == stretch)
|
||||
|
|
@ -3092,8 +3092,6 @@ void LLSelectMgr::adjustTexturesByScale(bool send_to_sim, bool stretch)
|
|||
|
||||
object->setTEScale(te_num, diffuse_scale_s, diffuse_scale_t);
|
||||
|
||||
LLTextureEntry* tep = object->getTE(te_num);
|
||||
|
||||
if (tep && !tep->getMaterialParams().isNull())
|
||||
{
|
||||
LLMaterialPtr orig = tep->getMaterialParams();
|
||||
|
|
@ -3131,6 +3129,47 @@ void LLSelectMgr::adjustTexturesByScale(bool send_to_sim, bool stretch)
|
|||
LLMaterialMgr::getInstance()->put(object->getID(), te_num, *p);
|
||||
}
|
||||
}
|
||||
|
||||
if (tep->getGLTFMaterial())
|
||||
{
|
||||
LLPointer<LLGLTFMaterial> material = tep->getGLTFMaterialOverride();
|
||||
if (!material)
|
||||
{
|
||||
material = new LLGLTFMaterial();
|
||||
tep->setGLTFMaterialOverride(material);
|
||||
}
|
||||
|
||||
F32 scale_x = 1;
|
||||
F32 scale_y = 1;
|
||||
|
||||
for (U32 i = 0; i < LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; ++i)
|
||||
{
|
||||
LLVector3 scale_ratio = selectNode->mGLTFScaleRatios[te_num][i];
|
||||
|
||||
if (planar)
|
||||
{
|
||||
scale_x = scale_ratio.mV[s_axis] / object_scale.mV[s_axis];
|
||||
scale_y = scale_ratio.mV[t_axis] / object_scale.mV[t_axis];
|
||||
}
|
||||
else
|
||||
{
|
||||
scale_x = scale_ratio.mV[s_axis] * object_scale.mV[s_axis];
|
||||
scale_y = scale_ratio.mV[t_axis] * object_scale.mV[t_axis];
|
||||
}
|
||||
material->mTextureTransform[i].mScale.set(scale_x, scale_y);
|
||||
}
|
||||
|
||||
LLFetchedGLTFMaterial* render_mat = (LLFetchedGLTFMaterial*)tep->getGLTFRenderMaterial();
|
||||
if (render_mat)
|
||||
{
|
||||
render_mat->applyOverride(*material);
|
||||
}
|
||||
|
||||
if (send_to_sim)
|
||||
{
|
||||
LLGLTFMaterialList::queueModify(object, te_num, material);
|
||||
}
|
||||
}
|
||||
send = send_to_sim;
|
||||
}
|
||||
}
|
||||
|
|
@ -6854,6 +6893,7 @@ void LLSelectNode::saveGLTFMaterials(const uuid_vec_t& materials, const gltf_mat
|
|||
void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query)
|
||||
{
|
||||
mTextureScaleRatios.clear();
|
||||
mGLTFScaleRatios.clear();
|
||||
|
||||
if (mObject.notNull())
|
||||
{
|
||||
|
|
@ -6888,6 +6928,40 @@ void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query)
|
|||
v.mV[t_axis] = diffuse_t/scale.mV[t_axis];
|
||||
mTextureScaleRatios.push_back(v);
|
||||
}
|
||||
|
||||
LLGLTFMaterial* material = tep->getGLTFMaterialOverride();
|
||||
LLVector3 material_v;
|
||||
F32 scale_x = 1;
|
||||
F32 scale_y = 1;
|
||||
std::vector<LLVector3> material_v_vec;
|
||||
for (U32 i = 0; i < LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; ++i)
|
||||
{
|
||||
if (material)
|
||||
{
|
||||
LLGLTFMaterial::TextureTransform& transform = material->mTextureTransform[i];
|
||||
scale_x = transform.mScale[VX];
|
||||
scale_y = transform.mScale[VY];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not having an override doesn't mean that there is no material
|
||||
scale_x = 1;
|
||||
scale_y = 1;
|
||||
}
|
||||
|
||||
if (tep->getTexGen() == LLTextureEntry::TEX_GEN_PLANAR)
|
||||
{
|
||||
material_v.mV[s_axis] = scale_x * scale.mV[s_axis];
|
||||
material_v.mV[t_axis] = scale_y * scale.mV[t_axis];
|
||||
}
|
||||
else
|
||||
{
|
||||
material_v.mV[s_axis] = scale_x / scale.mV[s_axis];
|
||||
material_v.mV[t_axis] = scale_y / scale.mV[t_axis];
|
||||
}
|
||||
material_v_vec.push_back(material_v);
|
||||
}
|
||||
mGLTFScaleRatios.push_back(material_v_vec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -239,6 +239,7 @@ public:
|
|||
uuid_vec_t mSavedGLTFMaterialIds;
|
||||
gltf_materials_vec_t mSavedGLTFOverrideMaterials;
|
||||
std::vector<LLVector3> mTextureScaleRatios;
|
||||
std::vector< std::vector<LLVector3> > mGLTFScaleRatios;
|
||||
std::vector<LLVector3> mSilhouetteVertices; // array of vertices to render silhouette of object
|
||||
std::vector<LLVector3> mSilhouetteNormals; // array of normals to render silhouette of object
|
||||
bool mSilhouetteExists; // need to generate silhouette?
|
||||
|
|
|
|||
Loading…
Reference in New Issue