fix some issues with model-cache-dir
This commit is contained in:
parent
2e7630b8f9
commit
bd4d95f48b
|
|
@ -138,8 +138,12 @@ operator = (const Texture ©) {
|
|||
Namable::operator = (copy);
|
||||
_filename = copy._filename;
|
||||
_alpha_filename = copy._alpha_filename;
|
||||
_fullpath = copy._fullpath;
|
||||
_alpha_fullpath = copy._alpha_fullpath;
|
||||
if (!copy._fullpath.empty()) {
|
||||
// Since the fullpath is often empty on a file loaded directly
|
||||
// from a txo, we only assign the fullpath if it is not empty.
|
||||
_fullpath = copy._fullpath;
|
||||
_alpha_fullpath = copy._alpha_fullpath;
|
||||
}
|
||||
_primary_file_num_channels = copy._primary_file_num_channels;
|
||||
_alpha_file_channel = copy._alpha_file_channel;
|
||||
_x_size = copy._x_size;
|
||||
|
|
@ -3175,11 +3179,7 @@ make_from_bam(const FactoryParams ¶ms) {
|
|||
// and don't load from the file.
|
||||
me = new Texture(name);
|
||||
me->_filename = filename;
|
||||
me->_fullpath = filename;
|
||||
me->_fullpath.make_absolute();
|
||||
me->_alpha_filename = alpha_filename;
|
||||
me->_alpha_fullpath = alpha_filename;
|
||||
me->_alpha_fullpath.make_absolute();
|
||||
me->_primary_file_num_channels = primary_file_num_channels;
|
||||
me->_alpha_file_channel = alpha_file_channel;
|
||||
me->_texture_type = texture_type;
|
||||
|
|
@ -3395,6 +3395,11 @@ write_datagram(BamWriter *manager, Datagram &me) {
|
|||
<< "Unsupported bam-texture-mode: " << (int)file_texture_mode << "\n";
|
||||
}
|
||||
|
||||
if (filename.empty()) {
|
||||
// If we don't have a filename, we have to store rawdata anyway.
|
||||
has_rawdata = true;
|
||||
}
|
||||
|
||||
me.add_string(get_name());
|
||||
me.add_string(filename);
|
||||
me.add_string(alpha_filename);
|
||||
|
|
|
|||
|
|
@ -224,7 +224,9 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels,
|
|||
ti = _textures.find(filename);
|
||||
if (ti != _textures.end()) {
|
||||
// This texture was previously loaded.
|
||||
return (*ti).second;
|
||||
Texture *tex = (*ti).second;
|
||||
nassertr(!tex->get_fullpath().empty(), tex);
|
||||
return tex;
|
||||
}
|
||||
|
||||
PT(Texture) tex;
|
||||
|
|
@ -261,8 +263,9 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels,
|
|||
}
|
||||
|
||||
// Set the original filename, before we searched along the path.
|
||||
nassertr(tex != (Texture *)NULL, false);
|
||||
nassertr(tex != (Texture *)NULL, NULL);
|
||||
tex->set_filename(orig_filename);
|
||||
tex->set_fullpath(filename);
|
||||
tex->_texture_pool_key = filename;
|
||||
_textures[filename] = tex;
|
||||
|
||||
|
|
@ -272,6 +275,7 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels,
|
|||
cache->store(record);
|
||||
}
|
||||
|
||||
nassertr(!tex->get_fullpath().empty(), tex);
|
||||
return tex;
|
||||
}
|
||||
|
||||
|
|
@ -305,7 +309,9 @@ ns_load_texture(const Filename &orig_filename,
|
|||
ti = _textures.find(filename);
|
||||
if (ti != _textures.end()) {
|
||||
// This texture was previously loaded.
|
||||
return (*ti).second;
|
||||
Texture *tex = (*ti).second;
|
||||
nassertr(!tex->get_fullpath().empty(), tex);
|
||||
return tex;
|
||||
}
|
||||
|
||||
PT(Texture) tex;
|
||||
|
|
@ -343,9 +349,11 @@ ns_load_texture(const Filename &orig_filename,
|
|||
}
|
||||
|
||||
// Set the original filenames, before we searched along the path.
|
||||
nassertr(tex != (Texture *)NULL, false);
|
||||
nassertr(tex != (Texture *)NULL, NULL);
|
||||
tex->set_filename(orig_filename);
|
||||
tex->set_fullpath(filename);
|
||||
tex->set_alpha_filename(orig_alpha_filename);
|
||||
tex->set_alpha_fullpath(alpha_filename);
|
||||
tex->_texture_pool_key = filename;
|
||||
_textures[filename] = tex;
|
||||
|
||||
|
|
@ -355,6 +363,7 @@ ns_load_texture(const Filename &orig_filename,
|
|||
cache->store(record);
|
||||
}
|
||||
|
||||
nassertr(!tex->get_fullpath().empty(), tex);
|
||||
return tex;
|
||||
}
|
||||
|
||||
|
|
@ -417,6 +426,7 @@ ns_load_3d_texture(const Filename &filename_pattern,
|
|||
// Set the original filename, before we searched along the path.
|
||||
nassertr(tex != (Texture *)NULL, false);
|
||||
tex->set_filename(filename_pattern);
|
||||
tex->set_fullpath(filename);
|
||||
tex->_texture_pool_key = filename;
|
||||
_textures[filename] = tex;
|
||||
|
||||
|
|
@ -426,6 +436,7 @@ ns_load_3d_texture(const Filename &filename_pattern,
|
|||
cache->store(record);
|
||||
}
|
||||
|
||||
nassertr(!tex->get_fullpath().empty(), tex);
|
||||
return tex;
|
||||
}
|
||||
|
||||
|
|
@ -487,6 +498,7 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps) {
|
|||
// Set the original filename, before we searched along the path.
|
||||
nassertr(tex != (Texture *)NULL, false);
|
||||
tex->set_filename(filename_pattern);
|
||||
tex->set_fullpath(filename);
|
||||
tex->_texture_pool_key = filename;
|
||||
_textures[filename] = tex;
|
||||
|
||||
|
|
@ -496,6 +508,7 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps) {
|
|||
cache->store(record);
|
||||
}
|
||||
|
||||
nassertr(!tex->get_fullpath().empty(), tex);
|
||||
return tex;
|
||||
}
|
||||
|
||||
|
|
@ -536,6 +549,7 @@ ns_add_texture(Texture *tex) {
|
|||
// We blow away whatever texture was there previously, if any.
|
||||
tex->_texture_pool_key = filename;
|
||||
_textures[filename] = tex;
|
||||
nassertv(!tex->get_fullpath().empty());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
Loading…
Reference in New Issue