mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
*** empty log message ***
This commit is contained in:
parent
548cb7767e
commit
c2eed48e87
@ -145,6 +145,16 @@ append_directory(const Filename &directory) {
|
|||||||
_directories.push_back(directory);
|
_directories.push_back(directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: DSearchPath::prepend_directory
|
||||||
|
// Access: Public
|
||||||
|
// Description: Adds a new directory to the front of the search list.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void DSearchPath::
|
||||||
|
prepend_directory(const Filename &directory) {
|
||||||
|
_directories.insert(_directories.begin(), directory);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DSearchPath::append_path
|
// Function: DSearchPath::append_path
|
||||||
// Access: Public
|
// Access: Public
|
||||||
|
@ -49,6 +49,7 @@ PUBLISHED:
|
|||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
void append_directory(const Filename &directory);
|
void append_directory(const Filename &directory);
|
||||||
|
void prepend_directory(const Filename &directory);
|
||||||
void append_path(const string &path,
|
void append_path(const string &path,
|
||||||
const string &delimiters = ": \t\n");
|
const string &delimiters = ": \t\n");
|
||||||
|
|
||||||
|
@ -290,6 +290,7 @@ copy_binary_file(Filename source, Filename dest) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dest.unlink();
|
||||||
if (!dest.open_write(out)) {
|
if (!dest.open_write(out)) {
|
||||||
nout << "Cannot write " << dest << "\n";
|
nout << "Cannot write " << dest << "\n";
|
||||||
return false;
|
return false;
|
||||||
@ -310,7 +311,7 @@ copy_binary_file(Filename source, Filename dest) {
|
|||||||
nout << "Error writing " << dest << "\n";
|
nout << "Error writing " << dest << "\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "fltExternalReference.h"
|
#include "fltExternalReference.h"
|
||||||
#include "fltRecordReader.h"
|
#include "fltRecordReader.h"
|
||||||
#include "fltRecordWriter.h"
|
#include "fltRecordWriter.h"
|
||||||
|
#include "fltHeader.h"
|
||||||
|
|
||||||
TypeHandle FltExternalReference::_type_handle;
|
TypeHandle FltExternalReference::_type_handle;
|
||||||
|
|
||||||
@ -35,6 +36,21 @@ output(ostream &out) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FltTexture::get_ref_filename
|
||||||
|
// Access: Public
|
||||||
|
// Description: Returns the name of the referenced file. If it
|
||||||
|
// appears to be a relative filename, it will be
|
||||||
|
// converted to the correct full pathname according to
|
||||||
|
// the model_path specified in the header.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
Filename FltExternalReference::
|
||||||
|
get_ref_filename() const {
|
||||||
|
Filename file(_filename);
|
||||||
|
file.resolve_filename(_header->get_model_path());
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: FltExternalReference::extract_record
|
// Function: FltExternalReference::extract_record
|
||||||
// Access: Protected, Virtual
|
// Access: Protected, Virtual
|
||||||
|
@ -36,6 +36,8 @@ public:
|
|||||||
string _bead_id;
|
string _bead_id;
|
||||||
int _flags;
|
int _flags;
|
||||||
|
|
||||||
|
Filename get_ref_filename() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool extract_record(FltRecordReader &reader);
|
virtual bool extract_record(FltRecordReader &reader);
|
||||||
virtual bool build_record(FltRecordWriter &writer) const;
|
virtual bool build_record(FltRecordWriter &writer) const;
|
||||||
|
@ -83,11 +83,12 @@ read_flt(Filename filename) {
|
|||||||
return FE_could_not_open;
|
return FE_could_not_open;
|
||||||
}
|
}
|
||||||
|
|
||||||
// By default, the filename's directory is added to the texture
|
// By default, the filename's directory is added to the texture and
|
||||||
// search path.
|
// model search path.
|
||||||
string dirname = filename.get_dirname();
|
string dirname = filename.get_dirname();
|
||||||
if (!dirname.empty()) {
|
if (!dirname.empty()) {
|
||||||
_texture_path.append_directory(dirname);
|
_texture_path.prepend_directory(dirname);
|
||||||
|
_model_path.prepend_directory(dirname);
|
||||||
}
|
}
|
||||||
|
|
||||||
return read_flt(in);
|
return read_flt(in);
|
||||||
@ -847,6 +848,40 @@ get_texture_path() const {
|
|||||||
return _texture_path;
|
return _texture_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FltHeader::set_model_path
|
||||||
|
// Access: Public
|
||||||
|
// Description: Sets the search path that relative external
|
||||||
|
// references will be looked for along.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void FltHeader::
|
||||||
|
set_model_path(const DSearchPath &path) {
|
||||||
|
_model_path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FltHeader::update_model_path
|
||||||
|
// Access: Public
|
||||||
|
// Description: Returns a non-const reference to the model search
|
||||||
|
// path, so that it may be appended to or otherwise
|
||||||
|
// modified.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
DSearchPath &FltHeader::
|
||||||
|
update_model_path() {
|
||||||
|
return _model_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FltHeader::get_model_path
|
||||||
|
// Access: Public
|
||||||
|
// Description: Returns the search path for looking up external
|
||||||
|
// references.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
const DSearchPath &FltHeader::
|
||||||
|
get_model_path() const {
|
||||||
|
return _model_path;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: FltHeader::has_light_source
|
// Function: FltHeader::has_light_source
|
||||||
// Access: Public
|
// Access: Public
|
||||||
|
@ -182,12 +182,17 @@ public:
|
|||||||
void add_texture(FltTexture *texture);
|
void add_texture(FltTexture *texture);
|
||||||
void remove_texture(int texture_index);
|
void remove_texture(int texture_index);
|
||||||
|
|
||||||
// Sometimes Flt files store textures as relative pathnames.
|
// Sometimes Flt files store textures and external references as
|
||||||
// Setting this search path helps resolve that tendency.
|
// relative pathnames. Setting these search paths helps resolve
|
||||||
|
// that tendency.
|
||||||
void set_texture_path(const DSearchPath &path);
|
void set_texture_path(const DSearchPath &path);
|
||||||
DSearchPath &update_texture_path();
|
DSearchPath &update_texture_path();
|
||||||
const DSearchPath &get_texture_path() const;
|
const DSearchPath &get_texture_path() const;
|
||||||
|
|
||||||
|
void set_model_path(const DSearchPath &path);
|
||||||
|
DSearchPath &update_model_path();
|
||||||
|
const DSearchPath &get_model_path() const;
|
||||||
|
|
||||||
|
|
||||||
// Accessors into the light source palette.
|
// Accessors into the light source palette.
|
||||||
bool has_light_source(int light_index) const;
|
bool has_light_source(int light_index) const;
|
||||||
@ -207,6 +212,9 @@ public:
|
|||||||
FltTrackplane *get_trackplane(int n);
|
FltTrackplane *get_trackplane(int n);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
DSearchPath _texture_path;
|
||||||
|
DSearchPath _model_path;
|
||||||
|
|
||||||
// Instance subtrees. These are standalone subtrees, which may be
|
// Instance subtrees. These are standalone subtrees, which may be
|
||||||
// referenced by various points in the hierarchy, stored by instance
|
// referenced by various points in the hierarchy, stored by instance
|
||||||
// ID number.
|
// ID number.
|
||||||
@ -252,7 +260,6 @@ private:
|
|||||||
AttrUpdate _auto_attr_update;
|
AttrUpdate _auto_attr_update;
|
||||||
typedef map<int, PT(FltTexture)> Textures;
|
typedef map<int, PT(FltTexture)> Textures;
|
||||||
Textures _textures;
|
Textures _textures;
|
||||||
DSearchPath _texture_path;
|
|
||||||
|
|
||||||
|
|
||||||
// Support for the light source palette.
|
// Support for the light source palette.
|
||||||
|
@ -50,9 +50,6 @@ FltCopy() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void FltCopy::
|
void FltCopy::
|
||||||
run() {
|
run() {
|
||||||
if (_search_path.get_num_directories() == 0) {
|
|
||||||
_search_path.append_directory(".");
|
|
||||||
}
|
|
||||||
SourceFiles::iterator fi;
|
SourceFiles::iterator fi;
|
||||||
for (fi = _source_files.begin(); fi != _source_files.end(); ++fi) {
|
for (fi = _source_files.begin(); fi != _source_files.end(); ++fi) {
|
||||||
ExtraData ed;
|
ExtraData ed;
|
||||||
@ -99,6 +96,7 @@ copy_flt_file(const Filename &source, const Filename &dest,
|
|||||||
CVSSourceDirectory *dir) {
|
CVSSourceDirectory *dir) {
|
||||||
PT(FltHeader) header = new FltHeader;
|
PT(FltHeader) header = new FltHeader;
|
||||||
header->set_texture_path(_search_path);
|
header->set_texture_path(_search_path);
|
||||||
|
header->set_model_path(_search_path);
|
||||||
|
|
||||||
// We don't want to automatically generate .attr files--we'd rather
|
// We don't want to automatically generate .attr files--we'd rather
|
||||||
// write them out explicitly.
|
// write them out explicitly.
|
||||||
@ -118,8 +116,7 @@ copy_flt_file(const Filename &source, const Filename &dest,
|
|||||||
Refs::const_iterator ri;
|
Refs::const_iterator ri;
|
||||||
for (ri = refs.begin(); ri != refs.end(); ++ri) {
|
for (ri = refs.begin(); ri != refs.end(); ++ri) {
|
||||||
FltExternalReference *ref = (*ri);
|
FltExternalReference *ref = (*ri);
|
||||||
Filename ref_filename = ref->_filename;
|
Filename ref_filename = ref->get_ref_filename();
|
||||||
ref_filename.resolve_filename(_search_path);
|
|
||||||
|
|
||||||
if (!ref_filename.exists()) {
|
if (!ref_filename.exists()) {
|
||||||
nout << "*** Warning: external reference " << ref_filename
|
nout << "*** Warning: external reference " << ref_filename
|
||||||
|
Loading…
x
Reference in New Issue
Block a user