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

View File

@ -143,9 +143,14 @@ def makePackedApp(args):
mainModule = mainModule.cStr().replace('/', '.') mainModule = mainModule.cStr().replace('/', '.')
packager.installDir = appDir packager.installDir = appDir
getModelPath().appendDirectory(root)
packager.allowPythonDev = allowPythonDev 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: try:
packager.setup() packager.setup()
packager.beginPackage(appBase, p3dApplication = True) packager.beginPackage(appBase, p3dApplication = True)