mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 08:44:19 -04:00
*** empty log message ***
This commit is contained in:
parent
8c7787003f
commit
858b3700c0
@ -25,7 +25,7 @@
|
||||
// time when we can't be sure what has or hasn't been
|
||||
// already initialized.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
const DSearchPath &
|
||||
DSearchPath &
|
||||
get_config_path(const string &config_var_name, DSearchPath *&static_ptr) {
|
||||
if (static_ptr == (DSearchPath *)NULL) {
|
||||
static_ptr = new DSearchPath;
|
||||
|
@ -28,7 +28,7 @@
|
||||
// time when we can't be sure what has or hasn't been
|
||||
// already initialized.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
EXPCL_PANDAEXPRESS const DSearchPath &
|
||||
EXPCL_PANDAEXPRESS DSearchPath &
|
||||
get_config_path(const string &config_var_name, DSearchPath *&static_ptr);
|
||||
|
||||
#endif
|
||||
|
@ -57,19 +57,19 @@ ConfigureFn(config_util) {
|
||||
|
||||
//const bool track_memory_usage = config_util.GetBool("track-memory-usage", false);
|
||||
|
||||
const DSearchPath &
|
||||
DSearchPath &
|
||||
get_model_path() {
|
||||
static DSearchPath *model_path = NULL;
|
||||
return get_config_path("model-path", model_path);
|
||||
}
|
||||
|
||||
const DSearchPath &
|
||||
DSearchPath &
|
||||
get_texture_path() {
|
||||
static DSearchPath *texture_path = NULL;
|
||||
return get_config_path("texture-path", texture_path);
|
||||
}
|
||||
|
||||
const DSearchPath &
|
||||
DSearchPath &
|
||||
get_sound_path() {
|
||||
static DSearchPath *sound_path = NULL;
|
||||
return get_config_path("sound-path", sound_path);
|
||||
|
@ -26,8 +26,8 @@ NotifyCategoryDecl(util, EXPCL_PANDA, EXPTP_PANDA);
|
||||
// computed based on the concatenation of all appearances of the
|
||||
// corresponding variable in the config files.
|
||||
|
||||
EXPCL_PANDA const DSearchPath &get_model_path();
|
||||
EXPCL_PANDA const DSearchPath &get_texture_path();
|
||||
EXPCL_PANDA const DSearchPath &get_sound_path();
|
||||
EXPCL_PANDA DSearchPath &get_model_path();
|
||||
EXPCL_PANDA DSearchPath &get_texture_path();
|
||||
EXPCL_PANDA DSearchPath &get_sound_path();
|
||||
|
||||
#endif /* __CONFIG_UTIL_H__ */
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "eggToBam.h"
|
||||
|
||||
#include <config_util.h>
|
||||
#include <bamFile.h>
|
||||
#include <load_egg_file.h>
|
||||
|
||||
@ -21,6 +22,12 @@ EggToBam() :
|
||||
("This program reads Egg files and outputs Bam files, the binary format "
|
||||
"suitable for direct loading of animation and models into Panda.");
|
||||
|
||||
add_option
|
||||
("tp", "path", 0,
|
||||
"Add the indicated colon-delimited paths to the texture-path. This "
|
||||
"option may also be repeated to add multiple paths.",
|
||||
&EggToBam::dispatch_search_path, NULL, &get_texture_path());
|
||||
|
||||
redescribe_option
|
||||
("cs",
|
||||
"Specify the coordinate system of the resulting " + _format_name +
|
||||
|
@ -135,7 +135,7 @@ import(const Filename &source, void *extra_data,
|
||||
return (CVSSourceDirectory *)NULL;
|
||||
}
|
||||
if (new_file) {
|
||||
create_file(dest);
|
||||
cvs_add(dest);
|
||||
}
|
||||
}
|
||||
|
||||
@ -315,14 +315,14 @@ copy_binary_file(Filename source, Filename dest) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CVSCopy::create_file
|
||||
// Function: CVSCopy::cvs_add
|
||||
// Access: Protected
|
||||
// Description: Invokes CVS to add the indicated filename to the
|
||||
// repository, if the user so requested. Returns true
|
||||
// if successful, false if there is an error.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool CVSCopy::
|
||||
create_file(const Filename &filename) {
|
||||
cvs_add(const Filename &filename) {
|
||||
if (_no_cvs) {
|
||||
return true;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ protected:
|
||||
bool verify_binary_file(Filename source, Filename dest);
|
||||
bool copy_binary_file(Filename source, Filename dest);
|
||||
|
||||
bool create_file(const Filename &filename);
|
||||
bool cvs_add(const Filename &filename);
|
||||
|
||||
private:
|
||||
bool scan_hierarchy();
|
||||
|
@ -29,6 +29,11 @@ AttribFile(const Filename &filename) {
|
||||
_pi_filename.set_extension("pi");
|
||||
_txa_fd = -1;
|
||||
|
||||
|
||||
_pi_dir = _pi_filename;
|
||||
_pi_dir.set_basename("");
|
||||
_pi_dir.make_canonical();
|
||||
|
||||
_default_group = (PaletteGroup *)NULL;
|
||||
|
||||
_optimal = false;
|
||||
@ -142,11 +147,56 @@ write() {
|
||||
return okflag;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AttribFile::write_pi_filename
|
||||
// Access: Public
|
||||
// Description: Returns a new filename that's made relative to the
|
||||
// .pi file itself, suitable for writing to the .pi file.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
Filename AttribFile::
|
||||
write_pi_filename(Filename filename) const {
|
||||
filename.make_canonical();
|
||||
filename.make_relative_to(_pi_dir);
|
||||
return filename;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AttribFile::read_pi_filename
|
||||
// Access: Public
|
||||
// Description: Returns an absolute pathname based on the given
|
||||
// relative pathname, presumably read from the .pi file
|
||||
// and relative to the .pi file.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
Filename AttribFile::
|
||||
read_pi_filename(Filename filename) const {
|
||||
if (!filename.empty()) {
|
||||
filename.make_absolute(_pi_dir);
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AttribFile::write_egg_filename
|
||||
// Access: Public
|
||||
// Description: Returns a new filename that's made relative to the
|
||||
// rel_directory, suitable for writing out within egg
|
||||
// files.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
Filename AttribFile::
|
||||
write_egg_filename(Filename filename) const {
|
||||
filename.make_canonical();
|
||||
filename.make_relative_to(_rel_dirname);
|
||||
return filename;
|
||||
}
|
||||
|
||||
void AttribFile::
|
||||
update_params(EggPalettize *prog) {
|
||||
if (prog->_got_map_dirname) {
|
||||
_map_dirname = prog->_map_dirname;
|
||||
}
|
||||
if (prog->_got_rel_dirname) {
|
||||
_rel_dirname = prog->_rel_dirname;
|
||||
}
|
||||
if (prog->_got_palette_size) {
|
||||
_pal_xsize = prog->_pal_size[0];
|
||||
_pal_ysize = prog->_pal_size[1];
|
||||
@ -160,6 +210,10 @@ update_params(EggPalettize *prog) {
|
||||
if (prog->_got_aggressively_clean_mapdir) {
|
||||
_aggressively_clean_mapdir = prog->_aggressively_clean_mapdir;
|
||||
}
|
||||
|
||||
if (!_rel_dirname.empty()) {
|
||||
_rel_dirname.make_canonical();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -508,8 +562,9 @@ get_eligible_textures(vector<TexturePacking *> &textures) {
|
||||
|
||||
SourceEgg *AttribFile::
|
||||
get_egg(Filename name) {
|
||||
string basename = name.get_basename();
|
||||
Eggs::iterator ei;
|
||||
ei = _eggs.find(name);
|
||||
ei = _eggs.find(basename);
|
||||
if (ei != _eggs.end()) {
|
||||
return (*ei).second;
|
||||
}
|
||||
@ -517,7 +572,7 @@ get_egg(Filename name) {
|
||||
SourceEgg *egg = new SourceEgg(this);
|
||||
egg->resolve_egg_filename(name);
|
||||
egg->set_egg_filename(name);
|
||||
_eggs[name] = egg;
|
||||
_eggs[basename] = egg;
|
||||
return egg;
|
||||
}
|
||||
|
||||
@ -799,6 +854,7 @@ write_pi(ostream &out) const {
|
||||
|
||||
out << "\nparams\n"
|
||||
<< " map_directory " << _map_dirname << "\n"
|
||||
<< " rel_directory " << write_pi_filename(_rel_dirname) << "\n"
|
||||
<< " pal_xsize " << _pal_xsize << "\n"
|
||||
<< " pal_ysize " << _pal_ysize << "\n"
|
||||
<< " default_margin " << _default_margin << "\n"
|
||||
@ -902,6 +958,8 @@ parse_params(const vector<string> &words, istream &infile,
|
||||
|
||||
if (param == "map_directory") {
|
||||
_map_dirname = value;
|
||||
} else if (param == "rel_directory") {
|
||||
_rel_dirname = read_pi_filename(value);
|
||||
} else if (param == "pal_xsize") {
|
||||
_pal_xsize = atoi(value.c_str());
|
||||
} else if (param == "pal_ysize") {
|
||||
@ -1013,12 +1071,12 @@ parse_pathname(const vector<string> &words, istream &infile,
|
||||
nout << "Expected texture name and pathname.\n";
|
||||
return false;
|
||||
}
|
||||
texture->add_filename(twords[0]);
|
||||
texture->add_filename(read_pi_filename(twords[0]));
|
||||
|
||||
} else if (twords.size() == 2) {
|
||||
// Two words on the line means it's a texture name and filename.
|
||||
texture = get_texture(twords[0]);
|
||||
texture->add_filename(twords[1]);
|
||||
texture->add_filename(read_pi_filename(twords[1]));
|
||||
|
||||
} else {
|
||||
// Anything else is a mistake.
|
||||
@ -1042,7 +1100,7 @@ parse_egg(const vector<string> &words, istream &infile,
|
||||
return false;
|
||||
}
|
||||
|
||||
SourceEgg *egg = get_egg(words[1]);
|
||||
SourceEgg *egg = get_egg(read_pi_filename(words[1]));
|
||||
|
||||
if (words.size() > 2 && words[2] == "in") {
|
||||
// Get the group names.
|
||||
@ -1143,7 +1201,7 @@ parse_palette(const vector<string> &words, istream &infile,
|
||||
return false;
|
||||
}
|
||||
|
||||
string filename = words[1];
|
||||
string filename = read_pi_filename(words[1]);
|
||||
if (!(words[2] == "in")) {
|
||||
nout << "Expected keyword 'in'\n";
|
||||
return false;
|
||||
|
@ -37,6 +37,10 @@ public:
|
||||
bool read(bool force_redo_all);
|
||||
bool write();
|
||||
|
||||
Filename write_pi_filename(Filename filename) const;
|
||||
Filename read_pi_filename(Filename filename) const;
|
||||
Filename write_egg_filename(Filename filename) const;
|
||||
|
||||
void update_params(EggPalettize *prog);
|
||||
|
||||
PaletteGroup *get_group(const string &group_name);
|
||||
@ -119,6 +123,8 @@ private:
|
||||
Filename _txa_filename;
|
||||
Filename _pi_filename;
|
||||
|
||||
Filename _pi_dir;
|
||||
|
||||
PaletteGroup *_default_group;
|
||||
|
||||
public:
|
||||
@ -128,6 +134,7 @@ public:
|
||||
// palettes, and thus should be stored in the .pi file for future
|
||||
// reference.
|
||||
string _map_dirname;
|
||||
Filename _rel_dirname;
|
||||
int _pal_xsize, _pal_ysize;
|
||||
int _default_margin;
|
||||
bool _force_power_2;
|
||||
|
@ -69,6 +69,11 @@ EggPalettize() : EggMultiFilter(true) {
|
||||
"this will be replaced with the \"dir\" string associated with a "
|
||||
"palette group.",
|
||||
&EggPalettize::dispatch_string, &_got_map_dirname, &_map_dirname);
|
||||
add_option
|
||||
("dr", "dirname", 0,
|
||||
"The directory to make map filenames relative to when writing egg "
|
||||
"files. If specified, this should be an initial substring of -dm.",
|
||||
&EggPalettize::dispatch_filename, &_got_rel_dirname, &_rel_dirname);
|
||||
add_option
|
||||
("g", "group", 0,
|
||||
"The default palette group that egg files will be assigned to if they "
|
||||
@ -181,7 +186,6 @@ handle_args(ProgramBase::Args &args) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
Args egg_names;
|
||||
Args txa_names;
|
||||
|
||||
|
@ -40,6 +40,8 @@ public:
|
||||
// reference.
|
||||
string _map_dirname;
|
||||
bool _got_map_dirname;
|
||||
Filename _rel_dirname;
|
||||
bool _got_rel_dirname;
|
||||
string _default_groupname;
|
||||
bool _got_default_groupname;
|
||||
string _default_groupdir;
|
||||
|
@ -358,7 +358,8 @@ write_pathname(ostream &out) const {
|
||||
nout << "Warning: texture " << _filename << " does not exist.\n";
|
||||
}
|
||||
|
||||
out << " " << _name << " " << _filename << "\n";
|
||||
out << " " << _name << " " << _attrib_file->write_pi_filename(_filename)
|
||||
<< "\n";
|
||||
|
||||
// Also write out all the alternate filenames.
|
||||
Filenames::const_iterator fi;
|
||||
@ -368,7 +369,7 @@ write_pathname(ostream &out) const {
|
||||
for (int i = 0; i < (int)_name.length() + 3; i++) {
|
||||
out << ' ';
|
||||
}
|
||||
out << (*fi) << "\n";
|
||||
out << _attrib_file->write_pi_filename(*fi) << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -357,7 +357,8 @@ finalize_palette() {
|
||||
|
||||
void Palette::
|
||||
write(ostream &out) const {
|
||||
out << "palette " << _filename << " in " << _group->get_name()
|
||||
out << "palette " << _attrib_file->write_pi_filename(_filename)
|
||||
<< " in " << _group->get_name()
|
||||
<< " size " << _xsize << " " << _ysize << " " << _components
|
||||
<< "\n";
|
||||
TexPlace::const_iterator ti;
|
||||
|
@ -289,14 +289,14 @@ update_trefs() {
|
||||
packing->get_omit() != OR_none) {
|
||||
// This texture wasn't palettized, so just rename the
|
||||
// reference to the new one.
|
||||
eggtex->set_fullpath(packing->get_new_filename());
|
||||
eggtex->set_fullpath(_attrib_file->write_egg_filename(packing->get_new_filename()));
|
||||
|
||||
} else {
|
||||
// This texture was palettized, so redirect the tref to point
|
||||
// within the palette.
|
||||
Palette *palette = packing->get_palette();
|
||||
|
||||
eggtex->set_fullpath(palette->get_filename());
|
||||
eggtex->set_fullpath(_attrib_file->write_egg_filename(palette->get_filename()));
|
||||
|
||||
// Set the texture attributes to be uniform across all palettes.
|
||||
eggtex->set_minfilter(EggTexture::FT_mipmap_trilinear);
|
||||
@ -402,9 +402,8 @@ set_matched_anything(bool matched_anything) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void SourceEgg::
|
||||
write_pi(ostream &out) const {
|
||||
Filename absolute_filename = get_egg_filename();
|
||||
absolute_filename.make_absolute();
|
||||
out << "egg " << absolute_filename << " in";
|
||||
Filename filename = _attrib_file->write_pi_filename(get_egg_filename());
|
||||
out << "egg " << filename << " in";
|
||||
PaletteGroups::const_iterator gi;
|
||||
for (gi = _groups.begin(); gi != _groups.end(); ++gi) {
|
||||
out << " " << (*gi)->get_name();
|
||||
|
@ -204,7 +204,7 @@ copy_texture(const Filename &source, const Filename &dest,
|
||||
tex->write_attr_data(attr_filename);
|
||||
|
||||
if (new_file) {
|
||||
create_file(attr_filename);
|
||||
add_cvs(attr_filename);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user