mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-18 04:33:04 -04:00
add had_absolute_pathnames()
This commit is contained in:
parent
b4280f10cf
commit
697f2a2b67
@ -25,6 +25,7 @@
|
||||
INLINE EggData::
|
||||
EggData() {
|
||||
_auto_resolve_externals = false;
|
||||
_had_absolute_pathnames = false;
|
||||
_coordsys = CS_default;
|
||||
}
|
||||
|
||||
@ -38,6 +39,7 @@ INLINE EggData::
|
||||
EggData(const EggData ©) :
|
||||
EggGroupNode(copy),
|
||||
_auto_resolve_externals(copy._auto_resolve_externals),
|
||||
_had_absolute_pathnames(copy._had_absolute_pathnames),
|
||||
_coordsys(copy._coordsys),
|
||||
_egg_filename(copy._egg_filename)
|
||||
{
|
||||
@ -52,6 +54,7 @@ INLINE EggData &EggData::
|
||||
operator = (const EggData ©) {
|
||||
EggGroupNode::operator = (copy);
|
||||
_auto_resolve_externals = copy._auto_resolve_externals;
|
||||
_had_absolute_pathnames = copy._had_absolute_pathnames;
|
||||
_coordsys = copy._coordsys;
|
||||
_egg_filename = copy._egg_filename;
|
||||
return *this;
|
||||
@ -81,6 +84,24 @@ get_auto_resolve_externals() const {
|
||||
return _auto_resolve_externals;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggData::original_had_absolute_pathnames
|
||||
// Access: Public
|
||||
// Description: Returns true if the data processed in the last call
|
||||
// to read() contained absolute pathnames, or false if
|
||||
// those pathnames were all relative.
|
||||
//
|
||||
// This method is necessary because if
|
||||
// auto_resolve_externals() is in effect, it may modify
|
||||
// the pathnames to be absolute whether or not they were
|
||||
// as loaded from disk. This method can be used to
|
||||
// query the state of the original egg file from disk.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool EggData::
|
||||
original_had_absolute_pathnames() const {
|
||||
return _had_absolute_pathnames;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggData::get_coordinate_system
|
||||
// Access: Public
|
||||
|
@ -342,6 +342,9 @@ post_read() {
|
||||
set_coordinate_system(old_coordsys);
|
||||
}
|
||||
|
||||
// Fill this in before we automatically resolve pathnames.
|
||||
_had_absolute_pathnames = has_absolute_pathnames();
|
||||
|
||||
if (get_auto_resolve_externals()) {
|
||||
// Resolve filenames that are relative to the egg file.
|
||||
DSearchPath dir;
|
||||
|
@ -62,6 +62,7 @@ PUBLISHED:
|
||||
|
||||
INLINE void set_auto_resolve_externals(bool resolve);
|
||||
INLINE bool get_auto_resolve_externals() const;
|
||||
INLINE bool original_had_absolute_pathnames() const;
|
||||
|
||||
void set_coordinate_system(CoordinateSystem coordsys);
|
||||
INLINE CoordinateSystem get_coordinate_system() const;
|
||||
@ -81,6 +82,7 @@ private:
|
||||
void pre_write();
|
||||
|
||||
bool _auto_resolve_externals;
|
||||
bool _had_absolute_pathnames;
|
||||
CoordinateSystem _coordsys;
|
||||
Filename _egg_filename;
|
||||
|
||||
|
@ -350,6 +350,63 @@ find_child(const string &name) const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggGroupNode::has_absolute_pathnames
|
||||
// Access: Published
|
||||
// Description: Returns true if any nodes at this level and below
|
||||
// include a reference to a file via an absolute
|
||||
// pathname, or false if all references are relative.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool EggGroupNode::
|
||||
has_absolute_pathnames() const {
|
||||
Children::const_iterator ci;
|
||||
for (ci = _children.begin();
|
||||
ci != _children.end();
|
||||
++ci) {
|
||||
EggNode *child = *ci;
|
||||
if (child->is_of_type(EggTexture::get_class_type())) {
|
||||
EggTexture *tex = DCAST(EggTexture, child);
|
||||
if (!tex->get_filename().is_local()) {
|
||||
if (egg_cat.is_debug()) {
|
||||
egg_cat.debug()
|
||||
<< "Absolute pathname: " << tex->get_filename()
|
||||
<< "\n";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (tex->has_alpha_filename()) {
|
||||
if (!tex->get_alpha_filename().is_local()) {
|
||||
if (egg_cat.is_debug()) {
|
||||
egg_cat.debug()
|
||||
<< "Absolute pathname: " << tex->get_alpha_filename()
|
||||
<< "\n";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (child->is_of_type(EggFilenameNode::get_class_type())) {
|
||||
EggFilenameNode *fnode = DCAST(EggFilenameNode, child);
|
||||
if (!fnode->get_filename().is_local()) {
|
||||
if (egg_cat.is_debug()) {
|
||||
egg_cat.debug()
|
||||
<< "Absolute pathname: " << fnode->get_filename()
|
||||
<< "\n";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} else if (child->is_of_type(EggGroupNode::get_class_type())) {
|
||||
if (DCAST(EggGroupNode, child)->has_absolute_pathnames()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggGroupNode::resolve_filenames
|
||||
// Access: Published
|
||||
|
@ -120,6 +120,7 @@ PUBLISHED:
|
||||
|
||||
EggNode *find_child(const string &name) const;
|
||||
|
||||
bool has_absolute_pathnames() const;
|
||||
void resolve_filenames(const DSearchPath &searchpath);
|
||||
void force_filenames(const Filename &directory);
|
||||
void reverse_vertex_ordering();
|
||||
|
Loading…
x
Reference in New Issue
Block a user