mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
preserve case of texture filenames
This commit is contained in:
parent
ee7f0dceb2
commit
4f99add87e
@ -896,15 +896,25 @@ get_default_group() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
TextureImage *Palettizer::
|
TextureImage *Palettizer::
|
||||||
get_texture(const string &name) {
|
get_texture(const string &name) {
|
||||||
|
// Look first in the same-case name, just in case it happens to be
|
||||||
|
// there (from an older version of egg-palettize that did this).
|
||||||
Textures::iterator ti = _textures.find(name);
|
Textures::iterator ti = _textures.find(name);
|
||||||
if (ti != _textures.end()) {
|
if (ti != _textures.end()) {
|
||||||
return (*ti).second;
|
return (*ti).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Then look in the downcase name, since we nowadays index textures
|
||||||
|
// only by their downcase names (to implement case insensitivity).
|
||||||
|
string downcase_name = downcase(name);
|
||||||
|
ti = _textures.find(downcase_name);
|
||||||
|
if (ti != _textures.end()) {
|
||||||
|
return (*ti).second;
|
||||||
|
}
|
||||||
|
|
||||||
TextureImage *image = new TextureImage;
|
TextureImage *image = new TextureImage;
|
||||||
image->set_name(name);
|
image->set_name(name);
|
||||||
// image->set_filename(name);
|
// image->set_filename(name);
|
||||||
_textures.insert(Textures::value_type(name, image));
|
_textures.insert(Textures::value_type(downcase_name, image));
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
@ -1120,9 +1130,9 @@ finalize(BamReader *manager) {
|
|||||||
ci != _texture_conflicts.end();
|
ci != _texture_conflicts.end();
|
||||||
++ci) {
|
++ci) {
|
||||||
TextureImage *texture_b = (*ci);
|
TextureImage *texture_b = (*ci);
|
||||||
string name = downcase(texture_b->get_name());
|
string downcase_name = downcase(texture_b->get_name());
|
||||||
|
|
||||||
Textures::iterator ti = _textures.find(name);
|
Textures::iterator ti = _textures.find(downcase_name);
|
||||||
nassertv(ti != _textures.end());
|
nassertv(ti != _textures.end());
|
||||||
TextureImage *texture_a = (*ti).second;
|
TextureImage *texture_a = (*ti).second;
|
||||||
_textures.erase(ti);
|
_textures.erase(ti);
|
||||||
@ -1131,11 +1141,11 @@ finalize(BamReader *manager) {
|
|||||||
// If either texture is not used, there's not really a
|
// If either texture is not used, there's not really a
|
||||||
// conflict--the other one wins.
|
// conflict--the other one wins.
|
||||||
if (texture_a->is_used()) {
|
if (texture_a->is_used()) {
|
||||||
bool inserted1 = _textures.insert(Textures::value_type(texture_a->get_name(), texture_a)).second;
|
bool inserted1 = _textures.insert(Textures::value_type(downcase_name, texture_a)).second;
|
||||||
nassertd(inserted1) { }
|
nassertd(inserted1) { }
|
||||||
|
|
||||||
} else if (texture_b->is_used()) {
|
} else if (texture_b->is_used()) {
|
||||||
bool inserted2 = _textures.insert(Textures::value_type(texture_b->get_name(), texture_b)).second;
|
bool inserted2 = _textures.insert(Textures::value_type(downcase_name, texture_b)).second;
|
||||||
nassertd(inserted2) { }
|
nassertd(inserted2) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1143,9 +1153,19 @@ finalize(BamReader *manager) {
|
|||||||
// If both textures are used, there *is* a conflict.
|
// If both textures are used, there *is* a conflict.
|
||||||
nout << "Texture name conflict: \"" << texture_a->get_name()
|
nout << "Texture name conflict: \"" << texture_a->get_name()
|
||||||
<< "\" vs. \"" << texture_b->get_name() << "\"\n";
|
<< "\" vs. \"" << texture_b->get_name() << "\"\n";
|
||||||
bool inserted1 = _textures.insert(Textures::value_type(texture_a->get_name(), texture_a)).second;
|
if (texture_a->get_name() != downcase_name &&
|
||||||
bool inserted2 = _textures.insert(Textures::value_type(texture_b->get_name(), texture_b)).second;
|
texture_b->get_name() != downcase_name) {
|
||||||
nassertd(inserted1 && inserted2) { }
|
// Arbitrarily pick texture_a to get the right case.
|
||||||
|
bool inserted1 = _textures.insert(Textures::value_type(downcase_name, texture_a)).second;
|
||||||
|
bool inserted2 = _textures.insert(Textures::value_type(texture_b->get_name(), texture_b)).second;
|
||||||
|
nassertd(inserted1 && inserted2) { }
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// One of them is already the right case.
|
||||||
|
bool inserted1 = _textures.insert(Textures::value_type(texture_a->get_name(), texture_a)).second;
|
||||||
|
bool inserted2 = _textures.insert(Textures::value_type(texture_b->get_name(), texture_b)).second;
|
||||||
|
nassertd(inserted1 && inserted2) { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,8 +108,18 @@ from_egg(EggFile *egg_file, EggData *data, EggTexture *egg_tex) {
|
|||||||
_properties._magfilter = _egg_tex->get_magfilter();
|
_properties._magfilter = _egg_tex->get_magfilter();
|
||||||
_properties._anisotropic_degree = _egg_tex->get_anisotropic_degree();
|
_properties._anisotropic_degree = _egg_tex->get_anisotropic_degree();
|
||||||
|
|
||||||
string name = downcase(filename.get_basename_wo_extension());
|
string name = filename.get_basename_wo_extension();
|
||||||
TextureImage *texture = pal->get_texture(name);
|
TextureImage *texture = pal->get_texture(name);
|
||||||
|
if (texture->get_name() != name) {
|
||||||
|
nout << "Texture name conflict: \"" << name
|
||||||
|
<< "\" conflicts with existing texture named \""
|
||||||
|
<< texture->get_name() << "\".\n";
|
||||||
|
|
||||||
|
// Make this a hard error; refuse to do anything else until the
|
||||||
|
// user fixes it. Case conflicts can be very bad, especially if
|
||||||
|
// CVS is involved on a Windows machine.
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
_source_texture = texture->get_source(filename, alpha_filename,
|
_source_texture = texture->get_source(filename, alpha_filename,
|
||||||
alpha_file_channel);
|
alpha_file_channel);
|
||||||
_source_texture->update_properties(_properties);
|
_source_texture->update_properties(_properties);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user