Skip to content

Commit 6403314

Browse files
committed
--revert change to user-def ptr attributes;
1 parent 0d74dc2 commit 6403314

3 files changed

Lines changed: 36 additions & 35 deletions

File tree

src/esp/assets/ResourceManager.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2360,7 +2360,7 @@ Mn::Trade::MaterialData ResourceManager::setDefaultMaterialUserAttributes(
23602360
arrayAppend(newAttributes, Cr::InPlaceInit, "hasPerVertexObjectId",
23612361
hasVertObjID);
23622362
if (hasTxtrObjID) {
2363-
arrayAppend(newAttributes, Cr::InPlaceInit, "objectIdTexture",
2363+
arrayAppend(newAttributes, Cr::InPlaceInit, "objectIdTexturePtr",
23642364
textures_.at(txtrIdx).get());
23652365
}
23662366
arrayAppend(newAttributes, Cr::InPlaceInit, "shaderTypeToUse",
@@ -2608,7 +2608,8 @@ void ResourceManager::loadMaterials(Importer& importer,
26082608
// copy texture into new attributes tagged with lowercase material
26092609
// name
26102610
auto newAttrName = Cr::Utility::formatString(
2611-
"{}{}", Cr::Utility::String::lowercase(attrName.slice(0, 1)),
2611+
"{}{}Ptr",
2612+
Cr::Utility::String::lowercase(attrName.slice(0, 1)),
26122613
attrName.slice(1, attrName.size()));
26132614
// Temporary debug message
26142615
Cr::Utility::formatInto(debugStr, debugStr.size(),
@@ -2673,7 +2674,7 @@ Mn::Trade::MaterialData ResourceManager::buildCustomAttributeFlatMaterial(
26732674
// material
26742675
if (flatMat.hasTexture()) {
26752676
arrayAppend(custAttributes,
2676-
{"ambientTexture",
2677+
{"ambientTexturePtr",
26772678
textures_.at(textureBaseIndex + flatMat.texture()).get()});
26782679
}
26792680
// Merge new attributes with those specified in original material

src/esp/gfx/GenericDrawable.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,24 @@ GenericDrawable::GenericDrawable(
4545
/* If texture transformation is specified, enable it only if the material is
4646
actually textured -- it's an error otherwise */
4747
if (materialData_->commonTextureMatrix() != Mn::Matrix3{} &&
48-
(materialData_->hasAttribute("ambientTexture") ||
49-
materialData_->hasAttribute("baseColorTexture") ||
50-
materialData_->hasAttribute("diffuseTexture") ||
51-
materialData_->hasAttribute("specularTexture") ||
52-
materialData_->hasAttribute("objectIdTexture"))) {
48+
(materialData_->hasAttribute("ambientTexturePtr") ||
49+
materialData_->hasAttribute("baseColorTexturePtr") ||
50+
materialData_->hasAttribute("diffuseTexturePtr") ||
51+
materialData_->hasAttribute("specularTexturePtr") ||
52+
materialData_->hasAttribute("objectIdTexturePtr"))) {
5353
flags_ |= Mn::Shaders::PhongGL::Flag::TextureTransformation;
5454
}
55-
if (materialData_->hasAttribute("ambientTexture")) {
55+
if (materialData_->hasAttribute("ambientTexturePtr")) {
5656
flags_ |= Mn::Shaders::PhongGL::Flag::AmbientTexture;
5757
}
58-
if (materialData_->hasAttribute("diffuseTexture")) {
58+
if (materialData_->hasAttribute("diffuseTexturePtr")) {
5959
flags_ |= Mn::Shaders::PhongGL::Flag::DiffuseTexture;
6060
}
61-
if (materialData_->hasAttribute("specularTexture")) {
61+
if (materialData_->hasAttribute("specularTexturePtr")) {
6262
flags_ |= Mn::Shaders::PhongGL::Flag::SpecularTexture;
6363
}
6464

65-
if (materialData_->hasAttribute("normalTexture")) {
65+
if (materialData_->hasAttribute("normalTexturePtr")) {
6666
if (meshAttributeFlags & Drawable::Flag::HasTangent) {
6767
flags_ |= Mn::Shaders::PhongGL::Flag::NormalTexture;
6868
if (meshAttributeFlags & Drawable::Flag::HasSeparateBitangent) {
@@ -76,7 +76,7 @@ GenericDrawable::GenericDrawable(
7676
if (materialData_->attribute<bool>("hasPerVertexObjectId")) {
7777
flags_ |= Mn::Shaders::PhongGL::Flag::InstancedObjectId;
7878
}
79-
if (materialData_->hasAttribute("objectIdTexture")) {
79+
if (materialData_->hasAttribute("objectIdTexturePtr")) {
8080
flags_ |= Mn::Shaders::PhongGL::Flag::ObjectIdTexture;
8181
}
8282
if (meshAttributeFlags & Drawable::Flag::HasVertexColor) {
@@ -184,23 +184,23 @@ void GenericDrawable::draw(const Mn::Matrix4& transformationMatrix,
184184

185185
if (flags_ & Mn::Shaders::PhongGL::Flag::AmbientTexture) {
186186
shader_->bindAmbientTexture(
187-
*(materialData_->attribute<Mn::GL::Texture2D*>("ambientTexture")));
187+
*(materialData_->attribute<Mn::GL::Texture2D*>("ambientTexturePtr")));
188188
}
189189
if (flags_ & Mn::Shaders::PhongGL::Flag::DiffuseTexture) {
190190
shader_->bindDiffuseTexture(
191-
*(materialData_->attribute<Mn::GL::Texture2D*>("diffuseTexture")));
191+
*(materialData_->attribute<Mn::GL::Texture2D*>("diffuseTexturePtr")));
192192
}
193193
if (flags_ & Mn::Shaders::PhongGL::Flag::SpecularTexture) {
194194
shader_->bindSpecularTexture(
195-
*(materialData_->attribute<Mn::GL::Texture2D*>("specularTexture")));
195+
*(materialData_->attribute<Mn::GL::Texture2D*>("specularTexturePtr")));
196196
}
197197
if (flags_ & Mn::Shaders::PhongGL::Flag::NormalTexture) {
198198
shader_->bindNormalTexture(
199-
*(materialData_->attribute<Mn::GL::Texture2D*>("normalTexture")));
199+
*(materialData_->attribute<Mn::GL::Texture2D*>("normalTexturePtr")));
200200
}
201201
if (flags_ >= Mn::Shaders::PhongGL::Flag::ObjectIdTexture) {
202202
shader_->bindObjectIdTexture(
203-
*(materialData_->attribute<Mn::GL::Texture2D*>("objectIdTexture")));
203+
*(materialData_->attribute<Mn::GL::Texture2D*>("objectIdTexturePtr")));
204204
}
205205

206206
if (skinData_) {

src/esp/gfx/PbrDrawable.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ PbrDrawable::PbrDrawable(scene::SceneNode& node,
3030
materialData_{
3131
shaderManager.get<Mn::Trade::MaterialData>(materialDataKey)},
3232
pbrIbl_(pbrIbl) {
33-
if (materialData_->hasAttribute("metallicTexture") &&
34-
materialData_->hasAttribute("roughnessTexture")) {
33+
if (materialData_->hasAttribute("metallicTexturePtr") &&
34+
materialData_->hasAttribute("roughnessTexturePtr")) {
3535
CORRADE_ASSERT(
36-
materialData_->attribute<Mn::GL::Texture2D*>("metallicTexture") ==
37-
materialData_->attribute<Mn::GL::Texture2D*>("roughnessTexture"),
36+
materialData_->attribute<Mn::GL::Texture2D*>("metallicTexturePtr") ==
37+
materialData_->attribute<Mn::GL::Texture2D*>("roughnessTexturePtr"),
3838
"PbrDrawable::PbrDrawable(): if both the metallic and roughness "
3939
"texture exist, they must be packed in the same texture based on glTF "
4040
"2.0 Spec.", );
@@ -46,16 +46,16 @@ PbrDrawable::PbrDrawable(scene::SceneNode& node,
4646
if (tmpMaterialData.commonTextureMatrix() != Mn::Matrix3{}) {
4747
flags_ |= PbrShader::Flag::TextureTransformation;
4848
}
49-
if (materialData_->hasAttribute("baseColorTexture")) {
49+
if (materialData_->hasAttribute("baseColorTexturePtr")) {
5050
flags_ |= PbrShader::Flag::BaseColorTexture;
5151
}
52-
if (materialData_->hasAttribute("roughnessTexture")) {
52+
if (materialData_->hasAttribute("roughnessTexturePtr")) {
5353
flags_ |= PbrShader::Flag::RoughnessTexture;
5454
}
55-
if (materialData_->hasAttribute("metallicTexture")) {
55+
if (materialData_->hasAttribute("metallicTexturePtr")) {
5656
flags_ |= PbrShader::Flag::MetallicTexture;
5757
}
58-
if (materialData_->hasAttribute("normalTexture")) {
58+
if (materialData_->hasAttribute("normalTexturePtr")) {
5959
flags_ |= PbrShader::Flag::NormalTexture;
6060
if (meshAttributeFlags & gfx::Drawable::Flag::HasTangent) {
6161
flags_ |= PbrShader::Flag::PrecomputedTangent;
@@ -67,7 +67,7 @@ PbrDrawable::PbrDrawable(scene::SceneNode& node,
6767
"must be positive.", );
6868
}
6969
}
70-
if (materialData_->hasAttribute("emissiveTexture")) {
70+
if (materialData_->hasAttribute("emissiveTexturePtr")) {
7171
flags_ |= PbrShader::Flag::EmissiveTexture;
7272
}
7373
if (materialData_->attribute<bool>("hasPerVertexObjectId")) {
@@ -165,19 +165,19 @@ void PbrDrawable::draw(const Mn::Matrix4& transformationMatrix,
165165
// just in case user would like to do so during the run-time.
166166

167167
if ((flags_ & PbrShader::Flag::BaseColorTexture) &&
168-
(materialData_->attribute<Mn::GL::Texture2D*>("baseColorTexture") !=
168+
(materialData_->attribute<Mn::GL::Texture2D*>("baseColorTexturePtr") !=
169169
nullptr)) {
170170
shader_->bindBaseColorTexture(
171-
*materialData_->attribute<Mn::GL::Texture2D*>("baseColorTexture"));
171+
*materialData_->attribute<Mn::GL::Texture2D*>("baseColorTexturePtr"));
172172
}
173173

174174
if (flags_ &
175175
(PbrShader::Flag::RoughnessTexture | PbrShader::Flag::MetallicTexture)) {
176176
Mn::GL::Texture2D* metallicRoughnessTexture =
177-
materialData_->attribute<Mn::GL::Texture2D*>("roughnessTexture");
177+
materialData_->attribute<Mn::GL::Texture2D*>("roughnessTexturePtr");
178178
if (!metallicRoughnessTexture) {
179179
metallicRoughnessTexture =
180-
materialData_->attribute<Mn::GL::Texture2D*>("metallicTexture");
180+
materialData_->attribute<Mn::GL::Texture2D*>("metallicTexturePtr");
181181
}
182182
CORRADE_ASSERT(metallicRoughnessTexture,
183183
"PbrDrawable::draw(): texture pointer cannot be nullptr if "
@@ -186,17 +186,17 @@ void PbrDrawable::draw(const Mn::Matrix4& transformationMatrix,
186186
}
187187

188188
if ((flags_ & PbrShader::Flag::NormalTexture) &&
189-
(materialData_->attribute<Mn::GL::Texture2D*>("normalTexture") !=
189+
(materialData_->attribute<Mn::GL::Texture2D*>("normalTexturePtr") !=
190190
nullptr)) {
191191
shader_->bindNormalTexture(
192-
*materialData_->attribute<Mn::GL::Texture2D*>("normalTexture"));
192+
*materialData_->attribute<Mn::GL::Texture2D*>("normalTexturePtr"));
193193
}
194194

195195
if ((flags_ & PbrShader::Flag::EmissiveTexture) &&
196-
(materialData_->attribute<Mn::GL::Texture2D*>("emissiveTexture") !=
196+
(materialData_->attribute<Mn::GL::Texture2D*>("emissiveTexturePtr") !=
197197
nullptr)) {
198198
shader_->bindEmissiveTexture(
199-
*materialData_->attribute<Mn::GL::Texture2D*>("emissiveTexture"));
199+
*materialData_->attribute<Mn::GL::Texture2D*>("emissiveTexturePtr"));
200200
}
201201

202202
if ((flags_ & PbrShader::Flag::TextureTransformation) &&

0 commit comments

Comments
 (0)