mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
Added support for bam-relative texture paths
This commit is contained in:
parent
c8e4f430aa
commit
6b82426994
@ -1455,9 +1455,14 @@ make_Texture(const FactoryParams ¶ms) {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// This texture does have a filename, so try to load it from disk.
|
// This texture does have a filename, so try to load it from disk.
|
||||||
|
VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
|
||||||
|
if (!manager->get_filename().empty())
|
||||||
|
vfs->resolve_filename(filename,manager->get_filename().get_dirname());
|
||||||
if (alpha_filename.empty()) {
|
if (alpha_filename.empty()) {
|
||||||
me = TexturePool::load_texture(filename, primary_file_num_channels);
|
me = TexturePool::load_texture(filename, primary_file_num_channels);
|
||||||
} else {
|
} else {
|
||||||
|
if (!manager->get_filename().empty())
|
||||||
|
vfs->resolve_filename(alpha_filename, manager->get_filename().get_dirname());
|
||||||
me = TexturePool::load_texture(filename, alpha_filename,
|
me = TexturePool::load_texture(filename, alpha_filename,
|
||||||
primary_file_num_channels, alpha_file_channel);
|
primary_file_num_channels, alpha_file_channel);
|
||||||
}
|
}
|
||||||
|
@ -404,7 +404,7 @@ continue_open_read(const string &bam_filename, bool report_errors) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_reader = new BamReader(&_din);
|
_reader = new BamReader(&_din, bam_filename);
|
||||||
if (!_reader->init()) {
|
if (!_reader->init()) {
|
||||||
close();
|
close();
|
||||||
return false;
|
return false;
|
||||||
|
@ -43,8 +43,8 @@ const int BamReader::_cur_minor = _bam_minor_ver;
|
|||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
BamReader::
|
BamReader::
|
||||||
BamReader(DatagramGenerator *generator)
|
BamReader(DatagramGenerator *generator, const Filename &name)
|
||||||
: _source(generator)
|
: _source(generator), _filename(name)
|
||||||
{
|
{
|
||||||
_num_extra_objects = 0;
|
_num_extra_objects = 0;
|
||||||
_now_creating = _created_objs.end();
|
_now_creating = _created_objs.end();
|
||||||
@ -169,6 +169,19 @@ get_aux_data(const string &name) const {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: BamReader::get_filename
|
||||||
|
// Access: Public
|
||||||
|
// Description: If a BAM is a file, then the BamReader should
|
||||||
|
// contain the name of the file. This enables the
|
||||||
|
// reader to interpret pathnames in the BAM as relative
|
||||||
|
// to the directory containing the BAM.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
const Filename &BamReader::
|
||||||
|
get_filename(void) const {
|
||||||
|
return _filename;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BamReader::read_object
|
// Function: BamReader::read_object
|
||||||
// Access: Public
|
// Access: Public
|
||||||
|
@ -94,14 +94,15 @@ public:
|
|||||||
static WritableFactory *const NullFactory;
|
static WritableFactory *const NullFactory;
|
||||||
|
|
||||||
// The primary interface for a caller.
|
// The primary interface for a caller.
|
||||||
BamReader(DatagramGenerator *generator);
|
BamReader(DatagramGenerator *generator, const Filename &name="");
|
||||||
~BamReader();
|
~BamReader();
|
||||||
|
|
||||||
bool init();
|
bool init();
|
||||||
|
|
||||||
void set_aux_data(const string &name, void *data);
|
void set_aux_data(const string &name, void *data);
|
||||||
void *get_aux_data(const string &name) const;
|
void *get_aux_data(const string &name) const;
|
||||||
|
const Filename &get_filename() const;
|
||||||
|
|
||||||
TypedWritable *read_object();
|
TypedWritable *read_object();
|
||||||
INLINE bool is_eof() const;
|
INLINE bool is_eof() const;
|
||||||
bool resolve();
|
bool resolve();
|
||||||
@ -142,7 +143,6 @@ public:
|
|||||||
|
|
||||||
TypeHandle read_handle(DatagramIterator &scan);
|
TypeHandle read_handle(DatagramIterator &scan);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
INLINE static WritableFactory *get_factory();
|
INLINE static WritableFactory *get_factory();
|
||||||
private:
|
private:
|
||||||
@ -172,6 +172,9 @@ private:
|
|||||||
typedef phash_map<int, TypeHandle, int_hash> IndexMap;
|
typedef phash_map<int, TypeHandle, int_hash> IndexMap;
|
||||||
IndexMap _index_map;
|
IndexMap _index_map;
|
||||||
|
|
||||||
|
// This is the filename of the BAM, or null string if not in a file.
|
||||||
|
Filename _filename;
|
||||||
|
|
||||||
// This maps the object ID numbers encountered within the Bam file
|
// This maps the object ID numbers encountered within the Bam file
|
||||||
// to the actual pointers of the corresponding generated objects.
|
// to the actual pointers of the corresponding generated objects.
|
||||||
class CreatedObj {
|
class CreatedObj {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user