solve some texture resolving issues

This commit is contained in:
David Rose 2009-10-10 09:10:06 +00:00
parent 2318cb3646
commit ec3352ec82
2 changed files with 30 additions and 14 deletions

View File

@ -533,14 +533,15 @@ class Packager:
# Any other file.
self.addComponent(file)
# Finally, now add the model files. It's important to add
# these after we have added all of the texture files, so
# we can determine which textures need to be implicitly
# pulled in.
# Now add the model files. It's important to add these
# after we have added all of the texture files, so we can
# determine which textures need to be implicitly pulled
# in.
# We walk through the list as we modify it. That's OK,
# because we may add new files that we want to process.
for file in self.files:
# We walk through a copy of the files list, since we might
# be adding more files (textures) to this list as we
# discover them in model files referenced in this list.
for file in self.files[:]:
if file.isExcluded(self):
# Skip this file.
continue
@ -700,29 +701,31 @@ class Packager:
file.filename.unlink()
def addFile(self, *args, **kw):
""" Adds the named file to the package. """
""" Adds the named file to the package. Returns the file
object, or None if it was not added by this call. """
file = Packager.PackFile(self, *args, **kw)
if file.filename in self.sourceFilenames:
# Don't bother, it's already here.
return
return None
if file.newName in self.targetFilenames:
# Another file is already in the same place.
file2 = self.targetFilenames[file.newName]
self.packager.notify.warning(
"%s is shadowing %s" % (file2.filename, file.filename))
return
return None
self.sourceFilenames[file.filename] = file
if file.text is None and not file.filename.exists():
if not file.isExcluded(self):
self.packager.notify.warning("No such file: %s" % (file.filename))
return
return None
self.files.append(file)
self.targetFilenames[file.newName] = file
return file
def excludeFile(self, filename):
""" Excludes the named file (or glob pattern) from the
@ -1387,8 +1390,16 @@ class Packager:
self.importedMapsDir, filename.getBasenameWoExtension(),
uniqueId, filename.getExtension())
self.addFile(filename, newName = newName, explicit = False,
compress = False)
file = self.addFile(
filename, newName = newName, explicit = False,
compress = False)
if file:
# If we added the file in this pass, then also
# immediately add it to the multifile (because we
# won't be visiting the files list again).
self.addComponent(file)
return newName
def addDcFile(self, file):

View File

@ -143,9 +143,14 @@ def makePackedApp(args):
mainModule = mainModule.cStr().replace('/', '.')
packager.installDir = appDir
getModelPath().appendDirectory(root)
packager.allowPythonDev = allowPythonDev
# Put the root directory on the front of the model-path, so that
# any texture references in egg or bam files that reference
# textures from the top of the root directory will be properly
# resolved.
getModelPath().prependDirectory(root)
try:
packager.setup()
packager.beginPackage(appBase, p3dApplication = True)