mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-18 12:43:44 -04:00
aggressively clear directory texture name
This commit is contained in:
parent
c292cfc628
commit
17164ac827
@ -158,7 +158,7 @@ bool MayaShaderColorDef::
|
|||||||
reset_maya_texture(const Filename &texture) {
|
reset_maya_texture(const Filename &texture) {
|
||||||
if (_color_object != (MObject *)NULL) {
|
if (_color_object != (MObject *)NULL) {
|
||||||
_has_texture = set_string_attribute(*_color_object, "fileTextureName",
|
_has_texture = set_string_attribute(*_color_object, "fileTextureName",
|
||||||
texture);
|
texture.to_os_generic());
|
||||||
_texture = texture;
|
_texture = texture;
|
||||||
|
|
||||||
if (!_has_texture) {
|
if (!_has_texture) {
|
||||||
@ -198,14 +198,16 @@ read_surface_color(const MayaShader *shader, MObject color) {
|
|||||||
_color_object = new MObject(color);
|
_color_object = new MObject(color);
|
||||||
string filename;
|
string filename;
|
||||||
_has_texture = get_string_attribute(color, "fileTextureName", filename);
|
_has_texture = get_string_attribute(color, "fileTextureName", filename);
|
||||||
|
_has_texture = _has_texture && !filename.empty();
|
||||||
if (_has_texture) {
|
if (_has_texture) {
|
||||||
_texture = Filename::from_os_specific(filename);
|
_texture = Filename::from_os_specific(filename);
|
||||||
if (_texture.is_directory()) {
|
if (_texture.is_directory()) {
|
||||||
maya_cat.warning()
|
maya_cat.warning()
|
||||||
<< "Shader " << shader->get_name()
|
<< "Shader " << shader->get_name()
|
||||||
<< " references texture filename " << filename
|
<< " references texture filename " << filename
|
||||||
<< " which is a directory; ignoring.\n";
|
<< " which is a directory; clearing.\n";
|
||||||
_has_texture = false;
|
_has_texture = false;
|
||||||
|
set_string_attribute(color, "fileTextureName", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,6 +103,58 @@ has_attribute(MObject &node, const string &attribute_name) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: remove_attribute
|
||||||
|
// Description: Removes the named attribute from the indicated Maya
|
||||||
|
// node. Returns true if successful, false otherwise.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool
|
||||||
|
remove_attribute(MObject &node, const string &attribute_name) {
|
||||||
|
MStatus status;
|
||||||
|
MFnDependencyNode node_fn(node, &status);
|
||||||
|
if (!status) {
|
||||||
|
maya_cat.error()
|
||||||
|
<< "Object is a " << node.apiTypeStr() << ", not a DependencyNode.\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MObject attr = node_fn.attribute(attribute_name.c_str(), &status);
|
||||||
|
if (!status) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Just to prove the the attr is, in fact, an Attribute.
|
||||||
|
// According to the Maya docs, we shouldn't leave the MFnAttribute
|
||||||
|
// object around while we remove the attribute, though.
|
||||||
|
MFnAttribute attr_fn(attr, &status);
|
||||||
|
if (!status) {
|
||||||
|
maya_cat.error()
|
||||||
|
<< "Attribute " << attribute_name << " on " << node_fn.name()
|
||||||
|
<< " is a " << attr.apiTypeStr() << ", not an Attribute.\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MFnDependencyNode::MAttrClass type = node_fn.attributeClass(attr, &status);
|
||||||
|
if (!status) {
|
||||||
|
maya_cat.error()
|
||||||
|
<< "Couldn't get class of attribute " << attribute_name << " on "
|
||||||
|
<< node_fn.name() << ".\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = node_fn.removeAttribute(attr, type);
|
||||||
|
if (!status) {
|
||||||
|
maya_cat.error()
|
||||||
|
<< "Couldn't remove attribute " << attribute_name << " from "
|
||||||
|
<< node_fn.name() << ".\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: get_bool_attribute
|
// Function: get_bool_attribute
|
||||||
// Description: Extracts the named boolean attribute from the
|
// Description: Extracts the named boolean attribute from the
|
||||||
|
@ -54,6 +54,9 @@ set_maya_attribute(MObject &node, const string &attribute_name,
|
|||||||
bool
|
bool
|
||||||
has_attribute(MObject &node, const string &attribute_name);
|
has_attribute(MObject &node, const string &attribute_name);
|
||||||
|
|
||||||
|
bool
|
||||||
|
remove_attribute(MObject &node, const string &attribute_name);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
get_bool_attribute(MObject &node, const string &attribute_name,
|
get_bool_attribute(MObject &node, const string &attribute_name,
|
||||||
bool &value);
|
bool &value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user